Next: Further Reading Up: Writing GNUstep Makefiles Previous: Debugging an Application

Preamble and Postamble

You may happen to need to pass additional flags to the compiler (in order to link with additional libraries, for example) or to be willing to perform some additional actions after compilation or installation. The standard way of doing this is as follows: add a file called GNUmakefile.preamble to your project directory. An example of a GNUmakefile.preamble is the following:
ADDITIONAL_OBJCFLAGS += -Wall
This simply adds the -Wall flag when compiling (by the way, it is good practice to always use this flag). In general, you would use a GNUmakefile.preamble to add any additional flags you need (to tell the compiler/linker to search additional directories upon compiling/linking, to link with additional libraries, etc).

Now, you would want your GNUmakefile to include the contents of your GNUmakefile.preamble before any processing. This is usually done as follows:

include $(GNUSTEP_MAKEFILES)/common.make

APP_NAME = PanelTest
PanelTest_OBJC_FILES = source.m

include GNUmakefile.preamble
include $(GNUSTEP_MAKEFILES)/application.make

The most important thing to notice is that the GNUmakefile.preamble is included before application.make. That is why is called a preamble.

Sometimes you also see people using

-include GNUmakefile.preamble
(with a hyphen, -, prepended). The hyphen before include tells the make tool not to complain if the file GNUmakefile.preamble is not found. If you want to make sure that the GNUmakefile.preamble is included, you should better not use the hyphen.

If you want to perform any special operation after the GNUmakefile package has done its work, you usually put them in a GNUmakefile.postamble file. The GNUmakefile.postamble is included after application.make; that is why is called a postamble:

include $(GNUSTEP_MAKEFILES)/common.make

APP_NAME = PanelTest
PanelTest_OBJC_FILES = source.m

include GNUmakefile.preamble
include $(GNUSTEP_MAKEFILES)/application.make
include GNUmakefile.postamble

Here is a concrete example of a GNUmakefile.postamble:

after-install::
        $(MKDIRS) /home/nicola/Tools; \
        cd $(GNUSTEP_OBJ_DIR); \
        $(INSTALL) myTool /home/nicola/Tools;
(make sure you start each indented line with TAB). This will install the tool myTool in the directory /home/nicola/Tools after compilation.

You rarely need to use GNUmakefile.postambles, and they were mentioned mainly to give you a complete picture.


Next: Further Reading Up: Writing GNUstep Makefiles Previous: Debugging an Application
Nicola Pero 2000-10-12