Skip to content

0.1 (alpha)

Pre-release
Pre-release
Compare
Choose a tag to compare
@Wallby Wallby released this 16 May 14:34

First release of makefile-mini.

To use makefile_mini.mk, include it in a Makefile.
Then you can use functions from makefile_mini.mk for creating shaders, libraries (both static (.lib/.a) and dynamic (.dll/.so)), executables, set up tests and generate a release (currently generating a release is only a .zip file).

For example, for creating an executable application.exe (if windows) or application (if linux) from a file main.c..

include makefile_mini.mk

# creates a variable of "type" (indicates by "_t" suffix)..
# .. mm_start_parameters_t
# there are no "types" in makefiles, but to use makefile_mini.mk this is..
# .. what is meant with "_t"
# v
$(call mm_start_parameters_t,a) #< 
$(call mm_start,a) #< calls function mm_start with variable a

$(call mm_add_executable_parameters_t,b)
b.c:=main.c
$(call mm_add_executable,application,b) #< "application" here is used for the name of the application

$(call mm_stop_parameters_t,c)
$(call mm_stop,c)

Running make will compile the executable.
Running make clean will remove the folder .makefile-mini and all generated binaries that are not in the folder .makefile-mini (by default only intermediate binaries (such as .o for C and C++, and .spvasm for shaders) are in this folder, but binaries can be specifically ignored as well, which is done in the last example below).

To add a static library library from two files library.c and library.h..

#... #< include makefile_mini.mk and mm_start are unchanged

$(call mm_add_library_parameters_t,b)
b.filetypes:=EMMLibraryfiletype_Static #< default .filetypes is empty, indicating a library with only .h/.hpp, no .c nor .cpp
b.h:=library.h #< setting .h here is required as for an external resource that references this library (e.g. c.libraries) folder for every .h will be included
b.c:=library.c
$(call mm_add_library,library,b)

$(call mm_add_executable_parameters_t,c)
c.libraries:=library #< "library" here is the first parameter that was passed to mm_add_library)
$(call mm_add_executable,application,c)

$(call mm_stop_parameters_t,d) #< it would work to leave "c" here, in C it would not
$(call mm_stop,d)

Running make will now compile both the library and the executable, in the correct order.

To add a test there is mm_add_test..

#... #< include makefile_mini.mk is unchanged

$(call mm_start_parameters_t,a)
# cannot be "test" as there could be e.g. both a library with resourcename test AND an executable with resourcename test, hence "^test$(MM_EXECUTABLE_EXTENSION)$$" here
# $$ because make will parse this once, hence $ would disappear
# an ignoredbinary is put in .makefile-mini
# v
a.ignoredbinaries:=^test$(MM_EXECUTABLE_EXTENSION)$$
$(call mm_start,a)
#... #< include makefile_mini.mk, mm_start, mm_add_library and mm_add_executable are unchanged

# adding a separate executable test.exe (if windows) or test (if linux) from test.c that tests the executable application.exe
# v
$(call mm_add_executable_parameters_t,d)
d.c:=test.c
$(call mm_add_executable,test,d)

$(call mm_add_test_parameters_t,e)
e.executables:=test
$(call mm_add_test,test,e) #< "test" here is currently unused but cannot be omitted

#... #< mm_stop but with "f" instead of "d"

An ignoredbinary won't be built if running make. A test will be built if running make test or make release.