-
Notifications
You must be signed in to change notification settings - Fork 0
kbob/better-makefiles
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This project is an exploration of Makefiles. It demonstrates how a hierarchy of makefiles can be designed to absolutely minimize the amount of per-file and per-directory noise. We draw on the ideas of Peter Miller's Recursive Make Considered Harmful[1]: Only one make instance runs, and it always runs from the project's root directory. We also assume a current GNU toolchain and rely heavily on features of GNU make and GCC. The project-specific information is in Makefile in the project root and in a makefile called Dir.make in each directory. Each of those can define any of four variables: dirs - a list of subdirectories make should traverse programs - a list of C programs in that directory test_programs - a set of standalone C test programs in that directory test_scripts - a set of test scripts in that directory libs - a set of libraries in that directory For each library libfoo listed in libs, the makefile should define these variables. libfoo_cfiles - a list of C source files in libfoo. For each program foo listed in programs, the makefile should define these variables. foo_cfiles - a list of C source files in foo. foo_libs - a list of project libraries that foo links against. For each test program foo listed in tests, the makefile should define these variables. foo_cfiles - a list of C source files in foo. foo_libs - a list of project libraries that foo links against. foo_CPPFLAGS - extra C preprocessor flags to compile foo. Makefile in the root directory MAY define libtype as either dynamic or static, to globally set the type of libraries built. And Makefile MUST end by including makefiles/project-root.make . Here's a very simple example. programs := hello hello_cfiles := hello.c include makefiles/project-root.make For a more interesting example, see the sample-project directory. -- [1] http://miller.emu.id.au/pmiller/books/rmch/
About
Best practices in Makefile construction. Avoid recursion and absolutely minimize per-file and per-directory noise.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published