|
|
@@ -1,9 +1,7 @@ |
|
|
|
#
|
|
|
|
# Makefile
|
|
|
|
#
|
|
|
|
# Main makefile for utl Unit test
|
|
|
|
# Makefile for utl Unit test
|
|
|
|
#
|
|
|
|
# Copyright (C) 2019 Christos Choutouridis <christos@choutouridis.net>
|
|
|
|
# Copyright (C) 2019-2020 Christos Choutouridis <christos@choutouridis.net>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser General Public License as
|
|
|
@@ -20,50 +18,69 @@ |
|
|
|
#
|
|
|
|
|
|
|
|
# ========== Project settings ==========
|
|
|
|
TARGET := utlTest.exe
|
|
|
|
SRC_DIR := tests gtest
|
|
|
|
INC_DIR := ../include gtest
|
|
|
|
EXC_FILE :=
|
|
|
|
# Excecutable's name
|
|
|
|
TARGET := utlTest
|
|
|
|
|
|
|
|
# List(space seperated) of source directories
|
|
|
|
# ex:
|
|
|
|
# SRC_DIR_LIST := src1 /var/src2 ../src3
|
|
|
|
SRC_DIR_LIST := tests gtest
|
|
|
|
|
|
|
|
# List(space seperated) of include directories
|
|
|
|
# ex:
|
|
|
|
# INC_DIR_LIST := inc /var/inc ../include2
|
|
|
|
INC_DIR_LIST := ../include gtest
|
|
|
|
|
|
|
|
# List(space seperated) of exclude files (filenames only)
|
|
|
|
# ex:
|
|
|
|
# EXC_FILE_LIST := bad.cpp old.cpp
|
|
|
|
EXC_FILE_LIST :=
|
|
|
|
|
|
|
|
# build directories
|
|
|
|
BUILD_DIR := bin
|
|
|
|
OBJ_DIR := $(BUILD_DIR)/obj
|
|
|
|
DEP_DIR := $(BUILD_DIR)/.dep
|
|
|
|
BUILD_DIR := bin
|
|
|
|
OBJ_DIR := $(BUILD_DIR)/obj
|
|
|
|
DEP_DIR := $(BUILD_DIR)/.dep
|
|
|
|
|
|
|
|
|
|
|
|
# ========== Compiler settings ==========
|
|
|
|
CXX := g++
|
|
|
|
CPP := g++ -E
|
|
|
|
CSIZE := size
|
|
|
|
CLANGXX := clang++
|
|
|
|
CLANGPP := clang++ -E
|
|
|
|
GCCXX := g++
|
|
|
|
GCCPP := g++ -E
|
|
|
|
|
|
|
|
CFLAGS := -std=c++14 -Wall -Wextra
|
|
|
|
DEB_FLAGS := -DDEBUG -g3
|
|
|
|
REL_FLAGS := -O3
|
|
|
|
LDFLAGS :=
|
|
|
|
CXX := $(GCCXX)
|
|
|
|
CPP := $(GCCPP)
|
|
|
|
CSIZE := size
|
|
|
|
|
|
|
|
PRE_DEFS :=
|
|
|
|
|
|
|
|
MAP_FILE := $(BUILD_DIR)/output.map
|
|
|
|
MAP_FLAG := -Xlinker -Map=$(MAP_FILE)
|
|
|
|
CFLAGS := -Wall -Wextra
|
|
|
|
DEB_FLAGS := -DDEBUG -g3
|
|
|
|
REL_FLAGS := -O2
|
|
|
|
# example: LDFLAGS := -pthread -lm
|
|
|
|
LDFLAGS := -pthread
|
|
|
|
# example: MYCAB=1729 SUPER_MODE
|
|
|
|
PRE_DEFS :=
|
|
|
|
|
|
|
|
MAP_FILE := $(BUILD_DIR)/output.map
|
|
|
|
MAP_FLAG := -Xlinker -Map=$(MAP_FILE)
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# =========== Main body and Patterns ===========
|
|
|
|
#
|
|
|
|
INC := $(foreach dir,$(INC_DIR),-I$(dir))
|
|
|
|
DEF := $(foreach def,$(PRE_DEFS),-D$(def))
|
|
|
|
|
|
|
|
# source files
|
|
|
|
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))) \
|
|
|
|
)
|
|
|
|
# source files. object and dependencies list
|
|
|
|
# recursive search into current and source directories
|
|
|
|
SRC := $(wildcard *.cpp)
|
|
|
|
SRC += $(foreach dir,$(SRC_DIR),$(wildcard $(dir)/*.cpp))
|
|
|
|
SRC += $(foreach dir,$(SRC_DIR),$(wildcard $(dir)/**/*.cpp))
|
|
|
|
# exclude every file from the exclude file list
|
|
|
|
SRC := $(filter-out $(wildcard $(EXC_FILE)),$(SRC))
|
|
|
|
SRC := $(wildcard *.cpp)
|
|
|
|
SRC += $(foreach dir,$(SRC_DIR_LIST),$(wildcard $(dir)/*.cpp))
|
|
|
|
SRC += $(foreach dir,$(SRC_DIR_LIST),$(wildcard $(dir)/**/*.cpp))
|
|
|
|
SRC := $(abspath $(filter-out $(EXC),$(SRC)))
|
|
|
|
|
|
|
|
OBJ := $(foreach file,$(SRC:%.cpp=%.o),$(OBJ_DIR)/$(file))
|
|
|
|
DEP := $(foreach file,$(SRC:%.cpp=%.d),$(DEP_DIR)/$(file))
|
|
|
|
OBJ := $(foreach file,$(SRC:%.cpp=%.o),$(OBJ_DIR)$(file))
|
|
|
|
DEP := $(foreach file,$(SRC:%.cpp=%.d),$(DEP_DIR)$(file))
|
|
|
|
|
|
|
|
|
|
|
|
# Make Dependencies pattern.
|
|
|
@@ -73,13 +90,12 @@ DEP := $(foreach file,$(SRC:%.cpp=%.d),$(DEP_DIR)/$(file)) |
|
|
|
# It is based on Tom Tromey's method.
|
|
|
|
#
|
|
|
|
# Invoke cpp to create makefile rules with dependencies for each source file
|
|
|
|
$(DEP_DIR)/%.d: %.cpp
|
|
|
|
$(DEP_DIR)%.d: %.cpp
|
|
|
|
@mkdir -p $(@D)
|
|
|
|
@$(CPP) $(CFLAGS) $(INC) $(DEF) -MM -MT $(OBJ_DIR)/$(<:.cpp=.o) -MF $@ $<
|
|
|
|
|
|
|
|
@$(CPP) $(CFLAGS) $(INC) $(DEF) -MM -MT $(OBJ_DIR)$(<:.cpp=.o) -MF $@ $<
|
|
|
|
|
|
|
|
# objects depent on .cpp AND dependency files, which have an empty recipe
|
|
|
|
$(OBJ_DIR)/%.o: %.cpp $(DEP_DIR)/%.d
|
|
|
|
$(OBJ_DIR)%.o: %.cpp $(DEP_DIR)%.d
|
|
|
|
@mkdir -p $(@D)
|
|
|
|
$(CXX) -c $(CFLAGS) $(INC) $(DEF) -o $@ $<
|
|
|
|
|
|
|
@@ -101,7 +117,6 @@ $(BUILD_DIR)/$(TARGET): $(OBJ) |
|
|
|
@$(CSIZE) $(@D)/$(TARGET)
|
|
|
|
@echo Done
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
@echo Cleaning build directories
|
|
|
@@ -110,21 +125,63 @@ clean: |
|
|
|
@rm -rf $(BUILD_DIR)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# ============ User Rules =============
|
|
|
|
#
|
|
|
|
|
|
|
|
.PHONY: gcc14
|
|
|
|
gcc14: CFLAGS += $(DEB_FLAGS)
|
|
|
|
gcc14: CFLAGS += -std=c++14
|
|
|
|
gcc14: $(BUILD_DIR)/$(TARGET)
|
|
|
|
|
|
|
|
.PHONY: gcc14_conc
|
|
|
|
gcc14_conc: CFLAGS += $(DEB_FLAGS)
|
|
|
|
gcc14_conc: CFLAGS += -std=c++14 -fconcepts
|
|
|
|
gcc14_conc: $(BUILD_DIR)/$(TARGET)
|
|
|
|
|
|
|
|
.PHONY: gcc17
|
|
|
|
gcc17: CFLAGS += $(DEB_FLAGS)
|
|
|
|
gcc17: CFLAGS += -std=c++17
|
|
|
|
gcc17: $(BUILD_DIR)/$(TARGET)
|
|
|
|
|
|
|
|
.PHONY: gcc17_conc
|
|
|
|
gcc17_conc: CFLAGS += $(DEB_FLAGS)
|
|
|
|
gcc17_conc: CFLAGS += -std=c++17 -fconcepts
|
|
|
|
gcc17_conc: $(BUILD_DIR)/$(TARGET)
|
|
|
|
|
|
|
|
.PHONY: gcc2a
|
|
|
|
gcc2a: CFLAGS += $(DEB_FLAGS)
|
|
|
|
gcc2a: CFLAGS += -std=c++2a
|
|
|
|
gcc2a: $(BUILD_DIR)/$(TARGET)
|
|
|
|
|
|
|
|
.PHONY: clang14
|
|
|
|
clang14: CXX := $(CLANGXX)
|
|
|
|
clang14: CPP := $(CLANGPP)
|
|
|
|
clang14: CFLAGS += $(DEB_FLAGS)
|
|
|
|
clang14: CFLAGS += -std=c++14
|
|
|
|
clang14: $(BUILD_DIR)/$(TARGET)
|
|
|
|
|
|
|
|
.PHONY: clang17
|
|
|
|
clang14: CXX := $(CLANGXX)
|
|
|
|
clang14: CPP := $(CLANGPP)
|
|
|
|
clang14: CFLAGS += $(DEB_FLAGS)
|
|
|
|
clang14: CFLAGS += -std=c++17
|
|
|
|
clang14: $(BUILD_DIR)/$(TARGET)
|
|
|
|
|
|
|
|
.PHONY: clang2a
|
|
|
|
clang14: CXX := $(CLANGXX)
|
|
|
|
clang14: CPP := $(CLANGPP)
|
|
|
|
clang14: CFLAGS += $(DEB_FLAGS)
|
|
|
|
clang14: CFLAGS += -std=c++2a
|
|
|
|
clang14: $(BUILD_DIR)/$(TARGET)
|
|
|
|
|
|
|
|
.PHONY: debug
|
|
|
|
debug: CFLAGS += $(DEB_FLAGS)
|
|
|
|
debug: $(BUILD_DIR)/$(TARGET)
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: release
|
|
|
|
release: CFLAGS += $(REL_FLAGS)
|
|
|
|
release: clean $(BUILD_DIR)/$(TARGET)
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: all
|
|
|
|
all: clean release
|
|
|
|
|