RapidApp uses several macros found in /usr/include/make to generate a simple, easy-to-use Makefile. In many cases, you can use the Makefile generated by RapidApp without change. Occasionally, you might need to add files and libraries to the Makefile.
To add files, simply add them to the USERFILES variable, which RapidApp generates as an empty list. RapidApp lists the code files that it generates in the BUILDERFILES variable; you shouldn't edit this list. The Makefile concatenates USERFILES and BUILDERFILES and assigns the result to C++FILES, which the Makefile uses to build the program according to the built-in rules.
RapidApp automatically lists in the Makefile the libraries it requires to compile the interface code for your program. However, you might need to add libraries to the link line to support the functionality you added to your program. To do this, list the libraries in the USERLIBS variable, which RapidApp generates as an empty list.
Nearly all paths referenced directly or indirectly in the Makefile are qualified by the variable ROOT. By default, if this variable isn't set, the paths are relative to / (the root directory). However, setting this variable allows you to point to an alternate set of development libraries, compilers, and other tools. Typically, you don't need to change this variable.
The Makefile loads many definitions with the line near the top of the file:
include $(ROOT)/usr/include/make/commondefs |
You can browse this file if you are interested in the symbols defined, but the following are the most useful definitions that you should know about:
| DIRT | Includes files such as core, *.o, and so on. You can add to this list by listing the files in the LDIRT variable in your Makefile. All items listed in DIRT are removed when you execute make clean. | |
| C++FLAGS | Determines the flags passed to the C++ compiler. You can add to these flags by defining an LC++FLAGS variable in your Makefile. | |
| LOCALDEFS and LOCALRULES |
|
Most options you normally set in a Makefile are available as symbols defined directly in the Makefile, and should be understandable by reading the comments in the Makefile. For example, to prepare your program for production by compiling with the optimizer on, change the line
OPTIMIZER= -g |
to
OPTIMIZER=-O2 |
The last line of the Makefile includes a common set of rules. The path represented by the COMMONRULES variable is defined in the commondefs file. This path is typically /usr/include/make/commonrules.
Among the rules defined in /usr/include/make/commonrules are:
| make clean | Removes “dirt”, as defined by the DIRT variable | |
| make clobber | Removes targets, dirt, and Makedepend files | |
| make rmtargets |
|