Update Makefile to support different release environments.
parent
36f5bf1dfc
commit
0f3d5b26b1
|
@ -2,5 +2,5 @@
|
|||
.direnv/
|
||||
bootstrap
|
||||
compile_commands.json
|
||||
dist/
|
||||
docs/
|
||||
test/test
|
||||
|
|
83
Makefile
83
Makefile
|
@ -1,20 +1,81 @@
|
|||
BUILD=clang -Og -g -I include src/*.c main.c -o bootstrap -lm
|
||||
# ============================================================
|
||||
# Configuration
|
||||
# ============================================================
|
||||
|
||||
all: build bear
|
||||
# To create a release build, run `make BUILD=release`.
|
||||
|
||||
build: include/*.h src/*.c
|
||||
@${BUILD}
|
||||
BUILD := debug
|
||||
PREFIX := ${CURDIR}/dist/${BUILD}
|
||||
OUT := bootstrap
|
||||
|
||||
bear: include/*.h src/*.c
|
||||
@bear -- ${BUILD}
|
||||
CCFLAGS.debug := -DDEBUG -g -Og
|
||||
CCFLAGS.release := -DNDEBUG
|
||||
LDFLAGS := -lm
|
||||
|
||||
docs:
|
||||
# ============================================================
|
||||
# Build
|
||||
# ============================================================
|
||||
|
||||
COMPILE := ${CC} ${CCFLAGS.${BUILD}} -I include src/*.c main.c -o ${PREFIX}/${OUT} ${LDFLAGS}
|
||||
|
||||
all: build all.${BUILD}
|
||||
all.debug: bear
|
||||
all.release:
|
||||
|
||||
build: ${PREFIX}/${OUT}
|
||||
|
||||
${PREFIX}/${OUT}: ${PREFIX} include/*.h src/*.c
|
||||
${COMPILE}
|
||||
|
||||
${PREFIX}:
|
||||
mkdir -p $@
|
||||
|
||||
# ============================================================
|
||||
# Compilation Database
|
||||
#
|
||||
# Generate a compilation database using [Bear](https://github.com/rizsotto/Bear).
|
||||
# ============================================================
|
||||
|
||||
bear: compile_commands.json
|
||||
|
||||
compile_commands.json: include/*.h src/*.c main.c
|
||||
# This file is only constructed in debug mode. If interested in expanding this
|
||||
# generation to other build types, add a release-specific dependency.
|
||||
ifeq ($(BUILD), debug)
|
||||
mkdir -p dist/debug
|
||||
bear -- ${COMPILE}
|
||||
endif
|
||||
|
||||
# ============================================================
|
||||
# Documentation.
|
||||
#
|
||||
# Generate documentation using [Doxygen](https://www.doxygen.nl/index.html).
|
||||
# ============================================================
|
||||
|
||||
docs: docs/index.html
|
||||
|
||||
# The `index.html` file is regenerated on each invocation of `doxygen`.
|
||||
docs/index.html: Doxyfile include/*.h src/*.c
|
||||
doxygen
|
||||
|
||||
test: test/test
|
||||
$^
|
||||
# ============================================================
|
||||
# Testing.
|
||||
#
|
||||
# We use [Sput](https://www.use-strict.de/sput-unit-testing/) to run tests.
|
||||
# ============================================================
|
||||
|
||||
test/test: include/*.h src/*.c test/*.h test/*.c
|
||||
clang -I include src/*.c test/*.c -o test/test -lm
|
||||
test: dist/test/suites
|
||||
dist/test/suites
|
||||
|
||||
dist/test/suites: include/*.h src/*.c test/*.h test/*.c
|
||||
mkdir -p dist/test
|
||||
${CC} ${CCFLAGS.debug} -I include src/*.c test/*.c -o dist/test/suites ${LDFLAGS}
|
||||
|
||||
# ============================================================
|
||||
# Other
|
||||
# ============================================================
|
||||
|
||||
clean:
|
||||
rm -r ${PREFIX}
|
||||
|
||||
.PHONY: test
|
||||
|
|
|
@ -174,6 +174,10 @@ Keep in mind this tool was originally written for personal usage and as such,
|
|||
any functionality (or lack thereof) reflects my own needs as I have come across
|
||||
them.
|
||||
|
||||
### Testing
|
||||
|
||||
TODO
|
||||
|
||||
### Documentation
|
||||
|
||||
We use [doxygen](https://www.doxygen.nl/index.html) for documentation
|
||||
|
|
19
flake.nix
19
flake.nix
|
@ -18,6 +18,22 @@
|
|||
'';
|
||||
in
|
||||
{
|
||||
packages = {
|
||||
bootstrap = pkgs.stdenv.mkDerivation {
|
||||
pname = "bootstrap";
|
||||
src = ./.;
|
||||
version = "0.1.0";
|
||||
nativeBuildInputs = with pkgs; [
|
||||
clang
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
make release
|
||||
'';
|
||||
};
|
||||
|
||||
default = self.packages.${system}.bootstrap;
|
||||
};
|
||||
devShells.default = pkgs.mkShell.override {
|
||||
# https://nixos.wiki/wiki/Using_Clang_instead_of_GCC
|
||||
stdenv = pkgs.clangStdenv;
|
||||
|
@ -28,9 +44,6 @@
|
|||
codelldb
|
||||
doxygen
|
||||
];
|
||||
buildInputs = with pkgs; [
|
||||
ncurses
|
||||
];
|
||||
shellHook = ''
|
||||
export BOOTSTRAP_ROOT_DIR="${./specs}"
|
||||
'';
|
||||
|
|
Loading…
Reference in New Issue