2022-03-21 21:52:44 -04:00
|
|
|
# Only used for standalone compilation, usually inherits these from the main makefile
|
2022-05-11 13:18:24 -04:00
|
|
|
|
2022-06-22 14:59:21 -04:00
|
|
|
CXX ?= g++
|
|
|
|
CC ?= gcc
|
2022-05-11 13:18:24 -04:00
|
|
|
AR := ar
|
|
|
|
FORMAT := clang-format-11
|
2022-06-22 14:59:21 -04:00
|
|
|
UNAME := $(shell uname)
|
2022-05-11 13:18:24 -04:00
|
|
|
|
|
|
|
ASAN ?= 0
|
|
|
|
DEBUG ?= 1
|
|
|
|
OPTFLAGS ?= -O0
|
|
|
|
LTO ?= 0
|
|
|
|
|
|
|
|
WARN := -Wall -Wextra -Werror \
|
|
|
|
-Wno-unused-variable \
|
|
|
|
-Wno-unused-parameter \
|
|
|
|
-Wno-unused-function \
|
|
|
|
-Wno-parentheses \
|
|
|
|
-Wno-narrowing \
|
2022-07-05 21:10:14 -04:00
|
|
|
-Wno-error=stringop-overflow \
|
2022-06-22 14:59:21 -04:00
|
|
|
-Wno-missing-field-initializers \
|
|
|
|
-Wno-error=multichar
|
2022-05-11 13:18:24 -04:00
|
|
|
|
2022-06-04 03:59:41 -04:00
|
|
|
CWARN :=
|
2022-07-06 18:49:45 -04:00
|
|
|
CXXWARN := -Wno-deprecated-enum-enum-conversion -Wno-error=maybe-uninitialized
|
2022-06-04 03:59:41 -04:00
|
|
|
|
|
|
|
CXXFLAGS := $(WARN) $(CXXWARN) -std=c++20 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0
|
|
|
|
CFLAGS := $(WARN) $(CWARN) -std=c99 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0
|
2022-05-11 13:18:24 -04:00
|
|
|
CPPFLAGS := -MMD
|
|
|
|
|
2022-06-22 14:59:21 -04:00
|
|
|
ifeq ($(UNAME), Darwin) #APPLE
|
|
|
|
CPPFLAGS += $(shell pkg-config --cflags sdl2 glew) -framework OpenGL
|
|
|
|
endif
|
|
|
|
|
2022-05-11 13:18:24 -04:00
|
|
|
ifneq ($(DEBUG),0)
|
|
|
|
CXXFLAGS += -g -D_DEBUG
|
|
|
|
CFLAGS += -g -D_DEBUG
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(ASAN),0)
|
|
|
|
CXXFLAGS += -fsanitize=address
|
|
|
|
CFLAGS += -fsanitize=address
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(LTO),0)
|
|
|
|
CXXFLAGS += -flto
|
|
|
|
CFLAGS += -flto
|
|
|
|
endif
|
2022-03-21 21:52:44 -04:00
|
|
|
|
2022-06-22 14:59:21 -04:00
|
|
|
SRC_DIRS := $(shell find . -type d -not -path "*build*")
|
2022-03-21 21:52:44 -04:00
|
|
|
|
2022-05-11 13:18:24 -04:00
|
|
|
CXX_FILES := \
|
2022-06-04 03:59:41 -04:00
|
|
|
$(shell find libultraship/Factories -name "*.cpp") \
|
2022-06-04 06:49:40 -04:00
|
|
|
$(shell find libultraship/Lib/Fast3D -name "*.cpp") \
|
2022-06-04 03:59:41 -04:00
|
|
|
$(shell find libultraship -maxdepth 1 -name "*.cpp") \
|
|
|
|
$(shell find libultraship/Lib/ImGui -maxdepth 1 -name "*.cpp") \
|
2022-05-11 13:18:24 -04:00
|
|
|
libultraship/Lib/ImGui/backends/imgui_impl_opengl3.cpp \
|
|
|
|
libultraship/Lib/ImGui/backends/imgui_impl_sdl.cpp \
|
|
|
|
libultraship/Lib/StrHash64.cpp \
|
|
|
|
libultraship/Lib/tinyxml2/tinyxml2.cpp
|
|
|
|
|
|
|
|
C_FILES := \
|
|
|
|
libultraship/mixer.c \
|
|
|
|
libultraship/Lib/stb/stb_impl.c
|
|
|
|
|
2022-06-04 03:59:41 -04:00
|
|
|
FMT_FILES := $(shell find libultraship/ -type f \( -name "*.cpp" -o -name "*.h" \) -a -not -path "libultraship/Lib/*")
|
2022-05-11 13:18:24 -04:00
|
|
|
|
|
|
|
O_FILES := \
|
|
|
|
$(CXX_FILES:%.cpp=build/%.o) \
|
|
|
|
$(C_FILES:%.c=build/%.o)
|
|
|
|
|
|
|
|
D_FILES := $(O_FILES:%.o=%.d)
|
|
|
|
|
|
|
|
LIB := libultraship.a
|
|
|
|
|
|
|
|
INC_DIRS := $(addprefix -I, \
|
|
|
|
../ZAPDTR/ZAPDUtils \
|
|
|
|
libultraship/Lib/Fast3D/U64 \
|
|
|
|
libultraship/Lib/spdlog \
|
|
|
|
libultraship/Lib/spdlog/include \
|
2022-06-22 14:59:21 -04:00
|
|
|
libultraship/Lib/ImGui \
|
2022-05-11 13:18:24 -04:00
|
|
|
libultraship \
|
2022-06-04 03:59:41 -04:00
|
|
|
../StormLib/src \
|
2022-05-11 13:18:24 -04:00
|
|
|
)
|
2022-03-21 21:52:44 -04:00
|
|
|
|
|
|
|
# create build directories
|
2022-05-11 13:18:24 -04:00
|
|
|
$(shell mkdir -p $(SRC_DIRS:%=build/%))
|
2022-03-21 21:52:44 -04:00
|
|
|
|
|
|
|
all: $(LIB)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf build $(LIB)
|
|
|
|
|
|
|
|
format:
|
2022-05-11 13:18:24 -04:00
|
|
|
$(FORMAT) -i $(FMT_FILES)
|
2022-03-21 21:52:44 -04:00
|
|
|
|
|
|
|
.PHONY: all clean format
|
|
|
|
|
|
|
|
build/%.o: %.cpp
|
2022-05-11 13:18:24 -04:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPTFLAGS) $(INC_DIRS) -c $< -o $@
|
|
|
|
|
|
|
|
build/%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) $(OPTFLAGS) $(INC_DIRS) -c $< -o $@
|
2022-03-21 21:52:44 -04:00
|
|
|
|
|
|
|
$(LIB): $(O_FILES)
|
|
|
|
$(AR) rcs $@ $^
|
2022-05-11 13:18:24 -04:00
|
|
|
|
2022-06-22 14:59:21 -04:00
|
|
|
-include $(D_FILES)
|