From 9fcd22a03b9fe3aa5659d4b544fc3ccc59730031 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Tue, 3 Dec 2024 00:22:14 +0000 Subject: Simplify build system RELEASE and DEBUG builds have differing build flags, triggered by setting RELEASE variable. No longer doing object based compilation because: + gcc is fast enough without it + stale code compilation bugs are annoying + having one output binary to clean-up is just easier when switching build-types --- Makefile | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 09de95d..b96aaa9 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,28 @@ CC=gcc -CFLAGS=-Wall -Wextra -Wpedantic -ggdb -fsanitize=address -std=c11 -LIBS= -OBJECTS=lib.o parser.o main.o OUT=obf.out +LIBS= ARGS= -%.o: %.c - $(CC) $(CFLAGS) -c $^ -o $@ $(LIBS) +RELEASE=0 +GFLAGS=-Wall -Wextra -Werror -Wswitch-enum -std=c11 +DFLAGS=-ggdb -fsanitize=address -fsanitize=undefined -DDEBUG +RFLAGS=-O3 +ifeq ($(RELEASE), 1) +CFLAGS=$(GFLAGS) $(RFLAGS) +else +CFLAGS=$(GFLAGS) $(DFLAGS) +endif -$(OUT): $(OBJECTS) - $(CC) $(CFLAGS) $^ -o $@ $(LIBS) +.PHONY: all +all: $(OUT) -.PHONY: -clean: - rm -rfv $(OUT) $(OBJECTS) +$(OUT): lib.c parser.c main.c + $(CC) $(CFLAGS) $^ -o $@ $(LIBS) .PHONY: run run: $(OUT) ./$^ $(ARGS) + +.PHONY: +clean: + rm -v $(OUT) -- cgit v1.2.3-13-gbd6f