From 1aabd17082d2b1bc09a2dfc0a720376f76e5ac07 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Tue, 31 May 2022 15:29:41 +0300 Subject: [PATCH] Add Makefile --- Makefile | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a72a73e --- /dev/null +++ b/Makefile @@ -0,0 +1,54 @@ +# 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/