libcdsb/Makefile

103 lines
3.8 KiB
Makefile
Raw Normal View History

2022-06-02 18:22:13 +03:00
# This software is licensed by the MIT License, see LICENSE file
# Copyright © 2022 Gregory Lirent
########################################################################################################################
BUILD_PATH ?= ./bin
LIB_NAME = cdsb
DEBUG_PATH = $(BUILD_PATH)/debug
RELEASE_PATH = $(BUILD_PATH)/release
########################################################################################################################
CC = clang
MKDIR = mkdir -p
RMRF = rm -rf
AR = ar crs
CP = cp
2022-06-03 12:19:40 +03:00
$(DEBUG_PATH)/obj/%.o: CFLAGS := $(CFLAGS) -DDEBUG -O0 -fPIC -c -g3 -Wall
2022-06-02 18:22:13 +03:00
$(RELEASE_PATH)/obj/%.o: CFLAGS := $(CFLAGS) -DNDEBUG -O2 -fPIC -c
########################################################################################################################
debug: modules $(DEBUG_PATH)/lib$(LIB_NAME).a
release: modules $(RELEASE_PATH)/lib$(LIB_NAME).a
########################################################################################################################
c_objects = $(addsuffix .o,$(addprefix $(2),$(notdir $(basename $(wildcard $(1)*.c)))))
OBJECTS = $(call c_objects,./src/,)\
$(call c_objects,./src/string/,string-)\
$(call c_objects,./src/array/,array-)\
$(call c_objects,./src/list/,list-)\
$(call c_objects,./src/map/,map-)\
$(call c_objects,./src/set/,set-)
########################################################################################################################
$(DEBUG_PATH)/lib$(LIB_NAME).a: $(addprefix $(DEBUG_PATH)/obj/,$(OBJECTS)) | $(DEBUG_PATH)/
$(RELEASE_PATH)/lib$(LIB_NAME).a: $(addprefix $(RELEASE_PATH)/obj/,$(OBJECTS)) | $(RELEASE_PATH)/
########################################################################################################################
$(DEBUG_PATH)/obj/string-%.o: ./src/string/%.c | $(DEBUG_PATH)/obj/
$(CC) $^ -o $@ $(CFLAGS)
$(DEBUG_PATH)/obj/array-%.o: ./src/array/%.c | $(DEBUG_PATH)/obj/
$(CC) $^ -o $@ $(CFLAGS)
$(DEBUG_PATH)/obj/list-%.o: ./src/list/%.c | $(DEBUG_PATH)/obj/
$(CC) $^ -o $@ $(CFLAGS)
$(DEBUG_PATH)/obj/map-%.o: ./src/map/%.c | $(DEBUG_PATH)/obj/
$(CC) $^ -o $@ $(CFLAGS)
$(DEBUG_PATH)/obj/set-%.o: ./src/set/%.c | $(DEBUG_PATH)/obj/
$(CC) $^ -o $@ $(CFLAGS)
$(DEBUG_PATH)/obj/%.o: ./src/%.c | $(DEBUG_PATH)/obj/
$(CC) $^ -o $@ $(CFLAGS)
########################################################################################################################
$(RELEASE_PATH)/obj/string-%.o: ./src/string/%.c | $(RELEASE_PATH)/obj/
$(CC) $^ -o $@ $(CFLAGS)
$(RELEASE_PATH)/obj/array-%.o: ./src/array/%.c | $(RELEASE_PATH)/obj/
$(CC) $^ -o $@ $(CFLAGS)
$(RELEASE_PATH)/obj/list-%.o: ./src/list/%.c | $(RELEASE_PATH)/obj/
$(CC) $^ -o $@ $(CFLAGS)
$(RELEASE_PATH)/obj/map-%.o: ./src/map/%.c | $(RELEASE_PATH)/obj/
$(CC) $^ -o $@ $(CFLAGS)
$(RELEASE_PATH)/obj/set-%.o: ./src/set/%.c | $(RELEASE_PATH)/obj/
$(CC) $^ -o $@ $(CFLAGS)
$(RELEASE_PATH)/obj/%.o: ./src/%.c | $(RELEASE_PATH)/obj/
$(CC) $^ -o $@ $(CFLAGS)
########################################################################################################################
$(BUILD_PATH)/:
$(MKDIR) $@
$(DEBUG_PATH)/: | $(BUILD_PATH)/
$(MKDIR) $@
$(RELEASE_PATH)/: | $(BUILD_PATH)/
$(MKDIR) $@
$(DEBUG_PATH)/obj/: | $(DEBUG_PATH)/
$(MKDIR) $@
$(RELEASE_PATH)/obj/: | $(RELEASE_PATH)/
$(MKDIR) $@
########################################################################################################################
clean:
$(RMRF) ./bin/
cd ./modules/libunic && $(MAKE) clean
%.a:
2022-06-03 12:19:40 +03:00
$(AR) $@ $?
2022-06-02 18:22:13 +03:00
########################################################################################################################
2022-06-03 19:33:18 +03:00
FORCE:
2022-06-02 18:22:13 +03:00
modules: ./modules/libunic/bin/libunic.a
2022-06-03 19:33:18 +03:00
./modules/libunic/bin/libunic.a: FORCE
2022-06-02 18:22:13 +03:00
cd ./modules/libunic && $(MAKE)