From 58020885559287e92e37278196d4db13f7868bd7 Mon Sep 17 00:00:00 2001
From: Anthony Mallet <anthony.mallet@laas.fr>
Date: Tue, 31 Jan 2012 14:29:56 +0100
Subject: [PATCH] [wip/geometric-tools] Fix many build issues

- Use proper build variables instead of re-defining a custom build rule
- Compute necessary CFLAGS/LDFLAGS for dependencies
- Disable for Darwin (no real testing infrastructure)
- Use INSTALLATION_DIRS instead of manual mkdir
- Handle DESTDIR in custom install rule
- Pass CC, CFLAGS, LDFLAGS to the package makefiles
- Fix hardcoded make program
- Add missing dependencies: X11, mesa, glu
- patch-aa: use gettimeofday() for all archs. ftime() is obsolete/not standard.

Bump PKGREVISION
---
 geometric-tools/Makefile         | 75 ++++++++++++++++++++++++--------
 geometric-tools/distinfo         |  1 +
 geometric-tools/patches/patch-aa | 22 ++++++++++
 3 files changed, 80 insertions(+), 18 deletions(-)
 create mode 100644 geometric-tools/patches/patch-aa

diff --git a/geometric-tools/Makefile b/geometric-tools/Makefile
index 8af0dfb0..b6d6cf21 100644
--- a/geometric-tools/Makefile
+++ b/geometric-tools/Makefile
@@ -2,38 +2,77 @@
 # Created:			Antonio El Khoury on Mon, 16 Jan 2012
 #
 
-WM5_NAME=		WildMagic
-WM5_VERSION_MAJOR=	5
-WM5_VERSION_MINOR=	7
-
+PKGREVISION=	1
 PKGNAME=	geometric-tools-${WM5_VERSION_MAJOR}p${WM5_VERSION_MINOR}
 DISTNAME=	${WM5_NAME}${WM5_VERSION_MAJOR}p${WM5_VERSION_MINOR}
 MASTER_SITES=	${HOMEPAGE}/Downloads/
 EXTRACT_SUFX=	.zip
 
-CATEGORIES=		math
-
+CATEGORIES=	math
 MAINTAINER=	hpp@laas.fr
 HOMEPAGE=	http://www.geometrictools.com
-COMMENT=	Geometric tools for mathematics, physics, numerical methods, and image analysis.
+COMMENT=	Geometric tools for mathematics, physics, graphics, imagics
 LICENSE=	bsl
 
-WRKSRC=			${WRKDIR}/GeometricTools/${WM5_NAME}${WM5_VERSION_MAJOR}
-USE_LANGUAGES+=		c c++
-NO_CONFIGURE=		yes
+NOT_FOR_PLATFORM+=	Darwin-%
+
+WM5_NAME=		WildMagic
+WM5_VERSION_MAJOR=	5
+WM5_VERSION_MINOR=	7
+
+WRKSRC=		${WRKDIR}/GeometricTools/${WM5_NAME}${WM5_VERSION_MAJOR}
+USE_LANGUAGES+=	c c++
+NO_CONFIGURE=	yes
+
+INSTALLATION_DIRS+=\
+		include/geometric-tools	\
+		lib
+
+CFLAGS+=	-DWM5_USE_OPENGL
+CFLAGS+=	-D__LINUX__ # not true, but means 'unix'
+
+# Compile flags for dependencies
+INCLUDE_DIRS.glu+=	include
+INCLUDE_DIRS.libX11+=	include
+INCLUDE_DIRS.mesa+=	include
+
+LIBRARY_DIRS.glu+=	lib
+LIBRARY_DIRS.libX11+=	lib
+LIBRARY_DIRS.mesa+=	lib
+
+RPATH_DIRS.glu+=	lib
+RPATH_DIRS.libX11+=	lib
+RPATH_DIRS.mesa+=	lib
+
+
+# Fix horrid Makefile...
 CFG=			ReleaseDynamic
+LIBPATH=		-L../../SDK/Library/$(CFG) ${LDFLAGS}
+MAKE_FLAGS+=		CFG=${CFG}
+MAKE_FLAGS+=		GRF=Glx
+MAKE_FLAGS+=		CC=$(call quote,${ROBOTPKG_CXX})
+MAKE_FLAGS+=		CFLAGS=$(call quote,${CFLAGS} -fPIC -c)
+MAKE_FLAGS+=		ARFLAGS=$(call quote,${LDFLAGS} -shared -fPIC -o)
+MAKE_FLAGS+=		LIBPATH=$(call quote,${LIBPATH})
+MAKE_FILE+=		${WRKSRC}/makefile.wm5
+BUILD_TARGET=		build
+
+SUBST_CLASSES+=		make
+SUBST_STAGE.make=	post-extract
+SUBST_MESSAGE.make=	Fixing hardcoded make program.
+SUBST_FILES.make=	makefile.wm5 */makefile.wm5
+SUBST_SED.make=		-e 's/ make / $${MAKE} /g'
 
 include ../../pkgtools/pax/depend.mk
 include ../../pkgtools/install-sh/depend.mk
 include ../../pkgtools/pkg-config/depend.mk
+include ../../mk/sysdep/glu.mk
+include ../../mk/sysdep/libX11.mk
+include ../../mk/sysdep/mesa.mk
 include ../../mk/robotpkg.mk
 
-do-build:
-	cd ${WRKSRC} && ${MAKE} CFG=${CFG} -f makefile.wm5
-
 do-install:
-	${MKDIR} ${PREFIX}/include/geometric-tools/
-	${MKDIR} ${PREFIX}/lib/
-	${CP} -R ${WRKSRC}/SDK/Include/*.h ${PREFIX}/include/geometric-tools/
-	${CP} -R ${WRKSRC}/SDK/Include/*.inl ${PREFIX}/include/geometric-tools/
-	${CP} -R ${WRKSRC}/SDK/Library/${CFG}/* ${PREFIX}/lib/
+	${RUN} \
+	${CP} ${WRKSRC}/SDK/Include/*.h ${WRKSRC}/SDK/Include/*.inl	\
+		${DESTDIR}${PREFIX}/include/geometric-tools/;		\
+	${CP} ${WRKSRC}/SDK/Library/${CFG}/*.so ${DESTDIR}${PREFIX}/lib/
diff --git a/geometric-tools/distinfo b/geometric-tools/distinfo
index 980d3bbc..c3d84ec6 100644
--- a/geometric-tools/distinfo
+++ b/geometric-tools/distinfo
@@ -1,3 +1,4 @@
 SHA1 (WildMagic5p7.zip) = b818f233742485349013dd6f36c06acd3a26d348
 RMD160 (WildMagic5p7.zip) = d8dac358babea94ac3a748f21ae8978b622f7ddb
 Size (WildMagic5p7.zip) = 37012533 bytes
+SHA1 (patch-aa) = 69abd1c14cacf1527765399116a96550a2e04635
diff --git a/geometric-tools/patches/patch-aa b/geometric-tools/patches/patch-aa
new file mode 100644
index 00000000..0d4d484f
--- /dev/null
+++ b/geometric-tools/patches/patch-aa
@@ -0,0 +1,22 @@
+Use gettimeofday() on all platforms instead of obsolete ftime()
+
+--- LibCore/Time/Wm5Time.cpp~	2011-07-30 06:55:20.000000000 +0200
++++ LibCore/Time/Wm5Time.cpp	2012-01-31 14:15:25.791505978 +0100
+@@ -12,7 +12,7 @@
+ namespace Wm5
+ {
+ 
+-#ifdef __APPLE__
++#if 1
+ #include <sys/time.h>
+ static timeval gsInitial;
+ static bool gsInitializedTime = false;
+@@ -26,7 +26,7 @@
+ //----------------------------------------------------------------------------
+ int64_t GetTimeInMicroseconds ()
+ {
+-#ifdef __APPLE__
++#if 1
+     if (!gsInitializedTime)
+     {
+         gsInitializedTime = true;
-- 
GitLab