2022-11-24 10:58:36 -06: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
|
|
|
|
2022-11-24 10:58:36 -06:00
|
|
|
CC := ccache $(CC)
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2022-11-24 10:58:36 -06:00
|
|
|
FLAGS = -DALLOW_SMP_DANGERS
|
2022-06-25 23:19:29 -05:00
|
|
|
|
2022-11-24 10:58:36 -06:00
|
|
|
QFLAGS = -O3 -DDBG=0
|
|
|
|
INFO = rel
|
|
|
|
PTYPE != uname -m
|
2022-06-22 23:04:35 -05:00
|
|
|
|
2022-11-24 10:58:36 -06:00
|
|
|
ifeq ($(DBG), 1)
|
|
|
|
QFLAGS = -O0 -g -DDBG=1
|
2021-11-30 21:29:18 -06:00
|
|
|
INFO = dbg
|
|
|
|
endif
|
|
|
|
|
2022-11-24 10:58:36 -06:00
|
|
|
QFLAGS := $(QFLAGS) $(FLAGS)
|
|
|
|
|
|
|
|
BIN = bin/
|
2022-02-04 11:36:24 -06:00
|
|
|
objprefix = $(BIN)obj
|
2022-01-19 16:43:21 -06:00
|
|
|
|
2022-11-23 22:44:42 -06:00
|
|
|
DIRS = engine editor
|
2022-02-04 08:38:25 -06:00
|
|
|
|
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-11-24 10:58:36 -06:00
|
|
|
edirs != find source -type d -name include
|
|
|
|
edirs += source/engine source/engine/thirdparty/Nuklear
|
|
|
|
ehead != $(call findindir, source/engine,*.h)
|
|
|
|
eobjects != find source/engine -type f -name '*.c' | sed -r 's|^(.*)\.c|$(objprefix)/\1.o|' # Gets all .c files and makes .o refs
|
2022-11-03 16:58:03 -05:00
|
|
|
eobjects != $(call rm,$(eobjects),sqlite pl_mpeg_extract_frames pl_mpeg_player yugine nuklear)
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2022-11-23 17:29:50 -06:00
|
|
|
includeflag != $(call prefix,$(edirs),-I)
|
2022-06-23 13:16:39 -05:00
|
|
|
|
2022-11-24 10:58:36 -06:00
|
|
|
WARNING_FLAGS = -Wall -pedantic #-Wno-incompatible-function-pointer-types -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-11-24 01:54:17 -06:00
|
|
|
|
|
|
|
SEM = 0.0.1
|
|
|
|
COM != git rev-parse --short HEAD
|
|
|
|
VER = $(SEM)-$(COM)
|
|
|
|
|
2022-11-24 10:58:36 -06:00
|
|
|
COMPILER_FLAGS = $(includeflag) -I/usr/local/include $(QFLAGS) -rdynamic -MD $(WARNING_FLAGS) -DVER=\"$(VER)\" -DINFO=\"$(INFO)\" -c $< -o $@
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2022-11-24 10:58:36 -06:00
|
|
|
LIBPATH = -Lbin -L/usr/local/lib
|
2022-06-28 18:51:21 -05:00
|
|
|
|
2021-11-30 21:29:18 -06:00
|
|
|
ifeq ($(UNAME), Windows_NT)
|
2022-11-23 17:29:50 -06:00
|
|
|
LINKER_FLAGS = -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-11-24 10:58:36 -06:00
|
|
|
ELIBS += SDL2_mixer FLAC vorbis vorbisenc vorbisfile mpg123 out123 syn123 opus opusurl opusfile ogg ssp shlwapi glew32
|
2022-02-03 09:16:22 -06:00
|
|
|
EXT = .exe
|
2021-11-30 21:29:18 -06:00
|
|
|
else
|
2022-11-24 10:58:36 -06:00
|
|
|
LINKER_FLAGS = $(QFLAGS) -rdynamic
|
2022-11-23 22:44:42 -06:00
|
|
|
ELIBS = engine pthread yughc mruby c m dl
|
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)
|
2022-11-24 10:58:36 -06:00
|
|
|
ELIBS := $(ELIBS) `pkg-config --libs source/glfw/build/src/glfw3.pc` `pkg-config --libs source/portaudio/build/portaudio-2.0.pc`
|
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
|
|
|
|
2022-11-24 10:58:36 -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-11-24 10:58:36 -06:00
|
|
|
LINK = $(LIBPATH) $(LINKER_FLAGS) $(ELIBS)
|
2022-11-24 01:54:17 -06:00
|
|
|
|
2022-11-24 10:58:36 -06:00
|
|
|
MYTAG = $(VER)_$(PTYPE)_$(INFO)
|
2022-11-24 01:54:17 -06:00
|
|
|
|
2022-11-23 17:29:50 -06:00
|
|
|
.PHONY: yugine
|
2022-02-03 11:29:43 -06:00
|
|
|
|
2022-11-24 10:58:36 -06:00
|
|
|
yugine: bin/obj/source/engine/yugine.o $(ENGINE) $(BIN)libportaudio.a $(BIN)libglfw3.a
|
2022-11-23 17:29:50 -06:00
|
|
|
@echo Linking yugine
|
|
|
|
$(CC) $< $(LINK) -o yugine
|
|
|
|
@echo Finished build
|
2022-08-12 14:03:56 -05:00
|
|
|
|
2022-11-24 01:54:17 -06:00
|
|
|
dist: yugine
|
|
|
|
mkdir -p bin/dist
|
|
|
|
cp yugine bin/dist
|
|
|
|
cp -rf assets/fonts bin/dist
|
|
|
|
cp -rf source/scripts bin/dist
|
|
|
|
cp -rf source/shaders bin/dist
|
2022-11-24 10:58:36 -06:00
|
|
|
tar -czf yugine-$(MYTAG).tar.gz --directory bin/dist .
|
2022-11-23 22:44:42 -06:00
|
|
|
|
2022-11-23 17:29:50 -06:00
|
|
|
install: yugine
|
|
|
|
cp yugine ~/.local/bin
|
2022-08-12 14:03:56 -05:00
|
|
|
|
2022-10-23 17:10:53 -05:00
|
|
|
$(ENGINE): $(eobjects)
|
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-11-20 15:50:14 -06:00
|
|
|
@mkdir -p $(INCLUDE)
|
2022-02-04 11:36:24 -06:00
|
|
|
@cp -u -r $(ehead) $(INCLUDE)
|
2022-02-04 08:38:25 -06:00
|
|
|
|
2022-11-03 16:58:03 -05:00
|
|
|
bin/libglfw3.a: source/glfw/build/src/libglfw3.a
|
|
|
|
@cp $< $@
|
|
|
|
|
|
|
|
source/glfw/build/src/libglfw3.a:
|
2022-06-22 20:39:18 -05:00
|
|
|
@echo Making GLFW
|
2022-11-03 16:58:03 -05:00
|
|
|
@mkdir -p source/glfw/build
|
2022-11-24 10:58:36 -06:00
|
|
|
@cd source/glfw/build; cmake ..; make -j$(PROCS)
|
2022-11-03 16:58:03 -05:00
|
|
|
@cp source/glfw/build/src/libglfw3.a bin
|
|
|
|
|
|
|
|
bin/libportaudio.a: source/portaudio/build/libportaudio.a
|
|
|
|
@cp $< $@
|
|
|
|
|
|
|
|
source/portaudio/build/libportaudio.a:
|
|
|
|
@echo Making Portaudio
|
|
|
|
@mkdir -p source/portaudio/build
|
2022-11-24 10:58:36 -06:00
|
|
|
@cd source/portaudio/build; cmake ..; make -j$(PROCS)
|
2022-11-03 16:58:03 -05:00
|
|
|
@cp source/portaudio/build/libportaudio.a bin
|
|
|
|
|
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
|
|
|
|
|
|
|
clean:
|
|
|
|
@echo Cleaning project
|
2022-06-28 22:13:39 -05:00
|
|
|
@find $(BIN) -type f -delete
|
2022-11-03 16:58:03 -05:00
|
|
|
@rm -rf source/portaudio/build source/glfw/build
|