Cleaned up build process, added lzma bin for x86_64
authorDavid Thornley <david.thornley@touchstargroup.com>
Tue, 31 May 2016 07:20:44 +0000 (17:20 +1000)
committerPiotr Dymacz <pepe2k@gmail.com>
Wed, 10 Aug 2016 12:59:54 +0000 (14:59 +0200)
Supplied compiled host_util for linux-x86_32 (original compiled)
and newly compiled linux-x86_64 and darwin-x86_64.

Split across different subfolders depending on HOSTOS-HOSTARCH,
made HOSTOS consistent in root Makefile.

Added LIBS_SHARED variable that is independently compiled,
as opposed to including common files in both LIBS and LIBS_BOOTSTRAP.

Cleaned up documentation (removed lzma mention in OS X build, now using macOS).

Makefile
README.md
host_util/darwin-x86_64/lzma [new file with mode: 0755]
host_util/linux-x86_32/lzma [new file with mode: 0755]
host_util/linux-x86_64/lzma [new file with mode: 0755]
host_util/lzma [deleted file]
u-boot/Makefile
u-boot/tools/mkimage.c

index 17b2b6c99074e53ac3d92730c35f59ec05063c85..aa0f2c9657cd973efe877ae753a4b002f84c8c6e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,17 +1,34 @@
 SHELL = bash
-UNAME_S := $(shell uname -s)
 
-ifeq ($(UNAME_S), Darwin)
-HOSTOS = osx
-else ifeq ($(UNAME_S), Linux)
-HOSTOS = linux
-else
-$(error Error! Unsupported Host Operating System!)
+HOSTARCH := $(shell uname -m | \
+       sed -e s/i.86/x86_32/      \
+           -e s/sun4u/sparc64/    \
+           -e s/arm.*/arm/        \
+           -e s/sa110/arm/        \
+           -e s/powerpc/ppc/      \
+           -e s/macppc/ppc/)
+
+HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
+           sed -e 's/\(cygwin\).*/cygwin/')
+
+ifneq ($(HOSTOS), darwin)
+  ifneq ($(HOSTOS), linux)
+    $(error Error! Unsupported host operating system/arch: "$(HOSTOS)-$(HOSTARCH)")
+  endif
 endif
 
+export HOSTOS
+export HOSTARCH
 export BUILD_TOPDIR=$(PWD)
 export STAGING_DIR=$(BUILD_TOPDIR)/tmp
 
+# --------------------------------------------------------------------------
+# Define absolute path to your toolchain directory here, for example:
+#
+# export TOOLCHAIN_DIR:=/home/user/toolchain-mips_34kc_gcc-5.4.0_musl-1.1.15
+# export PATH:=$(TOOLCHAIN_DIR)/bin:$(PATH)
+# --------------------------------------------------------------------------
+
 ifndef CROSS_COMPILE
 CROSS_COMPILE = mips-openwrt-linux-musl-
 endif
index 6dc6d9e6ed71a37416a18b92adc71d497cad2eec..e75b156357e87bea08b9654ced825a2668300d29 100644 (file)
--- a/README.md
+++ b/README.md
@@ -674,9 +674,9 @@ make tplink_wr703n
 
 will start building U-Boot image for **TP-Link TL-WR703N**.
 
-### Building on OS X
+### Building on macOS (OS X)
 
-You can build using the openwrt/lede toolchain as above under OS X as long as you install several gnu command line tools via brew. Note that bash is required to correct the usage of colorized echo output within the Makefiles (I was suprised how inconsistent FreeBSD is with Linux in this regard).
+You can build using the OpenWrt/LEDE toolchain as above under macOS (OS X) as long as you install several gnu command line tools via brew. Note that bash is required to correct the usage of colorized echo output within the Makefiles (I was suprised how inconsistent FreeBSD is with Linux/GNU in this regard).
 
 ```
 brew install bash coreutils gnu-sed
@@ -688,8 +688,6 @@ Subsequently, in addition to the toolchain being in your path, you will need to
 export PATH=/usr/local/opt/coreutils/libexec/gnubin:/usr/local/opt/gnu-sed/libexec/gnubin:$PATH
 ```
 
