Makefile 1.31 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

Alejandro Mery's avatar
Alejandro Mery committed
11
12
13
14
.PHONY: all clean

all: $(TOOLS)

15
16
misc: $(MISC_TOOLS)

Alejandro Mery's avatar
Alejandro Mery committed
17
clean:
18
	@rm -vf $(TOOLS) $(MISC_TOOLS) *.o *.elf
Alejandro Mery's avatar
Alejandro Mery committed
19

20

21
$(TOOLS): Makefile common.h
22

23
24
fex2bin bin2fex: fexc
	ln -s $< $@
25

26
fexc: fexc.h script.h script.c \
27
28
	script_bin.h script_bin.c \
	script_fex.h script_fex.c
Alejandro Mery's avatar
Alejandro Mery committed
29

30
31
32
33
34
35
36
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)

37
%: %.c
38
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS)
39

40
41
42
43
44
45
46
47
48
49
50
51
52
.dummy:	fel-pio.bin

fel-pio.bin: fel-pio.elf fel-pio.nm
	arm-none-eabi-objcopy -O binary fel-pio.elf fel-pio.bin

fel-pio.elf: fel-pio.c
	arm-none-eabi-gcc  -g  -Os   -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

fel-pio.nm: fel-pio.elf
	arm-none-eabi-nm fel-pio.elf | grep -v " _" >fel-pio.nm

bootinfo: bootinfo.c

Alejandro Mery's avatar
Alejandro Mery committed
53
54
.gitignore: Makefile
	@for x in $(TOOLS) '*.o' '*.swp'; do \
Alejandro Mery's avatar
Alejandro Mery committed
55
		echo "$$x"; \
Alejandro Mery's avatar
Alejandro Mery committed
56
	done > $@