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.

gcc-bison-flex-GNUmakefile is a GNU Make framework that handles the entire C build pipeline — from automatic source discovery and incremental dependency tracking, to running and debugging your programs with GDB and Valgrind. Drop it into any C project, declare your programs and source directories, and make all does the rest.

Introduction

Learn what the framework does, what tools it supports, and how it fits into a C project.

Quickstart

Set up the framework and build your first C program in minutes.

Configuration reference

Full reference for every variable and option the framework exposes.

Targets reference

All Make targets: building, running, debugging, profiling, and cleaning.

What it does

The framework plugs into GNU Make and provides a structured, reusable build system for C projects. It handles:
  • Source discovery — finds .c, .y (Bison/Yacc), and .l (Flex/Lex) files automatically
  • Code generation — runs Bison to produce .tab.c/.tab.h, and Flex to produce .lex.yy.c
  • Incremental builds — tracks header dependencies with .d files so only changed files recompile
  • Multiple output types — programs (executables), static libraries (.a), and shared libraries (.so)
  • Run and debug — built-in targets for executing programs, GDB debugging, and Valgrind analysis
1

Copy the framework

Copy the mkframework/ directory into your project root next to your GNUmakefile.
2

Include main.mk

Add include mkframework/main.mk (or use the provided GNUmakefile template) at the top of your makefile.
3

Declare your programs

Set BIN_PROGRAMS, define source files and source directory for each program.
4

Expand MKFWK_FOOTER

Add $(eval $(value MKFWK_FOOTER)) at the very end of your makefile to activate the framework rules.
5

Build

Run make all — the framework builds everything, generating intermediate files as needed.

Key features

Bison and Flex support

Automatically generates C source from .y and .l grammar files and integrates them into the build.

GDB and Valgrind targets

Run make gdb-myprogram or make valgrind-memcheck-myprogram with no extra setup.

Automatic dependency tracking

Header changes trigger the minimum necessary recompilation via auto-generated .d files.

Libraries

Build static (.a) and shared (.so) libraries alongside your programs in the same makefile.

Build docs developers (and LLMs) love