The framework exposes a single entry point for building your entire project — theDocumentation 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.
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.
REGENERATE_INTERMEDIATES is enabled.
With REGENERATE_INTERMEDIATES enabled (default)
With REGENERATE_INTERMEDIATES enabled (default)
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
REGENERATE_INTERMEDIATES=X is the default. You do not need to pass it explicitly unless you previously disabled it.With REGENERATE_INTERMEDIATES disabled
With REGENERATE_INTERMEDIATES disabled
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.
Pattern rules for each source type
The framework registers pattern rules inmaking.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 (*.o)
Object files (*.o)
Object files are produced by the assembling phase. Three separate pattern rules handle each source origin:
Object file generation requires
| Pattern | Source |
|---|---|
obj/%.o | .c source files |
obj/%.tab.o | Yacc .y source files (via generated obj/%.tab.c) |
obj/%.lex.yy.o | Flex .l source files (via generated obj/%.lex.yy.c) |
GENERATE_ASSEMBLING_OUTPUT=X (the default). When this option is enabled, the assembling-phase rule invokes CC with -c.Assembly files (*.s)
Assembly files (*.s)
Assembly files are generated during the compilation phase and are only produced when
CC is invoked with
GENERATE_COMPILING_OUTPUT is set.| Pattern | Source |
|---|---|
obj/%.s | .c source files |
obj/%.tab.s | Yacc .y source files |
obj/%.lex.yy.s | Flex .l source files |
-S to stop after the compilation phase and emit assembly output.Preprocessed files (*.i)
Preprocessed files (*.i)
Preprocessed files are generated during the preprocessing phase and are only produced when
CC is invoked with
GENERATE_PREPROCESSING_OUTPUT is set.| Pattern | Source |
|---|---|
obj/%.i | .c source files |
obj/%.tab.i | Yacc .y source files |
obj/%.lex.yy.i | Flex .l source files |
-E to stop after preprocessing and emit the expanded source.Yacc-generated files (*.tab.c, *.tab.h, *.output)
Yacc-generated files (*.tab.c, *.tab.h, *.output)
For every
YACC is always invoked with These flags cause Bison to write a detailed report of parser states, itemsets, and lookahead sets to
.y source file, the framework generates three files in one rule invocation using YACC (Bison by default):| Output | Description |
|---|---|
obj/%.tab.c | Parser implementation |
obj/%.tab.h | Token definitions header |
obj/%.output | Human-readable parser report |
-d (emit header) and -v (emit report), plus the flags from YFLAGS. The default YFLAGS are: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.Flex-generated files (*.lex.yy.c)
Flex-generated files (*.lex.yy.c)
For every
LEX (Flex by default) is invoked with flags from
.l source file, the framework generates a scanner implementation:| Output | Description |
|---|---|
obj/%.lex.yy.c | Scanner implementation |
LFLAGS and any per-file $(<file>_LFLAGS). The generated file is then compiled like any other .c file.Dependency files (*.d, *.d.timestamp)
Dependency files (*.d, *.d.timestamp)
Automatic dependency tracking files are maintained under
Each
.deps/:| Pattern | Source |
|---|---|
.deps/%.d | .c source files |
.deps/%.tab.d | Yacc .y source files |
.deps/%.lex.yy.d | Flex .l source files |
.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.
MUST_MAKE works with all targets in the framework — build targets, cleaning targets, and execution targets alike.VERBOSE option
WhenVERBOSE=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
--versionoutput) on first use - The state of relevant options (e.g.,
CC_DEBUG,CC_WARNINGS)