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 exposes a single entry point for building your entire project — the all target — along with a rich set of pattern rules that automatically handle every step from source file to linked binary. Understanding what each target produces, and when, helps you rebuild only what you need.

The all target

all is the default goal (set via .DEFAULT_GOAL:=all in main.mk). Running make with no arguments is equivalent to make all.
make all
The exact behavior depends on whether REGENERATE_INTERMEDIATES is enabled.
When REGENERATE_INTERMEDIATES is set (it is set to X by default), all explicitly depends on both the final binaries and every intermediate file the framework knows about:
  • Programs: bin/<name>
  • Static libraries: bin/lib<name>.a
  • Shared libraries: bin/lib<name>.so
  • Object files: obj/*.o, obj/*.tab.o, obj/*.lex.yy.o
  • Yacc-generated C files: obj/*.tab.c, obj/*.tab.h, obj/*.output
  • Flex-generated C files: obj/*.lex.yy.c
  • Preprocessed files (when enabled): obj/*.i, obj/*.tab.i, obj/*.lex.yy.i
  • Assembly files (when enabled): obj/*.s, obj/*.tab.s, obj/*.lex.yy.s
If any intermediate file was deleted, Make will regenerate it. This is the recommended mode for active development.
REGENERATE_INTERMEDIATES=X is the default. You do not need to pass it explicitly unless you previously disabled it.
When REGENERATE_INTERMEDIATES is empty, all depends only on the final programs and libraries. The intermediate files are registered with .SECONDARY, which means:
  • Make will not automatically delete them (they are kept on disk).
  • Make will not rebuild them if they are removed — it treats them as up-to-date once they exist.
This trades strict correctness for faster iteration: you can manually delete an intermediate file without triggering a full rebuild of everything downstream.To disable:
make REGENERATE_INTERMEDIATES=

Pattern rules for each source type

The framework registers pattern rules in making.mk that cover every compilation stage. Target directories (bin/, obj/, .deps/) are created automatically as order-only prerequisites, so you never have to create them manually.
Object files are produced by the assembling phase. Three separate pattern rules handle each source origin:
PatternSource
obj/%.o.c source files
obj/%.tab.oYacc .y source files (via generated obj/%.tab.c)
obj/%.lex.yy.oFlex .l source files (via generated obj/%.lex.yy.c)
Object file generation requires GENERATE_ASSEMBLING_OUTPUT=X (the default). When this option is enabled, the assembling-phase rule invokes CC with -c.
# Build everything including all .o files
make all
Assembly files are generated during the compilation phase and are only produced when GENERATE_COMPILING_OUTPUT is set.
PatternSource
obj/%.s.c source files
obj/%.tab.sYacc .y source files
obj/%.lex.yy.sFlex .l source files
CC is invoked with -S to stop after the compilation phase and emit assembly output.
make GENERATE_COMPILING_OUTPUT=X all
Preprocessed files are generated during the preprocessing phase and are only produced when GENERATE_PREPROCESSING_OUTPUT is set.
PatternSource
obj/%.i.c source files
obj/%.tab.iYacc .y source files
obj/%.lex.yy.iFlex .l source files
CC is invoked with -E to stop after preprocessing and emit the expanded source.
make GENERATE_PREPROCESSING_OUTPUT=X all
For every .y source file, the framework generates three files in one rule invocation using YACC (Bison by default):
OutputDescription
obj/%.tab.cParser implementation
obj/%.tab.hToken definitions header
obj/%.outputHuman-readable parser report
YACC is always invoked with -d (emit header) and -v (emit report), plus the flags from YFLAGS. The default YFLAGS are:
YFLAGS=--report=state --report=itemset --report=lookahead
These flags cause Bison to write a detailed report of parser states, itemsets, and lookahead sets to obj/%.output — essential reading when debugging shift/reduce or reduce/reduce conflicts.
The -Wall flag is also added to YFLAGS when YACC_WARNINGS=X (the default), enabling all Bison diagnostics.
For every .l source file, the framework generates a scanner implementation:
OutputDescription
obj/%.lex.yy.cScanner implementation
LEX (Flex by default) is invoked with flags from LFLAGS and any per-file $(<file>_LFLAGS). The generated file is then compiled like any other .c file.
Automatic dependency tracking files are maintained under .deps/:
PatternSource
.deps/%.d.c source files
.deps/%.tab.dYacc .y source files
.deps/%.lex.yy.dFlex .l source files
Each .d file contains a Make rule listing all headers that the corresponding source depends on. A .d.timestamp file is touched after each successful update. When INCLUDE_DEPS=X (the default), these files are sincluded so that header changes automatically trigger recompilation.
Dependency files are regenerated using CC with -MM -MF. Intermediate .d.tmp.1 and .d.tmp.2 files are used atomically during generation and are cleaned up by make cleandeps.

Directory creation

Every pattern rule lists its output directory as an order-only prerequisite (via | $(call mkfwk_dirname, $@)). The framework registers explicit rules for each directory in TARGET_DIRS (bin/, obj/, .deps/). You never need to create these manually — Make creates them on demand before running any recipe that writes into them. If a file already exists at a path that conflicts with a directory name, the framework automatically renames it to resolve the conflict before creating the directory.

MUST_MAKE option

MUST_MAKE is a dry-run mode for build targets. When set to any non-empty value, Make prints what would be rebuilt (the target name and its out-of-date prerequisites) instead of actually running any recipes.
# See what would be rebuilt
make MUST_MAKE=X

# Same effect — all is the default goal
make MUST_MAKE=X all
The output for each target that would be rebuilt looks like:
  * [target "bin/myprogram"]. Prerequisites newer than target: obj/main.o
This is useful for understanding why Make considers a target out of date without committing to a full rebuild.
MUST_MAKE works with all targets in the framework — build targets, cleaning targets, and execution targets alike.

VERBOSE option

When VERBOSE=X (the default), each recipe prints structured progress messages showing:
  • Which tool is being invoked (CC, YACC, LEX, AR, RANLIB)
  • The absolute pathname of the file being produced
  • The version of each tool (pathname and --version output) on first use
  • The state of relevant options (e.g., CC_DEBUG, CC_WARNINGS)
To suppress all progress output and show only compiler diagnostics:
make VERBOSE=

Build docs developers (and LLMs) love