[Home]MakefileDeMystified

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

Showing revision 8

Purpose

The EMC2 build system is complex. in addition to conventional user space programs, it needs to build kernel modules. And it needs to do so on systems ranging from kernel 2.2 thru 2.6 (and eventually beyond). The kernel build system was totally revamped for version 2.6, so our build system needs to deal with two completely different ways of doing kernel modules.

So, despite its title, this page does _not_ attempt to explain how the EMC2 makefiles work. What it _will_ do is explain how to do some useful things, such as add a new HAL component, or a new userspace program.

Getting Started

This page assumes that you already have a checkout of the source code. Instructions for doing that are at Installing EMC2 (see section 2).

Adding a new Real Time HAL module

Assuming you want to add a new component "foo". Your source file would be "src/hal/components/foo.c".

In "src/Makefile", find the section that starts with the comment "# Subdirectory: hal/components". At the end of that section, add the following two lines:

 obj-$(CONFIG_FOO) += foo.o
 foo-objs := hal/components/foo.o $(MATHSTUB)

Find the section that starts with the comment "# Rules to make .o (object) files". After the long list of lines starting with "../rtlib", add:

 ../rtlib/foo.o: $(addprefix objects/rt,$(foo-objs))

Then, in "src/Makefile.inc.in", find the section that starts with the comment "# HAL components". At the end of that section, add:

 CONFIG_FOO=m

Then re-run ./configure and make.

If you are creating a driver instead of a component, substitute "drivers" for "components" in the instructions above.

Adding a new userspace program

In "src/Makefile", find the section that starts with the comment "# Submakefiles from each of these directories will be included if they exist" In that section, add the information to find the submakefile:
Eg. for a submakefile in "hal/foofolder"
<snip>
    \
hal/components hal/drivers hal/user_comps/vcp hal/user_comps/devices \
hal/user_comps hal/classicladder hal/foofolder hal/utils hal \
\
<snip>
Now add a submakefile and your source code into the foofolder
look at submakefile.skel in the src folder for more information about how to write a submakefile

Adding a new source file to "task"


LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions | View current revision
Edited June 20, 2009 8:43 am by JeffEpler (diff)
Search:
Published under a Creative Commons License