From nobody@FreeBSD.org  Tue Jan  7 18:18:04 2014
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id BF8EB111
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  7 Jan 2014 18:18:04 +0000 (UTC)
Received: from oldred.freebsd.org (oldred.freebsd.org [IPv6:2001:1900:2254:206a::50:4])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 9EDC010DF
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  7 Jan 2014 18:18:04 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id s07II4nC088316
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 7 Jan 2014 18:18:04 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id s07II4Ne088291;
	Tue, 7 Jan 2014 18:18:04 GMT
	(envelope-from nobody)
Message-Id: <201401071818.s07II4Ne088291@oldred.freebsd.org>
Date: Tue, 7 Jan 2014 18:18:04 GMT
From: Rainer Hurling <rhurlin@gwdg.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [maintainer update] math/saga: unbreak build on 10.0 and higher
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         185559
>Category:       ports
>Synopsis:       [maintainer update] math/saga: unbreak build on 10.0 and higher
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    sunpoet
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 07 18:20:00 UTC 2014
>Closed-Date:    Sun Mar 23 17:34:16 UTC 2014
>Last-Modified:  Sun Mar 23 17:34:16 UTC 2014
>Originator:     Rainer Hurling
>Release:        11.0-CURRENT amd64 (clang)
>Organization:
>Environment:
FreeBSD xxx.xxx.xxx 11.0-CURRENT FreeBSD 11.0-CURRENT #1 r260318: Sun Jan  5 16:39:32 CET 2014     xxx@xxx.xxx.xxx:/usr/obj/usr/src/sys/XXX  amd64
>Description:
Errors with math/saga have been reported from cluster builds for several weeks now, for example
http://beefy2.isc.freebsd.org/bulk/10-release-amd64-RELENG10_0/latest/logs/errors/saga-2.1.0_3.log

While SAGA GIS does build on 8.x and 9.x, it fails on 10.0 and above.

The main problems seem to be related to the new linker behaviour and libstdc++/libc++ changes, both in 10.0 and HEAD.

Because of the upcoming 10.0 release, I decided to submit a (somewhat ugly) workaround. With the appended patch, SAGA GIS should be able to build on all OS versions again (proofed with 9.2 and 11.0-CURRENT).

