2022-11-22 23:31:21 +01:00
|
|
|
DUMPMACHINE := $(shell $(CC) -dumpmachine)
|
|
|
|
|
2022-11-25 13:36:53 +01:00
|
|
|
ifneq ($(SANITIZE_ADDRESS),1)
|
2022-11-27 19:46:01 +01:00
|
|
|
XCFLAGS = -Ofast -DNDEBUG
|
2022-11-22 23:31:21 +01:00
|
|
|
ifneq ($(firstword $(filter x86_64-%,$(DUMPMACHINE))),)
|
2022-11-25 13:36:53 +01:00
|
|
|
XCFLAGS += -march=x86-64 -mtune=nocona
|
2022-11-22 23:31:21 +01:00
|
|
|
else ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),)
|
2022-11-25 13:36:53 +01:00
|
|
|
XCFLAGS += -march=pentiumpro -mtune=intel
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
XCFLAGS = -fsanitize=address -static-libasan -g
|
2022-11-22 23:31:21 +01:00
|
|
|
endif
|
|
|
|
|
2022-11-25 13:36:53 +01:00
|
|
|
CFLAGS = -std=c99 -D_DEFAULT_SOURCE -Wpedantic -Iinclude $(XCFLAGS)
|
2022-11-22 23:31:21 +01:00
|
|
|
|
|
|
|
SRC_PATH := src
|
|
|
|
OBJ_PATH := obj
|
|
|
|
LIB_PATH := lib
|
2022-11-27 19:46:01 +01:00
|
|
|
ALL_PATH := $(SRC_PATH) $(OBJ_PATH) $(LIB_PATH)
|
2022-11-22 23:31:21 +01:00
|
|
|
|
2022-11-27 19:46:01 +01:00
|
|
|
SRC_FILE := $(wildcard $(SRC_PATH)/*.c)
|
|
|
|
OBJ_FILE := $(addprefix $(OBJ_PATH)/,$(patsubst %.c,%.o,$(notdir $(SRC_FILE))))
|
2022-11-22 23:31:21 +01:00
|
|
|
LIB_FILE := $(LIB_PATH)/libhashset-1.a
|
|
|
|
|
2022-11-27 19:46:01 +01:00
|
|
|
.PHONY: all build clean
|
2022-11-22 23:31:21 +01:00
|
|
|
|
2022-11-27 19:46:01 +01:00
|
|
|
all: clean build
|
2022-11-22 23:31:21 +01:00
|
|
|
|
2022-11-27 19:46:01 +01:00
|
|
|
build: $(ALL_PATH) $(LIB_FILE)
|
2022-11-22 23:31:21 +01:00
|
|
|
|
2022-11-27 19:46:01 +01:00
|
|
|
$(LIB_FILE): $(OBJ_FILE)
|
|
|
|
$(AR) rcs $@ $(OBJ_FILE)
|
|
|
|
|
|
|
|
$(OBJ_FILE):
|
2022-11-22 23:31:21 +01:00
|
|
|
$(CC) $(CFLAGS) -c $(SRC_PATH)/$(patsubst %.o,%.c,$(notdir $@)) -o $@
|
|
|
|
|
2022-11-27 19:46:01 +01:00
|
|
|
$(ALL_PATH):
|
2022-11-22 23:31:21 +01:00
|
|
|
mkdir -p $@
|
|
|
|
|
|
|
|
clean:
|
2022-11-27 19:46:01 +01:00
|
|
|
rm -vf $(LIB_FILE) $(OBJ_PATH)/*.o
|