prosperon/Makefile

122 lines
3.1 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-08-06 15:39:29 -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
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
2022-02-03 09:16:22 -06:00
define prefix
2022-08-06 15:39:29 -05:00
echo $(1) | tr " " "\n" | sed 's/.*/$(2)&$(3)/'
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 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-08-06 15:39:29 -05:00
edirs += ./source/engine/thirdparty/Chipmunk2D/include ./source/engine/thirdparty/enet/include ./source/engine/thirdparty/Nuklear
includeflag != $(call prefix,$(edirs) $(eddirs),-I)
COMPINCLUDE = $(edirs) $(eddirs)
2022-06-23 13:16:39 -05:00
2022-08-06 15:39:29 -05:00
WARNING_FLAGS = -Wno-everything #-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-08-06 15:39:29 -05:00
LIBPATH = -L./bin -L/usr/local/lib -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
2022-08-06 15:39:29 -05:00
ELIBS = m c engine 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-08-06 15:39:29 -05:00
objects = $(eobjects)
2022-02-03 11:29:43 -06:00
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
INCLUDE = $(BIN)include
2022-02-04 08:38:25 -06:00
2022-02-04 11:36:24 -06:00
LINK = $(LIBPATH) $(LINKER_FLAGS) $(LELIBS) -o $@
2022-08-06 15:39:29 -05:00
engine: $(yuginec:.%.c=$(objprefix)%.o) $(ENGINE)
2022-02-04 08:38:25 -06:00
@echo Linking engine
2022-08-06 15:39:29 -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-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