Created
May 9, 2020 18:36
-
-
Save abel0b/24c3c17b167b8f142829d22a90cdbb6a to your computer and use it in GitHub Desktop.
Makefile C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC ?= gcc | |
CFLAGS += -std=c99 -Wall -Wextra -Iinclude | |
LDLIBS = -lm | |
.PHONY: all release debug native %test clean% | |
all: release | |
release: target/release/foobar | |
debug: target/debug/foobar | |
native: target/native/foobar | |
target/release/%: CFLAGS += -O3 | |
target/debug/% target/test/%: CFLAGS += -DDEBUG -ggdb3 -O0 | |
target/native/%: CFLAGS += -O3 -march=native | |
target/%/kbc: src/foobar.c include/foobar.h | target/% | |
$(CC) $(CFLAGS) $^ $(LDLIBS) -o $@ | |
test: unit-test e2e-test | |
e2e-test: target/test/kbc | |
bash test/e2e/run.sh | |
unit-test: target/test/unit-test | |
./target/test/unit-test | |
target/test/unit-test: test/unit/main.c | target/test | |
$(CC) $(CFLAGS) $^ $(LDLIBS) -o $@ | |
clean: | |
rm -rf target | |
target/release target/debug target/test target/native: | |
mkdir -p $@ | |
compile_flags.txt: Makefile | |
printf '%s\n' $(CFLAGS) > $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment