# This software is licensed by the MIT License, see LICENSE file
#                                Copyright © 2022 Gregory Lirent

########################################################################################################################

BUILD_PATH  ?= ./bin

########################################################################################################################

CC    = clang
MKDIR = mkdir -p
RMRF  = rm -rf
AR    = ar crs
CP    = cp

########################################################################################################################

examples: modules
examples: $(addprefix $(BUILD_PATH)/,$(notdir $(basename $(wildcard ./*.c))))

$(BUILD_PATH)/%: ./%.c | $(BUILD_PATH)/
	$(CC) $^ ../bin/release/libcdsb.a ../modules/libunic/bin/libunic.a -o $@ $(CFLAGS) -O2 -Wall


$(BUILD_PATH)/:
	$(MKDIR) $@
$(BUILD_PATH)/obj/:   | $(BUILD_PATH)/
	$(MKDIR) $@

clean:
	$(RMRF) ./bin/
	cd ../ && $(MAKE) clean

########################################################################################################################

FORCE:
modules: ../bin/release/libcdsb.a

../bin/release/libcdsb.a: FORCE
	cd ../ && $(MAKE) release