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