From 5244e88f6bbb9faa79437946614b6c29d0f60020 Mon Sep 17 00:00:00 2001 From: Bernhard Nortmann Date: Thu, 27 Oct 2016 10:45:33 +0200 Subject: [PATCH 1/5] Makefile: Adjust default targets for "make" and "make install" Fixing the (currently erroneous) compilation of sunxi-pio will cause "make target-tools" to require a suitable cross-compiler installed. Otherwise "make target-tools" fails to build. As that is part of our default target ("make all"), we might possibly introduce a build breakage on quite a few systems. Avoid this situation by redefining "make tools" as the default, and change "make install" to "make install-tools", i.e. limit the standard targets to those builds that only rely on the host toolchain. From now, if you actually want to include the cross- compiling steps, use "make all" or "make install-all" instead. Signed-off-by: Bernhard Nortmann --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 975bf67..48594ac 100644 --- a/Makefile +++ b/Makefile @@ -56,16 +56,17 @@ BINDIR ?= $(PREFIX)/bin .PHONY: all clean tools target-tools install install-tools install-target-tools -all: tools target-tools - tools: $(TOOLS) $(FEXC_LINKS) target-tools: $(TARGET_TOOLS) +all: tools target-tools + misc: version.h $(MISC_TOOLS) binfiles: $(BINFILES) -install: install-tools install-target-tools +install: install-tools +install-all: install-tools install-target-tools install-tools: $(TOOLS) install -d $(DESTDIR)$(BINDIR) From 209633ab1d1b0d86f98a13ebab992b8a78cfbf75 Mon Sep 17 00:00:00 2001 From: Bernhard Nortmann Date: Fri, 28 Oct 2016 15:25:43 +0200 Subject: [PATCH 2/5] Makefile: Unify rules for target-tools, narrow down on dependencies This appends sunxi-meminfo to the TARGET_TOOLS, and adds a new rule to fix the compilation of sunxi-pio (by making it *cross-compile* for the target). Additionally adds a new build target "make install-misc". For more details, see github issues #69 and #70. Signed-off-by: Bernhard Nortmann --- Makefile | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 48594ac..b3862d6 100644 --- a/Makefile +++ b/Makefile @@ -39,8 +39,9 @@ TOOLS = sunxi-fexc sunxi-bootinfo sunxi-fel sunxi-nand-part FEXC_LINKS = bin2fex fex2bin # Tools which are only useful on the target -TARGET_TOOLS = sunxi-pio +TARGET_TOOLS = sunxi-meminfo sunxi-pio +# 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 @@ -61,7 +62,7 @@ target-tools: $(TARGET_TOOLS) all: tools target-tools -misc: version.h $(MISC_TOOLS) +misc: $(MISC_TOOLS) binfiles: $(BINFILES) @@ -83,12 +84,18 @@ install-target-tools: $(TARGET_TOOLS) 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: @rm -vf $(TOOLS) $(FEXC_LINKS) $(TARGET_TOOLS) $(MISC_TOOLS) @rm -vf version.h *.o *.elf *.sunxi *.bin *.nm *.orig -$(TOOLS) $(TARGET_TOOLS): Makefile common.h version.h +$(TOOLS) $(TARGET_TOOLS) $(MISC_TOOLS): Makefile common.h version.h fex2bin bin2fex: sunxi-fexc ln -nsf $< $@ @@ -113,6 +120,8 @@ sunxi-nand-part: nand-part-main.c nand-part.c nand-part-a10.h nand-part-a20.h sunxi-%: %.c $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS) +phoenix_info: phoenix_info.c + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) %.bin: %.elf $(CROSS_COMPILE)objcopy -O binary $< $@ @@ -153,11 +162,14 @@ boot_head_sun5i.elf: boot_head.S boot_head.lds sunxi-bootinfo: bootinfo.c +# target tools +TARGET_CFLAGS = -g -O0 -Wall -Wextra -std=c99 $(DEFINES) -Iinclude/ -static +sunxi-pio: pio.c + $(CROSS_COMPILE)gcc $(TARGET_CFLAGS) -o $@ $< sunxi-meminfo: meminfo.c - $(CROSS_COMPILE)gcc -g -O0 -Wall -static -o $@ $^ - + $(CROSS_COMPILE)gcc $(TARGET_CFLAGS) -o $@ $< sunxi-script_extractor: script_extractor.c - $(CROSS_COMPILE)gcc -g -O0 -Wall -static -o $@ $^ + $(CROSS_COMPILE)gcc $(TARGET_CFLAGS) -o $@ $< version.h: @./autoversion.sh > $@ From 8d1afa6d02e02bd56d5a9e49ba6528d89adb6385 Mon Sep 17 00:00:00 2001 From: Bernhard Nortmann Date: Fri, 28 Oct 2016 15:29:15 +0200 Subject: [PATCH 3/5] README: Document build dependencies and "make" targets Signed-off-by: Bernhard Nortmann --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/README.md b/README.md index 906f41f..84c9d0e 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,52 @@ To build this, get a toolchain and run: make CROSS_COMPILE=arm-linux-gnueabihf- sunxi-script_extractor --- +## Building + +Compilation requires the development version of *libusb-1.0* (include header +and library) to be installed for `sunxi-fel`. Unless you explicitly pass +*LIBUSB_CFLAGS* and *LIBUSB_LIBS* to the make utility, `pkg-config` is also +needed. + +Available build targets: + +* `make tools` +builds tools that are useful on the host. This is what most people will want, +and our default target (when simply using `make`). + +* `make target-tools` +builds tools that are intended for the target (Allwinner SoC), using a +cross-compiler. The toolchain prefix *CROSS_COMPILE* defaults to `arm-none-eabi-`, +adjust it if needed. +
_Hint:_ When compiling 'natively' on the target platform you may +simply use an empty toolchain prefix here (`make target-tools CROSS_COMPILE=` +or `make all CROSS_COMPILE=`). + +* `make all` +builds both *tools* and *target-tools*. + +* `make install-tools` +builds *tools* and then copies/installs them to a filesystem location. The +destination is affected by settings for `DESTDIR`, `PREFIX` and possibly +`BINDIR`. For details, please refer to the *Makefile*. +You may use `make install` as a shortcut for this. + +* `make install-target-tools` +builds *target-tools* and then copies/installs them to a filesystem location +selected by `DESTDIR`, `PREFIX` and possibly `BINDIR` - see `make install-tools` +above. + +* `make install-all` +builds and installs both *tools* and *target-tools*. + +* `make misc` +builds miscellaneous (host) utilities that are not part of our 'standard' suite. +Currently this means `phoenix_info` and `sunxi-nand-image-builder`. There is no +dedicated "install" target for these, you need to copy them manuallly. + +* `make install-misc` +builds *misc* and installs the resulting binaries. + ## License This software is licensed under the terms of GPLv2+ as defined by the Free Software Foundation, details can be read in the [LICENSE.md](LICENSE.md) From fbae32235b5379d88e78eeb23831b7c82011e298 Mon Sep 17 00:00:00 2001 From: Bernhard Nortmann Date: Sat, 29 Oct 2016 10:55:36 +0200 Subject: [PATCH 4/5] travisci: Adjust build config to use "make all" on Linux For Linux build testing, we want all targets compiled. To do so without a cross-toolchain, simply use the host compiler for the target tools. This can be achieved by setting CROSS_COMPILE to an empty string. OSX can't handle this: It neither supports "-static", nor would it successfully compile meminfo.c. Thus we keep the default "make", which should only build the 'tools' target. On Linux we'll also test the install-* targets by requesting installation to /tmp/sunxi-tools as a post-build step. Signed-off-by: Bernhard Nortmann --- .travis.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5da1f51..47aa891 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,9 @@ sudo: false language: c +# treat all warnings as errors +env: EXTRA_CFLAGS=-Werror + os: - linux - osx @@ -10,7 +13,7 @@ compiler: - gcc - clang -# OSX uses Apple's flavor of clang anyway, so there's no point in using "gcc". +# OSX uses Apple's flavor of clang anyway, so there's no point in trying "gcc". # This excludes the "gcc" compiler from the build matrix for OSX: matrix: exclude: @@ -23,17 +26,24 @@ addons: packages: - libusb-1.0-0-dev -# take care of the libusb dependency for Mac OS X +# take care of the libusb dependency for Mac OS X; on Linux use "make all" later before_install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew install libusb; + else + export TARGET="all CROSS_COMPILE="; fi -# build using the Makefile, treat all warnings as errors +# build using the Makefile script: - - make EXTRA_CFLAGS=-Werror - - make misc EXTRA_CFLAGS=-Werror + - make ${TARGET} && make misc + +# when on Linux: run/simulate a test install +after_success: + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + make install-all install-misc DESTDIR=/tmp PREFIX=/sunxi-tools; + fi # turn off email notifications notifications: From 90070ac822e2c7b7beb5ad36939159d242d39dea Mon Sep 17 00:00:00 2001 From: Bernhard Nortmann Date: Sat, 29 Oct 2016 11:21:44 +0200 Subject: [PATCH 5/5] Prepare v1.4.1 tag For now, this is for informational purposes (program version output), but it might also serve as an anchor point for a "bugfix" release after some changes made to the build system. Signed-off-by: Bernhard Nortmann --- autoversion.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoversion.sh b/autoversion.sh index 1769df3..8188b28 100755 --- a/autoversion.sh +++ b/autoversion.sh @@ -4,7 +4,7 @@ # output (on stdout) can easily be redirected to a file. # -LATEST_RELEASE="v1.4" +LATEST_RELEASE="v1.4.1" if VER=`git describe --tags --dirty --always`; then echo "Setting version information: ${VER}" >&2