mkgen.pl — generate makefiles
mkgen.pl {COMMAND} [OPTION...] [directory...]
Generate or clean makefiles from makefile.gen files found in specified directories and their subdirectories. If no directories are specified, current directory and all its subdirectories are processed.
The COMMAND must be one of:
Useful (but not all) options are:
The complete syntax of makefile.gen is quite complicated. In this section, only the most useful features will be described. Moreover, we will not differentiate between features implemented directly by the mkgen.pl, features defined in per-platform support files (as long as they serve the same purpose on all platforms) and macros defined in files automatically included from each makefile.gen. For more information about makefile.gen syntax and documentation of mkgen.pl in general check contents of the doc/mkgen directory. Note that while the documentation is nearly complete, it's quite sketchy and probably hard to understand.
The syntax is line-oriented. Lines beginning with a hash character (#) and empty lines are ignored. To split long lines into multiple lines, use a backslash character (\) at the end of each line that continues on the next line.
Each makefile.gen file should start with lines indicating which libraries are used by all projects described in the file. These settings mainly affect which directories will be searched for system headers:
STDCPP - standard C++ libraries
SDL - Simple DirectMedia Layer libraries
OPENGL - OpenGL and GLU libraries
If a project contains an idl.list, a mkgen script describing rules and dependencies required to generate sources from IDL files will be generated from the list. Always include this file into makefile.gen using the following line: include makefile_idl.gen.
Assignments to lists that apply for all projects described by makefile.gen should follow. The syntax of list foo assignment is:
items is list of whitespace separated words. If the list assigned to is list of file name, wildcard patterns can be used in items. Wildcard patterns are expanded to list of files that match the pattern in current directory. Note that if a list contains item foo.cpp, and you subtract *.cpp from the list, the foo.cpp will be removed from the list only if file with that name actually exists. Also note that currently the -= syntax is supported only when defining the sources list of a project.
The useful global lists you can assign to are:
includes - list of directories to search when including a file from C++ sources.
defines - list of macros to always define when compiling a C++ source file.
precompiled - name of C++ header to precompile. This list should contain only single item.
Each makefile.gen should contain definition of at least one project. To define a program project called foo, use the following syntax:
The project name must be unique.
Three project types are recognized:
A program, defined in program - endprogram block. This compiles and links an exectuable with the specified name.
A statically linked library, defined in library - endlibrary block.
A shared library, aka dynamically linked library, defined in shared_library - endshared_library block. When compiling an object that belongs to a shared library foo, macro OPTION_BUILD_SHARED_foo will be defined.
Project options are defined by list assignments inside the project block. The following lists exist:
sources - list of C++ sources the project consists of. When a project contains an idl.list, you can use assignment sources += @GENERATED_SOURCE@ to add list of all sources generated from the IDL files to the list of sources to compile.
libs - list of libraries to link with, if the project is a program, or list of libraries to build before current project, if the project is a library. A library should be specified using a relative path to the directory where the makefile.gen for the library is located, concatenated with the library name.
shlibs - list of shared libraries to link with, if the project is a program. If the project is a library, this list should contain all shared libraries that this library might reference, ie. require some symbols defined in some of the referenced shared libraries. All required libraries must be specified correctly, otherwise link of a program that used this library may fail on some platforms.
When compiling an object belonging to the project, macro OPTION_USE_SHARED_foo will defined for each referenced shared library foo
syslibs - list of system libraries to link with. The list should contain a symbolic name of the library - on Win32 without the .lib extension and on Unices without the lib prefix and the .a (or .so) suffix. Several macros are predefined to link program with some useful libraries:
STDCPP_LIBS - standard C++ libraries
SDL_LIBS - Simple DirectMedia Layer libraries
OPENGL_LIBS - OpenGL and GLU libraries
![]() | Note |
---|---|
It's not recommended to define multiple projects in single file, unless you really know what you are doing. |