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