Skip to content

bit2shift/ubermakefile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ubermakefile

For those who are not very fond of CMake. For C++ code bases.
It can be used with C if you're willing to do some little editing.

Relies on common essential tools—find, git, make (obviously) and pkg-config—in addition to jq—for querying ubermakefile.json.

5 steps quick start

  • Plop your code into a src folder
  • Specify the build (compile and link) flags alongside with normal dependencies in ubermakefile.json
  • Define the build targets with their even-so-more-specific flags and objects in ubermakefile.json
  • Either symlink ubermakefile/makefile into your project or have a shim makefile that includes or redirects all unmatched targets into it
  • make/make all or make devall, for building in release or debug mode, respectively

Optional step

  • Add any source-built dependencies as git submodules and declare them with build instructions in ubermakefile.json

Layout of ubermakefile.json


flags

Contains the build flags, i.e. CXXFLAGS, CPPFLAGS, LDFLAGS, LDLIBS, etc.
They are passed directly into make and, as such, are subject to expansion. That means you can use -I$(CURDIR)/... for adding include paths in the current directory.
It also means you can do all sorts of make shenanigans that are valid inside variable assignments.

common

For general build flags that do not affect debugging or optimisation levels.
Examples: -std=c++17, -pedantic, -Wall, -I...

debug

Flags typically used when debugging, i.e. -O0, -Og, -g, -g<1-3>, etc.

release

Normally the opposite of debugging, these flags are meant for increased optimisation, i.e. -O, -O<1-3>, -Os, -g0, etc.


targets

Build artifacts are declared in this section. There can be many, including test rigs.
Each key in this dictionary is the path of a single build artifact, as if located inside the src folder.

<target-path>

A single build artifact. Its name is used by make as target for a recipe.

static

A boolean value. Specifies if the current artifact is a static library.
Defaults to false if absent.

flags

Flags that are specific to the underlying type of artifact being built.
These should not affect debugging or optimisation characteristics.

objects

A string or an array of strings, each containing a pattern that can be passed to $(filter pattern…,text) in make.
Used for selecting the objects required for building the current artifact.
TL;DR: It's a list of wildcard paths, with the wildcard character being %.


dependencies

Build dependencies—normal and source-built—are declared here.
Each key in this dictionary is a package that can be queried with pkg-config.

<package-name>

A single dependency. Used in invocations of

pkg-config <package-name> [--static] <--cflags ¦ --libs-only-L --libs-only-other ¦ --libs-only-l>
static

A boolean value. Toggles the --static option of pkg-config.
Basically, it toggles between static and dynamic linking against <package-name>.

build

Only used for source-built dependencies.
A string or an array of strings containing commands to build <package-name>.
They are executed, in sequence, inside the corresponding submodule folder using git submodule foreach.

About

For those who are not very fond of CMake.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published