The framework generates a dedicated set of execution targets for every program listed inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/fernandodanielmaqueda/gcc-bison-flex-GNUmakefile/llms.txt
Use this file to discover all available pages before exploring further.
BIN_PROGRAMS. These targets let you run, debug with GDB, or analyze with Valgrind — all from the same make invocation that built the project, with consistent working directory and argument handling.
run-<program> targets
For each program named <program> in BIN_PROGRAMS, the framework generates a .PHONY target called run-<program>. The target:
- Checks that the program binary exists (exits with an error if it has not been built yet).
- Changes to
$(program)_CWDif it is set. - Executes the program using its absolute path, passing
$(program)_ARGSas arguments. - Returns to the previous directory.
Passing arguments at the command line
Passing arguments at the command line
$(program)_ARGS directly on the make invocation:Makefile:Configuring the working directory
Configuring the working directory
$(program)_CWD is set to $(BINDIR) (i.e., bin/), so the program runs from the output directory. To change it:$(program)_CWD is empty the framework skips the cd step entirely and runs the program directly in the current working directory.When the program has not been built yet
When the program has not been built yet
make all, then run it.gdb-<program> targets
For each program in BIN_PROGRAMS, the framework generates a gdb-<program> target that launches GDB with the program already loaded.
PATH, Make reports the error and stops before attempting to run any recipe.
Setting GDB flags
Setting GDB flags
GDBFLAGS is empty by default. Add options in your Makefile or on the command line:Using GDB interactively
Using GDB interactively
Enabling debug symbols
Enabling debug symbols
CC_DEBUG is enabled by default (CC_DEBUG=X), which adds -g3 to CFLAGS and -DDEBUG=1 to CPPFLAGS. If you previously disabled it, re-enable it and rebuild:-g3 includes macro definitions in the debug information, making it possible to inspect preprocessor macros from inside GDB.Working directory and arguments
Working directory and arguments
gdb-<program> respects the same $(program)_CWD and $(program)_ARGS variables as run-<program>. Arguments passed via $(program)_ARGS are forwarded to GDB so it can pass them to the inferior process when you run it.valgrind-<tool>-<program> targets
The framework generates a target for every combination of tool in VALGRIND_TOOLS and program in BIN_PROGRAMS. The default VALGRIND_TOOLS are none memcheck helgrind, giving you three targets per program out of the box.
valgrind-none-<program>
valgrind-none-<program>
memcheck tool but without any additional per-tool flags from the framework.VALGRIND_NONE_FLAGS is empty by default.valgrind-memcheck-<program>
valgrind-memcheck-<program>
memcheck tool with the default flags:--leak-check=full— reports each individual leaked block with a full stack trace.--track-origins=yes— traces the origin of uninitialized values, at the cost of extra runtime overhead.
valgrind-helgrind-<program>
valgrind-helgrind-<program>
helgrind tool, which detects threading errors such as data races, misuses of POSIX thread primitives, and lock ordering violations.VALGRIND_HELGRIND_FLAGS is empty by default. Add flags as needed:Global Valgrind flags
Global Valgrind flags
VALGRIND_FLAGS is applied to every Valgrind invocation regardless of tool. The default is --verbose. You can extend or replace it:Adding custom Valgrind tools
Adding custom Valgrind tools
VALGRIND_TOOLS before the framework footer is evaluated. The framework will generate targets and look for a matching VALGRIND_<TOOL>_FLAGS variable:make valgrind-cachegrind-myprogram and make valgrind-massif-myprogram become available.cachegrind, callgrind, drd, massif, dhat, lackey, exp-bbv.Valgrind and debug symbols
Valgrind and debug symbols
CC_DEBUG=X (the default) to include -g3. Without debug symbols, Valgrind cannot show source file names and line numbers in its reports.Configuring execution for all targets
The_ARGS and _CWD variables work the same way across run-, gdb-, and valgrind- targets.
Setting arguments
Setting arguments
Makefile, set program-specific arguments before the framework footer:Setting the working directory
Setting the working directory
_CWD means no cd is performed — the program runs in whatever directory make was invoked from.