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
This commit is contained in:
28
Makefile
28
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)
|
||||
.PHONY: all
|
||||
all: $(OUT)
|
||||
|
||||
$(OUT): lib.c parser.c main.c
|
||||
$(CC) $(CFLAGS) $^ -o $@ $(LIBS)
|
||||
|
||||
.PHONY:
|
||||
clean:
|
||||
rm -rfv $(OUT) $(OBJECTS)
|
||||
|
||||
.PHONY: run
|
||||
run: $(OUT)
|
||||
./$^ $(ARGS)
|
||||
|
||||
.PHONY:
|
||||
clean:
|
||||
rm -v $(OUT)
|
||||
|
||||
Reference in New Issue
Block a user