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