Skip to main content

Documentation 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.

The framework separates compiler configuration into several layers: the tool pathnames themselves, global flags that apply to every invocation, per-source-type flags applied only when compiling a specific kind of source (plain .c, Bison-generated, or Flex-generated), and linker flags. All of these variables are defined in main.mk and can be overridden in your GNUmakefile before the $(eval $(value MKFWK_FOOTER)) call, or from the command line.

Tool pathnames

By default the framework uses the conventional names for each tool. Override any of these to point at a specific installation path.
VariableDefaultDescription
CCgccC compiler
YACCbisonParser generator
LEXflexScanner generator
ARarStatic archive maintainer
RANLIBranlibArchive index generator
GDBgdbDebugger
VALGRINDvalgrindDynamic analysis tool
Each tool also has a corresponding version flag variable used by the framework to print version information when VERBOSE is enabled:
VariableDefault
CC_VERSION_FLAG--version
YACC_VERSION_FLAG--version
LEX_VERSION_FLAG--version
AR_VERSION_FLAG-V
RANLIB_VERSION_FLAG--version
GDB_VERSION_FLAG--version
VALGRIND_VERSION_FLAG--version
# Use Clang instead of GCC and a specific Bison install
CC=clang
YACC=/usr/local/bin/bison

Global compiler flags

These variables apply to all sources of their respective tool.
Default: empty (before option processing)Flags passed to CC during the preprocessing phase for every source type. The CC_DEBUG option appends either -DDEBUG=1 (when enabled) or -DDEBUG=0 (when disabled) to this variable automatically.
# Add an extra include directory globally
CPPFLAGS=-I'third_party/include'
After option processing the effective value is one of:
-DDEBUG=1   # CC_DEBUG=X (default)
-DDEBUG=0   # CC_DEBUG=
Default (before option processing): -fdiagnostics-color=always -std=c17 -O0After applying the CC_WARNINGS and CC_DEBUG options, the effective default becomes:
-fdiagnostics-color=always -std=c17 -O0 -Wall -Wpedantic -g3
To add your own flags without losing the defaults, use +=:
# Add optimisation and a target-architecture flag
CFLAGS+=-O2 -march=native
To replace the defaults entirely, use := or simple assignment:
# Fully custom flag set (drops -std=c17 etc.)
CFLAGS=-fdiagnostics-color=always -std=c11 -O3 -march=native
Default (before option processing): --report=state --report=itemset --report=lookaheadThese flags instruct Bison to emit detailed parser reports. After applying options:
  • YACC_WARNINGS=X (default) appends -Wall
  • YACC_DEBUG=X appends -t (enable Bison parser tracing)
# Add Bison verbose output in addition to the defaults
YFLAGS+=--verbose
Default: emptyFlags passed directly to Flex. After option processing:
  • LEX_DEBUG=X appends -d (enable Flex debug output at runtime)
LFLAGS+=--header-file=src/scanner.h
Default: emptyFlags passed to CC during the assembling phase for every source type.
ASFLAGS+=-Wa,-ahlms=listing.lst
Default: emptyFlags passed to CC during the linking phase (for -L paths and other linker options). Per-binary -L flags discovered from $(binary)_LIBDIR are appended to the per-binary $(binary)_LDFLAGS, not here.
LDFLAGS+=-L'/opt/custom/lib'

Per-source-type flags

These variables let you pass flags to CC only when compiling a specific category of source file, without affecting others. They are layered on top of the corresponding global flags.
Defaults: all emptyApplied exclusively when compiling hand-written .c source files (files that are not Bison-generated *.tab.c or Flex-generated *.lex.yy.c).
# Suppress a specific warning only for hand-written sources
CC_CFLAGS+=-Wno-unused-parameter
Defaults: empty (before option processing for YACC_CPPFLAGS)Applied exclusively when compiling Bison-generated *.tab.c files. YACC_CPPFLAGS is always augmented automatically:
  • YACC_DEBUG=X → appends -DYYDEBUG=1
  • YACC_DEBUG= (default) → appends -DYYDEBUG=0
This ensures YYDEBUG is always explicitly defined so Bison’s runtime debugging facilities are either fully compiled in or fully compiled out.
# Suppress implicit-fallthrough warnings in generated parser code
YACC_CFLAGS+=-Wno-implicit-fallthrough
Defaults: all emptyApplied exclusively when compiling Flex-generated *.lex.yy.c files.
# Suppress warnings common in generated scanner code
LEX_CFLAGS+=-Wno-unused-function -Wno-sign-compare

Valgrind configuration

Default: --verboseFlags passed to every valgrind-* target invocation before tool-specific flags.
VALGRIND_FLAGS=--verbose --log-file=valgrind.log
Default: none memcheck helgrindA space-separated list of Valgrind tool names. The framework generates a valgrind-<tool>-<program> target for each combination of tool and program. none means run Valgrind with no --tool flag (uses its default, memcheck).
# Add callgrind profiling targets
VALGRIND_TOOLS=none memcheck helgrind callgrind
Defaults shown below
VariableDefault value
VALGRIND_NONE_FLAGS(empty)
VALGRIND_MEMCHECK_FLAGS--leak-check=full --track-origins=yes
VALGRIND_HELGRIND_FLAGS(empty)
For any tool added to VALGRIND_TOOLS, define a corresponding VALGRIND_<TOOL>_FLAGS variable. The tool name is uppercased.
VALGRIND_CALLGRIND_FLAGS=--callgrind-out-file=callgrind.out.%p

Archive tool flags

VariableDefaultDescription
ARFLAGS-r -vFlags passed to ar when creating or updating static libraries
The -r flag inserts/replaces members and -v produces verbose output. RANLIB is invoked after ar when it is available (the framework treats it as a dispensable command and gracefully skips it when absent).
# Use deterministic mode for reproducible archives
ARFLAGS=-r -v -D

Build docs developers (and LLMs) love