From b164ac63745e307bfef009400fc3191a27f7c96c Mon Sep 17 00:00:00 2001 From: flu0r1ne Date: Mon, 31 Oct 2022 05:42:30 -0500 Subject: restructure library --- makefile | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'makefile') diff --git a/makefile b/makefile index e412184..8328469 100644 --- a/makefile +++ b/makefile @@ -1,3 +1,40 @@ -main: - gcc main.c ./util/hash.c ./util/prime_search.c -lhts -lm ./util/sds/sds.c ./util/err.c -g -o qidx -fsanitize=address -.PHONY: main +ifeq ($(PREFIX),) + PREFIX := /usr/local +endif + +ifeq ($(BINDIR),) + BINDIR := /bin +endif + +CMD=qidx + +CC=gcc + +DEBUG := -fsanitize=address -O2 + +CFLAGS := -Wall -pedantic -g +LDFLAGS := -lhts -lm + +SRC_EXT:=%.c + +_STD_BUILD=$(CC) $(CFLAGS) $(filter $(SRC_EXT) %.o, $^) -o $@ +STD_BUILD=$(_STD_BUILD) $(LDFLAGS) +STD_COMPILE=$(_STD_BUILD) -c + +OBJS = ./util/hash.o +OBJS += ./util/prime_search.o +OBJS += ./util/prime_search.o +OBJS += ./util/sds/sds.o +OBJS += ./util/err.o +OBJS += ./qidx.o + +make: $(CMD) + +$(CMD): ./main.c $(OBJS) + $(STD_BUILD) + +clean: + $(RM) $(CMD) $(OBJS) + +%.o: %.c + $(STD_COMPILE) -- cgit v1.2.3