0
|
1 # Cross-compiling (e.g., on Mac OS X, install arm-none-eabi-gcc with MacPorts)
|
11
|
2
|
6
|
3 CROSSCOMPILE := arm-linux-gnu-
|
0
|
4
|
20
|
5 CPU = armv8
|
16
|
6 CC = /usr/local/cbclang/bin/clang
|
0
|
7 AS = $(CROSSCOMPILE)as
|
|
8 LD = $(CROSSCOMPILE)ld
|
|
9 OBJCOPY = $(CROSSCOMPILE)objcopy
|
|
10 OBJDUMP = $(CROSSCOMPILE)objdump
|
|
11
|
20
|
12 # CFLAGS = -march=${CPU} -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -I. -g -O0
|
|
13 CFLAGS = -target ${CPU}-none-eabi -I /net/open/Linux/arm/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/ /net/open/Linux/arm/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include-fixed/ -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0
|
0
|
14 LDFLAGS = -L.
|
20
|
15 # ASFLAGS = -march=${CPU}
|
|
16 ASFLAGS = -target ${CPU}-none-eabi
|
0
|
17
|
11
|
18 #LIBGCC = $(shell $(gcc) -print-libgcc-file-name)
|
|
19 LIBGCC = /net/open/Linux/arm/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/libgcc.a
|
0
|
20
|
|
21 # host compiler
|
11
|
22 # HOSTCC_preferred = gcc
|
16
|
23 HOSTCC_preferred = /usr/local/cbclang/bin/clang
|
0
|
24 define get_hostcc
|
|
25 $(if $(shell which $(HOSTCC_preferred)),$(HOSTCC_preferred),"cc")
|
|
26 endef
|
|
27 HOSTCC := $(call get_hostcc)
|
|
28
|
|
29 # general rules
|
|
30 quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))
|
|
31
|
|
32 LINK_BIN = $(call quiet-command,$(LD) $(LDFLAGS) \
|
|
33 -T $(1) -o $(2) $(3) $(LIBS) -b binary $(4), " LINK $(TARGET_DIR)$@")
|
|
34
|
|
35 LINK_INIT = $(call quiet-command,$(LD) $(LDFLAGS) \
|
|
36 $(1) -o $@.out $<, " LINK $(TARGET_DIR)$@")
|
|
37 OBJCOPY_INIT = $(call quiet-command,$(OBJCOPY) \
|
|
38 -S -O binary --prefix-symbols="_binary_$@" $@.out $@, " OBJCOPY $(TARGET_DIR)$@")
|
|
39
|
|
40 build-directory = $(shell mkdir -p build build/device build/lib)
|
|
41
|
|
42 build/%.o: %.c
|
|
43 $(call build-directory)
|
|
44 $(call quiet-command,$(CC) $(CFLAGS) \
|
|
45 -c -o $@ $<," CC $(TARGET_DIR)$@")
|
|
46
|
|
47 AS_WITH = $(call quiet-command,$(CC) $(ASFLAGS) \
|
|
48 $(1) -c -o $@ $<," AS $(TARGET_DIR)$@")
|
|
49
|
|
50 build/%.o: %.S
|
|
51 $(call build-directory)
|
|
52 $(call AS_WITH, )
|