-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.archive
22 lines (17 loc) · 981 Bytes
/
Makefile.archive
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$(ARCHIVE_NAME)_SRC_DIR ?= $(ROOT_DIR)/$(ARCHIVE_NAME)
$(ARCHIVE_NAME)_BIN_DIR ?= $(BIN_DIR)/$(ARCHIVE_NAME)
$(ARCHIVE_NAME)_SRC ?= $(wildcard $($(ARCHIVE_NAME)_SRC_DIR)/*.c)
$(ARCHIVE_NAME)_OBJ ?= $($(ARCHIVE_NAME)_SRC:$($(ARCHIVE_NAME)_SRC_DIR)/%.c=$($(ARCHIVE_NAME)_BIN_DIR)/%.o)
$(ARCHIVE_NAME)_DEPS ?= $($(ARCHIVE_NAME)_OBJ:.o=.d)
$(ARCHIVE_NAME)_INCLUDE ?= -I $($(ARCHIVE_NAME)_SRC_DIR)/include
$(ARCHIVE_NAME)_ARCHIVE ?= $(BIN_DIR)/$(ARCHIVE_NAME).a
-include $($(ARCHIVE_NAME)_DEPS)
$($(ARCHIVE_NAME)_BIN_DIR):
mkdir -p $($(ARCHIVE_NAME)_BIN_DIR)
$($(ARCHIVE_NAME)_BIN_DIR)/%.o: ARCHIVE_INCLUDES:=$(ARCHIVE_INCLUDES)
$($(ARCHIVE_NAME)_BIN_DIR)/%.o: ARCHIVE_NAME:=$(ARCHIVE_NAME)
$($(ARCHIVE_NAME)_BIN_DIR)/%.o: $($(ARCHIVE_NAME)_SRC_DIR)/%.c | $($(ARCHIVE_NAME)_BIN_DIR)
$(CC) $(CFLAGS) $($(ARCHIVE_NAME)_INCLUDE) $(ARCHIVE_INCLUDES) -MMD -MP -c $< -o $@
$($(ARCHIVE_NAME)_ARCHIVE): $($(ARCHIVE_NAME)_OBJ)
$(AR) rcs $@ $^
$(ARCHIVE_NAME): $($(ARCHIVE_NAME)_ARCHIVE)