makemake [options]
This Perl utility creates Makefiles for building the GFI libraries and binaries. It is easier to use than imake(1) and should work on any platform supported by Perl. This should probably include more possibilities since the former has been developped fo building the X Window system. Furthermore, dependencies for object files can be automatically expanded to list all included non-system files, leading to better updates of the package. Finally, Makefiles are very short and easy to write.
Makemake will need two extra files: the first one is a definition file specific to targets being built, the second being a template for the final Makefile. A separate Makefile is created for each target. This may imply a little bit more compilation time. However, packages are not expected to be compiled too often. Source files in a software package are typically found in separate subdirectories, each of them containing its own Makefile for building corresponding sub part of the package. When using Makemake, there will typically be an definition file in each sub directories.
This section describes the syntax of the definition file. Comments are similar to those of Makefile, e.g. they start with a #. However, only spaces are allowed before the comment character. The top of the file contains definitions common to all targets to be built. This list is then followed by groups of definitions specific to each target to be built.
The syntax of a definition is
definition_1 = value of definition_1
definition_2 = first part of definition_2 \
second and last part of definition_2
...
As shown in the above example, definitions may expand over several lines, using the \ character as line continuation.
A group starts with its name followed by a colon. The folowing lines are definitions for this group only:
target_1:
definiton_1 = specific value of definition_1 for target_1
...
The list of specific definition for a specific target is ended by a line that does not contain a definition. It is recommended to use an empty line or a comment.
Common definitions and specific definitions use the same syntax, however, common definitions must start at the beginning of the line, while specific definitions must be indented. The keyword of a group declaring the beginning of definitions specific to a target must also start at the beginning of the line.
Each group appearing in the definition file has by default the following definitions, which default to the empty string: src, obj, lib, bin, srcs, objs, libs, bins and target. The default for target is determined from thee content of the definition file.
When parsing the file with a given target name, makemake will read all common definitions appearing at the top of the definition file. As soon as it finds the beginning of a group all dfinitions for this group are ignored, unless the name of the group corrrspond to the target name specified by option -t. Lines appearing after the list of definitions for this group are ignored. Hence, common definitions may be redefined for targets appearing later in the file.
Once the definition has been parsed, suffixes for the corresponding default definitions are added to each elements. This has been implemented to allow a better protability accros platforms. Default suffixes can be overridden with comman line options.
If the target has not been defined, it is determined according to the content of the definition file. This will be either bin, lib or obj if one of those definition is defined and non-empty.
A Makefile is then generated. Its content is taken from a template (option -T), where all occurences of PREFIXdefinitionSUFFIX are replaced by the value of definition. PREFIX and SUFFIX can be specified by options -P and -S. If the value of definition is empty or does not exists, and the current line contains a variable make definitions, its value is set to the empty string.
A line with PREFIXOBJ_DEPSUFFIX only will expand all listed sources into their dependencies. This is at least possible with cpp(1) and makedepend(1). In order to be used on different types of platforms, the command line must be specified by option -D.
Suffix for binary files listed in definitions bin and
bins. Default is the empty string.
Definition file. Default is MMFile.
Suffix for library files listed in definitions lib and
libs. Default is “.a”.
Suffix for object files listed in definitions obj and
objs. Default is “.o”.
Suffix for source files listed in definitions src and
srcs. Default is “.c”.
Name of target. This options specifies the keyword containing
the list of specific definitions to read. Default value is
determined according to the content of the definition file.
This option allows to define the command and all command line
parameters required for expanding source files into a list of
dependencies. The last argument of the comment must be the
source file name, which is added by makemake. Default is
the empty command.
Name of new Makefile. Default is stdout.
Prefix of strings to expand with definition values. Default is
MM_.
Suffix of strings to expand with definition values. Default is
_MM.
Name of Makefile template. Default is MMFile.mm.
A typical Makefile template for generating both library and binary files would be:
include makefile.defs
all: MM_target_MM
bin: MM_bin_MM
lib: MM_lib_MM
MM_bin_MM: MM_obj_MM MM_objs_MM MM_lib_MM MM_libs_MM
... commands to make the binary ...
MM_lib_MM: MM_obj_MM MM_objs_MM
... commands to make the library ...
MM_OBJ_DEP_MM
The first directive includes a file with all definitions for commands, suffixes, rules, ... This is usually a file which is platform specific. The second part contains the labels of targets to be built. These are automatically determined from the content of the MMFile. Then come the declarations on how to make the binary or library and their dependencies. The last line will generate a full list of all sources with all of their dependencies.
The MMfile for building a library or a binary would be:
... common definitions ...
foo:
lib = lib_file
srcs = f1 f2 ... fn
objs = f1 f2 ... fn
bar:
bin = bin_file
objs = F1 F2 ... Fm
srcs = f1 f2 ... fp
libs = l1 l2 ... lq
Running makemake with option -t foo on this file will generate a Makefile for building library lib_file from sources and objects f1 through fn. Running it with option -t bar will generate a make file for building binary bin_file.
Pierre Jaccard, Geophysical Institute, University of Bergen, 1999.