45 lines
1.3 KiB
Makefile
45 lines
1.3 KiB
Makefile
# This software is licensed by the MIT License, see LICENSE file
|
|
# Copyright © 2022 Gregory Lirent
|
|
|
|
BUILD_PATH ?= ./bin
|
|
LIB_NAME = unic
|
|
|
|
CC = clang
|
|
MKDIR = mkdir -p
|
|
RMRF = rm -rf
|
|
AR = ar crs
|
|
CP = cp
|
|
|
|
c_objects = $(addsuffix .o,$(addprefix $(2),$(notdir $(basename $(wildcard $(1)*.c)))))
|
|
|
|
$(BUILD_PATH)/obj/%.o: CFLAGS := $(CFLAGS) -DNDEBUG -O2 -c
|
|
$(BUILD_PATH)/lib$(LIB_NAME).a: $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./,libunic-))
|
|
$(BUILD_PATH)/lib$(LIB_NAME)-alt.a: $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./,libunic-))
|
|
|
|
$(BUILD_PATH)/lib$(LIB_NAME).a: $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./case_switch/,libunic-case-))
|
|
$(BUILD_PATH)/lib$(LIB_NAME)-alt.a: $(addprefix $(BUILD_PATH)/obj/,$(call c_objects,./case_switch/alt/,libunic-case-alt-))
|
|
|
|
build: $(BUILD_PATH)/lib$(LIB_NAME).a
|
|
build-alt: $(BUILD_PATH)/lib$(LIB_NAME)-alt.a
|
|
|
|
clean:
|
|
$(RMRF) $(BUILD_PATH)
|
|
|
|
$(BUILD_PATH)/obj/libunic-%.o: ./%.c | $(BUILD_PATH)/obj/
|
|
$(CC) $^ -o $@ $(CFLAGS)
|
|
|
|
$(BUILD_PATH)/obj/libunic-case-alt-%.o: ./case_switch/alt/%.c | $(BUILD_PATH)/obj/
|
|
$(CC) $^ -o $@ $(CFLAGS)
|
|
|
|
$(BUILD_PATH)/obj/libunic-case-%.o: ./case_switch/%.c | $(BUILD_PATH)/obj/
|
|
$(CC) $^ -o $@ $(CFLAGS)
|
|
|
|
%.a:
|
|
$(AR) $@ $^
|
|
|
|
$(BUILD_PATH)/:
|
|
$(MKDIR) $(BUILD_PATH)/
|
|
|
|
$(BUILD_PATH)/obj/: | $(BUILD_PATH)/
|
|
$(MKDIR) $(BUILD_PATH)/obj/
|