This guide walks you through the shortest path to a working build: one C source file, one makefile, and the framework. By the end you will have compiled a program intoDocumentation 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/ and run it through Make — with automatic dependency tracking enabled from the start.
Prerequisites
Before you begin, make sure the following tools are available on your system:- GNU Make 3.81 or later — run
make --versionto check - GCC — run
gcc --versionto check (or setCCto an alternative C compiler) - A POSIX shell at
/bin/sh— required by the framework’s startup checks
- Bison — for
.ygrammar files (bison --version) - Flex — for
.lscanner files (flex --version) - GDB — for
make gdb-<program>targets - Valgrind — for
make valgrind-*targets
On Windows, use MSYS2, Cygwin, or Git Bash to get a POSIX shell and GNU Make. The framework detects
OS=Windows_NT and automatically appends .exe to program names.Steps
Obtain the framework
Clone the repository or download the After copying, your project layout should look like this:
mkframework/ directory and place it in your project root.Create your GNUmakefile
Create a
GNUmakefile in your project root. The structure below is the canonical template derived from the reference implementation:Create your source file
Create the The framework discovers
src/ directory and a simple C file:hello.c automatically via the $(FIND) call in your makefile — you do not need to list it by name.Build with make all
Run the build from your project root:The framework will:
- Create
bin/,obj/, and.deps/directories - Compile
src/hello.c→obj/src/hello.o(with debug info and warnings enabled by default) - Generate
obj/src/hello.dfor incremental dependency tracking - Link
obj/src/hello.o→bin/myprogram(orbin/myprogram.exeon Windows)
VERBOSE=X, which is the default):If Make reports
make: Nothing to be done for 'all', verify that $(eval $(value MKFWK_FOOTER)) is the last line in your GNUmakefile and that src/hello.c exists.Run the program
Use the built-in The framework changes to the directory specified in To pass arguments, set
run-<program> target to execute the compiled program:$(program1)_CWD (set to $(BINDIR), i.e. bin/) and runs the program from there. Expected output:myprogram_ARGS in your makefile or override from the command line:What to do next
Installation
Full system requirements, startup checks, and how to obtain the framework.
Configuration variables
All variables you can set globally or per-program to control the build.
Bison and Flex project
Add grammar and scanner files to your project.
Building targets
All
make targets for building, cleaning, and more.