Makefile 5.33 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Copyright (C) 2012       Alejandro Mery <amery@geeks.cl>
# Copyright (C) 2012,2013  Henrik Nordstrom <henrik@henriknordstrom.net>
# Copyright (C) 2013       Patrick Wood <patrickhwood@gmail.com>
# Copyright (C) 2013       Pat Wood <Pat.Wood@efi.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

Alejandro Mery's avatar
Alejandro Mery committed
19
CC = gcc
20
CFLAGS = -g -O0 -Wall -Wextra
21
CFLAGS += -std=c99 -D_POSIX_C_SOURCE=200112L
22
CFLAGS += -Iinclude/
Alejandro Mery's avatar
Alejandro Mery committed
23

24
25
# Tools useful on host and target
TOOLS = sunxi-fexc bin2fex fex2bin sunxi-bootinfo sunxi-fel
26
TOOLS += sunxi-nand-part
Alejandro Mery's avatar
Alejandro Mery committed
27

28
29
30
# Tools which are only useful on the target
TARGET_TOOLS = sunxi-pio

31
32
MISC_TOOLS = phoenix_info

33
34
CROSS_COMPILE ?= arm-none-eabi-

35
36
37
.PHONY: all clean tools target-tools

all: tools target-tools
Alejandro Mery's avatar
Alejandro Mery committed
38

39
40
tools: $(TOOLS)
target-tools: $(TARGET_TOOLS)
Alejandro Mery's avatar
Alejandro Mery committed
41

42
43
misc: $(MISC_TOOLS)

Alejandro Mery's avatar
Alejandro Mery committed
44
clean:
45
	@rm -vf $(TOOLS) $(TARGET_TOOLS) $(MISC_TOOLS) *.o *.elf *.sunxi *.bin *.nm *.orig
Alejandro Mery's avatar
Alejandro Mery committed
46

47

48
$(TOOLS) $(TARGET_TOOLS): Makefile common.h
49

50
fex2bin bin2fex: sunxi-fexc
51
	ln -s $< $@
52

53
sunxi-fexc: fexc.h script.h script.c \
Alejandro Mery's avatar
Alejandro Mery committed
54
	script_uboot.h script_uboot.c \
55
56
	script_bin.h script_bin.c \
	script_fex.h script_fex.c
Alejandro Mery's avatar
Alejandro Mery committed
57

58
59
60
61
LIBUSB = libusb-1.0
LIBUSB_CFLAGS = `pkg-config --cflags $(LIBUSB)`
LIBUSB_LIBS = `pkg-config --libs $(LIBUSB)`

62
sunxi-fel: fel.c fel-to-spl-thunk.h
63
64
	$(CC) $(CFLAGS) $(LIBUSB_CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS) $(LIBUSB_LIBS)

65
sunxi-nand-part: nand-part-main.c nand-part.c nand-part-a10.h nand-part-a20.h
66
67
68
69
70
	$(CC) $(CFLAGS) -c -o nand-part-main.o nand-part-main.c
	$(CC) $(CFLAGS) -c -o nand-part-a10.o nand-part.c -D A10
	$(CC) $(CFLAGS) -c -o nand-part-a20.o nand-part.c -D A20
	$(CC) $(LDFLAGS) -o $@ nand-part-main.o nand-part-a10.o nand-part-a20.o $(LIBS)

71
sunxi-%: %.c
72
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS)
73

74
fel-pio.bin: fel-pio.elf fel-pio.nm
75
	$(CROSS_COMPILE)objcopy -O binary fel-pio.elf fel-pio.bin
76

77
78
fel-pio.elf: fel-pio.c fel-pio.lds
	$(CROSS_COMPILE)gcc  -g  -Os -fpic  -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder  fel-pio.c -nostdlib -o fel-pio.elf -T fel-pio.lds
79
80

fel-pio.nm: fel-pio.elf
81
82
83
84
85
86
87
88
89
90
	$(CROSS_COMPILE)nm fel-pio.elf | grep -v " _" >fel-pio.nm

jtag-loop.elf: jtag-loop.c jtag-loop.lds
	$(CROSS_COMPILE)gcc  -g  -Os  -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder  jtag-loop.c -nostdlib -o jtag-loop.elf -T jtag-loop.lds -Wl,-N

jtag-loop.bin: jtag-loop.elf
	$(CROSS_COMPILE)objcopy -O binary jtag-loop.elf jtag-loop.bin

jtag-loop.sunxi: jtag-loop.bin
	mksunxiboot jtag-loop.bin jtag-loop.sunxi
91

92
93
fel-sdboot.elf: fel-sdboot.c fel-sdboot.lds
	$(CROSS_COMPILE)gcc  -g  -Os  -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder  fel-sdboot.c -nostdlib -o fel-sdboot.elf -T fel-sdboot.lds -Wl,-N
94

95
96
fel-sdboot.bin: fel-sdboot.elf
	$(CROSS_COMPILE)objcopy -O binary fel-sdboot.elf fel-sdboot.bin
97

98
99
fel-sdboot.sunxi: fel-sdboot.bin
	mksunxiboot fel-sdboot.bin fel-sdboot.sunxi
100

101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
boot_head_sun3i.elf: boot_head_sun3i.S boot_head_sun3i.lds
	$(CROSS_COMPILE)gcc  -g  -Os  -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder  boot_head.S -nostdlib -o boot_head_sun3i.elf -T boot_head.lds -Wl,-N -DMACHID=0x1094

boot_head_sun3i.bin: boot_head_sun3i.elf
	$(CROSS_COMPILE)objcopy -O binary boot_head_sun3i.elf boot_head_sun3i.bin

boot_head_sun4i.elf: boot_head.S boot_head.lds
	$(CROSS_COMPILE)gcc  -g  -Os  -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder  boot_head.S -nostdlib -o boot_head_sun4i.elf -T boot_head.lds -Wl,-N -DMACHID=0x1008

boot_head_sun4i.bin: boot_head_sun4i.elf
	$(CROSS_COMPILE)objcopy -O binary boot_head_sun4i.elf boot_head_sun4i.bin

boot_head_sun5i.elf: boot_head.S boot_head.lds
	$(CROSS_COMPILE)gcc  -g  -Os  -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder  boot_head.S -nostdlib -o boot_head_sun5i.elf -T boot_head.lds -Wl,-N -DMACHID=0x102A

boot_head_sun5i.bin: boot_head_sun5i.elf
	$(CROSS_COMPILE)objcopy -O binary boot_head_sun5i.elf boot_head_sun5i.bin

119
sunxi-bootinfo: bootinfo.c
120

121
sunxi-meminfo: meminfo.c
122
123
	$(CROSS_COMPILE)gcc -g -O0 -Wall -static -o $@ $^

Alejandro Mery's avatar
Alejandro Mery committed
124
.gitignore: Makefile
125
	@for x in $(TOOLS) $(TARGET_TOOLS) '*.o' '*.swp'; do \
Alejandro Mery's avatar
Alejandro Mery committed
126
		echo "$$x"; \
Alejandro Mery's avatar
Alejandro Mery committed
127
	done > $@