From fa5b7c8b7d3b10eefa2e5873ab2a7d5c630ceb7c Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 18 Jan 2008 20:41:33 +0000
Subject: [PATCH] more work for Visual C++

---
 Geo/gmshSurface.cpp     |  3 ++-
 Mesh/Field.cpp          |  6 +++++-
 Numeric/gsl_min.cpp     | 29 ++++++++++++++++++++++++++++-
 configure.in            |  3 ++-
 contrib/NR/Makefile     | 21 ++++++++++-----------
 contrib/Tetgen/Makefile | 18 +++++++++---------
 variables.in            |  3 ++-
 7 files changed, 58 insertions(+), 25 deletions(-)

diff --git a/Geo/gmshSurface.cpp b/Geo/gmshSurface.cpp
index 09abb0d92f..a0e6c71f3e 100644
--- a/Geo/gmshSurface.cpp
+++ b/Geo/gmshSurface.cpp
@@ -1,4 +1,4 @@
-// $Id: gmshSurface.cpp,v 1.8 2007-03-14 10:21:12 remacle Exp $
+// $Id: gmshSurface.cpp,v 1.9 2008-01-18 20:41:33 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -117,6 +117,7 @@ SPoint3 gmshParametricSurface ::point(double par1, double par2) const
 {
 #if !defined(HAVE_MATH_EVAL)
   Msg(GERROR, "MathEval is not compiled in this version of Gmsh");
+  return SPoint3(0.,0.,0.);
 #else
   char *names[2] = {"u","v"};
   double values [2] = {par1,par2};
diff --git a/Mesh/Field.cpp b/Mesh/Field.cpp
index ab3d73428b..77bc44676f 100644
--- a/Mesh/Field.cpp
+++ b/Mesh/Field.cpp
@@ -1,4 +1,4 @@
-// $Id: Field.cpp,v 1.9 2008-01-14 21:29:14 remacle Exp $
+// $Id: Field.cpp,v 1.10 2008-01-18 20:41:33 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -195,6 +195,7 @@ double ParametricField::operator()(double x, double y, double z)
 {
 #if !defined(HAVE_MATH_EVAL)
   Msg(GERROR, "MathEval is not compiled in this version of Gmsh");
+  return 0.;
 #else
   static char *names[3] = {"x", "y", "z"};
   double values [3] = {x, y, z};
@@ -233,6 +234,7 @@ double FunctionField::operator()(double x, double y, double z)
 {
 #if !defined(HAVE_MATH_EVAL)
   Msg(GERROR, "MathEval is not compiled in this version of Gmsh");
+  return 0.;
 #else
   values[0] = x;
   values[1] = y;
@@ -388,6 +390,7 @@ double AttractorField::operator()(double X, double Y, double Z)
     return sqrt(dist[0]);
 #else
     Msg(GERROR,"GMSH should be compiled with ANN in order to enable attractors");
+    return 0.;
 #endif
   }
 }
@@ -506,6 +509,7 @@ double AttractorField_1DMesh::operator()(double X, double Y, double Z)
   return lc;
 #else
   Msg(GERROR,"GMSH should be compiled with ANN in order to enable attractors");
+  return 1.e22;
 #endif
 }
 
diff --git a/Numeric/gsl_min.cpp b/Numeric/gsl_min.cpp
index a9671be5db..7cc2510e12 100644
--- a/Numeric/gsl_min.cpp
+++ b/Numeric/gsl_min.cpp
@@ -1,4 +1,4 @@
-// $Id: gsl_min.cpp,v 1.1 2008-01-14 21:29:53 remacle Exp $
+// $Id: gsl_min.cpp,v 1.2 2008-01-18 20:41:33 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -291,6 +291,33 @@ void minimize_N (int N,
   
 } 					    
 
+#else
 
+#include "Message.h"
+
+void minimize_2 ( double (*f) (double, double, void *data), 
+		  void (*df) (double, double, double &, double &, double &, void *data) ,
+		  void *data,int niter,
+		  double &U, double &V, double &res)
+{
+  Msg(GERROR, "Gmsh must be compiled with GSL support for minimize_2");
+}
+
+void minimize_3 ( double (*f) (double, double, double, void *data), 
+		  void (*df) (double, double, double , double &, double &, double &, double &, void *data) ,
+		  void *data,int niter,
+		  double &U, double &V, double &W, double &res)
+{
+  Msg(GERROR, "Gmsh must be compiled with GSL support for minimize_3");
+}
+
+void minimize_N (int N, 
+		 double (*f) (double*, void *data), 
+		 void (*df) (double*, double*, double &, void *data) ,
+		 void *data,int niter,
+		 double *, double &res)
+{
+  Msg(GERROR, "Gmsh must be compiled with GSL support for minimize_N");
+}
 
 #endif
