JMK 2 Build System
JMK2 is a rewrite of the JMK build system. I am slowly porting Bluejay to JMK2 instead of the legacy M4-based JMK build system.
JMK2 is used to generate makefiles for each project in Bluejay. A
project is a directory with a Jmk2 file (case sensitive). Each
project produces a single output based on some sources.
The script bin/jmk2 looks in the source tree for Jmk2 files,
and process each one into the corresponding Makefile. It accepts
option definitions with the -D flag, eg ./bin/jmk2
-DSOME_OPTION=123. You can also specify the C compiler, assembler,
and linker to use with the -c, -a, and -l flags,
respectively.
Here is an example Jmk2 file:
init hello # hello is the name of the project
srcs hello.c world.c # the source files this project uses
type executable # the preset type of project this is
Each line consists of a command (init, srcs, type) and its
arguments. The commands are documented here:
- init name [target]
Initializes the project with a given name. The
nameis currently unused, but should be set to a descriptive identifier.targetis the name of the target that the project generates. By default it is the same asname. For an executable, this could behelloorhello.exe. For a shared library,libhello.so, etc.
- preset preset_name
Applies the preset
preset_name. A preset is a function defined in the::presetsnamespace which makes some changes to the project state.These are the default presets:
freestandingChanges thecflagsto build a freestanding binary (without linking the standard library).optimizeChanges thecflagsandasmflagsto enable compile-time optimizations.32Tells the compilers to produce a 32 bit build.debugTells the compilers to enable debug information in the resulting builds (enables DWARF symbols).warnEnables useful warnings and-Werror.nasmSetsnasmas the default assembler.
- presets preset_a [preset_b]...
Applies all the given presets in order. Identical to calling
presetonce for each argument.
- cflag string
Adds
stringto the::cflagsvariable, which will be passed to the C compiler.
- cflags string_a [string_b]...
Adds multiple strings to the
::cflagsvariable, the same as callingcflagsrepeatedly.
- asmflag, asmflags
Same as
cflag,cflagsbut for the::asmflagsvariable.
- option name default_value
If the option
namehas not been specified when invokingbin/jmk2, sets the value of the option todefault_value. Options can be read with::options(option_name).
TODO: finish!