Merge pull request #24 from jolan/jolan_typofix
[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/xprintf.c \
16 lib/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 # the cross compiler should already be in your path
39 CROSS_COMPILE = vc4-elf-
40 CC = $(CROSS_COMPILE)gcc
41 AS = $(CC)
42 OBJCOPY = $(CROSS_COMPILE)objcopy
43 LINKFLAGS = -nostdlib -nostartfiles
44 CFLAGS = -c -nostdlib -std=c11 -fsingle-precision-constant -Wdouble-promotion -D__VIDEOCORE4__ -I./vc4_include/
45 ASFLAGS = -c -nostdlib -x assembler-with-cpp -D__VIDEOCORE4__ -I./vc4_include/
46
47 HEADERS := \
48 $(shell find . -type f -name '*.h') \
49 $(shell find . -type f -name '*.hpp')
50
51 create_build_directory:
52 @mkdir -p $(TARGET_BUILD_DIR)
53 @mkdir -p $(PRODUCT_DIRECTORY)
54
55 CREATE_SUBDIR = \
56 @DIR="$(dir $@)"; \
57 if [ ! -d $$DIR ]; then mkdir -p $$DIR; fi
58
59
60 #
61 # rules to build c/asm files.
62 #
63 $(TARGET_BUILD_DIR)/%.o: %.c $(HEADERS)
64 $(CREATE_SUBDIR)
65 @echo $(WARN_COLOR)CC $(NO_COLOR) $@
66 @$(CC) $(CFLAGS) $< -o $@
67
68 $(TARGET_BUILD_DIR)/%.o: %.s $(HEADERS)
69 $(CREATE_SUBDIR)
70 @echo $(WARN_COLOR)AS $(NO_COLOR) $@
71 @$(AS) $(ASFLAGS) $< -o $@
72
73 .PRECIOUS: $(OBJ)
74
75 $(TARGET_BOOTCODE): create_build_directory $(OBJ)
76 @echo $(WARN_COLOR)LD $(NO_COLOR) $@.elf
77 @$(CC) $(LINKFLAGS) $(OBJ) -o $(PRODUCT_DIRECTORY)/$@.elf
78 @echo $(WARN_COLOR)OBJ$(NO_COLOR) $@
79 @$(OBJCOPY) -O binary $(PRODUCT_DIRECTORY)/$@.elf $(PRODUCT_DIRECTORY)/$@
80
81 clean:
82 @echo $(ERROR_COLOR)CLEAN$(NO_COLOR)
83 @-rm -rf ./$(BUILD_DIR)
This page took 0.070266 seconds and 4 git commands to generate.