diff --git a/configure.in b/configure.in
index e9d343b78b..492fa97793 100644
--- a/configure.in
+++ b/configure.in
@@ -1,4 +1,4 @@
-dnl $Id: configure.in,v 1.141 2008-01-18 20:02:27 geuzaine Exp $
+dnl $Id: configure.in,v 1.142 2008-01-18 20:41:33 geuzaine Exp $
 dnl
 dnl Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 dnl
@@ -869,6 +869,7 @@ AC_SUBST(OBJEXT)
 AC_SUBST(LIBEXT)
 AC_SUBST(ISYM)
 AC_SUBST(CSYM)
+AC_SUBST(DSYM)
 AC_SUBST(SYSINCLUDE)
 AC_OUTPUT(variables)
 
diff --git a/contrib/NR/Makefile b/contrib/NR/Makefile
index 22edd2e89c..239304dc13 100644
--- a/contrib/NR/Makefile
+++ b/contrib/NR/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.5 2008-01-18 20:02:30 geuzaine Exp $
+# $Id: Makefile,v 1.6 2008-01-18 20:41:33 geuzaine Exp $
 #
 # Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 #
@@ -21,11 +21,10 @@
 
 include ../../variables
 
-LIB     = ../../lib/libGmshNR.a
-INCLUDE = -I../../Common -I../../DataStr -I../../Numeric
+LIB     = ../../lib/libGmshNR${LIBEXT}
+INCLUDE = ${ISYM}../../Common ${ISYM}../../DataStr ${ISYM}../../Numeric
 # don't optimize this library: there are some problems with gcc...
-OPTIM = -O0
-CFLAGS  = ${OPTIM} ${FLAGS} ${INCLUDE} 
+CFLAGS  = ${FLAGS} ${INCLUDE} ${SYSINCLUDE}
 
 SRC = brent.cpp\
       dpythag.cpp\
@@ -39,19 +38,19 @@ SRC = brent.cpp\
       newt.cpp\
       nrutil.cpp
 
-OBJ = ${SRC:.cpp=.o}
+OBJ = ${SRC:.cpp=${OBJEXT}}
 
-.SUFFIXES: .o .cpp
+.SUFFIXES: ${OBJEXT} .cpp
 
 ${LIB}: ${OBJ}
-	${AR} ${LIB} ${OBJ}
+	${AR} ${ARFLAGS}${LIB} ${OBJ}
 	${RANLIB} ${LIB}
 
-.cpp.o:
-	${CXX} ${CFLAGS} -c $<
+.cpp${OBJEXT}:
+	${CXX} ${CFLAGS} ${CSYM} $<
 
 clean:
-	rm -f *.o 
+	rm -f *${OBJEXT} 
 
 depend:
 	(sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \
diff --git a/contrib/Tetgen/Makefile b/contrib/Tetgen/Makefile
index fc1a5d13c2..14beefce5b 100644
--- a/contrib/Tetgen/Makefile
+++ b/contrib/Tetgen/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.6 2008-01-18 20:13:13 geuzaine Exp $
+# $Id: Makefile,v 1.7 2008-01-18 20:41:33 geuzaine Exp $
 #
 # Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 #
@@ -21,24 +21,24 @@
 
 include ../../variables
 
-LIB     = ../../lib/libGmshTetgen.a
+LIB     = ../../lib/libGmshTetgen${LIBEXT}
 # Do not optimize (same as Triangle...) 
-CFLAGS  =  ${FLAGS} -DTETLIBRARY
+CFLAGS  = ${FLAGS} ${DSYM}TETLIBRARY
 
 SRC = predicates.cxx tetgen.cxx
-OBJ = ${SRC:.cxx=.o}
+OBJ = ${SRC:.cxx=${OBJEXT}}
 
-.SUFFIXES: .o .cxx
+.SUFFIXES: ${OBJEXT} .cxx
 
 ${LIB}: ${OBJ} 
-	${AR} ${LIB} ${OBJ} 
+	${AR} ${ARFLAGS}${LIB} ${OBJ} 
 	${RANLIB} ${LIB}
 
-.cxx.o:
-	${CXX} ${CFLAGS} -c $<
+.cxx${OBJEXT}:
+	${CXX} ${CFLAGS} ${CSYM} $<
 
 clean:
-	rm -f *.o
+	rm -f *${OBJEXT}
 
 depend:
 	(sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \
diff --git a/variables.in b/variables.in
index 49f9ec8678..e665704e79 100644
--- a/variables.in
+++ b/variables.in
@@ -1,4 +1,4 @@
-# $Id: variables.in,v 1.21 2008-01-18 20:13:12 geuzaine Exp $
+# $Id: variables.in,v 1.22 2008-01-18 20:41:33 geuzaine Exp $
 #
 # Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 #
@@ -57,6 +57,7 @@ RANLIB=@RANLIB@
 # The symbols used for includes and compiling
 ISYM=@ISYM@
 CSYM=@CSYM@
+DSYM=@DSYM@
 
 # The extension to use for object files, libraries and executables
 OBJEXT=@OBJEXT@
-- 
GitLab