From: David Thornley Date: Tue, 31 May 2016 07:20:44 +0000 (+1000) Subject: Cleaned up build process, added lzma bin for x86_64 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b635051eb1c13a8c87463ecda38568792e0d299a;p=oweals%2Fu-boot_mod.git Cleaned up build process, added lzma bin for x86_64 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). --- diff --git a/Makefile b/Makefile index 17b2b6c..aa0f2c9 100644 --- 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 diff --git a/README.md b/README.md index 6dc6d9e..e75b156 100644 --- 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 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 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 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 index ac81e12..0000000 Binary files a/host_util/lzma and /dev/null differ diff --git a/u-boot/Makefile b/u-boot/Makefile index 1855aae..6238357 100644 --- a/u-boot/Makefile +++ b/u-boot/Makefile @@ -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): diff --git a/u-boot/tools/mkimage.c b/u-boot/tools/mkimage.c index 2d4ab04..205db48 100644 --- a/u-boot/tools/mkimage.c +++ b/u-boot/tools/mkimage.c @@ -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);