AROS

The Amiga Research OS


(C) Copyright 1996 AROS - The Amiga Research OS


Chapter 7. MetaMake

7.1 Introduction

MetaMake is a version of make which allows to recursively build targets in the various directories of a project or even another project. It searches a directory tree for makefiles and all makefiles it finds for "metatargets" and then tries to build all metatargets. You can also specify a program which converts "source" makefiles into makefiles before MetaMake will invoke make.

We use MetaMake to build AROS - The Amiga Research OS. AROS consists of many different packages which depend on each other like this:

This is a metatarget in a makefile (MetaMake looks for #MM as the first thing in a line). It means that AROS depends on setup, includes, etc. as you are used to from Make.

The big point is: MetaMake will consider *all makefiles at once* when it checks a metatarget. So all metatargets "setup" in all makefiles will be build when MetaMake tries to build AROS. MetaMake searches itself for the makefiles, so to add a new package, just create a new makefile in that directory and invoke MetaMake again.

This also allows to build the project from anywhere. You can invoke MetaMake in a subdir or any other directory if you copy the config file to $HOME.

MetaMake can also read a file with Make-style variable definitions. This allows to build the project depending on some variable, for example:

will build kernel-linux-i386 before kernel on Linux/i386 machines.

MetaMake will calculate $(TOP) (the path to the top of the project) and CURDIR (the path to the current directory relative to $(TOP)) and pass them to make. Also $(TARGET) will contain the current target but this will not be passed to make automatically. If you need the target in the makefile, you can use the maketool option to change this.

For convenience, you can also let MetaMake find the target like this:

but this is not the same as above. In this case, MetaMake will not try to build kernel-$(ARCH)-$(CPU) but only kernel. This is useful if your metatarget doesn't depend on anything else than local targets in the current makefile.

7.2 Usage and Config Files

Usage: mmake [<options>] [<metatargets>] To build mmake, just compile mmake.c. It doesn't need any other files.

mmake looks for a config file mmake.config or .mmake.config in the current directory for a file in the environment variable $MMAKE_CONFIG or a file .mmake.config in the directory $HOME. This file can contain the following things:

#
This must be the first character in a line and begins a comment. Comments are completely ignored my mmake (as are empty lines).

[name]
This begins a config section for the project name. You can build targets for this project by saying name.target.

maketool
Specifies the name of the tool to build a target. The default is make "TOP=$(TOP)" "CURDIR=$(CURDIR)"

top <dir>
Specifies the root directory for a project. You will later find this config option in the variable $(TOP). The default is the current directory.

defaultmakefilename <filename>
Specifies the basename for makefiles in your project. Basename means that mmake will consider other files which have this stem and an extension, too. See the items to generate makefiles for details. The default is Makefile

defaulttarget <target>
The name of the default target which mmake will try to make if you call it with the name of the project alone. The default is all.

genmakefilescript <cmdline>
mmake will check for files with the basename as specified in defaultmakefilename with the extension .src. If such a file is found, the following conditions are checked: Whether this file is newer than the makefile, whether the makefile doesn't exist and whether the file genmakefiledeps is newer than the makefile. If any of these is true, mmake will call this script the the name of the source file as an extra option and the stdout of this script will be redirected to defaultmakefilename. If this is missing, mmake will not try to regenerate makefiles.

genmakefiledeps <path>
This is the name of a file which is considered when mmake tries to decide whether a makefile must be regenerated. Currently, only one such file can be specified.

globalvarfile <path>
This is a file which contains more variables in the normal make(1) syntax. mmake doesn't know about any special things like line continuation, so be careful not to use such variables later (but they don't do any harm if they exist in the file. You should just not use them anywhere in mmake).

add <path>
Adds a nonstandard makefile to the list of makefiles for this project. mmake will apply the standard rules to it as if the defaultmakefilename was like this filename.

ignoredir <path>
Will tell mmake to ignore directories with this name. Try ignore CVS if you use CVS to manage your projects' sources.

Any option which is not recognised will be added to the list of known variables (ie. foo bar will create a variable $(foo) which is expanded to bar).

7.3 Example

Here is an example:

A metatarget look like so: project.target. Example: AROS.setup. If nothing is specified, mmake will make the default target of the first project in the config file. If the project is specified but no target, mmake will make the default target of this project.


prev up next

If you have comments or suggestions, email me at digulla@aros.fh-konstanz.de. 24. Jul 1999