[OpenWrt-Devel] [PATCH 1/3] When building on darwin, add paths for Homebrew.

Lawrence D'Anna larry at elder-gods.org
Tue Jul 21 04:40:50 EDT 2015


Various host-side tools and libraries that we need are not provided by Mac OS
such as:

     * openssl
     * gnugetopt

Homebrew seems to be the standard way to install these things, so on when
building on Darwin we need to add some paths to Homebrew-installed things to
PATH, HOST_CPPFLAGS, and HOST_LDFLAGS.
---
 include/prereq-build.mk | 7 ++++++-
 rules.mk                | 8 +++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/include/prereq-build.mk b/include/prereq-build.mk
index 211201a..53eac37 100644
--- a/include/prereq-build.mk
+++ b/include/prereq-build.mk
@@ -107,11 +107,16 @@ $(eval $(call SetupHostCommand,grep,Please install GNU 'grep', \
 	ggrep --version 2>&1 | grep GNU, \
 	grep --version 2>&1 | grep GNU))
 
+ifeq ($(HOST_OS),Darwin)
+    HOMEBREW_GETOPT:= /usr/local/opt/gnu-getopt/bin/getopt -o t --long test -- --test | grep '^ *--test *--'
+endif
+
 $(eval $(call SetupHostCommand,getopt, \
 	Please install an extended getopt version that supports --long, \
 	gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
 	/usr/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \
-	getopt -o t --long test -- --test | grep '^ *--test *--'))
+	getopt -o t --long test -- --test | grep '^ *--test *--', \
+	$(HOMEBREW_GETOPT)))
 
 $(eval $(call SetupHostCommand,stat,Cannot find a file stat utility, \
 	gnustat -c%s $(TMP_DIR)/.host.mk, \
diff --git a/rules.mk b/rules.mk
index 58b9f3e..b72fb86 100644
--- a/rules.mk
+++ b/rules.mk
@@ -198,8 +198,14 @@ export PKG_CONFIG
 HOSTCC:=gcc
 HOSTCXX:=g++
 HOST_CPPFLAGS:=-I$(STAGING_DIR_HOST)/include -I$(STAGING_DIR_HOST)/usr/include
-HOST_CFLAGS:=-O2 $(HOST_CPPFLAGS)
 HOST_LDFLAGS:=-L$(STAGING_DIR_HOST)/lib -L$(STAGING_DIR_HOST)/usr/lib
+ifeq ($(shell uname),Darwin)
+    # add Homebrew to our flags
+    HOST_CPPFLAGS+= -I/usr/local/include -I/usr/local/opt/openssl/include
+    HOST_LDFLAGS+= -L/usr/local/lib -L/usr/local/opt/openssl/lib
+endif
+HOST_CFLAGS:=-O2 $(HOST_CPPFLAGS)
+
 
 ifeq ($(CONFIG_GCC_VERSION_4_4)$(CONFIG_GCC_VERSION_4_6)$(CONFIG_EXTERNAL_TOOLCHAIN),)
   TARGET_AR:=$(TARGET_CROSS)gcc-ar
-- 
2.3.8 (Apple Git-58)
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list