Declare several programs with per-program source directories, flags, and run settings in a single GNUmakefile, including shared libraries and test binaries.
Use this file to discover all available pages before exploring further.
A single GNUmakefile can build any number of programs, libraries, and shared libraries at once. Each declared binary gets its own source directory, source list, linking order, compiler flags, run arguments, and working directory — all fully isolated from the others. This pattern works well for projects with multiple utilities in one repository, client/server pairs, programs sharing a common library, or test suites alongside the main program.
The framework generates a complete set of build, run, and debug targets for each entry: make all, make run-server, make run-client, make gdb-server, make valgrind-memcheck-client, and so on.
Each program’s _FIND_SOURCES runs an independent FIND command scoped to its own _SRCDIR. Programs with different source directories never pick up each other’s files:
Include path (-I) and library path (-L) auto-discovery
Each program has its own _FIND_-I_FLAGS and _FIND_-L_FLAGS evaluated against its own _INCLUDEDIR and _LIBDIR. This means a program only picks up headers and libraries from its own subtree unless you explicitly add paths from outside:
# Build every program and library declared in the makefilemake all# The framework does not generate individual targets named after programs# by default — use make all, which is always the default goalmake all
To rebuild only one program, touch or modify one of its source files and run make all. The incremental dependency tracking system ensures only the affected binary is relinked.
# Run a specific programmake run-servermake run-client# Debug with GDBmake gdb-servermake gdb-client# Memory analysis with Valgrindmake valgrind-memcheck-servermake valgrind-memcheck-client# Valgrind with the none (no-tool) passthroughmake valgrind-none-client
Each run- and gdb- target uses the program’s _CWD and _ARGS settings.
Global CFLAGS (set in main.mk or overridden before the MKFWK_FOOTER expansion) apply to every compiled file across all programs. Per-program $(prog)_CFLAGS are appended on top of global CFLAGS for that program only.For example, to enable extra warnings only for the server:
$(server)_CFLAGS = -Wextra
And to disable debug symbols for both programs at once:
The BINARY_PREFIXES variable controls which sets of programs the framework processes. By default it contains only BIN. You can add a TEST prefix to place test executables in a separate directory: