From ce2719a49bb49c109b8961c39fc6551c14e2109d Mon Sep 17 00:00:00 2001
From: Raphael Kubo da Costa <rakuco@FreeBSD.org>
Date: Sat, 21 Nov 2015 17:18:10 +0000
Subject: Simplify Makefile and use the right flags when building.

Remove the custom do-configure and do-build target. The targets existed
because upstream's build instructions mention external.pro and
meshlab_full.pro need to be processed and built separately and Uses/qmake.mk
does not handle the multi-.pro case. do-build, however, was simply calling
${MAKE} and discarding both ${MAKE_ENV} and ${MAKE_ARGS} which, among other
things, resulted in no parallel builds and additional compiler flags like
-std=c++11 being omitted.

Instead, patch meshlab_full.pro and add external/external.pro as one of the
directory dependencies there along with the rest of the MeshLab code. Given
the way the QMake files are written in the port, this only helps a bit with
parallelism: each subdirectory is processed serially, but all files in them
can be built in parallel. Since a lot of the code is in plugin directories
with 1 or 2 files, the port still takes some time to build. The upside is
that it means external/ will always be built before the rest, which is what
we need.

As mentioned, the compiler flags in the build will change. However, I'm not
bumping PORTREVISION yet because it will come with the next commit updating
math/mpir.
---
 cad/meshlab/Makefile                                    | 12 +++---------
 cad/meshlab/files/patch-meshlab__full.pro               | 13 +++++++++++++
 ...atch-meshlabplugins-filter_photosynth-downloader.cpp | 17 +++++++++++++++++
 3 files changed, 33 insertions(+), 9 deletions(-)
 create mode 100644 cad/meshlab/files/patch-meshlab__full.pro
 create mode 100644 cad/meshlab/files/patch-meshlabplugins-filter_photosynth-downloader.cpp

(limited to 'cad')

diff --git a/cad/meshlab/Makefile b/cad/meshlab/Makefile
index 01019113f230..6fb3dfbcfbe2 100644
--- a/cad/meshlab/Makefile
+++ b/cad/meshlab/Makefile
@@ -26,9 +26,11 @@ USE_LDCONFIG=	yes
 DOS2UNIX_FILES=	external/structuresynth/ssynth/SyntopiaCore/GLEngine/Object3D.h \
 		external/structuresynth/ssynth/SyntopiaCore/GLEngine/Raytracer/VoxelStepper.cpp \
 		meshlabplugins/edit_arc3D/fillImage.cpp \
-		meshlabplugins/filter_csg/intercept.h
+		meshlabplugins/filter_csg/intercept.h \
+		meshlabplugins/filter_photosynth/downloader.cpp
 
 EXTRACT_CMD=	gtar
+QMAKE_SOURCE_PATH=	${WRKSRC}/meshlab_full.pro
 WRKSRC=		${WRKDIR}/${PORTNAME}/src
 
 pre-configure:
@@ -44,14 +46,6 @@ pre-configure:
 	    ${REINPLACE_CMD} -e '/^CONFIG +=/s|$$| debug|'
 .endif
 
-do-configure:
-	cd ${WRKSRC}/external && ${QMAKE} ${QMAKE_ARGS} -recursive external.pro
-	cd ${WRKSRC} && ${QMAKE} -spec ${QMAKESPEC} -recursive meshlab_full.pro
-
-do-build:
-	cd ${WRKSRC}/external && ${MAKE}
-	cd ${WRKSRC} && ${MAKE}
-
 do-install:
 	${MKDIR} ${STAGEDIR}${PREFIX}/lib/meshlab/plugins
 	cd ${WRKSRC}/distrib/plugins && ${INSTALL_LIB} *.so ${STAGEDIR}${PREFIX}/lib/meshlab/plugins
diff --git a/cad/meshlab/files/patch-meshlab__full.pro b/cad/meshlab/files/patch-meshlab__full.pro
new file mode 100644
index 000000000000..f58150ba34fb
--- /dev/null
+++ b/cad/meshlab/files/patch-meshlab__full.pro
@@ -0,0 +1,13 @@
+Make external libraries part of the default build. They are currently built
+before the rest, as qmake will recurse into each subdirectory in order.
+--- meshlab_full.pro.bak	2015-11-21 16:25:23.812658000 +0100
++++ meshlab_full.pro	2015-11-21 16:25:32.892417000 +0100
+@@ -1,7 +1,7 @@
+ #config += debug_and_release
+ TEMPLATE      = subdirs
+ CONFIG += ordered
+-SUBDIRS       = common \
++SUBDIRS       = external common \
+                 meshlab \
+                 meshlabserver \
+ # IO plugins
diff --git a/cad/meshlab/files/patch-meshlabplugins-filter_photosynth-downloader.cpp b/cad/meshlab/files/patch-meshlabplugins-filter_photosynth-downloader.cpp
new file mode 100644
index 000000000000..e57927cf60c4
--- /dev/null
+++ b/cad/meshlab/files/patch-meshlabplugins-filter_photosynth-downloader.cpp
@@ -0,0 +1,17 @@
+Prevents the following build error:
+
+downloader.cpp:686:23: error: non-constant-expression cannot be narrowed from type 'unsigned char' to 'char' in initializer list [-Wc++11-narrowing]
+  char reversed[] = { bytes[3],bytes[2],bytes[1],bytes[0] };
+                      ^~~~~~~~
+downloader.cpp:686:23: note: insert an explicit cast to silence this issue
+--- meshlabplugins/filter_photosynth/downloader.cpp.orig	2013-05-22 15:09:13 UTC
++++ meshlabplugins/filter_photosynth/downloader.cpp
+@@ -683,7 +683,7 @@
+     if(error)
+       return -1;
+   }
+-  char reversed[] = { bytes[3],bytes[2],bytes[1],bytes[0] };
++  unsigned char reversed[] = { bytes[3],bytes[2],bytes[1],bytes[0] };
+ 
+   float *f = (float *)(&  reversed[0]);
+   return*f;
-- 
cgit v1.2.3