You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.3 KiB

4 years ago
SRC = $(wildcard src/*.c)
INCLUDE =include/
4 years ago
BUILD:=build
4 years ago
4 years ago
OPT_FLAGS+= -fgraphite -fno-strict-aliasing -fomit-frame-pointer -fmerge-all-constants -fmodulo-sched -funswitch-loops -fsplit-loops
4 years ago
RELEASE_CFLAGS?= -O3 -flto $(OPT_FLAGS) -march=native
4 years ago
RELEASE_LDFLAGS?= -O3 -flto
4 years ago
4 years ago
DEBUG_CFLAGS?= -g -O0
DEBUG_LDFLAGS?= -O0
4 years ago
4 years ago
LIB = lib
CFLAGS+= $(addprefix -I,$(INCLUDE)) -Wall -pedantic --std=gnu11
LDFLAGS+= $(addprefix -L,$(LIB)) -lkhash
4 years ago
#./$(LIB)/libkhash.a -lpthread -ldl
4 years ago
PROJECT = kana-hash
4 years ago
OBJ = $(addprefix ./obj/,$(SRC:.c=.o))
4 years ago
OUTPUT = $(BUILD)/$(PROJECT)
.PHONY: release
release: | dirs $(OUTPUT)-release
4 years ago
4 years ago
.PHONY: debug
debug: | dirs $(OUTPUT)-debug
4 years ago
4 years ago
.PHONY: test
test: | dirs $(OUTPUT)-test
4 years ago
4 years ago
dirs:
@mkdir -p obj/src
@mkdir -p $(BUILD)
@ln -sf ./$(PROJECT)-release $(OUTPUT)
4 years ago
4 years ago
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)
4 years ago
./$@
4 years ago
clean:
rm -rf ./obj
rm -f $(OUTPUT)-{release,debug,test}