Files
Upsilon/ion/Makefile
2020-09-30 17:30:34 +02:00

85 lines
2.6 KiB
Makefile

GIT := $(shell command -v git 2> /dev/null)
PATCH_LEVEL = NONE
ifdef GIT
PATCH_LEVEL = $(shell git rev-parse HEAD | head -c 7)
endif
SFLAGS += -Iion/include -DKD_CONFIG_H=1
ifndef ION_KEYBOARD_LAYOUT
$(error platform.mak should define ION_KEYBOARD_LAYOUT)
endif
SFLAGS += -Iion/include/ion/keyboard/$(ION_KEYBOARD_LAYOUT)
# Image inliner
$(eval $(call rule_for, \
HOSTCC, \
ion/image/inliner, \
ion/image/inliner.c $(addprefix ion/src/external/lz4/, lz4.c lz4hc.c), \
$$(HOSTCC) -std=c99 `libpng-config --cflags` $$^ `libpng-config --ldflags` -o $$@, \
global \
))
INLINER := $(BUILD_DIR)/ion/image/inliner
.PRECIOUS: $(BUILD_DIR)/%.h $(BUILD_DIR)/%.cpp
$(eval $(call rule_for, \
INLINER, \
%.h %.cpp, \
%.png $$(INLINER), \
$$(INLINER) $$< $$(basename $$@).h $$(basename $$@).cpp, \
global \
))
# Mark a .cpp file as depending on a .png one
# This is called with $1 = code.cpp and $2 = image.png
# First, we mark code.o as requiring image.o. Rules will take care of inlining
# the PNG and building the inlined cpp file. Second, we add the directory
# corresponding to the one of code.cpp in the output dir as a header search
# path. Since $1 can be a list, we have to map with foreach.
define depends_on_image
$(call object_for,$(1)): $(call object_for,$(2))
$(call object_for,$(1)): SFLAGS += $(foreach d,$(sort $(dir $(call object_for,$(1)))),-I$(d))
ion_src += $(2)
endef
include ion/src/$(PLATFORM)/Makefile
-include ion/test/$(PLATFORM)/Makefile
include ion/src/shared/tools/Makefile
# We need to work around a GCC bug (concerning versions < 5.1). It is valid in
# C++11 to initialize a character array by providing a string litteral (e.g.
# char test[4]= "ab"; is valid and should initialize test to 'a','b',0,0).
# Older versions of GCC are not conformant so we resort to an initializer list.
initializer_list = $(shell echo $(1) | sed "s/\(.\)/'\1',/g")0
$(call object_for,ion/src/shared/platform_info.cpp): SFLAGS += -DPATCH_LEVEL="$(call initializer_list,$(PATCH_LEVEL))" -DEPSILON_VERSION="$(call initializer_list,$(EPSILON_VERSION))"
ion_src += $(addprefix ion/src/shared/, \
console_display.cpp:+consoledisplay \
console_line.cpp \
crc32_eat_byte.cpp \
decompress.cpp \
events.cpp \
events_keyboard.cpp \
events_modifier.cpp \
platform_info.cpp \
storage.cpp \
unicode/utf8_decoder.cpp\
unicode/utf8_helper.cpp\
)
ion_src += ion/src/external/lz4/lz4.c
tests_src += $(addprefix ion/test/,\
crc32.cpp\
events.cpp\
keyboard.cpp\
storage.cpp\
utf8_decoder.cpp\
utf8_helper.cpp\
)
ifdef ION_STORAGE_LOG
SFLAGS += -DION_STORAGE_LOG=1
endif