Makefile 3.77 KB
Newer Older
Alejandro Mery's avatar
Alejandro Mery committed
1
CC = gcc
2
CFLAGS = -g -O0 -Wall -Wextra
3
CFLAGS += -std=c99 -D_POSIX_C_SOURCE=200112L
4
CFLAGS += -Iinclude/
Alejandro Mery's avatar
Alejandro Mery committed
5

6
TOOLS = fexc bin2fex fex2bin bootinfo fel pio
7
TOOLS += nand-part
Alejandro Mery's avatar
Alejandro Mery committed
8

9
10
MISC_TOOLS = phoenix_info

11
12
CROSS_COMPILE ?= arm-none-eabi-

Alejandro Mery's avatar
Alejandro Mery committed
13
14
15
16
.PHONY: all clean

all: $(TOOLS)

17
18
misc: $(MISC_TOOLS)

Alejandro Mery's avatar
Alejandro Mery committed
19
clean:
20
	@rm -vf $(TOOLS) $(MISC_TOOLS) *.o *.elf *.sunxi *.bin *.nm *.orig
Alejandro Mery's avatar
Alejandro Mery committed
21

22

23
$(TOOLS): Makefile common.h
24

25
26
fex2bin bin2fex: fexc
	ln -s $< $@
27

28
fexc: fexc.h script.h script.c \
Alejandro Mery's avatar
Alejandro Mery committed
29
	script_uboot.h script_uboot.c \
30
31
	script_bin.h script_bin.c \
	script_fex.h script_fex.c
Alejandro Mery's avatar
Alejandro Mery committed
32

33
34
35
36
37
38
39
LIBUSB = libusb-1.0
LIBUSB_CFLAGS = `pkg-config --cflags $(LIBUSB)`
LIBUSB_LIBS = `pkg-config --libs $(LIBUSB)`

fel: fel.c
	$(CC) $(CFLAGS) $(LIBUSB_CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS) $(LIBUSB_LIBS)

40
%: %.c
41
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS)
42

43
fel-pio.bin: fel-pio.elf fel-pio.nm
44
	$(CROSS_COMPILE)objcopy -O binary fel-pio.elf fel-pio.bin
45

46
47
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
48
49

fel-pio.nm: fel-pio.elf
50
51
52
53
54
55
56
57
58
59
	$(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
60

61
62
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
63

64
65
fel-sdboot.bin: fel-sdboot.elf
	$(CROSS_COMPILE)objcopy -O binary fel-sdboot.elf fel-sdboot.bin
66

67
68
fel-sdboot.sunxi: fel-sdboot.bin
	mksunxiboot fel-sdboot.bin fel-sdboot.sunxi
69

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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

88
89
bootinfo: bootinfo.c

Alejandro Mery's avatar
Alejandro Mery committed
90
91
.gitignore: Makefile
	@for x in $(TOOLS) '*.o' '*.swp'; do \
Alejandro Mery's avatar
Alejandro Mery committed
92
		echo "$$x"; \
Alejandro Mery's avatar
Alejandro Mery committed
93
	done > $@