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