parent
f0a5462896
commit
2c942f2fff
@ -1,22 +1,56 @@
|
|||||||
SRC:= src/*.c
|
SRC = $(wildcard src/*.c)
|
||||||
INCLUDE:=include/
|
INCLUDE =include/
|
||||||
LIB:=lib
|
|
||||||
BUILD:=build
|
BUILD:=build
|
||||||
CFLAGS:= -g -Wall -pedantic
|
|
||||||
LFLAGS:= -lkhash
|
|
||||||
|
|
||||||
|
RELEASE_CFLAGS?= -O3 -flto -fgraphite
|
||||||
|
RELEASE_LDFLAGS?= -O3 -flto
|
||||||
|
|
||||||
all: clean test kana-hash
|
DEBUG_CFLAGS?= -g -O0
|
||||||
|
DEBUG_LDFLAGS?= -O0
|
||||||
|
|
||||||
clean:
|
LIB = lib
|
||||||
rm -f $(BUILD)/*
|
|
||||||
|
CFLAGS+= $(addprefix -I,$(INCLUDE)) -Wall -pedantic --std=gnu11
|
||||||
|
LDFLAGS+= $(addprefix -L,$(LIB)) -lkhash
|
||||||
|
|
||||||
|
PROJECT = kana-hash
|
||||||
|
OBJ = $(addprefix ./obj/$(SRC:.c=.o))
|
||||||
|
OUTPUT = $(BUILD)/$(PROJECT)
|
||||||
|
|
||||||
|
.PHONY: release
|
||||||
|
release: | dirs $(OUTPUT)-release
|
||||||
|
|
||||||
kana-hash:
|
.PHONY: debug
|
||||||
gcc $(SRC) -I$(INCLUDE) $(CFLAGS) -o $(BUILD)/$@ $(LFLAGS)
|
debug: | dirs $(OUTPUT)-debug
|
||||||
$(BUILD)/$@ test
|
|
||||||
|
|
||||||
test:
|
.PHONY: test
|
||||||
gcc $(SRC) -I$(INCLUDE) -DTEST $(CFLAGS) -o $(BUILD)/$@ $(LFLAGS)
|
test: | dirs $(OUTPUT)-test
|
||||||
$(BUILD)/$@
|
|
||||||
|
|
||||||
|
dirs:
|
||||||
|
@mkdir -p obj/src
|
||||||
|
@mkdir -p $(BUILD)
|
||||||
|
@ln -sf ./$(PROJECT)-release $(OUTPUT)
|
||||||
|
|
||||||
|
obj/%.o: %.c
|
||||||
|
$(CC) -c $< $(CFLAGS) -o $@ $(LDFLAGS)
|
||||||
|
|
||||||
|
$(OUTPUT)-debug: CFLAGS := $(CFLAGS) $(DEBUG_CFLAGS)
|
||||||
|
$(OUTPUT)-debug: LDFLAGS:= $(LDFLAGS) $(DEBUG_LDFLAGS)
|
||||||
|
$(OUTPUT)-debug: $(OBJ)
|
||||||
|
$(CC) $^ $(CFLAGS) -o $@ $(LDFLAGS)
|
||||||
|
|
||||||
|
$(OUTPUT)-release: CFLAGS := $(CFLAGS) $(RELEASE_CFLAGS)
|
||||||
|
$(OUTPUT)-release: LDFLAGS:= $(LDFLAGS) $(RELEASE_LDFLAGS)
|
||||||
|
$(OUTPUT)-release: $(OBJ)
|
||||||
|
$(CC) $^ $(CFLAGS) -o $@ $(LDFLAGS)
|
||||||
|
strip $@
|
||||||
|
|
||||||
|
$(OUTPUT)-test: CFLAGS:= $(CFLAGS) -DTEST
|
||||||
|
$(OUTPUT)-test: $(OBJ)
|
||||||
|
$(CC) $^ $(CFLAGS) -o $@ $(LDFLAGS)
|
||||||
|
./$@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf ./obj
|
||||||
|
rm -f $(OUTPUT)-{release,debug,test}
|
||||||
|
Loading…
Reference in new issue