Initial commit
[rpi-open-firmware.git] / arm_chainloader / Makefile
1
2 TARGET_ARM_CHAINLOADER = arm_chainloader.bin
3
4 SRCS = \
5 start.s \
6 drivers/uart.c \
7 ../lib/xprintf.c \
8 firmware_rendezvous.c \
9 main.c
10
11 ARCH = armv6zk
12
13 BUILD_DIR = build
14 TARGET_BUILD_DIR = $(BUILD_DIR)/$(ARCH)-objects
15 PRODUCT_DIRECTORY = $(BUILD_DIR)
16
17 NO_COLOR=""
18 OK_COLOR=""
19 ERROR_COLOR=""
20 WARN_COLOR=""
21
22 .PHONY: default all clean create_build_directory device
23
24 default: $(TARGET_ARM_CHAINLOADER)
25
26 OBJ := $(addprefix $(TARGET_BUILD_DIR)/, $(addsuffix .o, $(basename $(SRCS))))
27
28 CROSS_COMPILE = arm-none-eabi-
29 CC = $(CROSS_COMPILE)gcc
30 AS = $(CC)
31 OBJCOPY = $(CROSS_COMPILE)objcopy
32 LINKFLAGS = -nostdlib -march=$(ARCH) -Wl,--build-id=none -T linker.lds
33 COMMON_FLAGS = -c -nostdlib -nostartfiles -ffreestanding -march=$(ARCH) -I../ -I./ -mfpu=vfp -mfloat-abi=hard -mtune=arm1176jzf-s
34 CFLAGS = $(COMMON_FLAGS) -std=c11
35 ASFLAGS = $(COMMON_FLAGS) -x assembler-with-cpp
36
37 HEADERS := \
38 $(shell find . -type f -name '*.h') \
39 $(shell find . -type f -name '*.hpp')
40
41 create_build_directory:
42 @mkdir -p $(TARGET_BUILD_DIR)
43 @mkdir -p $(PRODUCT_DIRECTORY)
44
45 CREATE_SUBDIR = \
46 @DIR="$(dir $@)"; \
47 if [ ! -d $$DIR ]; then mkdir -p $$DIR; fi
48
49 #
50 # rules to build c/asm files.
51 #
52 $(TARGET_BUILD_DIR)/%.o: %.c $(HEADERS)
53 $(CREATE_SUBDIR)
54 @echo $(WARN_COLOR)CC $(NO_COLOR) $@
55 @$(CC) $(CFLAGS) $< -o $@
56
57 $(TARGET_BUILD_DIR)/%.o: %.s $(HEADERS)
58 $(CREATE_SUBDIR)
59 @echo $(WARN_COLOR)AS $(NO_COLOR) $@
60 @$(AS) $(ASFLAGS) $< -o $@
61
62 .PRECIOUS: $(OBJ)
63
64 $(TARGET_ARM_CHAINLOADER): create_build_directory $(OBJ)
65 @echo $(WARN_COLOR)LD $(NO_COLOR) $@.elf
66 @$(CC) $(LINKFLAGS) $(OBJ) -o $(PRODUCT_DIRECTORY)/$@.elf -lgcc
67 @echo $(WARN_COLOR)OBJ$(NO_COLOR) $@
68 @$(OBJCOPY) -O binary $(PRODUCT_DIRECTORY)/$@.elf $(PRODUCT_DIRECTORY)/$@
69
70 clean:
71 @echo $(ERROR_COLOR)CLEAN$(NO_COLOR)
72 @-rm -rf ./$(BUILD_DIR)
This page took 0.069275 seconds and 5 git commands to generate.