3
|
1 # Cross-compiling (e.g., on Mac OS X, install arm-none-eabi-gcc with MacPorts)
|
|
2 CROSSCOMPILE :=
|
|
3
|
|
4 CC = $(CROSSCOMPILE)/Users/one/src/cbclang-arm/build/bin/clang
|
|
5 AS = $(CROSSCOMPILE)as
|
|
6 LD = $(CROSSCOMPILE)ld
|
|
7 OBJCOPY = $(CROSSCOMPILE)objcopy
|
|
8 OBJDUMP = $(CROSSCOMPILE)objdump
|
|
9
|
|
10 CFLAGS = -arch arm -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -I. -g -O0 \
|
|
11 -Wno-macro-redefined -Wno-gnu-designator -Wno-sometimes-uninitialized -Wno-tautological-compare \
|
|
12 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include
|
|
13 LDFLAGS = -L. -arch armv7
|
|
14 ASFLAGS = -arch arm
|
|
15
|
|
16 LIBGCC = $(shell $(CC) -print-libgcc-file-name)
|
|
17
|
|
18 # host compiler
|
|
19 HOSTCC_preferred = clang
|
|
20 define get_hostcc
|
|
21 $(if $(shell which $(HOSTCC_preferred)),$(HOSTCC_preferred),"cc")
|
|
22 endef
|
|
23 HOSTCC := $(call get_hostcc)
|
|
24
|
|
25 # general rules
|
|
26 quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))
|
|
27
|
|
28 LINK_BIN = $(call quiet-command,$(LD) $(LDFLAGS) \
|
|
29 -T $(1) -o $(2) $(3) $(LIBS) -b binary $(4), " LINK $(TARGET_DIR)$@")
|
|
30
|
|
31 LINK_INIT = $(call quiet-command,$(LD) $(LDFLAGS) \
|
|
32 $(1) -o $@.out $<, " LINK $(TARGET_DIR)$@")
|
|
33 OBJCOPY_INIT = $(call quiet-command,$(OBJCOPY) \
|
|
34 -S -O binary --prefix-symbols="_binary_$@" $@.out $@, " OBJCOPY $(TARGET_DIR)$@")
|
|
35
|
|
36 build-directory = $(shell mkdir -p build build/device build/lib)
|
|
37
|
|
38 build/%.o: %.c
|
|
39 $(call build-directory)
|
|
40 $(call quiet-command,$(CC) $(CFLAGS) \
|
|
41 -c -o $@ $<," CC $(TARGET_DIR)$@")
|
|
42
|
|
43 AS_WITH = $(call quiet-command,$(CC) $(ASFLAGS) \
|
|
44 $(1) -c -o $@ $<," AS $(TARGET_DIR)$@")
|
|
45
|
|
46 build/%.o: %.S
|
|
47 $(call build-directory)
|
|
48 $(call AS_WITH, )
|