prosperon/Makefile

171 lines
4.3 KiB
Makefile
Raw Normal View History

2022-06-23 13:16:39 -05:00
procs != nproc
MAKEFLAGS = --jobs=$(procs)
2022-02-04 08:38:25 -06:00
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
2022-06-28 22:13:39 -05:00
CCACHE = #ccache
2022-06-25 23:19:29 -05:00
2021-11-30 21:29:18 -06:00
#CC specifies which compiler we're using
2022-08-01 13:32:58 -05:00
CC = $(CCACHE) clang -DSDL_DISABLE_IMMINTRIN_H
CLINK = clang
2022-06-22 23:04:35 -05:00
MUSL = /usr/local/musl/include
2022-06-21 12:48:19 -05:00
2021-11-30 21:29:18 -06:00
ifeq ($(DEBUG), 1)
DEFFALGS += -DDEBUG
INFO = dbg
endif
2022-02-04 11:36:24 -06:00
BIN = ./bin/
objprefix = $(BIN)obj
2022-01-19 16:43:21 -06:00
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-06-22 15:20:29 -05:00
find $(1) -type f -name '*.c' | sed 's|\.c.*|.o|' | sed 's|\.|$(objprefix)|1'
2022-02-04 08:38:25 -06:00
endef
define make_obj
echo $(1) | tr " " "\n" | sed 's|\.c.*|.o|' | sed 's|\.|$(objprefix)|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-04 08:38:25 -06:00
define findindir
2022-02-04 11:36:24 -06:00
find $(1) -maxdepth 1 -type f -name '$(2)'
2022-02-04 08:38:25 -06:00
endef
2022-02-03 09:16:22 -06:00
# All other sources
2022-02-04 08:38:25 -06:00
edirs != find ./source/engine -type d -name include
edirs += ./source/engine
ehead != $(call findindir,./source/engine,*.h)
2022-02-03 09:16:22 -06:00
eobjects != $(call make_objs, ./source/engine)
2022-06-23 02:34:51 -05:00
eobjects != $(call rm,$(eobjects),sqlite pl_mpeg_extract_frames pl_mpeg_player yugine)
2021-11-30 21:29:18 -06:00
2022-02-03 09:16:22 -06:00
eddirs != find ./source/editor -type d
2022-02-04 08:38:25 -06:00
eddirs += ./source/editor
edhead != $(call findindir,./source/editor,*.h)
2022-06-22 15:20:29 -05:00
edobjects != find ./source/editor -maxdepth 1 -type f -name '*.c'
2022-02-04 08:38:25 -06:00
edobjects != $(call make_obj,$(edobjects))
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)
2022-02-04 11:36:24 -06:00
COMPINCLUDE = $(edirs) $(eddirs) $(pindirs) $(bsdirs)
2021-11-30 21:29:18 -06:00
2022-06-23 13:16:39 -05:00
2022-07-09 21:46:23 -05:00
WARNING_FLAGS = -Wno #-Wall -Wwrite-strings -Wunsupported -Wall -Wextra -Wwrite-strings -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces -Wno-incompatible-function-pointer-types -Wno-gnu-statement-expression -Wno-complex-component-init -pedantic
2022-06-23 13:16:39 -05:00
2022-06-28 22:13:39 -05:00
COMPILER_FLAGS = $(includeflag) -I/usr/local/include -g -O0 -MD $(WARNING_FLAGS) -c $< -o $@
2021-11-30 21:29:18 -06:00
2022-07-03 00:43:42 -05:00
LIBPATH = -L./bin -L/usr/local/lib -L/usr/local/lib/tcc -L/usr/lib64/pipewire-0.3/jack
2021-11-30 21:29:18 -06:00
2022-06-28 18:51:21 -05:00
ALLFILES != find source/ -name '*.[ch]' -type f
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
2022-02-04 11:36:24 -06:00
ELIBS = engine editor mingw32 SDL2main SDL2 m dinput8 dxguid dxerr8 user32 gdi32 winmm imm32 ole32 oleaut32 shell32 version uuid setupapi opengl32 stdc++ winpthread
2022-02-03 09:16:22 -06:00
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-08-01 13:32:58 -05:00
LINKER_FLAGS = -g /usr/lib64/pipewire-0.3/jack/libjack.so.0
ELIBS = m c engine editor glfw3 portaudio rt asound pthread SDL2 yughc mruby
2022-06-22 20:39:18 -05:00
CLIBS =
2022-02-03 09:16:22 -06:00
EXT =
2021-11-30 21:29:18 -06:00
endif
2022-02-03 09:16:22 -06:00
ELIBS != $(call prefix, $(ELIBS), -l)
2021-11-30 21:29:18 -06:00
2022-06-22 23:04:35 -05:00
LELIBS = $(ELIBS) $(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-02-04 11:36:24 -06:00
ENGINE = $(BIN)libengine.a
EDITOR = $(BIN)libeditor.a
INCLUDE = $(BIN)include
2022-02-04 08:38:25 -06:00
2022-06-21 15:21:00 -05:00
linkinclude = $(BIN)include
2022-02-04 11:36:24 -06:00
LINK = $(LIBPATH) $(LINKER_FLAGS) $(LELIBS) -o $@
2022-07-12 15:43:02 -05:00
engine: tags $(yuginec:.%.c=$(objprefix)%.o) $(ENGINE)
2022-02-04 08:38:25 -06:00
@echo Linking engine
2022-08-01 13:32:58 -05:00
@$(CLINK) $@ $(LINK)
2022-02-06 10:14:57 -06:00
@echo Finished build
2021-11-30 21:29:18 -06:00
2022-07-12 15:43:02 -05:00
editor: tags $(yuginec:.%.c=$(objprefix)%.o) $(EDITOR) $(ENGINE)
2022-02-04 08:38:25 -06:00
@echo Linking editor
2022-08-01 13:32:58 -05:00
@$(CLINK) $^ $(LINK)
2022-02-06 10:14:57 -06:00
@echo Finished build
2022-02-03 11:29:43 -06:00
2022-06-22 20:39:18 -05:00
$(ENGINE): $(eobjects) bin/libglfw3.a
2022-02-04 08:38:25 -06:00
@echo Making library engine.a
2022-06-23 13:16:39 -05:00
@ar r $(ENGINE) $(eobjects)
2022-02-04 11:36:24 -06:00
@cp -u -r $(ehead) $(INCLUDE)
2022-02-04 08:38:25 -06:00
2022-02-04 11:36:24 -06:00
$(EDITOR): $(edobjects)
2022-02-04 08:38:25 -06:00
@echo Making editor library
2022-06-23 13:16:39 -05:00
@ar r $(EDITOR) $^
2022-02-04 11:36:24 -06:00
@cp -u -r $(edhead) $(INCLUDE)
2021-11-30 21:29:18 -06:00
2022-06-23 02:34:51 -05:00
xbrainstorm: $(bsobjects) $(ENGINE) $(EDITOR)
2022-01-19 16:43:21 -06:00
@echo Making brainstorm
2022-08-01 13:32:58 -05:00
$(CLINK) $^ $(LINK)
2022-02-04 11:36:24 -06:00
@mv xbrainstorm brainstorm/brainstorm$(EXT)
2021-11-30 21:29:18 -06:00
2022-07-12 15:43:02 -05:00
pinball: tags $(ENGINE) $(pinobjects)
2022-02-03 09:16:22 -06:00
@echo Making pinball
2022-08-01 13:32:58 -05:00
@$(CLINK) $(pinobjects) $(LINK) -o $@
2022-02-04 11:36:24 -06:00
@mv pinball paladin/pinball
2022-02-03 09:16:22 -06:00
2022-06-22 20:39:18 -05:00
bin/libglfw3.a:
@echo Making GLFW
2022-06-23 13:16:39 -05:00
@make glfw/build
@cp glfw/build/src/libglfw3.a bin/libglfw3.a
2022-06-22 20:39:18 -05:00
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-06-30 10:31:23 -05:00
@$(CC) $(COMPILER_FLAGS)
2021-11-30 21:29:18 -06:00
2022-06-28 18:51:21 -05:00
tags: $(ALLFILES)
@echo Making tags
@ctags -x -R source > tags
2021-11-30 21:29:18 -06:00
clean:
@echo Cleaning project
2022-06-28 22:13:39 -05:00
@find $(BIN) -type f -delete