107 lines
5.4 KiB
Makefile
107 lines
5.4 KiB
Makefile
# 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
|
|
|
|
$(BUILD_PATH)/obj/%.o: CFLAGS := $(CFLAGS) -Og -fPIC -c -g3 -Wall
|
|
|
|
########################################################################################################################
|
|
|
|
c_objects = $(addsuffix .o,$(addprefix $(2),$(notdir $(basename $(wildcard $(1)*.c)))))
|
|
|
|
OBJECTS_TESTS := $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/,))
|
|
OBJECTS_BASE := $(addprefix ../bin/debug/obj/,$(call c_objects,../src/,))
|
|
OBJECTS_STRING := $(addprefix ../bin/debug/obj/,$(call c_objects,../src/string/,string-))
|
|
OBJECTS_ARRAY := $(addprefix ../bin/debug/obj/,$(call c_objects,../src/array/,array-))
|
|
OBJECTS_LIST := $(addprefix ../bin/debug/obj/,$(call c_objects,../src/list/,list-))
|
|
OBJECTS_MAP := $(addprefix ../bin/debug/obj/,$(call c_objects,../src/map/,map-))
|
|
OBJECTS_SET := $(addprefix ../bin/debug/obj/,$(call c_objects,../src/set/,set-))
|
|
OBJECTS_DICT := $(addprefix ../bin/debug/obj/,$(call c_objects,../src/dict/,dict-))
|
|
|
|
OBJECTS_GLOBAL := $(OBJECTS_TESTS) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/global/src/,global-))
|
|
|
|
OBJECTS_STRING := $(OBJECTS_BASE) $(OBJECTS_TESTS) $(OBJECTS_STRING) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/string/src/,string-))
|
|
OBJECTS_ARRAY := $(OBJECTS_BASE) $(OBJECTS_TESTS) $(OBJECTS_ARRAY) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/array/src/,array-))
|
|
OBJECTS_LIST := $(OBJECTS_BASE) $(OBJECTS_TESTS) $(OBJECTS_LIST) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/list/src/,list-))
|
|
OBJECTS_MAP := $(OBJECTS_BASE) $(OBJECTS_TESTS) $(OBJECTS_MAP) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/map/src/,map-))
|
|
OBJECTS_SET := $(OBJECTS_BASE) $(OBJECTS_TESTS) $(OBJECTS_SET) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/set/src/,set-))
|
|
OBJECTS_DICT := $(OBJECTS_BASE) $(OBJECTS_TESTS) $(OBJECTS_DICT) $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./src/dict/src/,dict-))
|
|
|
|
########################################################################################################################
|
|
|
|
tests: modules
|
|
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))))
|
|
tests: $(addprefix $(BUILD_PATH)/dict-,$(notdir $(basename $(wildcard ./src/dict/*.c))))
|
|
tests: $(addprefix $(BUILD_PATH)/global-,$(notdir $(basename $(wildcard ./src/global/*.c))))
|
|
|
|
|
|
########################################################################################################################
|
|
|
|
$(BUILD_PATH)/obj/%.o: ./src/%.c | $(BUILD_PATH)/obj/
|
|
$(CC) $^ -o $@ $(CFLAGS)
|
|
|
|
$(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)
|
|
$(BUILD_PATH)/obj/dict-%.o: ./src/dict/src/%.c | $(BUILD_PATH)/obj/
|
|
$(CC) $^ -o $@ $(CFLAGS)
|
|
$(BUILD_PATH)/obj/global-%.o: ./src/global/src/%.c | $(BUILD_PATH)/obj/
|
|
$(CC) $^ -o $@ $(CFLAGS)
|
|
|
|
$(BUILD_PATH)/array-%: ./src/array/%.c $(OBJECTS_ARRAY) | $(BUILD_PATH)/
|
|
$(CC) $^ -o $@ $(CFLAGS) -g3 -Wall
|
|
$(BUILD_PATH)/string-%: ./src/string/%.c $(OBJECTS_STRING) | $(BUILD_PATH)/
|
|
$(CC) $^ -o $@ ../modules/libunic/bin/libunic.a $(CFLAGS) -g3 -Wall
|
|
$(BUILD_PATH)/list-%: ./src/list/%.c $(OBJECTS_LIST) | $(BUILD_PATH)/
|
|
$(CC) $^ -o $@ $(CFLAGS) -g3 -Wall
|
|
$(BUILD_PATH)/map-%: ./src/map/%.c $(OBJECTS_MAP) | $(BUILD_PATH)/
|
|
$(CC) $^ -o $@ $(CFLAGS) -g3 -Wall
|
|
$(BUILD_PATH)/set-%: ./src/set/%.c $(OBJECTS_SET) | $(BUILD_PATH)/
|
|
$(CC) $^ -o $@ $(CFLAGS) -g3 -Wall
|
|
$(BUILD_PATH)/dict-%: ./src/dict/%.c $(OBJECTS_DICT) | $(BUILD_PATH)/
|
|
$(CC) $^ -o $@ $(CFLAGS) -g3 -Wall
|
|
$(BUILD_PATH)/global-%: ./src/global/%.c $(OBJECTS_GLOBAL) | $(BUILD_PATH)/
|
|
$(CC) $^ ../bin/debug/libcdsb.a ../modules/libunic/bin/libunic.a -o $@ $(CFLAGS) -g3 -Wall
|
|
|
|
########################################################################################################################
|
|
|
|
$(BUILD_PATH)/:
|
|
$(MKDIR) $@
|
|
$(BUILD_PATH)/obj/: | $(BUILD_PATH)/
|
|
$(MKDIR) $@
|
|
|
|
########################################################################################################################
|
|
|
|
clean:
|
|
$(RMRF) ./bin/
|
|
cd ../ && $(MAKE) clean
|
|
|
|
########################################################################################################################
|
|
|
|
FORCE:
|
|
modules: ../bin/debug/libcdsb.a
|
|
|
|
../bin/debug/libcdsb.a: FORCE
|
|
cd ../ && CFLAGS=-DDICT_CAPACITY_BLOCK\=5 $(MAKE) debug
|