-Lastly, you will need a localised (osx) build of lzma replacing the supplied ELF32 binary in the host_utils folder. I have tested with [lzma-4.32.7](http://tukaani.org/lzma/lzma-4.32.7.tar.gz) ; just run ./configure and then make and grab the executable from src/lzma.
-
 This process was tested on Yosemite and El Capitan.
 
 FAQ
diff --git a/host_util/darwin-x86_64/lzma b/host_util/darwin-x86_64/lzma
new file mode 100755 (executable)
index 0000000..9e161c9
Binary files /dev/null and b/host_util/darwin-x86_64/lzma differ
diff --git a/host_util/linux-x86_32/lzma b/host_util/linux-x86_32/lzma
new file mode 100755 (executable)
index 0000000..ac81e12
Binary files /dev/null and b/host_util/linux-x86_32/lzma differ
diff --git a/host_util/linux-x86_64/lzma b/host_util/linux-x86_64/lzma
new file mode 100755 (executable)
index 0000000..fa22863
Binary files /dev/null and b/host_util/linux-x86_64/lzma differ
diff --git a/host_util/lzma b/host_util/lzma
deleted file mode 100755 (executable)
index ac81e12..0000000
Binary files a/host_util/lzma and /dev/null differ
index 1855aaeeffa8979cdfaffbfa99d2afac72bcb130..62383577949f1dfeea1d85045cfe452e0b5cd887 100644 (file)
@@ -20,8 +20,8 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 # MA 02111-1307 USA
 #
-SHELL = bash
 
+SHELL                  = bash
 VERSION                        = 1
 PATCHLEVEL             = 1
 SUBLEVEL               = 4
@@ -36,19 +36,6 @@ else
 U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)"-clean"
 endif
 
-HOSTARCH := $(shell uname -m | \
-       sed -e s/i.86/i386/ \
-           -e s/sun4u/sparc64/ \
-           -e s/arm.*/arm/ \
-           -e s/sa110/arm/ \
-           -e s/powerpc/ppc/ \
-           -e s/macppc/ppc/)
-
-HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
-           sed -e 's/\(cygwin\).*/cygwin/')
-
-export HOSTARCH HOSTOS
-
 # Deal with colliding definitions from tcsh etc.
 VENDOR=
 
@@ -124,12 +111,6 @@ endif
 
 LIBS  = lib_generic/libgeneric.a
 LIBS += common/libcommon.a
-LIBS += board/$(BOARDDIR)/lib$(BOARD).a
-LIBS += cpu/$(CPU)/lib$(CPU).a
-
-ifdef SOC
-LIBS += cpu/$(CPU)/$(SOC)/lib$(SOC).a
-endif
 
 LIBS += lib_$(ARCH)/lib$(ARCH).a
 LIBS += drivers/libdrivers.a
@@ -138,22 +119,27 @@ LIBS += rtc/librtc.a
 LIBS += httpd/libhttpd.a
 LIBS += $(BOARDLIBS)
 
+LIBS_SHARED = board/$(BOARDDIR)/lib$(BOARD).a
+ifdef SOC
+LIBS_SHARED += cpu/$(CPU)/$(SOC)/lib$(SOC).a
+endif
+LIBS_SHARED += cpu/$(CPU)/lib$(CPU).a
+
 ifdef COMPRESSED_UBOOT
        ifndef CONFIG_SKIP_LOWLEVEL_INIT
-LIBS_BOOTSTRAP = lib_bootstrap/libbootstrap.a 
-LIBS_BOOTSTRAP += board/$(BOARDDIR)/lib$(BOARD).a 
-LIBS_BOOTSTRAP += cpu/$(CPU)/lib$(CPU).a
-LIBS_BOOTSTRAP += cpu/$(CPU)/$(SOC)/lib$(SOC).a
+LIBS_BOOTSTRAP = lib_bootstrap/libbootstrap.a
        endif
 endif
 
