Hack on the loader
[rpi-open-firmware.git] / arm_chainloader / Makefile
1
2 TARGET_ARM_CHAINLOADER = arm_chainloader.bin
3
4 SRCS = \
5 start.s \
6 boot.s \
7 lib/arm_bcopy.s \
8 lib/arm_bzero.s \
9 lib/arm_locore.s \
10 lib/arm_strlen.s \
11 lib/arm_memcmp.s \
12 lib/string_misc.c \
13 drivers/uart.c \
14 drivers/cprman.cc \
15 drivers/libfdt/fdt.c \
16 drivers/libfdt/fdt_ro.c \
17 drivers/libfdt/fdt_wip.c \
18 drivers/libfdt/fdt_rw.c \
19 drivers/libfdt/fdt_strerror.c \
20 drivers/fatfs/ff.c \
21 drivers/sdhost_impl.cc \
22 drivers/mbr_disk.cc \
23 drivers/mailbox.cc \
24 ../lib/xprintf.c \
25 ../lib/panic.c \
26 ../lib/udelay.c \
27 ../lib/tlsf/tlsf.c \
28 firmware_rendezvous.c \
29 minicxx.cc \
30 loader.cc \
31 main.c
32
33 ARCH = armv6zk
34
35 BUILD_DIR = build
36 TARGET_BUILD_DIR = $(BUILD_DIR)/$(ARCH)-objects
37 PRODUCT_DIRECTORY = $(BUILD_DIR)
38
39 NO_COLOR=""
40 OK_COLOR=""
41 ERROR_COLOR=""
42 WARN_COLOR=""
43
44 .PHONY: default all clean create_build_directory device
45
46 default: $(TARGET_ARM_CHAINLOADER)
47
48 OBJ := $(addprefix $(TARGET_BUILD_DIR)/, $(addsuffix .o, $(basename $(SRCS))))
49
50 CROSS_COMPILE = arm-none-eabi-
51 CC = $(CROSS_COMPILE)gcc
52 CXX = $(CROSS_COMPILE)gcc
53 AS = $(CC)
54 OBJCOPY = $(CROSS_COMPILE)objcopy
55 LINKFLAGS = -nostdlib -march=$(ARCH) -Wl,--build-id=none -T linker.lds
56 COMMON_FLAGS = -c -nostdlib -nostartfiles -ffreestanding -march=$(ARCH) -I../ -I./ -I./drivers/libfdt/ \
57 -mfpu=vfp -mfloat-abi=hard -mtune=arm1176jzf-s
58
59 CFLAGS = $(COMMON_FLAGS) -std=c11
60 CXXFLAGS = $(COMMON_FLAGS) -std=c++11 -fno-exceptions -fno-rtti
61 ASFLAGS = $(COMMON_FLAGS) -x assembler-with-cpp
62
63 HEADERS := \
64 $(shell find . -type f -name '*.h') \
65 $(shell find . -type f -name '*.hpp')
66
67 create_build_directory:
68 @mkdir -p $(TARGET_BUILD_DIR)
69 @mkdir -p $(PRODUCT_DIRECTORY)
70
71 CREATE_SUBDIR = \
72 @DIR="$(dir $@)"; \
73 if [ ! -d $$DIR ]; then mkdir -p $$DIR; fi
74
75 #
76 # rules to build c/asm files.
77 #
78 $(TARGET_BUILD_DIR)/%.o: %.c $(HEADERS)
79 $(CREATE_SUBDIR)
80 @echo $(WARN_COLOR)CC $(NO_COLOR) $@
81 @$(CC) $(CFLAGS) $< -o $@
82
83 $(TARGET_BUILD_DIR)/%.o: %.cc $(HEADERS)
84 $(CREATE_SUBDIR)
85 @echo $(WARN_COLOR)CXX $(NO_COLOR) $@
86 @$(CXX) $(CXXFLAGS) $< -o $@
87
88 $(TARGET_BUILD_DIR)/%.o: %.s $(HEADERS)
89 $(CREATE_SUBDIR)
90 @echo $(WARN_COLOR)AS $(NO_COLOR) $@
91 @$(AS) $(ASFLAGS) $< -o $@
92
93 .PRECIOUS: $(OBJ)
94
95 $(TARGET_ARM_CHAINLOADER): create_build_directory $(OBJ)
96 @echo $(WARN_COLOR)LD $(NO_COLOR) $@.elf
97 @$(CC) $(LINKFLAGS) $(OBJ) -o $(PRODUCT_DIRECTORY)/$@.elf -lgcc
98 @echo $(WARN_COLOR)OBJ$(NO_COLOR) $@
99 @$(OBJCOPY) -O binary $(PRODUCT_DIRECTORY)/$@.elf $(PRODUCT_DIRECTORY)/$@
100
101 clean:
102 @echo $(ERROR_COLOR)CLEAN$(NO_COLOR)
103 @-rm -rf ./$(BUILD_DIR)
This page took 0.075831 seconds and 4 git commands to generate.