Refactored the Makefiles.
This commit is contained in:
parent
3f197143f6
commit
b49e1497bf
31
config.mk
Normal file
31
config.mk
Normal file
@ -0,0 +1,31 @@
|
||||
DUMPMACHINE := $(shell $(CC) -dumpmachine)
|
||||
ifeq ($(DUMPMACHINE),)
|
||||
$(error The C compiler could not be detected!)
|
||||
endif
|
||||
|
||||
ifneq ($(DEBUG),)
|
||||
XCFLAGS = -Og -g
|
||||
else
|
||||
ifneq ($(ASAN),)
|
||||
XCFLAGS = -O1 -g -fsanitize=address -fno-omit-frame-pointer
|
||||
XLDFLAGS += -static-libasan
|
||||
else
|
||||
XCFLAGS = -Ofast -DNDEBUG
|
||||
ifneq ($(firstword $(filter x86_64-%,$(DUMPMACHINE))),)
|
||||
XCFLAGS += -march=x86-64 -mtune=nocona
|
||||
else ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),)
|
||||
XCFLAGS += -march=pentiumpro -mtune=intel
|
||||
endif
|
||||
ifneq ($(FLTO),)
|
||||
XCFLAGS += -flto
|
||||
endif
|
||||
XLDFLAGS += -s -static
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(firstword $(filter %-mingw32 %-cygwin,$(DUMPMACHINE))),)
|
||||
EXE_SUFFIX := .exe
|
||||
ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),)
|
||||
XLDFLAGS += -Wl,--large-address-aware
|
||||
endif
|
||||
endif
|
@ -1,32 +1,7 @@
|
||||
DUMPMACHINE := $(shell $(CC) -dumpmachine)
|
||||
|
||||
ifneq ($(DEBUG),)
|
||||
XCFLAGS = -Og -g
|
||||
else
|
||||
ifneq ($(ASAN),)
|
||||
XCFLAGS = -O1 -g -fsanitize=address -fno-omit-frame-pointer -static-libasan
|
||||
else
|
||||
XCFLAGS = -Ofast -DNDEBUG
|
||||
ifneq ($(firstword $(filter x86_64-%,$(DUMPMACHINE))),)
|
||||
XCFLAGS += -march=x86-64 -mtune=nocona
|
||||
else ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),)
|
||||
XCFLAGS += -march=pentiumpro -mtune=intel
|
||||
endif
|
||||
ifneq ($(FLTO),)
|
||||
XCFLAGS += -flto
|
||||
endif
|
||||
XCFLAGS += -s -static
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(firstword $(filter %-mingw32 %-cygwin,$(DUMPMACHINE))),)
|
||||
EXE_SUFFIX := .exe
|
||||
ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),)
|
||||
XCFLAGS += -Wl,--large-address-aware
|
||||
endif
|
||||
endif
|
||||
include ../../config.mk
|
||||
|
||||
CFLAGS = -std=c99 -D_DEFAULT_SOURCE -Wpedantic -I../../libhashset/include $(XCFLAGS)
|
||||
LDFLAGS = -L../../libhashset/lib -lhashset-1 $(XLDFLAGS)
|
||||
|
||||
SRC_PATH := src
|
||||
BIN_PATH := bin
|
||||
@ -34,7 +9,6 @@ ALL_PATH := $(SRC_PATH) $(BIN_PATH)
|
||||
|
||||
BIN_FILE := $(BIN_PATH)/example-hash-map$(EXE_SUFFIX)
|
||||
SRC_FILE := $(wildcard $(SRC_PATH)/*.c)
|
||||
LIB_FILE := ../../libhashset/lib/libhashset-1.a
|
||||
|
||||
.PHONY: all build clean
|
||||
|
||||
@ -42,11 +16,11 @@ all: clean build
|
||||
|
||||
build: $(ALL_PATH) $(BIN_FILE)
|
||||
|
||||
$(BIN_FILE): $(SRC_FILE) $(LIB_FILE)
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
$(BIN_FILE): $(SRC_FILE)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
$(ALL_PATH):
|
||||
mkdir -p $@
|
||||
|
||||
clean:
|
||||
rm -f $(BIN_FILE)
|
||||
rm -vf $(BIN_FILE)
|
||||
|
@ -1,32 +1,7 @@
|
||||
DUMPMACHINE := $(shell $(CC) -dumpmachine)
|
||||
|
||||
ifneq ($(DEBUG),)
|
||||
XCFLAGS = -Og -g
|
||||
else
|
||||
ifneq ($(ASAN),)
|
||||
XCFLAGS = -O1 -g -fsanitize=address -fno-omit-frame-pointer -static-libasan
|
||||
else
|
||||
XCFLAGS = -Ofast -DNDEBUG
|
||||
ifneq ($(firstword $(filter x86_64-%,$(DUMPMACHINE))),)
|
||||
XCFLAGS += -march=x86-64 -mtune=nocona
|
||||
else ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),)
|
||||
XCFLAGS += -march=pentiumpro -mtune=intel
|
||||
endif
|
||||
ifneq ($(FLTO),)
|
||||
XCFLAGS += -flto
|
||||
endif
|
||||
XCFLAGS += -s -static
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(firstword $(filter %-mingw32 %-cygwin,$(DUMPMACHINE))),)
|
||||
EXE_SUFFIX := .exe
|
||||
ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),)
|
||||
XCFLAGS += -Wl,--large-address-aware
|
||||
endif
|
||||
endif
|
||||
include ../../config.mk
|
||||
|
||||
CFLAGS = -std=c99 -D_DEFAULT_SOURCE -Wpedantic -I../../libhashset/include $(XCFLAGS)
|
||||
LDFLAGS = -L../../libhashset/lib -lhashset-1 $(XLDFLAGS)
|
||||
|
||||
SRC_PATH := src
|
||||
BIN_PATH := bin
|
||||
@ -34,7 +9,6 @@ ALL_PATH := $(SRC_PATH) $(BIN_PATH)
|
||||
|
||||
BIN_FILE := $(BIN_PATH)/example-hash-set$(EXE_SUFFIX)
|
||||
SRC_FILE := $(wildcard $(SRC_PATH)/*.c)
|
||||
LIB_FILE := ../../libhashset/lib/libhashset-1.a
|
||||
|
||||
.PHONY: all build clean
|
||||
|
||||
@ -42,11 +16,11 @@ all: clean build
|
||||
|
||||
build: $(ALL_PATH) $(BIN_FILE)
|
||||
|
||||
$(BIN_FILE): $(SRC_FILE) $(LIB_FILE)
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
$(BIN_FILE): $(SRC_FILE)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
$(ALL_PATH):
|
||||
mkdir -p $@
|
||||
|
||||
clean:
|
||||
rm -f $(BIN_FILE)
|
||||
rm -vf $(BIN_FILE)
|
||||
|
@ -1,22 +1,4 @@
|
||||
DUMPMACHINE := $(shell $(CC) -dumpmachine)
|
||||
|
||||
ifneq ($(DEBUG),)
|
||||
XCFLAGS = -Og -g
|
||||
else
|
||||
ifneq ($(ASAN),)
|
||||
XCFLAGS = -O1 -g -fsanitize=address -fno-omit-frame-pointer -static-libasan
|
||||
else
|
||||
XCFLAGS = -Ofast -DNDEBUG
|
||||
ifneq ($(firstword $(filter x86_64-%,$(DUMPMACHINE))),)
|
||||
XCFLAGS += -march=x86-64 -mtune=nocona
|
||||
else ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),)
|
||||
XCFLAGS += -march=pentiumpro -mtune=intel
|
||||
endif
|
||||
ifneq ($(FLTO),)
|
||||
XCFLAGS += -flto
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
include ../config.mk
|
||||
|
||||
CFLAGS = -std=c99 -D_DEFAULT_SOURCE -Wpedantic -Iinclude $(XCFLAGS)
|
||||
|
||||
|
@ -1,40 +1,14 @@
|
||||
DUMPMACHINE := $(shell $(CC) -dumpmachine)
|
||||
|
||||
ifneq ($(DEBUG),)
|
||||
XCFLAGS = -Og -g
|
||||
else
|
||||
ifneq ($(ASAN),)
|
||||
XCFLAGS = -O1 -g -fsanitize=address -fno-omit-frame-pointer -static-libasan
|
||||
else
|
||||
XCFLAGS = -Ofast -DNDEBUG
|
||||
ifneq ($(firstword $(filter x86_64-%,$(DUMPMACHINE))),)
|
||||
XCFLAGS += -march=x86-64 -mtune=nocona
|
||||
else ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),)
|
||||
XCFLAGS += -march=pentiumpro -mtune=intel
|
||||
endif
|
||||
ifneq ($(FLTO),)
|
||||
XCFLAGS += -flto
|
||||
endif
|
||||
XCFLAGS += -s -static
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(firstword $(filter %-mingw32 %-cygwin,$(DUMPMACHINE))),)
|
||||
EXE_SUFFIX := .exe
|
||||
ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),)
|
||||
XCFLAGS += -Wl,--large-address-aware
|
||||
endif
|
||||
endif
|
||||
include ../../config.mk
|
||||
|
||||
CFLAGS = -std=c99 -D_DEFAULT_SOURCE -Wpedantic -I../../libhashset/include $(XCFLAGS)
|
||||
LDFLAGS = -L../../libhashset/lib -lhashset-1 $(XLDFLAGS)
|
||||
|
||||
SRC_PATH := src
|
||||
BIN_PATH := bin
|
||||
ALL_PATH := $(SRC_PATH) $(BIN_PATH)
|
||||
|
||||
BIN_FILE := $(BIN_PATH)/hashset-test$(EXE_SUFFIX)
|
||||
BIN_FILE := $(BIN_PATH)/test-hash-set$(EXE_SUFFIX)
|
||||
SRC_FILE := $(wildcard $(SRC_PATH)/*.c)
|
||||
LIB_FILE := ../../libhashset/lib/libhashset-1.a
|
||||
|
||||
.PHONY: all build clean
|
||||
|
||||
@ -42,11 +16,11 @@ all: clean build
|
||||
|
||||
build: $(ALL_PATH) $(BIN_FILE)
|
||||
|
||||
$(BIN_FILE): $(SRC_FILE) $(LIB_FILE)
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
$(BIN_FILE): $(SRC_FILE)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
$(ALL_PATH):
|
||||
mkdir -p $@
|
||||
|
||||
clean:
|
||||
rm -f $(BIN_FILE)
|
||||
rm -vf $(BIN_FILE)
|
||||
|
Loading…
Reference in New Issue
Block a user