b781bfba900cce71b5f570f6d23d370e33ba4fad
[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.c \
14 trap.c \
15 lib/ee_printf.c \
16 panic.c \
17 lib/udelay.c \
18 lib/memcpy.c \
19 chainloader_inc.s
20
21 ARCH = vc4
22
23 BUILD_DIR = build
24 TARGET_BUILD_DIR = $(BUILD_DIR)/$(ARCH)-objects
25 PRODUCT_DIRECTORY = $(BUILD_DIR)
26
27 NO_COLOR=""
28 OK_COLOR=""
29 ERROR_COLOR=""
30 WARN_COLOR=""
31
32 .PHONY: default all clean create_build_directory device
33
34 default: $(TARGET_BOOTCODE)
35
36 OBJ := $(addprefix $(TARGET_BUILD_DIR)/, $(addsuffix .o, $(basename $(SRCS))))
37
38 CROSS_COMPILE = /Developer/vc4-toolchain/prefix/bin/vc4-elf-
39 CC = $(CROSS_COMPILE)gcc
40 AS = $(CC)
41 OBJCOPY = $(CROSS_COMPILE)objcopy
42 LINKFLAGS = -nostdlib -nostartfiles
43 CFLAGS = -c -nostdlib -std=c11 -fsingle-precision-constant -Wdouble-promotion -D__VIDEOCORE4__ -I./vc4_include/
44 ASFLAGS = -c -nostdlib -x assembler-with-cpp -D__VIDEOCORE4__ -I./vc4_include/
45
46 HEADERS := \
47 $(shell find . -type f -name '*.h') \
48 $(shell find . -type f -name '*.hpp')
49
50 create_build_directory:
51 @mkdir -p $(TARGET_BUILD_DIR)
52 @mkdir -p $(PRODUCT_DIRECTORY)
53
54 CREATE_SUBDIR = \
55 @DIR="$(dir $@)"; \
56 if [ ! -d $$DIR ]; then mkdir -p $$DIR; fi
57
58
59 #
60 # rules to build c/asm files.
61 #
62 $(TARGET_BUILD_DIR)/%.o: %.c $(HEADERS)
63 $(CREATE_SUBDIR)
64 @echo $(WARN_COLOR)CC $(NO_COLOR) $@
65 @$(CC) $(CFLAGS) $< -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_BOOTCODE): create_build_directory $(OBJ)
75 @echo $(WARN_COLOR)LD $(NO_COLOR) $@.elf
76 @$(CC) $(LINKFLAGS) $(OBJ) -o $(PRODUCT_DIRECTORY)/$@.elf
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.067119 seconds and 3 git commands to generate.