-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
72 lines (51 loc) · 1.72 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# WhateverDSP library build file
include buildvars.mk
TARGET ?= $(LIB_NAME)
# C sources
C_SOURCES = \
src/wdsp.c
# ASM sources
ASM_SOURCES =
# C includes
C_INCLUDES = \
-I $(CONFIG_DIR)/ \
-I includes \
-I includes/arm \
-I includes/cmsis \
-I includes/stm
C_DEFS += -DLIB_BUILD
include boards/$(BOARD)/board.mk
include boards/$(BOARD)/build.mk
include cores/$(CORE)/core.mk
include cores/$(CORE)/build.mk
# Reset default goal so it doesn't get overriden by rules in the included files
.DEFAULT_GOAL :=
$(info building $(TARGET).a for board $(BOARD))
# list of objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(sort $(C_SOURCES:.c=.o))))
vpath %.c $(sort $(dir $(C_SOURCES)))
# list of ASM program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(sort $(ASM_SOURCES:.s=.o))))
vpath %.s $(sort $(dir $(ASM_SOURCES)))
.PHONY: all
all: config $(OBJECTS) $(TARGET).a($(OBJECTS))
# Generate dependency information
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
$(AS) -c $(CFLAGS) $< -o $@
$(BUILD_DIR):
mkdir -p $@
$(CONFIG_DIR):
mkdir -p $@
$(CONFIG_DIR)/config.%: boards/$(BOARD)/config.ini $(USER_CONFIG) | $(CONFIG_DIR)
awk -f tools/mkconf.awk -v mode=$* $^ > $@
# Include autogenerated dependency information
-include $(wildcard $(BUILD_DIR)/*.d)
.PHONY: config
config: $(CONFIG_DIR)/config.h $(CONFIG_DIR)/config.mk
.PHONY: clean
clean:
-rm -f $(OBJECTS) $(OBJECTS:%.o=%.d) $(OBJECTS:%.o=%.lst) $(TARGET).a $(CONFIG_DIR)/config.h $(CONFIG_DIR)/config.mk
-rmdir $(CONFIG_DIR) $(BUILD_DIR)