swissChili | 01ba07f | 2022-07-03 21:36:42 -0700 | [diff] [blame] | 1 | JMK 2 Build System |
| 2 | ================== |
| 3 | |
| 4 | JMK2 is a rewrite of the JMK build system. I am slowly porting |
| 5 | Bluejay to JMK2 instead of the legacy M4-based JMK build system. |
| 6 | |
| 7 | JMK2 is used to generate makefiles for each project in Bluejay. A |
| 8 | project is a directory with a ``Jmk2`` file (case sensitive). Each |
| 9 | project produces a single output based on some sources. |
| 10 | |
| 11 | The script ``bin/jmk2`` looks in the source tree for ``Jmk2`` files, |
| 12 | and process each one into the corresponding Makefile. It accepts |
| 13 | option definitions with the ``-D`` flag, eg ``./bin/jmk2 |
| 14 | -DSOME_OPTION=123``. |
| 15 | |
| 16 | Here is an example Jmk2 file: |
| 17 | |
| 18 | .. code-block:: tcl |
| 19 | |
| 20 | init hello # hello is the name of the project |
| 21 | srcs hello.c world.c # the source files this project uses |
| 22 | type executable # the preset type of project this is |
| 23 | |
| 24 | Each line consists of a command (``init``, ``srcs``, ``type``) and its |
| 25 | arguments. The commands are documented here: |
| 26 | |
| 27 | .. function:: init name [target] |
| 28 | |
| 29 | Initializes the project with a given name. The ``name`` is currently |
| 30 | unused, but should be set to a descriptive identifier. |
| 31 | |
| 32 | ``target`` is the name of the target that the project |
| 33 | generates. By default it is the same as ``name``. For an |
| 34 | executable, this could be ``hello`` or ``hello.exe``. For a shared |
| 35 | library, ``libhello.so``, etc. |
| 36 | |
| 37 | .. function:: preset preset_name |
| 38 | |
| 39 | Applies the preset ``preset_name``. A preset is a function defined |
| 40 | in the ``::presets`` namespace which makes some changes to the |
| 41 | project state. |
| 42 | |
| 43 | These are the default presets: |
| 44 | |
| 45 | * ``freestanding`` Changes the ``cflags`` to build a freestanding binary (without linking the standard library). |
| 46 | * ``optimize`` Changes the ``cflags`` and ``asmflags`` to enable \ |
| 47 | compile-time optimizations. |
| 48 | * ``32`` Tells the compilers to produce a 32 bit build. |
| 49 | * ``debug`` Tells the compilers to enable debug information in the \ |
| 50 | resulting builds (enables DWARF symbols). |
| 51 | * ``warn`` Enables useful warnings and ``-Werror``. |
| 52 | * ``nasm`` Sets ``nasm`` as the default assembler. |
| 53 | |
| 54 | .. function:: presets preset_a [preset_b]... |
| 55 | |
| 56 | Applies all the given presets in order. Identical to calling |
| 57 | ``preset`` once for each argument. |
| 58 | |
| 59 | .. function:: cflag string |
| 60 | |
| 61 | Adds ``string`` to the ``::cflags`` variable, which will be passed |
| 62 | to the C compiler. |
| 63 | |
| 64 | .. function:: cflags string_a [string_b]... |
| 65 | |
| 66 | Adds multiple strings to the ``::cflags`` variable, the same as |
| 67 | calling ``cflags`` repeatedly. |
| 68 | |
| 69 | .. function:: asmflag, asmflags |
| 70 | |
| 71 | Same as ``cflag``, ``cflags`` but for the ``::asmflags`` variable. |
| 72 | |
| 73 | .. function:: option name default_value |
| 74 | |
| 75 | If the option ``name`` has not been specified when invoking |
| 76 | ``bin/jmk2``, sets the value of the option to |
| 77 | ``default_value``. Options can be read with |
| 78 | ``::options(option_name)``. |
| 79 | |
| 80 | TODO: finish! |