Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Jul 2015 03:59:26 +1030
From:      Michael Vale <m.vale@live.com.au>
To:        "sbruno@freebsd.org" <sbruno@freebsd.org>, "freebsd-mips@freebsd.org" <freebsd-mips@freebsd.org>, "freebsd-embedded@freebsd.org" <freebsd-embedded@freebsd.org>, "freebsd-arm@freebsd.org" <freebsd-arm@freebsd.org>
Subject:   RE: Cross Ports - working - find attached bsd.port.mk
Message-ID:  <COL130-W48BB71B82F38A333B3E3FBC49F0@phx.gbl>
In-Reply-To: <559FF4D5.6040605@ignoranthack.me>
References:  <COL130-W6FB5D38826E76368EA830C49F0@phx.gbl>, <559FF4D5.6040605@ignoranthack.me>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
please find attached unified diff patch.

> Date: Fri, 10 Jul 2015 09:37:41 -0700
> From: sbruno@ignoranthack.me
> To: m.vale@live.com.au; freebsd-mips@freebsd.org
> Subject: Re: Cross Ports - working - find attached bsd.port.mk
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
> 
> On 07/10/15 08:31, Michael Vale wrote:
> > Okay, So, I'm submitting my work on cross ports. Here's what works
> > and what doesn't work Clang support is there but GNU configure
> > tries to append -march=mips32r2 to the command which causes the
> > compiler check to fail. GCC support is there, except when a GNU
> > configure script tries to link -lgcc_s - apparently Adrian and bapt
> > were meant to have fixed this in -head, but I updated and still had
> > the problem. So an example of the ports I've tried and worked are: 
> > sysutils/busyboxsecurity/dropbear Now when running bmake
> > X_BUILD_FOR=mips on dropbear, it fails "installing" files into the
> > stage.  But if you run bmake again without X_BUILD_FOR=mips it
> > "installs" those files into stage and one can continue along with
> > bmake install. It is assumed that one has built a world with
> > freebsd-wifi-build. An example of running a bmake is 
> > SRCDIR=/home/masked/work/src bmake X_BUILD_FOR=mips
> > 
> > 
> 
> I'm glad that you've made some progress with cross building without
> emulation.  I'd like to see what you've been able to accomplish with
> your changes.
> 
> Is there anyway you can post some kind of unified diff that we can
> view so that we can more easily (I'm lazy) see what you've been up to?
> 
> sean
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2
> 
> iQF8BAEBCgBmBQJVn/TTXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
> ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRCQUFENDYzMkU3MTIxREU4RDIwOTk3REQx
> MjAxRUZDQTFFNzI3RTY0AAoJEBIB78oecn5kUKMIAL/ob4UX18T811yyO0KA82YE
> HJVXdVN/bbx1gQ1PKJVXms5c8nylQ0RRScEvBQUmWXMEsVMFGXbeyPCuqBgEZakT
> UlRGnEOh3swzXfr6ssXI4afguKmlf/CC/lUPCDauL4efDJGqix2IjjuQhXdnl0y+
> E6xZD67NdgyRhOCl/Ynz1LRf5Ov6kYwUoxsnTE6nVACL7VXT1gxEm1pL/yl7n9cA
> psrbkwOMmANvakTfaVeO2em22YB/YkwYHFjorzxgPWPm3W0gDisQTPck37y8hEqP
> Vx9W8zdNbt0FMIjip+dY4EbBQZKHW9QfeWK5YBeOQ8d0m+vNLwnz1EQCfLdfsC4=
> =lh//
> -----END PGP SIGNATURE-----
 		 	   		  
[-- Attachment #2 --]
--- bsd.port.mk	2015-07-11 03:25:50.184416000 +1000
+++ bsd.port.mk.done	2015-07-11 03:26:26.233266000 +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,44 @@
 				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
+CONFIGURE_TARGET=	${ARCH}-portbld-${OPSYS:tl}${OSREL}
+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
+CONFIGURE_TARGET=       ${ARCH}-portbld-${OPSYS:tl}${OSREL}
+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 +2654,13 @@
 
 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_TARGET_BUILD?=	${BUILD_ARCH}-portbld-${OPSYS:tl}${OSREL}
+CONFIGURE_TARGET_BUILD:=	${CONFIGURE_TARGET_BUILD:S/--build=//}
+#.if defined(X_BUILD_FOR)
+#CONFIGURE_TARGET_TARGET?=		${ARCH}-portbld-${OPSYS:tl}${OSREL}
+#CONFIGURE_TARGET_TARGET:=		${CONFIGURE_TARGET_TARGET:S/--target=//}
+#.endif
 CONFIGURE_LOG?=		config.log
 
 # A default message to print if do-configure fails.
@@ -2637,9 +2675,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 +2691,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_TARGET_BUILD} --host=${CONFIGURE_TARGET}" ; \
 	else \
 		_LATE_CONFIGURE_ARGS="$${_LATE_CONFIGURE_ARGS} ${CONFIGURE_TARGET}" ; \
 	fi ;
help

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