forked from marcelobarrosufu/kved
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (40 loc) · 1.03 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
TARGET = kved
DEBUG = 1
OPT = -Og
BUILD_DIR = build
C_SOURCES = \
kved.c \
kved_cpu.c \
./port/simul/port_flash.c \
./test/kved_test.c \
./test/kved_test_main.c
#PREFIX = arm-none-eabi-
PREFIX =
CC = $(PREFIX)gcc
AS = $(PREFIX)gcc -x assembler-with-cpp
CP = $(PREFIX)objcopy
SZ = $(PREFIX)size
C_DEFS = \
-DKVED_FLASH_WORD_SIZE=8
C_INCLUDES = \
-I.
CFLAGS = $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
ifeq ($(DEBUG), 1)
CFLAGS += -g
C_DEFS += -DKVED_DEBUG
endif
LIBS =
LIBDIR =
LDFLAGS = $(LIBDIR) $(LIBS) -Wl,--gc-sections
all: $(BUILD_DIR)/$(TARGET).elf
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
$(BUILD_DIR):
mkdir $@
clean:
-rm -fR $(BUILD_DIR)
-include $(wildcard $(BUILD_DIR)/*.d)