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