libunic/Makefile

55 lines
1.5 KiB
Makefile
Raw Normal View History

2022-05-31 15:29:41 +03:00
# This software is licensed by the MIT License, see LICENSE file
# Copyright © 2022 Gregory Lirent
BUILD_PATH ?= ./bin
LIB_NAME = unic
EXAMPLE_PATH = $(BUILD_PATH)/examples
DEBUG_PATH = $(BUILD_PATH)/debug
RELEASE_PATH = $(BUILD_PATH)/release
EXAMPLE_DEBUG_PATH = $(BUILD_PATH)/debug/examples
EXAMPLE_RELEASE_PATH = $(BUILD_PATH)/release/examples
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/