JABY_ENGINE_DIR = ../../..
include $(JABY_ENGINE_DIR)/mkfile/common/RebuildTarget.mk

ARTIFACT  = libFontWriter
BUILD_DIR = bin

DEFAULT_FONT_IMAGE = src/default_font_data.hpp

CCFLAGS += -I../../include -I$(JABY_ENGINE_DIR)/include
CCFLAGS += -save-temps=obj

include $(JABY_ENGINE_DIR)/mkfile/common/Wildcard.mk
SRCS = $(call rwildcard, src, c cpp s)

include $(JABY_ENGINE_DIR)/mkfile/Makefile
LIB_DIR = ../../lib/$(CONFIG_NAME)

LIB_OBJS = $(filter-out $(MAIN_BOOT_OBJ) $(OVERLAY_BOOT_OBJ),$(OBJS))

#$(info $$var  is [${MAIN_BOOT_OBJ}])
#$(info $$var2 is [${LIB_OBJS}])

$(DEFAULT_FONT_IMAGE): ressources/DefaultFont.png
	psxfileconv --lz4 $< simple-tim clut4 --semi-trans --color-trans | cpp_out --name default_font_data -o $@

#Linking rule
$(TARGET).a: $(LIB_OBJS)
	@mkdir -p $(dir $@)
	$(AR) rcs $(TARGET).a $(LIB_OBJS)

#Copy rules
$(LIB_DIR)/$(ARTIFACT).a: $(TARGET).a
	@mkdir -p $(LIB_DIR)
	cp $(TARGET).a $(LIB_DIR)/$(ARTIFACT).a

#Rules section for default compilation and linking
all: $(DEFAULT_FONT_IMAGE) $(LIB_DIR)/$(ARTIFACT).a 

clean:
	rm -fr $(DEFAULT_FONT_IMAGE)
	rm -fr $(OUTPUT_DIR)
	rm -fr $(LIB_DIR)/$(ARTIFACT).a