parent
f0a5462896
commit
2c942f2fff
@ -1,22 +1,56 @@
|
||||
SRC:= src/*.c
|
||||
INCLUDE:=include/
|
||||
LIB:=lib
|
||||
SRC = $(wildcard src/*.c)
|
||||
INCLUDE =include/
|
||||
|
||||
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:
|
||||
rm -f $(BUILD)/*
|
||||
LIB = lib
|
||||
|
||||
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:
|
||||
gcc $(SRC) -I$(INCLUDE) $(CFLAGS) -o $(BUILD)/$@ $(LFLAGS)
|
||||
$(BUILD)/$@ test
|
||||
.PHONY: debug
|
||||
debug: | dirs $(OUTPUT)-debug
|
||||
|
||||
test:
|
||||
gcc $(SRC) -I$(INCLUDE) -DTEST $(CFLAGS) -o $(BUILD)/$@ $(LFLAGS)
|
||||
$(BUILD)/$@
|
||||
.PHONY: test
|
||||
test: | dirs $(OUTPUT)-test
|
||||
|
||||
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