Commit 40e6ff5d authored by NiteHawk's avatar NiteHawk Committed by GitHub
Browse files

Merge pull request #73 from n1tehawk/20161027_issue70

Build system improvements
parents 1351c828 90070ac8
...@@ -3,6 +3,9 @@ sudo: false ...@@ -3,6 +3,9 @@ sudo: false
language: c language: c
# treat all warnings as errors
env: EXTRA_CFLAGS=-Werror
os: os:
- linux - linux
- osx - osx
...@@ -10,7 +13,7 @@ compiler: ...@@ -10,7 +13,7 @@ compiler:
- gcc - gcc
- clang - 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: # This excludes the "gcc" compiler from the build matrix for OSX:
matrix: matrix:
exclude: exclude:
...@@ -23,17 +26,24 @@ addons: ...@@ -23,17 +26,24 @@ addons:
packages: packages:
- libusb-1.0-0-dev - 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: before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew update; brew update;
brew install libusb; brew install libusb;
else
export TARGET="all CROSS_COMPILE=";
fi fi
# build using the Makefile, treat all warnings as errors # build using the Makefile
script: script:
- make EXTRA_CFLAGS=-Werror - make ${TARGET} && make misc
- make misc EXTRA_CFLAGS=-Werror
# 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 # turn off email notifications
notifications: notifications:
......
...@@ -39,8 +39,9 @@ TOOLS = sunxi-fexc sunxi-bootinfo sunxi-fel sunxi-nand-part ...@@ -39,8 +39,9 @@ TOOLS = sunxi-fexc sunxi-bootinfo sunxi-fel sunxi-nand-part
FEXC_LINKS = bin2fex fex2bin FEXC_LINKS = bin2fex fex2bin
# Tools which are only useful on the target # 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 MISC_TOOLS = phoenix_info sunxi-nand-image-builder
# ARM binaries and images # ARM binaries and images
...@@ -56,16 +57,17 @@ BINDIR ?= $(PREFIX)/bin ...@@ -56,16 +57,17 @@ BINDIR ?= $(PREFIX)/bin
.PHONY: all clean tools target-tools install install-tools install-target-tools .PHONY: all clean tools target-tools install install-tools install-target-tools
all: tools target-tools
tools: $(TOOLS) $(FEXC_LINKS) tools: $(TOOLS) $(FEXC_LINKS)
target-tools: $(TARGET_TOOLS) target-tools: $(TARGET_TOOLS)
misc: version.h $(MISC_TOOLS) all: tools target-tools
misc: $(MISC_TOOLS)
binfiles: $(BINFILES) binfiles: $(BINFILES)
install: install-tools install-target-tools install: install-tools
install-all: install-tools install-target-tools
install-tools: $(TOOLS) install-tools: $(TOOLS)
install -d $(DESTDIR)$(BINDIR) install -d $(DESTDIR)$(BINDIR)
...@@ -82,12 +84,18 @@ install-target-tools: $(TARGET_TOOLS) ...@@ -82,12 +84,18 @@ install-target-tools: $(TARGET_TOOLS)
install -m0755 $$t $(DESTDIR)$(BINDIR)/$$t ; \ install -m0755 $$t $(DESTDIR)$(BINDIR)/$$t ; \
done done
install-misc: $(MISC_TOOLS)
install -d $(DESTDIR)$(BINDIR)
@set -ex ; for t in $^ ; do \
install -m0755 $$t $(DESTDIR)$(BINDIR)/$$t ; \
done
clean: clean:
@rm -vf $(TOOLS) $(FEXC_LINKS) $(TARGET_TOOLS) $(MISC_TOOLS) @rm -vf $(TOOLS) $(FEXC_LINKS) $(TARGET_TOOLS) $(MISC_TOOLS)
@rm -vf version.h *.o *.elf *.sunxi *.bin *.nm *.orig @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 fex2bin bin2fex: sunxi-fexc
ln -nsf $< $@ ln -nsf $< $@
...@@ -118,6 +126,8 @@ sunxi-nand-part: nand-part-main.c nand-part.c nand-part-a10.h nand-part-a20.h ...@@ -118,6 +126,8 @@ 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)
phoenix_info: phoenix_info.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
%.bin: %.elf %.bin: %.elf
$(CROSS_COMPILE)objcopy -O binary $< $@ $(CROSS_COMPILE)objcopy -O binary $< $@
...@@ -158,11 +168,14 @@ boot_head_sun5i.elf: boot_head.S boot_head.lds ...@@ -158,11 +168,14 @@ boot_head_sun5i.elf: boot_head.S boot_head.lds
sunxi-bootinfo: bootinfo.c 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 sunxi-meminfo: meminfo.c
$(CROSS_COMPILE)gcc -g -O0 -Wall -static -o $@ $^ $(CROSS_COMPILE)gcc $(TARGET_CFLAGS) -o $@ $<
sunxi-script_extractor: script_extractor.c sunxi-script_extractor: script_extractor.c
$(CROSS_COMPILE)gcc -g -O0 -Wall -static -o $@ $^ $(CROSS_COMPILE)gcc $(TARGET_CFLAGS) -o $@ $<
version.h: version.h:
@./autoversion.sh > $@ @./autoversion.sh > $@
......
...@@ -91,6 +91,52 @@ To build this, get a toolchain and run: ...@@ -91,6 +91,52 @@ To build this, get a toolchain and run:
make CROSS_COMPILE=arm-linux-gnueabihf- sunxi-script_extractor 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.
<br>_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 ## License
This software is licensed under the terms of GPLv2+ as defined by the 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) Free Software Foundation, details can be read in the [LICENSE.md](LICENSE.md)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# output (on stdout) can easily be redirected to a file. # 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 if VER=`git describe --tags --dirty --always`; then
echo "Setting version information: ${VER}" >&2 echo "Setting version information: ${VER}" >&2
......
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