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))
|
|
|
|
|
|
|
|
########################################################################################################################
|
|
|
|
|
|
|
|
tests: modules
|
|
|
|
tests: $(BUILD_PATH)/array
|
|
|
|
tests: $(BUILD_PATH)/string
|
|
|
|
tests: $(BUILD_PATH)/list
|
|
|
|
tests: $(BUILD_PATH)/map
|
|
|
|
tests: $(BUILD_PATH)/set
|
|
|
|
|
|
|
|
########################################################################################################################
|
|
|
|
|
|
|
|
$(BUILD_PATH)/obj/%.o: ./src/%.c | $(BUILD_PATH)/obj/
|
|
|
|
$(CC) $^ -o $@ $(CFLAGS)
|
|
|
|
|
|
|
|
$(BUILD_PATH)/array: ./src/array/main.c $(OBJECTS_ARRAY) | $(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)/string: ./src/string/main.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-02 22:23:01 +03:00
|
|
|
$(BUILD_PATH)/list: ./src/list/main.c $(OBJECTS_LIST) | $(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)/map: ./src/map/main.c $(OBJECTS_MAP) | $(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)/set: ./src/set/main.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
|
|
|
|
|
|
|
|
########################################################################################################################
|
|
|
|
|
|
|
|
modules: ../bin/debug/libcdsb.a
|
|
|
|
|
|
|
|
../bin/debug/libcdsb.a:
|
|
|
|
cd ../ && $(MAKE) debug
|