Next: 4 Multiple instances Up: 3 Single instance Previous: 3.1 Compiling multiple files

3.2 Adding before-xxx-all and after-xxx-all steps

If you need to add some custom steps before or after your instance is built, you can use before-xxx-all and after-xxx-all rules. These steps will always be executed exactly before and after the compilation of your instance. In other words, the building process for the HelloWorld tool is really composed of the following steps:
Step 0. Execute before-HelloWorld-all:: if it exists
Step 1. Compiling HelloWorld.m and main.m (in parallel)
Step 2. Linking them together
Step 3. Execute after-HelloWorld-all:: if it exists

For example, let's say that for some reason you need to create a header file, HelloWorld.h, which is then included by your Objective-C files HelloWorld.m and main.m. Obviously this needs to happen before any compilation takes place.

To do so, in your GNUmakefile.postamble you would add the following:

before-HelloWorld-all::
       cp HelloWorld.h.in HelloWorld.h
Please note that there should be a TAB character before the 'cp', and that if you don't have a GNUmakefile.postamble, you can simply put this rule in your GNUmakefile, at the end of it, after all the gnustep-make makefiles have been included.

In the real world, this would probably be a more complicated rule, creating HelloWorld.h from HelloWorld.h.in by using sed or some other file editing tool. But whatever it is, you can simply have your code executed before any compilation is done by placing it in a before-HelloWorld-all:: rule.

Obviously if your tool is called HelloMoon, then you would place your code into a before-HelloMoon-all:: rule.

This code would always be executed serially, before the tool is compiled.


Next: 4 Multiple instances Up: 3 Single instance Previous: 3.1 Compiling multiple files
2010-03-12