prosperon/Makefile

123 lines
4.1 KiB
Makefile
Raw Normal View History

2021-11-30 21:29:18 -06:00
MAKEFLAGS := --jobs=$(shell nproc)
UNAME := $(shell uname)
ifeq ($(OS),Windows_NT)
UNAME := Windows_NT
endif
UNAME_P := $(shell uname -m)
#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
BINDIR := ./bin
BUILDDIR := ./obj
2022-01-19 16:43:21 -06:00
objprefix = ./obj
DIRS := engine pinball editor brainstorm
2022-01-21 11:26:22 -06:00
ETP := ./source/engine/thirdparty/
2022-01-19 16:43:21 -06:00
# All other sources
esrcs := $(shell find ./source/engine -name '*.c*')
2022-01-21 11:26:22 -06:00
esrcs := $(filter-out %sqlite3.c %shell.c, $(esrcs))
2022-01-19 16:43:21 -06:00
eheaders := $(shell find ./source/engine -name '*.h')
2022-01-21 11:26:22 -06:00
edirs := $(addprefix $(ETP), Chipmunk2D/include bitmap-outliner cgltf enet/include pl_mpeg s7 sqlite3 stb) ./source/engine # $(shell find ./source/engine -type d)
2022-01-25 09:22:03 -06:00
edirs := $(filter-out %docs %doc %include% %src %examples , $(edirs)) /usr/include/directfb
2022-01-19 16:43:21 -06:00
eobjects := $(sort $(patsubst .%.cpp, $(objprefix)%.o, $(filter %.cpp, $(esrcs))) $(patsubst .%.c, $(objprefix)%.o, $(filter %.c, $(esrcs))))
2021-11-30 21:29:18 -06:00
2022-01-20 11:16:44 -06:00
imguidir := ./source/editor/imgui/
imguisrcs := $(addprefix $(imguidir), imgui imgui_draw imgui_widgets imgui_tables backends/imgui_impl_sdl backends/imgui_impl_opengl3)
imguisrcs := $(addsuffix .cpp, $(imguisrcs))
imguiobjs := $(sort $(patsubst .%.cpp, $(objprefix)%.o, $(filter %.cpp, $(imguisrcs))) $(patsubst .%.c, $(objprefix)%.o, $(filter %.c, $(imguisrcs))))
edsrcs := $(wildcard ./source/editor/*)
2022-01-19 16:43:21 -06:00
edheaders := $(shell find ./source/editor -name '*.h')
eddirs := $(shell find ./source/editor -type d)
2021-11-30 21:29:18 -06:00
2022-01-20 11:16:44 -06:00
edobjects := $(sort $(patsubst .%.cpp, $(objprefix)%.o, $(filter %.cpp, $(edsrcs))) $(patsubst .%.c, $(objprefix)%.o, $(filter %.c, $(edsrcs)))) $(imguiobjs)
eobjects := $(filter-out %yugine.o %pl_mpeg_extract_frames.o %pl_mpeg_player.o, $(eobjects)) $(edobjects)
edirs := $(edirs) $(eddirs)
2021-11-30 21:29:18 -06:00
2022-01-19 16:43:21 -06:00
bssrcs := $(shell find ./source/brainstorm -name '*.c*')
bsheaders := $(shell find ./source/brainstorm -name '*.h')
eddirs := $(shell find ./source/brainstorm -type d)
2021-11-30 21:29:18 -06:00
2022-01-19 16:43:21 -06:00
bsobjects := $(sort $(patsubst .%.cpp, $(objprefix)%.o, $(filter %.cpp, $(bssrcs))) $(patsubst .%.c, $(objprefix)%.o, $(filter %.c, $(bssrcs))))
2021-11-30 21:29:18 -06:00
2022-01-19 16:43:21 -06:00
pinsrcs := $(shell find ./source/editor -name '*.c*')
pinheaders := $(shell find ./source/editor -name '*.h')
pindirs := $(shell find ./source/pinball -type d)
edobjects := $(sort $(patsubst .%.cpp, $(objprefix)%.o, $(filter %.cpp, $(edsrcs))) $(patsubst .%.c, $(objprefix)%.o, $(filter %.c, $(edsrcs))))
2022-01-20 11:16:44 -06:00
includeflag := $(addprefix -I, $(edirs) $(eddirs) $(pindirs) $(bsdirs) ./source/editor ./source/editor/imgui ./source/editor/imgui/backends)
2021-11-30 21:29:18 -06:00
#COMPILER_FLAGS specifies the additional compilation options we're using
WARNING_FLAGS := -w #-pedantic -Wall -Wextra -Wwrite-strings
COMPILER_FLAGS := -g -O0 $(WARNING_FLAGS)
2022-01-20 11:16:44 -06:00
LIBPATH := $(addprefix -L, .)
2021-11-30 21:29:18 -06:00
ifeq ($(UNAME), Windows_NT)
2022-01-25 09:22:03 -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 := $(ELIBS) SDL2_mixer FLAC vorbis vorbisenc vorbisfile mpg123 out123 syn123 opus opusurl opusfile ogg ssp shlwapi
CLIBS := glew32
2021-11-30 21:29:18 -06:00
EXT := .exe
else
LINKER_FLAGS :=
2022-01-20 11:16:44 -06:00
ELIBS := engine
2022-01-19 16:43:21 -06:00
CLIBS := SDL2 SDL2_mixer GLEW GL dl pthread
2021-11-30 21:29:18 -06:00
EXT :=
endif
LELIBS := -Wl,-Bstatic $(addprefix -l, ${ELIBS}) -Wl,-Bdynamic $(addprefix -l, $(CLIBS))
2022-01-31 17:04:59 -06:00
DEPENDS := $(patsubst %.o, %.d, $(bsobjects) $(eobjects))
2021-11-30 21:29:18 -06:00
2022-01-20 11:16:44 -06:00
yuginec := ./source/engine/yugine.c
2022-01-19 16:43:21 -06:00
.SECONARY: $(eobjects)
2021-11-30 21:29:18 -06:00
2022-01-21 11:26:22 -06:00
engine: libengine.a
2022-01-19 16:43:21 -06:00
@echo 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-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-01-31 17:04:59 -06:00
-include $(DEPENDS)
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-01-25 09:22:03 -06:00
@rm -f $(eobjects) $(bsobjects)
2021-11-30 21:29:18 -06:00