add preliminary clock code that's expected to be set up by fw, gut old arm loader...
[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_monitor.cc \
13 trap.c \
14 lib/xprintf.c \
15 lib/panic.c \
16 lib/udelay.c \
17 lib/memcpy.c \
18 lib/cxx_runtime.c \
19 drivers/IODevice.cc \
20 drivers/BCM2708PowerManagement.cc \
21 drivers/BCM2708UsbPhy.cc \
22 drivers/BCM2708ArmControl.cc \
23 drivers/BCM2708ClockDomains.cc \
24 drivers/BCM2708Gpio.cc \
25 BCM2708PlatformStartup.cc \
26 chainloader_inc.s
27
28 ARCH = vc4
29
30 BUILD_DIR = build
31 TARGET_BUILD_DIR = $(BUILD_DIR)/$(ARCH)-objects
32 PRODUCT_DIRECTORY = $(BUILD_DIR)
33
34 NO_COLOR=""
35 OK_COLOR=""
36 ERROR_COLOR=""
37 WARN_COLOR=""
38
39 .PHONY: default all clean create_build_directory device
40
41 default: $(TARGET_BOOTCODE)
42
43 OBJ := $(addprefix $(TARGET_BUILD_DIR)/, $(addsuffix .o, $(basename $(SRCS))))
44
45 # the cross compiler should already be in your path
46 CROSS_COMPILE = vc4-elf-
47 CC = $(CROSS_COMPILE)gcc
48 CXX = $(CROSS_COMPILE)g++
49 AS = $(CC)
50 OBJCOPY = $(CROSS_COMPILE)objcopy
51 LINKFLAGS = -nostdlib -nostartfiles -Wl,--build-id=none -T linker.lds
52
53 CFLAGS = -c -nostdlib -Wno-multichar -std=c11 -fsingle-precision-constant -Wdouble-promotion -D__VIDEOCORE4__ -I./vc4_include/ -I./
54 ASFLAGS = -c -nostdlib -x assembler-with-cpp -D__VIDEOCORE4__ -I./vc4_include/ -I./
55 CXXFLAGS = -c -nostdlib -Wno-multichar -std=c++11 -fno-exceptions -fno-rtti -D__VIDEOCORE4__ -I./vc4_include/ -I./
56
57 HEADERS := \
58 $(shell find . -type f -name '*.h') \
59 $(shell find . -type f -name '*.hpp')
60
61 create_build_directory:
62 @mkdir -p $(TARGET_BUILD_DIR)
63 @mkdir -p $(PRODUCT_DIRECTORY)
64
65 CREATE_SUBDIR = \
66 @DIR="$(dir $@)"; \
67 if [ ! -d $$DIR ]; then mkdir -p $$DIR; fi
68
69
70 #
71 # rules to build c/asm files.
72 #
73 $(TARGET_BUILD_DIR)/%.o: %.c $(HEADERS)
74 $(CREATE_SUBDIR)
75 @echo $(WARN_COLOR)CC $(NO_COLOR) $@
76 @$(CC) $(CFLAGS) $< -o $@
77
78 $(TARGET_BUILD_DIR)/%.o: %.cc $(HEADERS)
79 $(CREATE_SUBDIR)
80 @echo $(WARN_COLOR)CXX $(NO_COLOR) $@
81 @$(CXX) $(CXXFLAGS) $< -o $@
82
83 $(TARGET_BUILD_DIR)/%.o: %.s $(HEADERS)
84 $(CREATE_SUBDIR)
85 @echo $(WARN_COLOR)AS $(NO_COLOR) $@
86 @$(AS) $(ASFLAGS) $< -o $@
87
88 .PRECIOUS: $(OBJ)
89
90 $(TARGET_BOOTCODE): create_build_directory $(OBJ)
91 @echo $(WARN_COLOR)LD $(NO_COLOR) $@.elf
92 @$(CC) $(LINKFLAGS) $(OBJ) -o $(PRODUCT_DIRECTORY)/$@.elf
93 @echo $(WARN_COLOR)OBJ$(NO_COLOR) $@
94 @$(OBJCOPY) -O binary $(PRODUCT_DIRECTORY)/$@.elf $(PRODUCT_DIRECTORY)/$@
95
96 clean:
97 @echo $(ERROR_COLOR)CLEAN$(NO_COLOR)
98 @-rm -rf ./$(BUILD_DIR)
This page took 0.068557 seconds and 4 git commands to generate.