3f790939a0ae56ce4e00a0c1a140052956225be5
[rpi-open-firmware.git] / Makefile
1
2 TARGET_BOOTCODE = bootcode.bin
3
4 #
5 # when building bootcode.bin, always ensure start.s is at the top, providing
6 # the 0x200 byte long header and some init code.
7 #
8 SRCS = \
9 start.s \
10 romstage.c \
11 sdram.c \
12 arm_loader.c \
13 arm_monitor.cc \
14 trap.c \
15 lib/xprintf.c \
16 lib/panic.c \
17 lib/udelay.c \
18 lib/memcpy.c \
19 lib/cxx_runtime.c \
20 drivers/IODevice.cc \
21 drivers/BCM2708PowerManagement.cc \
22 drivers/BCM2708UsbPhy.cc \
23 BCM2708PlatformStartup.cc \
24 chainloader_inc.s
25
26 ARCH = vc4
27
28 BUILD_DIR = build
29 TARGET_BUILD_DIR = $(BUILD_DIR)/$(ARCH)-objects
30 PRODUCT_DIRECTORY = $(BUILD_DIR)
31
32 NO_COLOR=""
33 OK_COLOR=""
34 ERROR_COLOR=""
35 WARN_COLOR=""
36
37 .PHONY: default all clean create_build_directory device
38
39 default: $(TARGET_BOOTCODE)
40
41 OBJ := $(addprefix $(TARGET_BUILD_DIR)/, $(addsuffix .o, $(basename $(SRCS))))
42
43 # the cross compiler should already be in your path
44 CROSS_COMPILE = vc4-elf-
45 CC = $(CROSS_COMPILE)gcc
46 CXX = $(CROSS_COMPILE)g++
47 AS = $(CC)
48 OBJCOPY = $(CROSS_COMPILE)objcopy
49 LINKFLAGS = -nostdlib -nostartfiles -Wl,--build-id=none -T linker.lds
50
51 CFLAGS = -c -nostdlib -Wno-multichar -std=c11 -fsingle-precision-constant -Wdouble-promotion -D__VIDEOCORE4__ -I./vc4_include/ -I./
52 ASFLAGS = -c -nostdlib -x assembler-with-cpp -D__VIDEOCORE4__ -I./vc4_include/ -I./
53 CXXFLAGS = -c -nostdlib -Wno-multichar -std=c++11 -fno-exceptions -fno-rtti -D__VIDEOCORE4__ -I./vc4_include/ -I./
54
55 HEADERS := \
56 $(shell find . -type f -name '*.h') \
57 $(shell find . -type f -name '*.hpp')
58
59 create_build_directory:
60 @mkdir -p $(TARGET_BUILD_DIR)
61 @mkdir -p $(PRODUCT_DIRECTORY)
62
63 CREATE_SUBDIR = \
64 @DIR="$(dir $@)"; \
65 if [ ! -d $$DIR ]; then mkdir -p $$DIR; fi
66
67
68 #
69 # rules to build c/asm files.
70 #
71 $(TARGET_BUILD_DIR)/%.o: %.c $(HEADERS)
72 $(CREATE_SUBDIR)
73 @echo $(WARN_COLOR)CC $(NO_COLOR) $@
74 @$(CC) $(CFLAGS) $< -o $@
75
76 $(TARGET_BUILD_DIR)/%.o: %.cc $(HEADERS)
77 $(CREATE_SUBDIR)
78 @echo $(WARN_COLOR)CXX $(NO_COLOR) $@
79 @$(CXX) $(CXXFLAGS) $< -o $@
80
81 $(TARGET_BUILD_DIR)/%.o: %.s $(HEADERS)
82 $(CREATE_SUBDIR)
83 @echo $(WARN_COLOR)AS $(NO_COLOR) $@
84 @$(AS) $(ASFLAGS) $< -o $@
85
86 .PRECIOUS: $(OBJ)
87
88 $(TARGET_BOOTCODE): create_build_directory $(OBJ)
89 @echo $(WARN_COLOR)LD $(NO_COLOR) $@.elf
90 @$(CC) $(LINKFLAGS) $(OBJ) -o $(PRODUCT_DIRECTORY)/$@.elf
91 @echo $(WARN_COLOR)OBJ$(NO_COLOR) $@
92 @$(OBJCOPY) -O binary $(PRODUCT_DIRECTORY)/$@.elf $(PRODUCT_DIRECTORY)/$@
93
94 clean:
95 @echo $(ERROR_COLOR)CLEAN$(NO_COLOR)
96 @-rm -rf ./$(BUILD_DIR)
This page took 0.075996 seconds and 3 git commands to generate.