Initial commit
[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 trap.c \
14 lib/xprintf.c \
15 lib/panic.c \
16 lib/udelay.c \
17 lib/memcpy.c \
18 chainloader_inc.s
19
20 ARCH = vc4
21
22 BUILD_DIR = build
23 TARGET_BUILD_DIR = $(BUILD_DIR)/$(ARCH)-objects
24 PRODUCT_DIRECTORY = $(BUILD_DIR)
25
26 NO_COLOR=""
27 OK_COLOR=""
28 ERROR_COLOR=""
29 WARN_COLOR=""
30
31 .PHONY: default all clean create_build_directory device
32
33 default: $(TARGET_BOOTCODE)
34
35 OBJ := $(addprefix $(TARGET_BUILD_DIR)/, $(addsuffix .o, $(basename $(SRCS))))
36
37 CROSS_COMPILE = /Developer/vc4-toolchain/prefix/bin/vc4-elf-
38 CC = $(CROSS_COMPILE)gcc
39 AS = $(CC)
40 OBJCOPY = $(CROSS_COMPILE)objcopy
41 LINKFLAGS = -nostdlib -nostartfiles
42 CFLAGS = -c -nostdlib -std=c11
43 ASFLAGS = -c -nostdlib -x assembler-with-cpp
44
45 HEADERS := \
46 $(shell find . -type f -name '*.h') \
47 $(shell find . -type f -name '*.hpp')
48
49 create_build_directory:
50 @mkdir -p $(TARGET_BUILD_DIR)
51 @mkdir -p $(PRODUCT_DIRECTORY)
52
53 CREATE_SUBDIR = \
54 @DIR="$(dir $@)"; \
55 if [ ! -d $$DIR ]; then mkdir -p $$DIR; fi
56
57
58 #
59 # rules to build c/asm files.
60 #
61 $(TARGET_BUILD_DIR)/%.o: %.c $(HEADERS)
62 $(CREATE_SUBDIR)
63 @echo $(WARN_COLOR)CC $(NO_COLOR) $@
64 @$(CC) $(CFLAGS) $< -o $@
65
66 $(TARGET_BUILD_DIR)/%.o: %.s $(HEADERS)
67 $(CREATE_SUBDIR)
68 @echo $(WARN_COLOR)AS $(NO_COLOR) $@
69 @$(AS) $(ASFLAGS) $< -o $@
70
71 .PRECIOUS: $(OBJ)
72
73 $(TARGET_BOOTCODE): create_build_directory $(OBJ)
74 @echo $(WARN_COLOR)LD $(NO_COLOR) $@.elf
75 @$(CC) $(LINKFLAGS) $(OBJ) -o $(PRODUCT_DIRECTORY)/$@.elf
76 @echo $(WARN_COLOR)OBJ$(NO_COLOR) $@
77 @$(OBJCOPY) -O binary $(PRODUCT_DIRECTORY)/$@.elf $(PRODUCT_DIRECTORY)/$@
78
79 clean:
80 @echo $(ERROR_COLOR)CLEAN$(NO_COLOR)
81 @-rm -rf ./$(BUILD_DIR)
This page took 0.066938 seconds and 5 git commands to generate.