prosperon/Makefile

123 lines
3.3 KiB
Makefile
Raw Normal View History

2022-02-03 09:16:22 -06:00
UNAME != uname
2021-11-30 21:29:18 -06:00
ifeq ($(OS),Windows_NT)
2022-02-03 09:16:22 -06:00
UNAME = Windows_NT
2021-11-30 21:29:18 -06:00
endif
2022-02-03 09:16:22 -06:00
UNAME_P != uname -m
2021-11-30 21:29:18 -06:00
#CC specifies which compiler we're using
2022-01-21 11:26:22 -06:00
CC = clang
2021-11-30 21:29:18 -06:00
CXX = clang++
ifeq ($(DEBUG), 1)
DEFFALGS += -DDEBUG
INFO = dbg
endif
2022-01-19 16:43:21 -06:00
objprefix = ./obj
2022-02-03 09:16:22 -06:00
DIRS = engine pinball editor brainstorm
ETP = ./source/engine/thirdparty/
2021-11-30 21:29:18 -06:00
2022-02-03 09:16:22 -06:00
define make_objs
2022-02-03 11:29:43 -06:00
find $(1) -type f -name '*.c' -o -name '*.cpp' | sed 's|\.c.*|.o|' | sed 's|\.|./obj|1'
2022-02-03 09:16:22 -06:00
endef
2022-01-20 11:16:44 -06:00
2022-02-03 09:16:22 -06:00
define find_include
2022-02-03 11:29:43 -06:00
find $(1) -type f -name '*.h' | sed 's|\/[^\/]*\.h$$||' | sort | uniq
2022-02-03 09:16:22 -06:00
endef
2021-11-30 21:29:18 -06:00
2022-02-03 09:16:22 -06:00
define prefix
echo $(1) | tr " " "\n" | sed 's|.*|$(2)&$(3)|'
endef
2022-01-20 11:16:44 -06:00
2022-02-03 09:16:22 -06:00
define rm
tmp=$$(mktemp); \
echo $(2) | tr " " "\n" > $${tmp}; \
echo $(1) | tr " " "\n" | grep -v -f $${tmp}; \
rm $${tmp}
endef
2022-01-20 11:16:44 -06:00
2022-02-03 09:16:22 -06:00
# All other sources
edirs != $(call find_include, ./source/engine)
eobjects != $(call make_objs, ./source/engine)
eobjects != $(call rm,$(eobjects),sqlite s7 pl_mpeg_extract_frames pl_mpeg_player)
2021-11-30 21:29:18 -06:00
2022-02-03 09:16:22 -06:00
imguisrcs = imgui imgui_draw imgui_widgets imgui_tables backends/imgui_impl_sdl backends/imgui_impl_opengl3
imguiobjs != $(call prefix,$(imguisrcs),./source/editor/imgui/,.o)
2021-11-30 21:29:18 -06:00
2022-02-03 09:16:22 -06:00
eddirs != find ./source/editor -type d
edobjects != $(call make_objs, ./source/editor)
2021-11-30 21:29:18 -06:00
2022-02-03 09:16:22 -06:00
bsdirs != find ./source/brainstorm -type d
bsobjects != $(call make_objs, ./source/brainstorm)
2022-01-19 16:43:21 -06:00
2022-02-03 09:16:22 -06:00
pindirs != find ./source/pinball -type d
pinobjects != $(call make_objs, ./source/pinball);
2022-01-19 16:43:21 -06:00
2022-02-03 09:16:22 -06:00
edirs += ./source/engine/thirdparty/Chipmunk2D/include ./source/engine/thirdparty/enet/include
includeflag != $(call prefix,$(edirs) $(eddirs) $(pindirs) $(bsdirs),-I)
2021-11-30 21:29:18 -06:00
#COMPILER_FLAGS specifies the additional compilation options we're using
2022-02-03 09:16:22 -06:00
WARNING_FLAGS = -w #-pedantic -Wall -Wextra -Wwrite-strings
COMPILER_FLAGS = -g -O0 $(WARNING_FLAGS)
2021-11-30 21:29:18 -06:00
2022-02-03 09:16:22 -06:00
LIBPATH = -L.
2021-11-30 21:29:18 -06:00
ifeq ($(UNAME), Windows_NT)
2022-02-03 09:16:22 -06:00
LINKER_FLAGS = -static -DSDL_MAIN_HANDLED
ELIBS = engine mingw32 SDL2main SDL2 m dinput8 dxguid dxerr8 user32 gdi32 winmm imm32 ole32 oleaut32 shell32 version uuid setupapi opengl32 stdc++ winpthread
ELIBS += SDL2_mixer FLAC vorbis vorbisenc vorbisfile mpg123 out123 syn123 opus opusurl opusfile ogg ssp shlwapi
CLIBS = glew32
EXT = .exe
2021-11-30 21:29:18 -06:00
else
2022-02-03 09:16:22 -06:00
LINKER_FLAGS =
ELIBS = engine
CLIBS = SDL2 SDL2_mixer GLEW GL dl pthread
EXT =
2021-11-30 21:29:18 -06:00
endif
2022-02-03 09:16:22 -06:00
ELIBS != $(call prefix, $(ELIBS), -l)
CLIBS != $(call prefix, $(CLIBS), -l)
2021-11-30 21:29:18 -06:00
2022-02-03 09:16:22 -06:00
LELIBS = -Wl,-Bstatic $(ELIBS) -Wl,-Bdynamic $(CLIBS)
2021-11-30 21:29:18 -06:00
2022-02-03 11:29:43 -06:00
objects = $(bsobjects) $(eobjects) $(pinobjects)
DEPENDS = $(objects:.o=.d)
-include $(DEPENDS)
2022-02-03 09:16:22 -06:00
yuginec = ./source/engine/yugine.c
2022-01-19 16:43:21 -06:00
2022-01-21 11:26:22 -06:00
engine: libengine.a
2022-02-03 11:29:43 -06:00
Linking engine
2022-01-20 11:16:44 -06:00
$(CXX) $(yuginec) -DGLEW_STATIC $(includeflag) $(LIBPATH) $(LINKER_FLAGS) $(LELIBS) -o yugine
2021-11-30 21:29:18 -06:00
2022-01-21 11:26:22 -06:00
libengine.a: $(eobjects)
2022-01-19 16:43:21 -06:00
@echo Making library engine.a
2022-02-03 11:29:43 -06:00
2022-01-21 11:26:22 -06:00
@ar -r libengine.a $(eobjects)
2021-11-30 21:29:18 -06:00
2022-01-21 11:26:22 -06:00
xbrainstorm: libengine.a $(bsobjects)
2022-01-19 16:43:21 -06:00
@echo Making brainstorm
2022-01-25 09:22:03 -06:00
@$(CXX) $(bsobjects) -DGLEW_STATIC $(includeflag) $(LIBPATH) $(LINKER_FLAGS) $(LELIBS) -o $@
mv xbrainstorm brainstorm/brainstorm$(EXT)
2021-11-30 21:29:18 -06:00
2022-02-03 09:16:22 -06:00
pinball: libengine.a $(pinobjects)
@echo Making pinball
@$(CXX) $(pinobjects) -DGLEW_STATIC $(includeflag) $(LIBPATH) $(LINKER_FLAGS) $(LELIBS) -o $@
mv pinball paladin/pinball
2021-11-30 21:29:18 -06:00
$(objprefix)/%.o:%.cpp
2022-01-20 11:16:44 -06:00
@mkdir -p $(@D)
2022-01-19 16:43:21 -06:00
@echo Making C++ object $@
2022-01-31 17:04:59 -06:00
@$(CXX) $(includeflag) $(COMPILER_FLAGS) -c -MMD -MP $< -o $@
2021-11-30 21:29:18 -06:00
$(objprefix)/%.o:%.c
2022-01-20 11:16:44 -06:00
@mkdir -p $(@D)
2022-01-19 16:43:21 -06:00
@echo Making C object $@
2022-01-31 17:04:59 -06:00
@$(CC) $(includeflag) $(COMPILER_FLAGS) -c -MMD -MP $< -o $@
2021-11-30 21:29:18 -06:00
clean:
@echo Cleaning project
2022-02-03 11:29:43 -06:00
@rm -f $(eobjects) $(bsobjects)