Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Jul 2015 17:18:12 +1030
From:      Michael Vale <m.vale@live.com.au>
To:        "freebsd-embedded@freebsd.org" <freebsd-embedded@freebsd.org>, "freebsd-mips@freebsd.org" <freebsd-mips@freebsd.org>, "freebsd-arm@freebsd.org" <freebsd-arm@freebsd.org>
Subject:   REVISION: Cross Ports patch
Message-ID:  <COL130-W3FB64ED85D3D0AA1D87BDC49E0@phx.gbl>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
This fixes the problem that wasn't producing target binaries.
You may notice when some GNU configure scripts are running that this appears to hang, but it doesn't it just takes time:
[     checking for BSD- or MS-compatible name lister (nm)...    ]
You may notice this taking it's sweet time and also failing (but the build still works):
[     checking command to parse /usr/local/bin/mips-portbld-freebsd11.0-nm output from mips-portbld-freebsd11.0-gcc object...    ]
So, with that said, many ports appear to work.
The only bug left is when it fails to "install" files into the stage after building, you must run "bmake" manually (from the ports directory - not this when dealing with dependencies), then follow it up with "SRCDIR=/path/to/src bmake X_BUILD_FOR=arch install" 		 	   		  
[-- Attachment #2 --]
--- bsd.port.mk	2015-07-11 03:25:50.184416000 +1000
+++ bsd.port.mk.done	2015-07-11 09:48:26.303591000 +1000
@@ -1,7 +1,7 @@
 #-*- tab-width: 4; -*-
 # ex:ts=4
 #
-# $FreeBSD$
+# $FreeBSD: head/Mk/bsd.port.mk 391295 2015-07-04 08:56:54Z bapt $
 #	$NetBSD: $
 #
 #	bsd.port.mk - 940820 Jordan K. Hubbard.
@@ -1078,25 +1078,26 @@
 .if !defined(.PARSEDIR)
 IGNORE=	Cross building can only be done when using bmake(1) as make(1)
 .endif
+.if !defined(ARCH)
+ARCH=		${X_BUILD_FOR}
+.endif
 # Do not define CPP on purpose
 .if !defined(HOSTCC)
 HOSTCC:=	${CC}
 HOSTCXX:=	${CXX}
 .endif
-.if !exists(/usr/${X_BUILD_FOR}/usr/bin/cc)
-X_SYSROOT=	${LOCALBASE}/${X_BUILD_FOR}
-.else
-X_SYSROOT=	/usr/${X_BUILD_FOR}
-.endif
-CC=		${X_SYSROOT}/usr/bin/cc
-CXX=	${X_SYSROOT}/usr/bin/c++
-NM=		${X_BUILD_FOR}-nm
-STRIP_CMD=	${X_BUILD_FOR}-strip
+
+SYSROOT=	${SRCDIR}/../root/${ARCH}/
+
+NM=		${ARCH}-freebsd-nm
+STRIP_CMD=	${ARCH}-freebsd-strip
 # only bmake support the below
 STRIPBIN=	${STRIP_CMD}
 .export.env STRIPBIN
+
 .endif
 
+
 #
 # DESTDIR section to start a chrooted process if invoked with DESTDIR set
 #
@@ -1541,12 +1542,42 @@
 				PORTSDIR="${PORTSDIR}"
 
 .if defined(X_BUILD_FOR)
-BUILD_DEPENDS+=	${X_BUILD_FOR}-cc:${PORTSDIR}/devel/${X_BUILD_FOR}-xdev
-PKG_ENV+=		ABI_FILE=${X_SYSROOT}/usr/lib/crt1.o
-MAKE_ENV+=		NM=${NM} \
-				STRIPBIN=${X_BUILD_FOR}-strip \
-				PKG_CONFIG_SYSROOT_DIR="${X_SYSROOT}"
-CONFIGURE_ENV+=	PKG_CONFIG_SYSROOT_DIR="${X_SYSROOT}"
+.if ${CC} == gcc
+CC=			${CONFIGURE_TARGET}-gcc
+CXX=			${ARCH}-portbld-${OPSYS:tl}${OSREL}-g++
+BUILD_DEPENDS+=		${CONFIGURE_TARGET}-gcc:${PORTSDIR}/devel/${ARCH}-gcc
+        		@if [ ! -h /usr/local/bin/mips-portbld-freebsd11.0-ar  ]; then \
+			   ln -sf /usr/local/bin/mips-freebsd-ar /usr/local/bin/mips-portbld-freebsd11.0-ar ; \
+			fi ;
+			if [ ! -h /usr/local/bin/mips-portbld-freebsd11.0-nm  ]; then \
+			   ln -sf /usr/local/bin/mips-freebsd-nm /usr/local/bin/mips-portbld-freebsd11.0-nm ; \
+			fi ;
+			if [ ! -h /usr/local/bin/mips-portbld-freebsd11.0-ranlib  ]; then \
+			   ln -sf /usr/local/bin/mips-freebsd-ranlib /usr/local/bin/mips-portbld-freebsd11.0-ranlib ; \
+			fi ;
+			if [ ! -h /usr/local/bin/mips-portbld-freebsd11.0-strip  ]; then \
+			   ln -sf /usr/local/bin/mips-freebsd-strip /usr/local/bin/mips-portbld-freebsd11.0-strip ; \
+			fi
+
+.endif
+.if ${CC} == cc || ${CC} == clang
+CFLAGS+=		--target=${CONFIGURE_TARGET}
+.endif
+
+PKG_ENV+=		ABI_FILE=${SYSROOT}/usr/lib/crt1.o
+NM=			${NM}
+LD=			${CONFIGURE_TARGET}-gcc-ld
+AR=			${CONFIGURE_TARGET}-gcc-ar
+RANLIB=			${CONFIGURE_TARGET}-gcc-ranlib
+INCS=			-I${SRCDIR}/../root/${ARCH}/usr/include
+CROSS_COMPILE=		${ARCH}-portbld-freebsd${OS_REL}
+SYSROOT=		${SRCDIR}/../root/${ARCH}
+CFLAGS+=		--sysroot=${SYSROOT} ${CPU_ARGS} ${INCS} -O
+CXXFLAGS+=		--sysroot=${SYSROOT} ${CPU_ARGS} ${INCS} -O
+LDFLAGS+=		--sysroot=${SYSROOT}
+STRIPBIN=		${STRIP}
+PKG_CONFIG_SYSROOT_DIR=	"${SYSROOT}"
+CONFIGURE_ENV+=		PKG_CONFIG_SYSROOT_DIR="${SYSROOT}"
 .endif
 
 WRKDIR?=		${WRKDIRPREFIX}${.CURDIR}/work
@@ -2621,8 +2652,16 @@
 
 CONFIGURE_SCRIPT?=	configure
 CONFIGURE_CMD?=		./${CONFIGURE_SCRIPT}
-CONFIGURE_TARGET?=	${ARCH}-portbld-${OPSYS:tl}${OSREL}
-CONFIGURE_TARGET:=	${CONFIGURE_TARGET:S/--build=//}
+BUILD_ARCH!=		${UNAME} -p
+CONFIGURE_BUILD?=	${BUILD_ARCH}-portbld-${OPSYS:tl}${OSREL}
+CONFIGURE_BUILD:=	${CONFIGURE_BUILD:S/--build=//}
+HOST_ARCH!=		${UNAME} -m
+CONFIGURE_HOST?=	${HOST_ARCH}-portbld-${OPSYS:tl}${OSREL}
+CONFIGURE_HOST:=	${CONFIGURE_HOST:S/--host=//}
+.if defined(X_BUILD_FOR)
+CONFIGURE_TARGET?=		${ARCH}-portbld-${OPSYS:tl}${OSREL}
+CONFIGURE_TARGET:=		${CONFIGURE_TARGET:S/--target=//}
+.endif
 CONFIGURE_LOG?=		config.log
 
 # A default message to print if do-configure fails.
@@ -2637,9 +2676,6 @@
 GNU_CONFIGURE_MANPREFIX?=	${MANPREFIX}
 CONFIG_SITE?=		${PORTSDIR}/Templates/config.site
 CONFIGURE_ARGS+=	--prefix=${GNU_CONFIGURE_PREFIX} $${_LATE_CONFIGURE_ARGS}
-.if defined(X_BUILD_FOR)
-CONFIGURE_ARGS+=	--host=${X_BUILD_FOR}
-.endif
 CONFIGURE_ENV+=		CONFIG_SITE=${CONFIG_SITE} lt_cv_sys_max_cmd_len=${CONFIGURE_MAX_CMD_LEN}
 HAS_CONFIGURE=		yes
 
@@ -2656,7 +2692,7 @@
 	    _LATE_CONFIGURE_ARGS="$${_LATE_CONFIGURE_ARGS} --infodir=${GNU_CONFIGURE_PREFIX}/${INFO_PATH}/${INFO_SUBDIR}" ; \
 	fi ; \
 	if [ -z "`./${CONFIGURE_SCRIPT} --version 2>&1 | ${EGREP} -i '(autoconf.*2\.13|Unrecognized option)'`" ]; then \
-		_LATE_CONFIGURE_ARGS="$${_LATE_CONFIGURE_ARGS} --build=${CONFIGURE_TARGET}" ; \
+		_LATE_CONFIGURE_ARGS="$${_LATE_CONFIGURE_ARGS} --build=${CONFIGURE_BUILD} --host=${CONFIGURE_HOST} --target=${CONFIGURE_TARGET}" ; \
 	else \
 		_LATE_CONFIGURE_ARGS="$${_LATE_CONFIGURE_ARGS} ${CONFIGURE_TARGET}" ; \
 	fi ;

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?COL130-W3FB64ED85D3D0AA1D87BDC49E0>