-.PHONY : $(LIBS)
+PHONY_LIBS = $(LIBS) $(LIBS_SHARED)
 
 ifdef COMPRESSED_UBOOT
-       ifndef CONFIG_SKIP_LOWLEVEL_INIT
-.PHONY : $(LIBS_BOOTSTRAP)
-       endif
+ifndef CONFIG_SKIP_LOWLEVEL_INIT
+PHONY_LIBS = $(LIBS_BOOTSTRAP) $(LIBS_SHARED)
 endif
+endif
+
+.PHONY : $(PHONY_LIBS)
 
 # Add GCC lib
 PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
@@ -199,12 +185,15 @@ u-boot.img:       u-boot.bin
 u-boot.dis:    u-boot
        $(OBJDUMP) -d $< > $@
 
-u-boot:        depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT)
-       UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) |sed  -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
+u-boot:        depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LIBS_SHARED) $(LDSCRIPT)
+       UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) $(LIBS_SHARED) |sed  -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
                $(LD) $(LDFLAGS) $$UNDEF_SYM $(OBJS) \
-               --start-group $(LIBS) --end-group $(PLATFORM_LIBS) \
+               --start-group $(LIBS) $(LIBS_SHARED) --end-group $(PLATFORM_LIBS) \
                -Map u-boot.map -o u-boot
 
+$(LIBS_SHARED):
+       $(MAKE) -C `dirname $@`
+
 $(LIBS):
        $(MAKE) -C `dirname $@`
 
@@ -213,7 +202,7 @@ $(SUBDIRS):
 
 ifdef COMPRESSED_UBOOT
 ifndef CONFIG_SKIP_LOWLEVEL_INIT
-LZMA = $(BUILD_TOPDIR)/host_util/lzma
+LZMA = $(BUILD_TOPDIR)/host_util/$(HOSTOS)-$(HOSTARCH)/lzma
 
 tuboot.bin:    System.map bootstrap.bin u-boot.lzimg   
        @cat bootstrap.bin > $@
@@ -231,10 +220,10 @@ u-boot.lzimg: $(obj)u-boot.bin System.map
 bootstrap.bin: bootstrap
        $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
 
-bootstrap:     depend version $(SUBDIRS) $(OBJS_BOOTSTRAP) $(LIBS_BOOTSTRAP) $(LDSCRIPT_BOOTSTRAP)
+bootstrap:     depend version $(SUBDIRS) $(OBJS_BOOTSTRAP) $(LIBS_BOOTSTRAP) $(LIBS_SHARED) $(LDSCRIPT_BOOTSTRAP)
        UNDEF_SYM=`$(OBJDUMP) -x $(LIBS_BOOTSTRAP) |sed  -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
                $(LD) $(LDFLAGS_BOOTSTRAP) $$UNDEF_SYM $(OBJS_BOOTSTRAP) \
-               --start-group $(LIBS_BOOTSTRAP) --end-group $(PLATFORM_LIBS) \
+               --start-group $(LIBS_BOOTSTRAP) $(LIBS_SHARED) --end-group $(PLATFORM_LIBS) \
                -Map bootstrap.map -o bootstrap
 
 $(LIBS_BOOTSTRAP):
index 2d4ab04d2065194c42eec1a9548585a4768fa7a8..205db4855f3888aa4eff4b5f53c19fe6a7cb79d6 100644 (file)
@@ -441,7 +441,7 @@ NXTARG:             ;
        }
 
        /* We're a bit of paranoid */
-#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__)
+#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__) && !defined(__APPLE__)
        (void) fdatasync (ifd);
 #else
        (void) fsync (ifd);
@@ -491,7 +491,7 @@ NXTARG:             ;
        (void) munmap((void *)ptr, sbuf.st_size);
 
        /* We're a bit of paranoid */
-#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__)
+#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__) && !defined(__APPLE__)
        (void) fdatasync (ifd);
 #else
        (void) fsync (ifd);