Commit bbdae674 authored by Bernhard Nortmann's avatar Bernhard Nortmann
Browse files

Makefile: Add "binfiles" target and simplify rule sets



"make binfiles" should allow building ARM binaries more easily.

Factor out common $(ARM_ELF_FLAGS).

Also rewrite some rules using $< and $@, to avoid repeating
filenames. And trim down on the number of rules using patterns
for objcopy (%.elf -> %.bin) and mksunxiboot (%.bin -> %.sunxi).
Signed-off-by: default avatarBernhard Nortmann <bernhard.nortmann@web.de>
parent 68ce3d4d
...@@ -43,7 +43,12 @@ TARGET_TOOLS = sunxi-pio ...@@ -43,7 +43,12 @@ TARGET_TOOLS = sunxi-pio
MISC_TOOLS = phoenix_info MISC_TOOLS = phoenix_info
# ARM binaries and images
# Note: To use this target, set/adjust CROSS_COMPILE and MKSUNXIBOOT if needed
BINFILES = fel-pio.bin jtag-loop.sunxi fel-sdboot.sunxi
CROSS_COMPILE ?= arm-none-eabi- CROSS_COMPILE ?= arm-none-eabi-
MKSUNXIBOOT ?= mksunxiboot
DESTDIR ?= DESTDIR ?=
PREFIX ?= /usr/local PREFIX ?= /usr/local
...@@ -58,6 +63,8 @@ target-tools: $(TARGET_TOOLS) ...@@ -58,6 +63,8 @@ target-tools: $(TARGET_TOOLS)
misc: $(MISC_TOOLS) misc: $(MISC_TOOLS)
binfiles: $(BINFILES)
install: install-tools install-target-tools install: install-tools install-target-tools
install-tools: $(TOOLS) install-tools: $(TOOLS)
...@@ -106,50 +113,39 @@ sunxi-nand-part: nand-part-main.c nand-part.c nand-part-a10.h nand-part-a20.h ...@@ -106,50 +113,39 @@ sunxi-nand-part: nand-part-main.c nand-part.c nand-part-a10.h nand-part-a20.h
sunxi-%: %.c sunxi-%: %.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS)
%.bin: %.elf
$(CROSS_COMPILE)objcopy -O binary $< $@
%.sunxi: %.bin
$(MKSUNXIBOOT) $< $@
fel-pio.bin: fel-pio.elf fel-pio.nm fel-pio.bin: fel-pio.elf fel-pio.nm
$(CROSS_COMPILE)objcopy -O binary fel-pio.elf fel-pio.bin
ARM_ELF_FLAGS = -Os -fpic -Wall
ARM_ELF_FLAGS += -fno-common -fno-builtin -ffreestanding -nostdinc
ARM_ELF_FLAGS += -mno-thumb-interwork -fno-stack-protector -fno-toplevel-reorder
ARM_ELF_FLAGS += -Wstrict-prototypes -Wno-format-nonliteral -Wno-format-security
fel-pio.elf: fel-pio.c fel-pio.lds 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 $(CROSS_COMPILE)gcc -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T fel-pio.lds
fel-pio.nm: fel-pio.elf fel-pio.nm: fel-pio.elf
$(CROSS_COMPILE)nm fel-pio.elf | grep -v " _" >fel-pio.nm $(CROSS_COMPILE)nm $< | grep -v " _" >$@
jtag-loop.elf: jtag-loop.c jtag-loop.lds 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 $(CROSS_COMPILE)gcc -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -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
fel-sdboot.elf: fel-sdboot.c fel-sdboot.lds 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 $(CROSS_COMPILE)gcc -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T fel-sdboot.lds -Wl,-N
fel-sdboot.bin: fel-sdboot.elf
$(CROSS_COMPILE)objcopy -O binary fel-sdboot.elf fel-sdboot.bin
fel-sdboot.sunxi: fel-sdboot.bin
mksunxiboot fel-sdboot.bin fel-sdboot.sunxi
boot_head_sun3i.elf: boot_head_sun3i.S boot_head_sun3i.lds boot_head_sun3i.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_sun3i.elf -T boot_head.lds -Wl,-N -DMACHID=0x1094 $(CROSS_COMPILE)gcc -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -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 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 $(CROSS_COMPILE)gcc -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -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 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 $(CROSS_COMPILE)gcc -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -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
sunxi-bootinfo: bootinfo.c sunxi-bootinfo: bootinfo.c
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment