Add Makefile
This commit is contained in:
parent
78ac4abe3e
commit
1aabd17082
54
Makefile
Normal file
54
Makefile
Normal file
@ -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/
|
Loading…
Reference in New Issue
Block a user