sunxi-tools/Makefile

219 lines
7.2 KiB
Makefile
Raw Permalink Normal View History

Add copyright headers to various files. I'd like to package sunxi-tools for Debian and therefore it is important for the licensing information to be complete/accurate. I believe the intention was for everything here to be GPL2+ by default, since that is the license on every file which has one and COPYING contains GPL2. Early on the license applied to this repo was GPLv3 however this was changed to GPL2+ by Alejandro in 79ea14d4e050 at which point he had been the only contributor. This patch adds the standard GPL2+ stanza used already in sunxi-tools.git or the MIT license stanza when requested by the copyright holder to various files which were missing one as follows: adb-devprobe.sh fel-gpio According to git all of these were written by Henrik. Copyright years according to git. Henrik requested that these be put under an MIT license, so that is what has been done. boot_head.lds fel-pio.lds fel-sdboot.lds jtag-loop.lds According to git all of these were written by Henrik. Copyright years according to git. According to Henrik "These linker scripts are all GPLv2+ as the C / ASM sources they refer to". include/endian_compat.h The content of this file was originally added to fel.c (commit c71ff92c02d3), which had a GPL2+ stanza at the time, by Eric Molitor and later those lines were moved by Alejandro (commit bcde0fc72170) into this file. I originally added GPL2+ from fel.c and added Eric's copyright with the correct year according to git but Eric said "Ack but also would prefer MIT/Dual :)", so it has now been changed to MIT. include/types.h: Henrik originally added some of these lines to bootinfo.c, along with a GPL2+ stanza, in the original version (commit c26e5ff80af6). Later on Alejandro moved them into this file (commit 329a13ed75e5) and added more. I've copied the stanza from bootinfo.c and added both copyrights with the years according to git. Authors: Henrik, who says "OK". Alejandro Mery Makefile: GPL2+ with copyrights and years according to git. Authors are: Alejandro Mery Henrik Nordstrom, who says "Yes" Pat Wood, who says "Fine with me" usb-boot: Henrik is the primary author, added MIT license on Henrik's request with his copyright and years according to git. Authors are: Henrik Nordstrom, who says "Yes, that too should be MIT" Alejandro Mery (typo fix) Michal Suchanek (typo fix) Everyone affected by the above is CCd. This probably seems pretty obvious to most people, sorry for being so pedantic about it. It will save hassel when it comes to getting it into Debian though. Signed-off-by: Ian Campbell <ijc@hellion.org.uk> Cc: Henrik Nordstrom <henrik@henriknordstrom.net> Cc: Eric Molitor <eric@molitor.org> Cc: Alejandro Mery <amery@geeks.cl> Cc: Pat Wood <Pat.Wood@efi.com> Cc: Michal Suchanek <hramrach@gmail.com> --- v2: Gathered feedback from the authors - Pat said "Fine with me" - Henrik asked that adb-devprobe.sh, fel-gpio and usb-boot be MIT, acked *.lds, types.h and Makefile - Explicitly listed authors of Makefile and usb-boot - Michal Suchanek make a typo fix to usb-boot but wasn't CCd, sorry. - Reworded commit message due to some bits now being MIT on request of the author.
2014-06-05 20:03:45 +01:00
# 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/>.
# Windows predefines OS in the environment (to "Windows_NT"), otherwise use uname
OS ?= $(shell uname)
CC ?= gcc
DEFAULT_CFLAGS := -std=c99
DEFAULT_CFLAGS += -Wall -Wextra -Wno-unused-result
2012-05-02 09:35:52 +02:00
DEFAULT_CFLAGS += -D_POSIX_C_SOURCE=200112L
# Define _BSD_SOURCE, necessary to expose all endian conversions properly.
# See http://linux.die.net/man/3/endian
DEFAULT_CFLAGS += -D_BSD_SOURCE
# glibc 2.20+ also requires _DEFAULT_SOURCE
DEFAULT_CFLAGS += -D_DEFAULT_SOURCE
ifeq ($(OS),NetBSD)
# add explicit _NETBSD_SOURCE, see https://github.com/linux-sunxi/sunxi-tools/pull/22
DEFAULT_CFLAGS += -D_NETBSD_SOURCE
endif
DEFAULT_CFLAGS += -Iinclude/
PKG_CONFIG ?= pkg-config
# Tools useful on host and target
TOOLS = sunxi-fexc sunxi-bootinfo sunxi-fel sunxi-nand-part sunxi-pio
# Symlinks to sunxi-fexc
FEXC_LINKS = bin2fex fex2bin
2012-05-02 09:35:52 +02:00
# Tools which are only useful on the target
TARGET_TOOLS = sunxi-meminfo
# Misc tools (of more "exotic" nature) not part of our default build / install
MISC_TOOLS = phoenix_info sunxi-nand-image-builder
# ARM binaries and images
# Note: To use this target, set/adjust CROSS_COMPILE, MKIMAGE and MKSUNXIBOOT if needed
BINFILES = jtag-loop.sunxi fel-sdboot.sunxi uart0-helloworld-sdboot.sunxi
BINFILE_ELFS = $(BINFILES:.sunxi=.elf)
BINFILE_BINS = $(BINFILES:.sunxi=.bin)
BOOT_HEAD_ELFS = boot_head_sun3i.elf boot_head_sun4i.elf boot_head_sun5i.elf
CLEANFILES = $(BINFILES) $(BINFILE_ELFS) $(BINFILE_BINS) $(BOOT_HEAD_ELFS)
MKSUNXIBOOT ?= mksunxiboot
MKIMAGE ?= mkimage
MKIMAGE_SUNXI_EGON = $(shell $(MKIMAGE) -T list 2>&1 | grep -q 'sunxi_egon' && echo y)
SUNXI_BOOT_IMAGE = $(if $(MKIMAGE_SUNXI_EGON),$(MKIMAGE) -T sunxi_egon -d,$(MKSUNXIBOOT))
PATH_DIRS := $(shell echo $$PATH | sed -e 's/:/ /g')
# Try to guess a suitable default ARM cross toolchain
CROSS_DEFAULT := arm-none-eabi-
CROSS_COMPILE ?= $(or $(shell ./find-arm-gcc.sh),$(CROSS_DEFAULT))
CROSS_CC := $(CROSS_COMPILE)gcc
2012-09-04 21:48:23 +02:00
DESTDIR ?=
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/share/man/man1
.PHONY: all clean tools target-tools install install-tools install-target-tools
.PHONY: check
tools: $(TOOLS) $(FEXC_LINKS)
target-tools: $(TARGET_TOOLS)
2012-05-02 09:35:52 +02:00
all: tools target-tools
misc: $(MISC_TOOLS)
binfiles: $(BINFILES)
install: install-tools
install-all: install-tools install-target-tools
install-tools: $(TOOLS)
install -d $(DESTDIR)$(BINDIR)
@set -ex ; for t in $^ ; do \
install -m0755 $$t $(DESTDIR)$(BINDIR)/$$t ; \
done
@set -ex ; for l in $(FEXC_LINKS) ; do \
ln -nfs sunxi-fexc $(DESTDIR)$(BINDIR)/$$l ; \
done
install -D -m0644 -t $(DESTDIR)$(MANDIR) sunxi-fel.1
2012-05-02 09:35:52 +02:00
install-target-tools: $(TARGET_TOOLS)
install -d $(DESTDIR)$(BINDIR)
@set -ex ; for t in $^ ; do \
install -m0755 $$t $(DESTDIR)$(BINDIR)/$$t ; \
done
install-misc: $(MISC_TOOLS)
install -d $(DESTDIR)$(BINDIR)
@set -ex ; for t in $^ ; do \
install -m0755 $$t $(DESTDIR)$(BINDIR)/$$t ; \
done
clean:
make -C tests/ clean
@rm -vf $(TOOLS) $(FEXC_LINKS) $(TARGET_TOOLS) $(MISC_TOOLS)
@rm -vf version.h *.o $(CLEANFILES)
$(TOOLS) $(TARGET_TOOLS) $(MISC_TOOLS): Makefile common.h version.h
fex2bin bin2fex: sunxi-fexc
ln -nsf $< $@
sunxi-fexc: fexc.h script.h script.c \
2012-09-29 18:42:17 +02:00
script_uboot.h script_uboot.c \
script_bin.h script_bin.c \
script_fex.h script_fex.c
2012-05-11 09:22:47 +02:00
LIBUSB = libusb-1.0
LIBUSB_CFLAGS ?= `$(PKG_CONFIG) --cflags $(LIBUSB)`
LIBUSB_LIBS ?= `$(PKG_CONFIG) --libs $(LIBUSB)`
ZLIB = zlib
ZLIB_CFLAGS ?= `$(PKG_CONFIG) --cflags $(ZLIB)`
ZLIB_LIBS ?= `$(PKG_CONFIG) --libs $(ZLIB)`
ifeq ($(OS),Windows_NT)
# Windows lacks mman.h / mmap()
DEFAULT_CFLAGS += -DNO_MMAP
# portable_endian.h relies on winsock2
LIBS += -lws2_32
endif
HOST_CFLAGS = $(DEFAULT_CFLAGS) $(CFLAGS)
PROGRESS := progress.c progress.h
SOC_INFO := soc_info.c soc_info.h
FEL_LIB := fel_lib.c fel_lib.h
SPI_FLASH:= fel-spiflash.c fel-spiflash.h fel-remotefunc-spi-data-transfer.h
sunxi-fel: fel.c fit_image.c thunks/fel-to-spl-thunk.h $(PROGRESS) $(SOC_INFO) $(FEL_LIB) $(SPI_FLASH)
$(CC) $(HOST_CFLAGS) $(LIBUSB_CFLAGS) $(ZLIB_CFLAGS) $(LDFLAGS) -o $@ \
$(filter %.c,$^) $(LIBS) $(LIBUSB_LIBS) $(ZLIB_LIBS) -lfdt
sunxi-nand-part: nand-part-main.c nand-part.c nand-part-a10.h nand-part-a20.h
$(CC) $(HOST_CFLAGS) -c -o nand-part-main.o nand-part-main.c
$(CC) $(HOST_CFLAGS) -c -o nand-part-a10.o nand-part.c -D A10
$(CC) $(HOST_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)
sunxi-%: %.c
$(CC) $(HOST_CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS)
phoenix_info: phoenix_info.c
$(CC) $(HOST_CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
%.bin: %.elf
$(CROSS_COMPILE)objcopy -O binary $< $@
%.sunxi: %.bin
$(SUNXI_BOOT_IMAGE) $< $@
ARM_ELF_FLAGS = -Os -marm -fpic -Wall
ARM_ELF_FLAGS += -fno-common -fno-builtin -ffreestanding -nostdinc -fno-strict-aliasing
ARM_ELF_FLAGS += -mno-thumb-interwork -fno-stack-protector -fno-toplevel-reorder
ARM_ELF_FLAGS += -Wstrict-prototypes -Wno-format-nonliteral -Wno-format-security
jtag-loop.elf: jtag-loop.c bare-metal.c bare-metal.lds
$(CROSS_CC) -march=armv5te -g $(ARM_ELF_FLAGS) $(filter %.c,$^) -nostdlib -o $@ -T $(lastword $^) -Wl,-N
fel-sdboot.elf: fel-sdboot.S fel-sdboot.lds
$(CROSS_CC) -march=armv5te -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T $(lastword $^) -Wl,-N
2012-09-04 21:52:56 +02:00
uart0-helloworld-sdboot.elf: uart0-helloworld-sdboot.c bare-metal.c bare-metal.lds
$(CROSS_CC) -march=armv5te -g $(ARM_ELF_FLAGS) $(filter %.c,$^) -nostdlib -o $@ -T $(lastword $^) -Wl,-N
boot_head_sun3i.elf: boot_head.S boot_head.lds
$(CROSS_CC) -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T $(lastword $^) -Wl,-N -DMACHID=0x1094
boot_head_sun4i.elf: boot_head.S boot_head.lds
$(CROSS_CC) -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T $(lastword $^) -Wl,-N -DMACHID=0x1008
boot_head_sun5i.elf: boot_head.S boot_head.lds
$(CROSS_CC) -g $(ARM_ELF_FLAGS) $< -nostdlib -o $@ -T $(lastword $^) -Wl,-N -DMACHID=0x102A
sunxi-bootinfo: bootinfo.c
# "preprocessed" .h files for inclusion of ARM thunk code
headers:
make -C thunks/ CROSS_COMPILE=$(CROSS_COMPILE)
# target tools
TARGET_CFLAGS = $(DEFAULT_CFLAGS) -static $(CFLAGS)
sunxi-meminfo: meminfo.c
$(CROSS_CC) $(TARGET_CFLAGS) -o $@ $<
sunxi-script_extractor: script_extractor.c
$(CROSS_CC) $(TARGET_CFLAGS) -o $@ $<
version.h:
@./autoversion.sh > $@
2012-05-02 09:35:52 +02:00
.gitignore: Makefile
@for x in $(TOOLS) $(FEXC_LINKS) $(TARGET_TOOLS) version.h '*.o' '*.swp'; do \
2012-07-31 14:27:04 +02:00
echo "$$x"; \
done | sort -V > $@
check: $(FEXC_LINKS)
make -C tests/