Next: , Previous: , Up: Anatomy of a GSRC Makefile   [Contents]

A.2.3 Build recipes

The final section of the GSRC Makefile contains the specifics of building the package. For most cases, it is sufficient to just add include ../../gar.lib/, which will work for any package that follows the GNU building and installation standards. This will, among other actions, automatically define the CONFIGURE_SCRIPTS, BUILD_SCRIPTS and INSTALL_SCRIPTS variables and it will include the Makefile. If the package does not follow this building standard, then add include ../../ directly. Following this, the user’s package configuration should be loaded with include

Because there is the possibility that the user specify some configuration options, any further options that must be set within the Makefile should be done after the user configuration has been loaded. By convention, whereas the user specifies options with the CONFIGURE_OPTS and BUILD_OPTS variables, inside the GSRC Makefile options should be included by appending to the CONFIGURE_ARGS and BUILD_ARGS variables:

CONFIGURE_ARGS += --some-option

Finally, if necessary, the actual recipes are written. Note that if gar.lib/ was included, no recipes should need to be written. In general, there are two kinds of targets for which recipes may need to be written.

The first correspond to the files listed under CONFIGURE_SCRIPTS, BUILD_SCRIPTS and INSTALL_SCRIPTS. As mentioned previously, user-level targets, such as build, depend on lower-level targets such as build-work/hello-2.9/Makefile. These are the targets that must be implemented for each of the designated configure/build/install scripts. For each target, a recipe is written using the normal Make syntax to perform the necessary task. Recall that phony targets may be specified as configure/build/install scripts. So, if INSTALL_SCRIPTS = java, then a target named install-java must be written.

The second kind of targets that may be written are pre- and post- rules. These recipes are run before or after the specified top-level target. For example, a target called pre-build is run immediately before the build target. These targets are convenient for performing pre- or post-processing on files. Note that there are also pre-everything and post-everything targets that can be written.

Next: , Previous: , Up: Anatomy of a GSRC Makefile   [Contents]