From cb3ff7597f4e43aef49cd6fa0b9def62cbb5de72 Mon Sep 17 00:00:00 2001 From: TheOnePath Date: Tue, 10 Sep 2024 23:12:27 +0100 Subject: [PATCH] Added Makefile --- Makefile | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..266bc05 --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +# Debug flags and release flags for GCC +ifeq ($(BUILD),debug) +CFLAGS += -O0 -g +BUILD_DIR = build/debug +else +CFLAGS += -O2 -s -DNDEBUG +BUILD_DIR = build/release +endif + +# Get the system architecture if not specified +ifeq ($(ARCH),) + ARCH = $(shell uname -m) +endif + +VALGRIND_ARGS += --leak-check=full --track-origins=yes --show-leak-kinds=all +BINARY_NAME = demo + +$(BUILD_DIR)/$(ARCH)/$(BINARY_NAME): obj/kernels.o obj/solve.o obj/gp.o obj/main.o + gcc -std=c99 $(CFLAGS) obj/kernels.o obj/gp.o obj/solve.o obj/main.o\ + -lgsl -lopenblas -lm -o $(BUILD_DIR)/$(ARCH)/$(BINARY_NAME).$(ARCH) +obj/$(BINARY_NAME).o: $(BINARY_NAME).c + gcc -Wall -c main.c -o obj/main.o +obj/kernels.o: src/kernels.c + gcc -Wall -c src/kernels.c -o obj/kernels.o +obj/solve.o: src/solve.c + gcc -Wall -c src/solve.c -o obj/solve.o +obj/gp.o: src/gp.c + gcc -Wall -c src/gp.c -o obj/gp.o + +.PHONY : debug +debug: + $(MAKE) "BUILD=debug" && valgrind $(VALGRIND_ARGS) build/debug/main.x86_64 + +.PHONY : clean +clean: + rm obj/*.o