|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PROJECT := utl
-
- TARGET := utlTest
-
-
- SRC_DIR_LIST := tests gtest
-
-
- INC_DIR_LIST := ../include gtest
-
-
-
-
- BUILD_DIR := bin
- OBJ_DIR := $(BUILD_DIR)/obj
- DEP_DIR := $(BUILD_DIR)/.dep
-
-
- CLANGXX := clang++
- GCCXX := g++
- CSIZE := size
-
- DEB_CFLAGS := -DDEBUG -g3 -Wall -Wextra
- REL_CFLAGS := -Wall -Wextra -O2
-
-
-
-
-
- LDFLAGS := -pthread
-
- MAP_FILE := output.map
- MAP_FLAG := -Xlinker -Map=$(BUILD_DIR)/$(MAP_FILE)
-
-
-
-
-
-
-
- DOCKER_VOL_DIR := "$${PWD%/*}"
- DOCKER_WRK_DIR := test
- DOCKER_RUN := docker run --rm -v $(DOCKER_VOL_DIR):/usr/src/$(PROJECT) -w /usr/src/$(PROJECT)/$(DOCKER_WRK_DIR)
-
-
-
- CFLAGS := $(DEB_CFLAGS)
- CXX := $(GCCXX)
- DOCKER :=
-
-
-
-
- ifeq ($(OS), Windows_NT)
- TARGET := $(TARGET).exe
- endif
- INC := $(foreach dir,$(INC_DIR_LIST),-I$(dir))
- DEF := $(foreach def,$(PRE_DEFS),-D$(def))
- EXC := $(foreach fil,$(EXC_FILE_LIST), \
- $(foreach dir,$(SRC_DIR_LIST),$(wildcard $(dir)/$(fil))) \
- )
-
-
- SRC := $(wildcard *.cpp)
- SRC += $(foreach dir,$(SRC_DIR_LIST),$(wildcard $(dir)/*.cpp))
- SRC += $(foreach dir,$(SRC_DIR_LIST),$(wildcard $(dir)/**/*.cpp))
-
- SRC := $(filter-out $(EXC),$(SRC))
-
- OBJ := $(foreach file,$(SRC:%.cpp=%.o),$(OBJ_DIR)/$(file))
- DEP := $(foreach file,$(SRC:%.cpp=%.d),$(DEP_DIR)/$(file))
-
-
-
-
-
-
-
-
-
- $(DEP_DIR)/%.d: %.cpp
- @mkdir -p $(@D)
- @$(DOCKER) $(CXX) -E $(CFLAGS) $(INC) $(DEF) -MM -MT $(OBJ_DIR)/$(<:.cpp=.o) -MF $@ $<
-
-
- $(OBJ_DIR)/%.o: %.cpp $(DEP_DIR)/%.d
- @mkdir -p $(@D)
- $(DOCKER) $(CXX) -c $(CFLAGS) $(INC) $(DEF) -o $@ $<
-
-
- $(DEP):
-
-
-
- include $(wildcard $(DEP))
-
-
- $(BUILD_DIR)/$(TARGET): $(OBJ)
- @mkdir -p $(@D)
- @echo Linking to target: $(TARGET)
- @echo $(DOCKER) $(CXX) $(LDFLAGS) $(MAP_FLAG) -o $(@D)/$(TARGET) '$$(OBJ)'
- @$(DOCKER) $(CXX) $(LDFLAGS) $(MAP_FLAG) -o $(@D)/$(TARGET) $(OBJ)
- @echo
- @echo Print size information
- @$(CSIZE) $(@D)/$(TARGET)
- @echo Done
-
- .PHONY: clean
- clean:
- @echo Cleaning build directories
- @rm -rf $(OBJ_DIR)
- @rm -rf $(DEP_DIR)
- @rm -rf $(BUILD_DIR)
-
-
-
-
-
-
-
-
- .PHONY: build-gcc
- build-gcc: CFLAGS += $(MK_ARG)
- build-gcc: $(BUILD_DIR)/$(TARGET)
-
- .PHONY: build-clang
- build-clang: CXX := $(CLANGXX)
- build-clang: CFLAGS += $(MK_ARG)
- build-clang: $(BUILD_DIR)/$(TARGET)
-
- .PHONY: debug
- debug: $(BUILD_DIR)/$(TARGET)
-
- .PHONY: release
- release: CFLAGS := $(REL_FLAGS)
- release: clean $(BUILD_DIR)/$(TARGET)
-
- .PHONY: all
- all: clean release
-
-
-
-
-
-
-
- .PHONY: dock-gcc
- dock-gcc: DOCKER := $(DOCKER_RUN) $(IMAGE)
- dock-gcc: CFLAGS += $(MK_ARG)
- dock-gcc: $(BUILD_DIR)/$(TARGET)
-
- .PHONY: dock-clang
- dock-clang: CXX := $(CLANGXX)
- dock-clang: DOCKER := $(DOCKER_RUN) $(IMAGE)
- dock-clang: CFLAGS += $(MK_ARG)
- dock-clang: $(BUILD_DIR)/$(TARGET)
-
-
|