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
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
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
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
-SHELL = bash
+SHELL = bash
VERSION = 1
PATCHLEVEL = 1
SUBLEVEL = 4
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=
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
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
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 $@`
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 > $@
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):