RP6 ROBOT SYSTEM - 4. Programming the RP6
4.5. Makefiles
The “Make”-tool simplifies the compiling process by automatically executing a great
number of jobs required to compile a C program. The automated process is defined in
a so-called “Makefile”, including all command sequences and informations for the com-
pile process of a project. We provide these makefiles for all RP6 example projects, but
of course you may create makefiles for your own projects as well. We will not discuss
a makefile's structure in all details, as this would go far beyond the scope of this
manual. For all RP6-projects, you can concentrate on the four following entries. Other
entries are not required for beginners and may be ignored.
TARGET
= programName
RP6_LIB_PATH
=../../RP6lib
RP6_LIB_PATH_OTHERS
=$(RP6_LIB_PATH)/RP6base $(RP6_LIB_PATH)/RP6common
SRC
+= $(RP6_LIB_PATH)/RP6base/RP6RobotBaseLib.c
SRC
+= $(RP6_LIB_PATH)/RP6common/RP6uart.c
SRC
+= $(RP6_LIB_PATH)/RP6common/RP6I2CslaveTWI.c
Our makefiles contain some comment lines in between. Makefile's comments always
start with “#” and will be ignored in the make-process.
RP6's sample projects provide customized makefiles ready for use and you will not
need any modifications unless you are planning to include new C files into the pro-
ject's structure or if you start renaming files.
Start creating a makefile by specifying the program's file-name containing the Main-
Function in the “TARGET”-entry. You must specify the name without extension, so
please never add the “.c”-extension here! Unfortunately many other extensions will
have to be specified and it might be a good idea to study existing examples of make-
files and details in the comments!
The second entry “RP6_LIB_PATH” allows you to specify the pathname of the RP6Lib-
rary files. Please specify a relative path name, e.g. “../RP6lib” or “../../RP6lib” (in
which “../” is means “one directory level up”).
A third entry RP6_LIB_PATH_OTHERS is used to specify all other directories. We split-
ted the RP6Library in a number of subdirectories and you must name all of the re-
quired subdirectories for your project.
Finally you have to define all C files in the “SRC” entry (do not include any header files
with “.h”-extensions, which will be automatically searched for in all specified director-
ies!), that are used beneath the file containing the main-function. Additionally you will
have to specify all RP6Library's files you are using.
Now, what does $(RP6_LIB_PATH) mean? Well, that's the way to use variables in
makefiles! We already defined a “variable” named RP6_LIB_PATH. Once a variable has
been declared, the variable's content may be used by writing $(<Variable>) in the
succeeding text of the makefile. This useful feature will prevent a considerable amount
of typing effort in makefiles...
Usually you will not have to modify anything else in the RP6 makefiles. If you are
looking for additional information on this topic you may look at the detailed manual:
http://www.gnu.org/software/make/manual/
- 78 -