2022-06-02 22:23:01 +03:00
|
|
|
# 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
|
|
|
|
|
2022-06-03 11:53:54 +03:00
|
|
|
$(BUILD_PATH)/obj/%.o: CFLAGS := $(CFLAGS) -Og -fPIC -c -g3 -Wall
|
2022-06-02 22:23:01 +03:00
|
|
|
|
|
|
|
########################################################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
c_objects = $(addsuffix .o,$(addprefix $(2),$(notdir $(basename $(wildcard $(1)*.c)))))
|
|
|
|
|
|
|
|
OBJECTS_TESTS := $(call c_objects,./src/,)
|
|
|
|
OBJECTS_BASE := $(call c_objects,../src/,)
|
|
|
|
OBJECTS_STRING := $(OBJECTS_BASE) $(call c_objects,../src/string/,string-)
|
|
|
|
OBJECTS_ARRAY := $(OBJECTS_BASE) $(call c_objects,../src/array/,array-)
|
|
|
|
OBJECTS_LIST := $(OBJECTS_BASE) $(call c_objects,../src/list/,list-)
|
|
|
|
OBJECTS_MAP := $(OBJECTS_BASE) $(call c_objects,../src/map/,map-)
|
|
|
|
OBJECTS_SET := $(OBJECTS_BASE) $(call c_objects,../src/set/,set-)
|
|
|
|
|
|
|
|
OBJECTS_BASE := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_BASE))
|
|
|
|
OBJECTS_STRING := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_STRING))
|
|
|
|
OBJECTS_ARRAY := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_ARRAY))
|
|
|
|
OBJECTS_LIST := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_LIST))
|
|
|
|
OBJECTS_MAP := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_MAP))
|
|
|
|
OBJECTS_SET := $(addprefix $(BUILD_PATH)/obj/,$(OBJECTS_TESTS)) $(addprefix ../bin/debug/obj/,$(OBJECTS_SET))
|
|
|
|
|
2022-06-09 11:39:19 +03:00
|
|
|
OBJECTS_STRING := $(OBJECTS_STRING) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/string/src/,string-))
|
|
|
|
OBJECTS_ARRAY := $(OBJECTS_ARRAY) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/array/src/,array-))
|
|
|
|
OBJECTS_LIST := $(OBJECTS_LIST) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/list/src/,list-))
|
|
|
|
OBJECTS_MAP := $(OBJECTS_MAP) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/map/src/,map-))
|
|
|
|
OBJECTS_SET := $(OBJECTS_SET) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/set/src/,set-))
|
|
|
|
|
2022-06-02 22:23:01 +03:00
|
|
|
########################################################################################################################
|
|
|
|
|
|
|
|
tests: modules
|
2022-06-03 14:09:41 +03:00
|
|
|
tests: $(addprefix $(BUILD_PATH)/array-,$(notdir $(basename $(wildcard ./src/array/*.c))))
|
|
|
|
tests: $(addprefix $(BUILD_PATH)/string-,$(notdir $(basename $(wildcard ./src/string/*.c))))
|
|
|
|
tests: $(addprefix $(BUILD_PATH)/list-,$(notdir $(basename $(wildcard ./src/list/*.c))))
|
|
|
|
tests: $(addprefix $(BUILD_PATH)/map-,$(notdir $(basename $(wildcard ./src/map/*.c))))
|
|
|
|
tests: $(addprefix $(BUILD_PATH)/set-,$(notdir $(basename $(wildcard ./src/set/*.c))))
|
|
|
|
|
2022-06-02 22:23:01 +03:00
|
|
|
|
|
|
|
########################################################################################################################
|
|
|
|
|
|
|
|
$(BUILD_PATH)/obj/%.o: ./src/%.c | $(BUILD_PATH)/obj/
|
|
|
|
$(CC) $^ -o $@ $(CFLAGS)
|
|
|
|
|
2022-06-09 11:39:19 +03:00
|
|
|
$(BUILD_PATH)/obj/array-%.o: ./src/array/src/%.c | $(BUILD_PATH)/obj/
|
|
|
|
$(CC) $^ -o $@ $(CFLAGS)
|
|
|
|
$(BUILD_PATH)/obj/string-%.o: ./src/string/src/%.c | $(BUILD_PATH)/obj/
|
|
|
|
$(CC) $^ -o $@ $(CFLAGS)
|
|
|
|
$(BUILD_PATH)/obj/list-%.o: ./src/list/src/%.c | $(BUILD_PATH)/obj/
|
|
|
|
$(CC) $^ -o $@ $(CFLAGS)
|
|
|
|
$(BUILD_PATH)/obj/map-%.o: ./src/map/src/%.c | $(BUILD_PATH)/obj/
|
|
|
|
$(CC) $^ -o $@ $(CFLAGS)
|
|
|
|
$(BUILD_PATH)/obj/set-%.o: ./src/set/src/%.c | $(BUILD_PATH)/obj/
|
|
|
|
$(CC) $^ -o $@ $(CFLAGS)
|
|
|
|
|
2022-06-03 14:09:41 +03:00
|
|
|
$(BUILD_PATH)/array-%: ./src/array/%.c $(OBJECTS_ARRAY) | $(BUILD_PATH)/
|
2022-06-03 11:53:54 +03:00
|
|
|
$(CC) $^ -o $@ $(CFLAGS) -g3 -Wall
|
2022-06-03 14:09:41 +03:00
|
|
|
$(BUILD_PATH)/string-%: ./src/string/%.c $(OBJECTS_STRING) | $(BUILD_PATH)/
|
2022-06-03 11:53:54 +03:00
|
|
|
$(CC) $^ -o $@ ../modules/libunic/bin/libunic.a $(CFLAGS) -g3 -Wall
|
2022-06-03 14:09:41 +03:00
|
|
|
$(BUILD_PATH)/list-%: ./src/list/%.c $(OBJECTS_LIST) | $(BUILD_PATH)/
|
2022-06-03 11:53:54 +03:00
|
|
|
$(CC) $^ -o $@ $(CFLAGS) -g3 -Wall
|
2022-06-03 14:09:41 +03:00
|
|
|
$(BUILD_PATH)/map-%: ./src/map/%.c $(OBJECTS_MAP) | $(BUILD_PATH)/
|
2022-06-03 11:53:54 +03:00
|
|
|
$(CC) $^ -o $@ $(CFLAGS) -g3 -Wall
|
2022-06-03 14:09:41 +03:00
|
|
|
$(BUILD_PATH)/set-%: ./src/set/%.c $(OBJECTS_SET) | $(BUILD_PATH)/
|
2022-06-03 11:53:54 +03:00
|
|
|
$(CC) $^ -o $@ $(CFLAGS) -g3 -Wall
|
2022-06-02 22:23:01 +03:00
|
|
|
|
|
|
|
########################################################################################################################
|
|
|
|
|
|
|
|
$(BUILD_PATH)/:
|
|
|
|
$(MKDIR) $@
|
|
|
|
$(BUILD_PATH)/obj/: | $(BUILD_PATH)/
|
|
|
|
$(MKDIR) $@
|
|
|
|
|
|
|
|
########################################################################################################################
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(RMRF) ./bin/
|
|
|
|
cd ../ && $(MAKE) clean
|
|
|
|
|
|
|
|
########################################################################################################################
|
|
|
|
|
2022-06-03 19:28:44 +03:00
|
|
|
FORCE:
|
2022-06-02 22:23:01 +03:00
|
|
|
modules: ../bin/debug/libcdsb.a
|
|
|
|
|
2022-06-03 19:28:44 +03:00
|
|
|
../bin/debug/libcdsb.a: FORCE
|
2022-06-02 22:23:01 +03:00
|
|
|
cd ../ && $(MAKE) debug
|