-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcommon.mk
More file actions
36 lines (25 loc) · 834 Bytes
/
common.mk
File metadata and controls
36 lines (25 loc) · 834 Bytes
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
CC := arm-none-eabi-gcc
AS := arm-none-eabi-as
LD := arm-none-eabi-gcc
OBJCOPY := arm-none-eabi-objcopy
CFLAGS := -std=gnu99 -Os -mthumb -mcpu=cortex-a9 -fno-builtin-printf -fno-strict-aliasing -fno-builtin-memcpy -mno-unaligned-access -Wall -Wextra
LDFLAGS := -T common/linker.x -nodefaultlibs -nostdlib -lgcc
BUILD_DIR := build
TARGET := $(PAYLOAD_CPU)_payload
C_SRC = common/main.c device.c
ASM_SRC = common/start.S
OBJ = $(C_SRC:%.c=$(BUILD_DIR)/%.o) $(ASM_SRC:%.S=$(BUILD_DIR)/%.o)
DEP = $(OBJ:%.o=%.d)
$(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).elf
$(OBJCOPY) -O binary $^ $@
$(BUILD_DIR)/$(TARGET).elf: $(OBJ)
$(LD) -o $@ $^ $(LDFLAGS)
-include $(DEP)
$(BUILD_DIR)/%.o: %.c
mkdir -p $(@D)
$(CC) -MMD -c -o $@ $< $(CFLAGS)
$(BUILD_DIR)/%.o: %.S
mkdir -p $(@D)
$(AS) -o $@ $<
clean:
rm -rf $(BUILD_DIR)