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