With OS versions 10.0 and HEAD I tried to use combinations of gcc46+ and CXXFLAGS+=-std=gnu++0x, as suggested by the cluster report. This overcomes the errors reported by the cluster, but fails with new errors, related to wxgtk. I was not able to find a solution, so I decided to waive the OpenMP option for 10.0 and above :(

-------
With clang build on 10.0 and higher, one big problem remains: the SAGA GIS module 'libio_gdal.so' (at /usr/local/lib/saga/) is corrupted and because of this, the usage of 'saga_cmd' core dumps. You can easily try this by running 'saga_cmd' in a terminal.

I would be very happy, if someone could have a deeper look into this GDAL related problem. Perhaps something is wrong in graphics/gdal itself?
-------

While here, I did
- support STAGEDIR
- correct usage of <bsd.port.options.mk>,
  thanks to John Marino, http://www.freebsd.org/cgi/query-pr.cgi?pr=185166
- USES=dos2unix
- different builds, depending on OSVERSION (gcc/clang)
- OpenMP only on FreeBSD 8.x and 9.x (before 10.0)


If this PR will be committed, it would be nice to close PR 185166, see above.


It would be nice also, if someone could have a look at PR 181329 with latest contribution from December 2013, thanks. There is a patch for an update of x11-toolkits/wxgtk29 to x11-toolkits/wxgtk30, which is the better choice for SAGA GIS. http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/181329

>How-To-Repeat:

>Fix:


Patch attached with submission follows:

diff -u saga.orig/Makefile saga/Makefile
--- saga.orig/Makefile	2014-01-04 08:35:30.000000000 +0100
+++ saga/Makefile	2014-01-07 16:56:15.000000000 +0100
@@ -3,7 +3,7 @@
 
 PORTNAME=	saga
 PORTVERSION=	2.1.0
-PORTREVISION=	3
+PORTREVISION=	4
 CATEGORIES=	math
 MASTER_SITES=	SF/saga-gis/SAGA%20-%20${PORTVERSION:C/\.[[:digit:]]*$//}/SAGA%20${PORTVERSION}
 DISTNAME=	${PORTNAME}_${PORTVERSION}_src
@@ -21,34 +21,38 @@
 		liblas.so:${PORTSDIR}/devel/liblas \
 		libopencv_core.so:${PORTSDIR}/graphics/opencv-core
 
+USES=		dos2unix
+DOS2UNIX_GLOB=	dlg_about.cpp
 USE_ZIP=	yes
-USE_WX=		2.9
+USE_WX=		2.9-3.0
 WX_UNICODE=	yes
 USE_LDCONFIG=	yes
 GNU_CONFIGURE=	yes
 USE_AUTOTOOLS=	autoconf autoheader automake aclocal libtoolize
 AUTOMAKE_ARGS=	--add-missing
 
-# CLANG is not able to handle neither Fortran nor OpenMP
-USE_GCC=	any
-CFLAGS+=	-I${LOCALBASE}/include
-USE_DOS2UNIX=	dlg_about.cpp
-
-MAN1=		saga_cmd.1 saga_gui.1
-
 DESKTOP_ENTRIES=	"SAGA GIS" "${COMMENT}" "${DATADIR}/saga.png" \
 			"saga_gui" "Science;Geoscience;Math;" true
 
 OPTIONS_DEFINE=	PYTHON OPENMP HARU VIGRA
 OPTIONS_DEFAULT=	OPENMP HARU VIGRA
 NO_OPTIONS_SORT=	yes
-OPENMP_DESC=	Enable Multiprocessing
+OPENMP_DESC=	Enable Multiprocessing (FreeBSD before 10.0 ONLY)
 HARU_DESC=	Enable Haru Free PDF Library
 VIGRA_DESC=	Enable 'Vision with Generic Algorithms' Library
 
-NO_STAGE=	yes
 .include <bsd.port.options.mk>
 
+# CLANG is not able to handle neither Fortran nor OpenMP
+.if ${OSVERSION} < 1000054
+USE_GCC=	any
+#USES+=		compiler:openmp
+#CXXFLAGS+=     -std=gnu++0x
+.else
+USES+=		compiler:c++11-lib
+.endif
+CFLAGS+=	-I${LOCALBASE}/include
+
 LDFLAGS+=	-L${LOCALBASE}/lib -lopencv_core
 CONFIGURE_ARGS+=	CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}"
 
@@ -57,14 +61,14 @@
 BUILD_DEPENDS+=	swig2.0:${PORTSDIR}/devel/swig20
 RUN_DEPENDS+=	swig2.0:${PORTSDIR}/devel/swig20
 CONFIGURE_ENV+=	SWIG="${LOCALBASE}/bin/swig2.0"
-USE_PYTHON=	2.6-2.7
+USE_PYTHON=	2.7
 PLIST_SUB+=	SAGA_PYTHON=""
 .else
 CONFIGURE_ARGS+=	--disable-python
 PLIST_SUB+=	SAGA_PYTHON="@comment "
 .endif
 
-.if ${PORT_OPTIONS:MOPENMP}
+.if ${PORT_OPTIONS:MOPENMP} && (${OSVERSION} < 1000054)
 LDFLAGS+=		${PTHREAD_LIBS}
 CONFIGURE_ARGS+=	--enable-openmp
 .else
@@ -88,8 +92,6 @@
 PLIST_SUB+=	VIGRA="@comment "
 .endif
 
-.include <bsd.port.pre.mk>
-
 post-extract:
 	@${REINPLACE_CMD} -e's|wx-config |${WX_CONFIG} |g' \
 		${WRKSRC}/configure.in \
@@ -119,12 +121,12 @@
 .endif
 
 post-install:
-	@${MKDIR} ${DATADIR}
-	${INSTALL_DATA} ${WRKSRC}/src/saga_core/saga_gui/res/saga_tip.txt ${DATADIR}
-	${INSTALL_DATA} ${WRKSRC}/src/saga_core/saga_gui/res/saga.png ${DATADIR}
+	@${MKDIR} ${STAGEDIR}${DATADIR}
+	${INSTALL_DATA} ${WRKSRC}/src/saga_core/saga_gui/res/saga_tip.txt ${STAGEDIR}${DATADIR}
+	${INSTALL_DATA} ${WRKSRC}/src/saga_core/saga_gui/res/saga.png ${STAGEDIR}${DATADIR}
 # library helper files are not needed and cripple some math/qgis extensions
-	@${RM} ${PREFIX}/lib/saga/*.la
-	@${RM} ${PREFIX}/lib/saga/*.a
+	@${RM} ${STAGEDIR}${PREFIX}/lib/saga/*.la
+	@${RM} ${STAGEDIR}${PREFIX}/lib/saga/*.a
 	@${CAT} ${PKGMESSAGE}
 
-.include <bsd.port.post.mk>
+.include <bsd.port.mk>
Common subdirectories: saga.orig/files and saga/files
diff -u saga.orig/pkg-plist saga/pkg-plist
--- saga.orig/pkg-plist	2013-01-17 11:53:41.000000000 +0100
+++ saga/pkg-plist	2014-01-05 18:15:15.000000000 +0100
@@ -82,6 +82,8 @@
 lib/saga/libtin_tools.so
 lib/saga/libtin_viewer.so
 lib/saga/libtransect.so
+man/man1/saga_cmd.1.gz
+man/man1/saga_gui.1.gz
 %%VIGRA%%lib/saga/libvigra.so
 %%DATADIR%%/saga.png
 %%DATADIR%%/saga_tip.txt


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->sunpoet 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Tue Jan 7 18:20:09 UTC 2014 
Responsible-Changed-Why:  
sunpoet@ wants this submitter's PRs (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=185559 

From: John Marino <freebsd.contact@marino.st>
To: bug-followup@FreeBSD.org, rhurlin@gwdg.de
Cc:  
Subject: Re: ports/185559: [maintainer update] math/saga: unbreak build on
 10.0 and higher
Date: Tue, 07 Jan 2014 19:43:58 +0100

 Please do not use OSVERSION without OPSYS.
 
 e.g.
 +.if ${PORT_OPTIONS:MOPENMP} && (${OSVERSION} < 1000054)
 would need to be
 +.if ${PORT_OPTIONS:MOPENMP} && (${OPSYS} == FreeBSD && ${OSVERSION} <
 1000054)
 
 However, having OpenMP on FreeBSD 9 and below only may be a bad idea
 anyway.  There was a similar discussion about "conditional" openMP use
 based on Release and it turns out there are a number of issues,
 especially with combining libraries built by gcc and libc++.
 
 The conclusion was that OpenMP should be off by default on ALL releases.
 
 Going back to OSVERSION, this is basically a dirty word and OpenMP
 capability should be detected, e.g. by headers, not by OSVERSION.
 Portmgr still needs to rule on this...
 
 John

From: Rainer Hurling <rhurlin@gwdg.de>
To: bug-followup@FreeBSD.org, rhurlin@gwdg.de
Cc:  
Subject: Re: ports/185559: [maintainer update] math/saga: unbreak build on
 10.0 and higher
Date: Tue, 07 Jan 2014 20:26:01 +0100

 I am fine with using ${OPSYS} and disabling OpenMP option as default,
 thanks for the pointer.
 
 Yes, I followed the discussions with graphics/rawtherapee and
 graphics/darktable for OpenMP usage. Both wanted to differentiate
 between compilers.
 
 I am really interested in detecting OpenMP by some 'approved rules' ...
 
 Rainer

From: John Marino <freebsd.contact@marino.st>
To: bug-followup@FreeBSD.org, rhurlin@gwdg.de
Cc:  
Subject: Re: ports/185559: [maintainer update] math/saga: unbreak build on
 10.0 and higher
Date: Wed, 08 Jan 2014 00:14:14 +0100

 Has this changeset been run through redports yet to gauge how it builds
 on all systems?
 
 If not, whoever takes the PR (perhaps myself) will have to do it.

From: Rainer Hurling <rhurlin@gwdg.de>
To: bug-followup@FreeBSD.org, rhurlin@gwdg.de
Cc:  
Subject: Re: ports/185559: [maintainer update] math/saga: unbreak build on
 10.0 and higher
Date: Wed, 08 Jan 2014 07:46:34 +0100

 No, sorry. It only has passed builds on my 11.0-CURRENT boxes and one
 9.2 tinderbox run.
 
 If I should do it, I soonest can start it in some hours.

From: Rainer Hurling <rhurlin@gwdg.de>
To: bug-followup@FreeBSD.org, rhurlin@gwdg.de
Cc:  
Subject: Re: ports/185559: [maintainer update] math/saga: unbreak build on
 10.0 and higher
Date: Wed, 08 Jan 2014 14:30:24 +0100

 Builds on RedPorts just finished successful within the following
 buildgroups:
 
 10-CURRENT/amd64 and 10-CURRENT/i386;
 9.2-RELEASE/amd64 and 9.2-RELEASE/i386;
 8.4-RELEASE/amd64 and 8.4-RELEASE/i386.
 
 I would suggest, that instead of using 'USE_GCC=any' for <10.0 it should
 be changed into 'USES+=compiler:openmp'. I am testing it now on RedPorts
 with 8.4 and 9.2.

From: John Marino <freebsd.contact@marino.st>
To: bug-followup@FreeBSD.org, rhurlin@gwdg.de
Cc:  
Subject: Re: ports/185559: [maintainer update] math/saga: unbreak build on
 10.0 and higher
Date: Wed, 08 Jan 2014 21:11:40 +0100

 I just noticed sunpoet already has this PR.  He'll take care of you.
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Sun Mar 23 17:33:58 UTC 2014 
State-Changed-Why:  
Superseded by ports/187795. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=185559 
>Unformatted:
