Index: /issm/trunk-jpl/externalpackages/curl/install-7.67-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/curl/install-7.67-static.sh	(revision 25744)
+++ /issm/trunk-jpl/externalpackages/curl/install-7.67-static.sh	(revision 25745)
@@ -28,5 +28,6 @@
 	--disable-dependency-tracking \
 	--disable-manual \
-	--disable-verbose
+	--disable-verbose \
+	--without-libidn2
 
 # Compile and install
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/include/xtndispatch.h
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/include/xtndispatch.h	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/include/xtndispatch.h	(revision 25745)
@@ -0,0 +1,147 @@
+/*  This code was computer generated */
+
+/*
+
+  These programs construct and manipulate orthogonal 
+arrays.  They were prepared by
+
+    Art Owen
+    Department of Statistics
+    Sequoia Hall
+    Stanford CA 94305
+
+  They may be freely used and shared.  This code comes
+with no warranty of any kind.  Use it at your own
+risk.
+
+  I thank the Semiconductor Research Corporation and
+the National Science Foundation for supporting this
+work.
+
+*/
+
+/* Fix for C99 */
+extern int ipow(int a, int b); /* primes.c */
+
+if(  q== ipow(2,2)  )xtn = xtn2t2;
+if(  q== ipow(2,3)  )xtn = xtn2t3;
+if(  q== ipow(2,4)  )xtn = xtn2t4;
+if(  q== ipow(2,5)  )xtn = xtn2t5;
+if(  q== ipow(2,6)  )xtn = xtn2t6;
+if(  q== ipow(2,7)  )xtn = xtn2t7;
+if(  q== ipow(2,8)  )xtn = xtn2t8;
+if(  q== ipow(2,9)  )xtn = xtn2t9;
+if(  q== ipow(2,10)  )xtn = xtn2t10;
+if(  q== ipow(2,11)  )xtn = xtn2t11;
+if(  q== ipow(2,12)  )xtn = xtn2t12;
+if(  q== ipow(2,13)  )xtn = xtn2t13;
+if(  q== ipow(2,14)  )xtn = xtn2t14;
+if(  q== ipow(2,15)  )xtn = xtn2t15;
+if(  q== ipow(2,16)  )xtn = xtn2t16;
+if(  q== ipow(2,17)  )xtn = xtn2t17;
+if(  q== ipow(2,18)  )xtn = xtn2t18;
+if(  q== ipow(2,19)  )xtn = xtn2t19;
+if(  q== ipow(2,20)  )xtn = xtn2t20;
+if(  q== ipow(2,21)  )xtn = xtn2t21;
+if(  q== ipow(2,22)  )xtn = xtn2t22;
+if(  q== ipow(2,23)  )xtn = xtn2t23;
+if(  q== ipow(2,24)  )xtn = xtn2t24;
+if(  q== ipow(2,25)  )xtn = xtn2t25;
+if(  q== ipow(2,26)  )xtn = xtn2t26;
+if(  q== ipow(2,27)  )xtn = xtn2t27;
+if(  q== ipow(2,28)  )xtn = xtn2t28;
+if(  q== ipow(2,29)  )xtn = xtn2t29;
+if(  q== ipow(3,2)  )xtn = xtn3t2;
+if(  q== ipow(3,3)  )xtn = xtn3t3;
+if(  q== ipow(3,4)  )xtn = xtn3t4;
+if(  q== ipow(3,5)  )xtn = xtn3t5;
+if(  q== ipow(3,6)  )xtn = xtn3t6;
+if(  q== ipow(3,7)  )xtn = xtn3t7;
+if(  q== ipow(3,8)  )xtn = xtn3t8;
+if(  q== ipow(3,9)  )xtn = xtn3t9;
+if(  q== ipow(3,10)  )xtn = xtn3t10;
+if(  q== ipow(3,11)  )xtn = xtn3t11;
+if(  q== ipow(3,12)  )xtn = xtn3t12;
+if(  q== ipow(3,13)  )xtn = xtn3t13;
+if(  q== ipow(3,14)  )xtn = xtn3t14;
+if(  q== ipow(3,15)  )xtn = xtn3t15;
+if(  q== ipow(3,16)  )xtn = xtn3t16;
+if(  q== ipow(3,17)  )xtn = xtn3t17;
+if(  q== ipow(3,18)  )xtn = xtn3t18;
+if(  q== ipow(5,2)  )xtn = xtn5t2;
+if(  q== ipow(5,3)  )xtn = xtn5t3;
+if(  q== ipow(5,4)  )xtn = xtn5t4;
+if(  q== ipow(5,5)  )xtn = xtn5t5;
+if(  q== ipow(5,6)  )xtn = xtn5t6;
+if(  q== ipow(5,7)  )xtn = xtn5t7;
+if(  q== ipow(5,8)  )xtn = xtn5t8;
+if(  q== ipow(5,9)  )xtn = xtn5t9;
+if(  q== ipow(5,10)  )xtn = xtn5t10;
+if(  q== ipow(5,11)  )xtn = xtn5t11;
+if(  q== ipow(5,12)  )xtn = xtn5t12;
+if(  q== ipow(7,2)  )xtn = xtn7t2;
+if(  q== ipow(7,3)  )xtn = xtn7t3;
+if(  q== ipow(7,4)  )xtn = xtn7t4;
+if(  q== ipow(7,5)  )xtn = xtn7t5;
+if(  q== ipow(7,6)  )xtn = xtn7t6;
+if(  q== ipow(7,7)  )xtn = xtn7t7;
+if(  q== ipow(7,8)  )xtn = xtn7t8;
+if(  q== ipow(7,9)  )xtn = xtn7t9;
+if(  q== ipow(7,10)  )xtn = xtn7t10;
+if(  q== ipow(11,2)  )xtn = xtn11t2;
+if(  q== ipow(11,3)  )xtn = xtn11t3;
+if(  q== ipow(11,4)  )xtn = xtn11t4;
+if(  q== ipow(11,5)  )xtn = xtn11t5;
+if(  q== ipow(11,6)  )xtn = xtn11t6;
+if(  q== ipow(11,7)  )xtn = xtn11t7;
+if(  q== ipow(11,8)  )xtn = xtn11t8;
+if(  q== ipow(13,2)  )xtn = xtn13t2;
+if(  q== ipow(13,3)  )xtn = xtn13t3;
+if(  q== ipow(13,4)  )xtn = xtn13t4;
+if(  q== ipow(13,5)  )xtn = xtn13t5;
+if(  q== ipow(13,6)  )xtn = xtn13t6;
+if(  q== ipow(13,7)  )xtn = xtn13t7;
+if(  q== ipow(13,8)  )xtn = xtn13t8;
+if(  q== ipow(17,2)  )xtn = xtn17t2;
+if(  q== ipow(17,3)  )xtn = xtn17t3;
+if(  q== ipow(17,4)  )xtn = xtn17t4;
+if(  q== ipow(17,5)  )xtn = xtn17t5;
+if(  q== ipow(17,6)  )xtn = xtn17t6;
+if(  q== ipow(17,7)  )xtn = xtn17t7;
+if(  q== ipow(19,2)  )xtn = xtn19t2;
+if(  q== ipow(19,3)  )xtn = xtn19t3;
+if(  q== ipow(19,4)  )xtn = xtn19t4;
+if(  q== ipow(19,5)  )xtn = xtn19t5;
+if(  q== ipow(19,6)  )xtn = xtn19t6;
+if(  q== ipow(19,7)  )xtn = xtn19t7;
+if(  q== ipow(23,2)  )xtn = xtn23t2;
+if(  q== ipow(23,3)  )xtn = xtn23t3;
+if(  q== ipow(23,4)  )xtn = xtn23t4;
+if(  q== ipow(23,5)  )xtn = xtn23t5;
+if(  q== ipow(23,6)  )xtn = xtn23t6;
+if(  q== ipow(29,2)  )xtn = xtn29t2;
+if(  q== ipow(29,3)  )xtn = xtn29t3;
+if(  q== ipow(29,4)  )xtn = xtn29t4;
+if(  q== ipow(29,5)  )xtn = xtn29t5;
+if(  q== ipow(29,6)  )xtn = xtn29t6;
+if(  q== ipow(31,2)  )xtn = xtn31t2;
+if(  q== ipow(31,3)  )xtn = xtn31t3;
+if(  q== ipow(31,4)  )xtn = xtn31t4;
+if(  q== ipow(31,5)  )xtn = xtn31t5;
+if(  q== ipow(31,6)  )xtn = xtn31t6;
+if(  q== ipow(37,2)  )xtn = xtn37t2;
+if(  q== ipow(37,3)  )xtn = xtn37t3;
+if(  q== ipow(37,4)  )xtn = xtn37t4;
+if(  q== ipow(37,5)  )xtn = xtn37t5;
+if(  q== ipow(41,2)  )xtn = xtn41t2;
+if(  q== ipow(41,3)  )xtn = xtn41t3;
+if(  q== ipow(41,4)  )xtn = xtn41t4;
+if(  q== ipow(41,5)  )xtn = xtn41t5;
+if(  q== ipow(43,2)  )xtn = xtn43t2;
+if(  q== ipow(43,3)  )xtn = xtn43t3;
+if(  q== ipow(43,4)  )xtn = xtn43t4;
+if(  q== ipow(43,5)  )xtn = xtn43t5;
+if(  q== ipow(47,2)  )xtn = xtn47t2;
+if(  q== ipow(47,3)  )xtn = xtn47t3;
+if(  q== ipow(47,4)  )xtn = xtn47t4;
+if(  q== ipow(47,5)  )xtn = xtn47t5;
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/src/Bose/boselink.c
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/src/Bose/boselink.c	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/src/Bose/boselink.c	(revision 25745)
@@ -0,0 +1,150 @@
+#if defined(HAVE_CONFIG_H) && !defined(DISABLE_DAKOTA_CONFIG_H)
+  #include "ddace_config.h"
+#endif
+#include <math.h>
+#include <stdio.h>
+#include "galois.h"
+
+/* Fix for C99*/
+extern int bose(struct GF *gf, int **A, int ncol); /* construct.c */
+extern int bush(struct GF *gf, int **A, int str, int ncol); /* construct.c */
+extern void GF_free(struct GF *gf); /* galois.c */
+extern int GF_getfield(int q, struct GF *gf); /* gfields.c */
+
+int bose_link( int n, int ninputs, int str, int ***AA )
+{
+   int    i, nsym, nsamples, **A; 
+   double dtemp, dpower;
+   struct GF gf;
+
+   if ( n <= 0 ) return -1;
+
+   /* only one method for strength of 3 */
+
+   if ( str == 3 )
+   {
+      dtemp = (double) n;
+      dtemp = pow(dtemp, 0.333333334);
+      nsym  = (int) dtemp;
+      if( ninputs > (nsym+1) ){
+         fprintf(stderr,"Only q+1 = %d cols given in Bush design.\n",nsym+1);
+         fprintf(stderr,"Columns requested was %d.\n",ninputs);
+	 return -1;
+      }
+      if(  !GF_getfield(nsym, &gf)  ) {
+         fprintf(stderr,"Could not construct the Galois field needed\n");
+         fprintf(stderr,"for the strength 3 Bush design.\n");
+	 GF_free( &gf );
+	 return -1;
+      }
+      nsamples = nsym * nsym * nsym;
+      A = imatrix( 0, nsamples, 0, ninputs-1  );
+      if(  !A  )
+      {
+         fprintf(stderr,"Could not allocate array for Bush design.\n");
+	 GF_free( &gf );
+	 return -1;
+      }
+      if(  ! bush( &gf, A, 3, ninputs )  )
+      {
+         fprintf(stderr,"Unable to construct the strength 3 ");
+         fprintf(stderr,"Bush design nsym=%d, ninputs=%d.\n", nsym,ninputs);
+	 GF_free( &gf );
+	 return -1;
+      }
+      else
+      {
+         (*AA) = A;
+         return nsamples;
+      }
+   }
+
+   /* only one method for strength greater than 3 */
+
+   if ( str > 3 )
+   {
+      dtemp = (double) n;
+      dpower = 1.0 / (double) str + 0.00000001;
+      dtemp = pow(dtemp, dpower);
+      nsym  = (int) dtemp;
+      if( ninputs > (nsym+1) ){
+         fprintf(stderr,"Only q+1 = %d cols given in Bush design.\n",nsym+1);
+         fprintf(stderr,"Columns requested was %d.\n",ninputs);
+	 return -1;
+      }
+      nsamples = nsym;
+      for ( i = 1; i < str; i++ ) nsamples = nsamples * nsym;
+      if(  !GF_getfield(nsym, &gf)  ){
+         fprintf(stderr,"Could not construct the Galois field needed\n");
+         fprintf(stderr,"for the strength %d Bush design\n",str);
+         fprintf(stderr,"on %d levels.\n", nsym);
+	 GF_free( &gf );
+	 return -1;
+      }
+      A = imatrix( 0, nsamples-1, 0, ninputs-1  );
+      if(  !A  )
+      {
+         fprintf(stderr,"Could not allocate array for Bush design.\n");
+	 GF_free( &gf );
+	 return -1;
+      } 
+      if(  ! bush( &gf, A, str, ninputs )  )
+      {
+         fprintf(stderr,"Unable to construct the strength %d \n", str);
+         fprintf(stderr,"Bush design nsym=%d, ninputs=%d.\n", nsym,ninputs);
+	 GF_free( &gf );
+	 return -1;
+      }
+      else
+      {
+         (*AA) = A;
+	 GF_free( &gf );
+         return nsamples;
+      }
+   }
+
+   /* for the cases when strength = 2 */
+
+   if ( str == 2 )
+   {
+      dtemp = (double) n;
+      dtemp = pow(dtemp, 0.500001);
+      nsym  = (int) dtemp;
+
+      if ( ninputs > ( nsym + 1 ) ) 
+      {
+         fprintf(stderr,"Number of samples too small to construct OA.\n");
+         fprintf(stderr,"Need at least %d. \n", (ninputs-1)*(ninputs-1));
+         return -1;
+      } 
+      if(  !GF_getfield( nsym, &gf)  )
+      {
+         fprintf(stderr,"Could not construct Galois field needed\n");
+         fprintf(stderr,"for Bose design.\n");
+	 GF_free( &gf );
+	 return -1;
+      }
+      nsamples = nsym * nsym;
+      A = imatrix( 0, nsamples-1, 0, ninputs-1  );
+      if(  !A  )
+      {
+         fprintf(stderr,"Could not allocate array for Bose design.\n");
+	 GF_free( &gf );
+	 return -1;
+      }
+      if(  ! bose( &gf, A, ninputs )  )
+      {
+         fprintf(stderr,"Unable to construct Bose design q=%d,",nsym);
+         fprintf(stderr," ninputs=%d.\n", ninputs);
+	 GF_free( &gf );
+	 return -1;
+      }
+      else
+      {
+         (*AA) = A;
+	 GF_free( &gf );
+         return nsamples;
+      }
+   }
+}
+
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/src/Bose/construct.c
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/src/Bose/construct.c	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/src/Bose/construct.c	(revision 25745)
@@ -0,0 +1,410 @@
+#if defined(HAVE_CONFIG_H) && !defined(DISABLE_DAKOTA_CONFIG_H)
+  #include "ddace_config.h"
+#endif
+/*
+
+  These programs construct and manipulate orthogonal 
+arrays.  They were prepared by
+
+    Art Owen
+    Department of Statistics
+    Sequoia Hall
+    Stanford CA 94305
+
+  They may be freely used and shared.  This code comes
+with no warranty of any kind.  Use it at your own
+risk.
+
+  I thank the Semiconductor Research Corporation and
+the National Science Foundation for supporting this
+work.
+
+*/
+
+
+/*  Constructions for designs using Galois fields */
+
+#include <math.h>
+#include <stdio.h>
+
+#include "galois.h"
+
+/* Fix for C99 */
+extern int ipow(int a, int b); /* primes.c */
+extern int isprime(int p); /* primes.c */
+extern void free_ivector(int *v, int nl, int nh); /* memory.c */
+extern void free_imatrix(int **m, int nrl, int nrh, int ncl, int nch); /* memory.c */
+extern int akodd(struct GF *gf, int *kay, int *b, int *c, int *k); /* akconst.c */
+extern int akeven(struct GF *gf, int *kay, int *b, int *c, int *k); /* akconst.c */
+
+/*  Glossary:
+
+    bose:            OA( q^2, q+1, q, 2  )
+                     R.C. Bose (1938) Sankhya Vol 3 pp 323-338
+    bosecheck:       test input to bose
+
+    bosebush:        OA( 2q^2, 2q+1, q, 2 ), only implemented for q=2^n
+    bosebushcheck:   test input to bosebush
+
+    polyeval:        evaluate a polynomial with coefficients, argument
+                     and result in a Galois field
+
+*/
+
+
+bosecheck( q,ncol )
+int q, ncol;
+{
+if(  ncol > q+1  ){
+  fprintf(stderr,"Bose's design must have ncol <= q+1.\n");
+  fprintf(stderr,"Had q=%d and ncol=%d.\n",q,ncol);
+  return 0;
+}
+if(  ncol <= 0  ){
+  fprintf(stderr,"Nonpositive number of columns requested for Bose's design\n");
+  return 0;
+}
+return 1;
+}
+
+
+bose( gf, A, ncol )
+struct GF *gf;
+int    **A, ncol;
+{
+int i,j, icol,  q=gf->q, irow;
+
+if(  !bosecheck(q,ncol)  )return 0;
+
+irow = 0;
+for(  i=0; i<q; i++  )
+for(  j=0; j<q; j++  ){
+  icol=0;
+  A[ irow ][ icol++ ] = i;
+  if(  ncol > 1 )A[ irow  ][ icol++ ] = j;
+  for(  icol=2; icol<ncol; icol++ )
+    A[ irow ][ icol ] = gf->plus[j][gf->times[i][icol-1]];
+  irow++;
+}
+
+
+return 1;
+}
+
+itopoly( n,q,d,coef )
+int  n,q,d,*coef;
+{
+int i;
+
+for(  i=0; i<=d; i++  ){
+  coef[i] = n % q;
+  n = n/q;
+}
+}
+
+
+polyeval( gf, d, poly, arg, value )
+/*  find  value = poly(arg) where poly is a polynomial of degree d  
+    and all the arithmetic takes place in the given Galois field.*/
+
+struct GF *gf;
+int    d, *poly, arg, *value;
+{
+int   i,ans;
+
+ans = 0;
+for(  i= d; i>=0; i--  )  /* Horner's rule */
+  ans = gf->plus[  gf->times[ans][arg]  ][  poly[i] ];
+
+*value = ans;
+}
+
+bushcheck(q,str,ncol)
+int q,str,ncol;
+{
+if(  ncol > q+1  ){
+  fprintf(stderr,"Bush designs require ncol <= q+1.\n");
+  fprintf(stderr,"Cannot have q = %d and ncol = %d.\n",q,ncol);
+  return 0;
+}
+if(  str > ncol  ){
+  fprintf(stderr,"It doesn't make sense to have an array of strength\n");
+  fprintf(stderr,"%d with only %d columns.\n",str,ncol);
+  return 0;
+}
+if(  str >= q+1  ){
+  fprintf(stderr,"Bush's (1952) theorem has a condition t<q where t\n");
+  fprintf(stderr,"is the strength of the array and q is the number of symbols.\n");
+  fprintf(stderr,"Here we have t = %d and q = %d.  The array may still\n",str,q);
+  fprintf(stderr,"be useful, but a full factorial would have at least as\n");
+  fprintf(stderr,"many columns.\n");
+  return 1;
+}
+
+return 1;
+}
+
+
+bush( gf, A, str, ncol  )
+struct GF *gf;
+int       **A, str, ncol;
+{
+int   *coef;
+int   q, i,j;
+
+q = gf->q;
+if(  !bushcheck(q,str,ncol)  )return 0;
+
+coef = ivector( 0,str-1  );  
+if( !coef  ){ /* Very unlikely */
+  fprintf(stderr,"Could not allocate memory for Bush design.\n");
+  return 0;
+}
+
+for(  i=0; i<ipow(q,str); i++  ){
+  itopoly( i,q,str-1,coef );
+  A[i][0] = coef[str-1];  
+  for(  j=0; j<ncol-1; j++  )
+    polyeval( gf, str-1, coef, j, &A[i][1+j] );
+}
+free_ivector( coef,0,str-1  );  
+return 1;
+}
+
+
+addelkempcheck( q,p,ncol )
+int  q,p,ncol;
+{
+
+if(  p==2 && q>4 ){
+  fprintf(stderr,"This Addelman-Kempthorne OA(2q^2,ncol,q,2) is only\n");
+  fprintf(stderr,"available for odd prime powers q and for even prime\n");
+  fprintf(stderr,"powers q<=4.  q=%d is not available, but a Bose Bush\n",q);
+  fprintf(stderr,"construction exists for that design.\n");
+  return 0;
+}
+
+if(  ncol > 2*q+1  ){
+  fprintf(stderr,"The Addelman-Kempthorne construction needs ncol <= 2q+1.\n");
+  fprintf(stderr,"Can't have ncol = %d with q = %d,\n",ncol,q);
+  return 0;
+}
+
+if(  ncol == 2*q+1  ){
+  fprintf(stderr,"\nWarning: The Addelman-Kempthorne construction with ncol = 2q+1\n");
+  fprintf(stderr,"has a defect.  While it is still an OA(2q^2,2q+1,q,2),\n");
+  fprintf(stderr,"there exist some pairs of rows that agree in three columns.\n");
+  fprintf(stderr,"The final column in the array is involved in all of these\n");
+  fprintf(stderr,"triple coincidences.\n\n\n");
+}
+return 1;
+}
+
+
+addelkemp( gf, A, ncol )
+/* Implement Addelman and Kempthorne's 1961 A.M.S. method with n=2 */
+struct GF *gf;
+int    ncol, **A;
+{
+int i,j,m,p,q;
+int kay,*b,*c,*k;  /* A&K notation */
+int row, col, square, ksquare, temp;
+
+p=gf->p, q=gf->q;
+
+if(  !addelkempcheck( q,p,ncol )  )return 0;
+
+b = ivector( 0,q-1 );
+c = ivector( 0,q-1 );
+k = ivector( 0,q-1 );
+
+for(  i=0; i<q; i++  ){           /* First q*q rows */
+  square = gf->times[i][i];
+  for(  j=0; j<q; j++  ){
+    row = i*q+j;
+    col = 0;
+    if( col<ncol  )A[row][col++]=j;
+    for(  m=1; m<q && col<ncol; m++  )
+      A[row][col++] = gf->plus[i][gf->times[m][j]];
+    for(  m=0; m<q && col<ncol; m++  ){
+      temp = gf->plus[j][gf->times[m][i]];
+      A[row][col++] = gf->plus[temp][square]; /* Rgt cols */
+    }
+    if( col<ncol  )A[row][col++]=i;
+  }
+}
+
+if(  p !=2  )                    /* Constants kay,b,c,k for odd p */
+  akodd(  gf,&kay,b,c,k );
+else                             /* Constants kay,b,c,k for even p */
+  akeven( gf,&kay,b,c,k );
+
+for(  i=0; i<q; i++  ){           /* Second q*q rows */
+  square = gf->times[i][i];
+  ksquare = gf->times[kay][square];
+  for(  j=0; j<q; j++  ){
+    row = q*q+i*q+j;
+    col = 0;
+    if( col<ncol  )A[row][col++]=j;
+    for(  m=1; m<q && col<ncol; m++,col++  )
+      A[row][col] = gf->plus[A[row-q*q][col]][b[m]];
+    if( col<ncol  )A[row][col++] = gf->plus[ksquare][j]; /* q+1 */
+    for(  m=1; m<q && col<ncol; m++  ){
+      temp = gf->times[i][k[m]];
+      temp = gf->plus[ksquare][temp];
+      temp = gf->plus[j][temp];
+      A[row][col++] = gf->plus[temp][c[m]];
+    }
+    if( col<ncol  )A[row][col++]=i;
+  }
+}
+
+/*for(  i=0; i<2*q*q; i++  )
+for(  j=0; j<ncol; j++  )
+  printf("%3d%s",A[i][j],j==(ncol-1)?"\n":" ");
+*/
+
+return 1;
+}
+
+
+bosebushcheck( q,p,ncol  )
+int  q,p,ncol;
+{
+
+if(  p!=2  ){
+  fprintf(stderr,"This version of Bose and Bush needs q=2^n for some n.\n");
+  return 0;
+}
+
+if(  ncol > 2*q+1  ){
+  fprintf(stderr,"The Bose-Bush construction needs ncol <= 2q+1.\n");
+  fprintf(stderr,"Can't have ncol = %d with q = %d,\n",ncol,q);
+  return 0;
+}
+
+if(  ncol == 2*q+1  ){
+  fprintf(stderr,"\nWarning: The Bose-Bush construction with ncol = 2q+1\n");
+  fprintf(stderr,"has a defect.  While it is still an OA(2q^2,2q+1,q,2),\n");
+  fprintf(stderr,"there exist some pairs of rows that agree in three columns.\n\n\n");
+}
+return 1;
+}
+
+bosebush( gf, B, ncol )
+/* Implement Bose and Bush's 1952 A.M.S. method with p=2, u=1 */
+struct GF *gf;
+int **B;
+{
+int p,q,s,irow;
+int i,j,k,mul;
+int **A;
+
+p=gf->p,   /* GF(q) used to generate design with q/2 levels */
+q=gf->q;
+s=q/2;     /* number of levels in design */
+
+if(  !bosebushcheck( s,p,ncol )  )
+  return 0;
+
+A = imatrix(0,s-1,0,q-1);
+if(  !A  ){
+  fprintf(stderr,"Unable to allocate scratch space for Bose-Bush array.\n");
+  return 0;
+}
+
+irow = 0;
+for(  i=0; i<q; i++  ){
+  for(  j=0; j<q; j++  ){
+    mul = gf->times[i][j];
+    mul = mul % s;
+    for( k=0; k<s; k++  )
+/*      A[k][j] = gf->plus[mul][k];*/
+      A[k][j] = gf->plus[mul][k];
+  }
+  for(  k=0; k<s; k++  ){
+    for( j=0; j<ncol && j<2*s+1; j++ )
+      B[irow][j] = A[k][j];
+    if(  ncol==2*s+1  )
+      B[irow][ncol-1] = i%s;
+    irow++;
+  }
+}
+free_imatrix(A,0,s-1,0,q-1);
+return 1;
+}
+  
+  
+bosebushlcheck( s,p,lam,ncol  )
+int  s,p,lam,ncol;
+{
+
+if(  !isprime(p)  ){
+  fprintf(stderr,"Bose Bush routine given a nonprime.\n");
+  return 0;
+}
+
+if(  ncol > lam*s+1  ){
+  fprintf(stderr,"The Bose-Bush construction needs ncol <= lambda*q+1.\n");
+  fprintf(stderr,"Can't have ncol = %d with lam = %d and q = %d,\n",ncol,lam,s);
+  return 0;
+}
+
+if(  ncol == lam*s+1  ){
+  fprintf(stderr,"\nWarning: The Bose-Bush construction with ncol = lambda*q+1\n");
+  fprintf(stderr,"has a defect.  While it is still an OA(lambda*q^2,lambda*q+1,q,2),\n");
+  fprintf(stderr,"it may have worse coincidence properties than\n");
+  fprintf(stderr,"OA(lambda*q^2,lambda*q+1,q,2).\n");
+}
+return 1;
+}
+
+bosebushl( gf, lam, B, ncol )
+/* Implement Bose and Bush's 1952 A.M.S. method with given lambda */
+struct GF *gf;
+int **B, lam;
+{
+int p,q,s,irow;
+int i,j,k,mul;
+int **A;
+
+p=gf->p,   /* GF(q) used to generate design with q/lam levels */
+q=gf->q;
+s=q/lam;     /* number of levels in design */
+
+if(  !bosebushlcheck( s,p,lam,ncol )  )
+  return 0;
+
+A = imatrix(0,s-1,0,q-1);
+if(  !A  ){
+  fprintf(stderr,"Unable to allocate scratch space for Bose-Bush array.\n");
+  return 0;
+}
+
+irow = 0;
+for(  i=0; i<q; i++  ){
+  for(  j=0; j<q; j++  ){
+    mul = gf->times[i][j];
+    mul = mul % s;
+    for( k=0; k<s; k++  )
+/*      A[k][j] = gf->plus[mul][k];*/
+      A[k][j] = gf->plus[mul][k];
+  }
+  for(  k=0; k<s; k++  ){
+    for( j=0; j<ncol && j<lam*s+1; j++ )
+      B[irow][j] = A[k][j];
+    if(  ncol==lam*s+1  )
+      B[irow][ncol-1] = i%s;
+    irow++;
+  }
+}
+
+
+
+
+
+free_imatrix(A,0,s-1,0,q-1);
+return 1;
+}
+  
+  
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/src/Bose/galois.c
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/src/Bose/galois.c	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/src/Bose/galois.c	(revision 25745)
@@ -0,0 +1,264 @@
+#if defined(HAVE_CONFIG_H) && !defined(DISABLE_DAKOTA_CONFIG_H)
+  #include "ddace_config.h"
+#endif
+/**
+
+  These programs construct and manipulate orthogonal 
+arrays.  They were prepared by
+
+    Art Owen
+    Department of Statistics
+    Sequoia Hall
+    Stanford CA 94305
+
+  They may be freely used and shared.  This code comes
+with no warranty of any kind.  Use it at your own
+risk.
+
+  I thank the Semiconductor Research Corporation and
+the National Science Foundation for supporting this
+work.
+
+*/
+
+
+/*     Manipulation of generic Galois fields.  See gfields.c
+   for construction of specific Galois fields.  */
+
+#include <math.h>
+#include <stdio.h>
+
+#include "galois.h"
+
+/* Fix for C99 */
+extern void free_ivector(int v, int nl, int nh); /* memory.c */
+extern void free_imatrix(int m, int nrl, int nrh, int ncl, int nch); /* memory.c */
+
+/*  Glossary:
+
+       GF_poly_sum       Addition in polynomial representation
+       GF_poly_prod      Multiplication in polynomial representation
+       GF_poly2int       Convert polynomial to integer in 0..q-1
+       GF_ready          Prepare (+,*,^-1) lookup tables
+       GF_print          Print Galois field
+       GF_free           Free storage
+
+*/
+
+
+/*---------------------------------------------------------------*/
+
+GF_poly_sum( p,n,p1,p2,sum )
+int  n,p,*p1,*p2,*sum;
+{
+int i;
+
+for(  i=0; i<n; i++  )
+  sum[i] = (p1[i]+p2[i]) % p;
+}
+
+/*---------------------------------------------------------------*/
+
+GF_poly_prod( p,n,xton,p1,p2,prod )
+/*
+  Set prod = p1*p2 with coefficients modulo p, and x^n replaced
+by polynomial xton.
+*/
+int  n,p,*xton,*p1,*p2,*prod;
+{
+int i,j, *longprod;
+
+longprod = ivector(0,2*n-2);
+
+for(  i=0; i<2*n-1; i++  )
+  longprod[i] = 0;
+for(  i=0; i<n; i++  )
+for(  j=0; j<n; j++  )
+  longprod[i+j] += p1[i]*p2[j];
+for(  i=2*n-2; i>n-1; i--  )
+for(  j=0; j<n; j++  )
+  longprod[i-n+j] += xton[j]*longprod[i];
+for(  i=0; i<n; i++  )
+  prod[i] = longprod[i] % p;
+
+free_ivector(longprod,0,2*n-2);
+}
+
+/*---------------------------------------------------------------*/
+
+int GF_poly2int( p,n,poly )
+
+int n,p,*poly;
+{
+int ans, i;
+
+ans = 0;
+for(  i=n-1; i>0; i--  )
+  ans = (ans+poly[i])*p;
+ans += poly[0];
+
+return ans;
+}
+
+/*---------------------------------------------------------------*/
+
+#define GFPUNT {fprintf(stderr,"Unable to allocate space for Galois field on %d elements.\n",q);return 0;}
+
+GF_ready( gf,p,n,xton )
+/* 
+   Make ready the Galois Field
+*/
+struct GF *gf;
+int  n,p,*xton;
+{
+int i,j,q,click,*poly;
+
+poly = ivector(0,n-1);
+
+gf->n = n;
+gf->p = p;
+q = 1;
+for(  i=0; i<n; i++  )
+  q *= p;
+gf->q = q;
+gf->xton = ivector(0,n-1);        if(  !gf->xton  )GFPUNT;
+for(  i=0; i<n; i++  )
+  gf->xton[i] = xton[i];
+gf->plus = imatrix(0,q-1,0,q-1);  if(  !gf->plus  )GFPUNT;
+gf->times= imatrix(0,q-1,0,q-1);  if(  !gf->times )GFPUNT;
+gf->inv  = ivector(0,q-1);        if(  !gf->inv   )GFPUNT;
+gf->neg  = ivector(0,q-1);        if(  !gf->neg   )GFPUNT;
+gf->root = ivector(0,q-1);        if(  !gf->root  )GFPUNT;
+gf->poly = imatrix(0,q-1,0,n-1);  if(  !gf->poly  )GFPUNT;
+
+for(  i=0; i<n; i++  )
+  gf->poly[0][i] = 0;
+
+for( i=1; i<q; i++  ){
+  for( click=0; gf->poly[i-1][click]==(p-1); click++  )
+    gf->poly[i][click] = 0;
+  gf->poly[i][click] = gf->poly[i-1][click]+1;
+  for(  j=click+1; j<n; j++  )
+    gf->poly[i][j] = gf->poly[i-1][j];
+}
+
+for(  i=0; i<q; i++  )
+for(  j=0; j<q; j++  ){
+  GF_poly_sum( p,n,gf->poly[i],gf->poly[j],poly );
+  gf->plus[i][j] = GF_poly2int( p,n,poly );
+  GF_poly_prod( p,n,xton,gf->poly[i],gf->poly[j],poly );
+  gf->times[i][j] = GF_poly2int( p,n,poly );
+}
+
+for(  i=0; i<q; i++  ){
+  gf->inv[i] = -1;
+  for(  j=0; j<q;  j++  )
+    if(  gf->times[i][j]==1  )
+      gf->inv[i] = j;
+  if(  i>0 && gf->inv[i] <= 0  ){
+    fprintf(stderr,"There is something wrong with the Galois field\n");
+    fprintf(stderr,"used for q=%d.  Element %d has no reciprocal.\n",q,i);
+    return 0;
+  }
+}
+
+for(  i=0; i<q; i++  ){
+  gf->neg[i] = -1;
+  for(  j=0; j<q;  j++  )
+    if(  gf->plus[i][j]==0  )
+      gf->neg[i] = j;
+  if(  i>0 && gf->neg[i] <= 0  ){
+    fprintf(stderr,"There is something wrong with the Galois field\n");
+    fprintf(stderr,"used for q=%d.  Element %d has no negative.\n",q,i);
+    return 0;
+  }
+}
+
+for(  i=0; i<q; i++  ){
+  gf->root[i] = -1;
+  for(  j=0; j<q;  j++  )
+    if(  gf->times[j][j]==i  )
+      gf->root[i] = j;
+}
+
+/*printf("%d %d %d\n",q,p,n);*/
+
+/* Added by J Cramp 07.02.04 to fix memory leak. */
+free_ivector(poly,0,n-1);
+
+return 1;
+}
+
+/*---------------------------------------------------------------*/
+
+GF_print( gf )
+
+struct GF *gf;
+{
+int i,j,n,p,q;
+
+n=gf->n, p=gf->p, q=gf->q;
+
+if( q>999 )fprintf(stderr,"Warning q=%d will overflow print field.\n",q);
+
+printf("\nFor GF(%d) p=%d n=%d\n",q,p,n);
+printf("x**n = (");
+for( i=0; i<n-1; i++  )
+  printf("%d,",gf->xton[i]);
+printf("%d)\n",gf->xton[n-1]);
+printf("\n\nGF(%d) Polynomial coefficients:\n",q);
+for(  i=0; i<q; i++  ){
+  printf("  %3d  ",i);
+  for(  j=0; j<n; j++  )
+    printf("%3d ",gf->poly[i][j]);
+  printf("\n");
+}
+printf("\n\nGF(%d) Addition Table\n",q);
+for(  i=0; i<q; i++  ){
+  printf("  ");
+  for(  j=0; j<q; j++  )
+    printf(" %3d",gf->plus[i][j]);
+  printf("\n");
+}
+printf("\n\nGF(%d) Multiplication table\n",q);
+for(  i=0; i<q; i++  ){
+  printf("  ");
+  for(  j=0; j<q; j++  )
+    printf(" %3d",gf->times[i][j]);
+  printf("\n");
+}
+printf("\n\nGF(%d) Reciprocals\n",q);
+for(  i=1; i<q; i++  )
+  printf(" %3d %3d\n",i,gf->inv[i]);
+
+printf("\n\nGF(%d) Negatives\n",q);
+for(  i=0; i<q; i++  )
+  printf(" %3d %3d\n",i,gf->neg[i]);
+
+printf("\n\nGF(%d) Square roots\n",q);
+for(  i=0; i<q; i++  )
+  printf(" %3d %3d\n",i,gf->root[i]);
+}
+
+/*---------------------------------------------------------------*/
+
+GF_free( gf )
+/* 
+   Deallocate the Galois Field
+*/
+struct GF *gf;
+{
+/*int q,p,n;
+q = gf->q, p=gf->p, n=gf->n;*/
+
+int q,n;
+q = gf->q, n=gf->n; /* Shuts lint up */
+
+free_imatrix(gf->poly,0,q-1,0,n-1);
+free_ivector(gf->root,0,q-1);
+free_ivector(gf->neg,0,q-1);
+free_ivector(gf->inv,0,q-1);
+free_imatrix(gf->times,0,q-1,0,q-1);
+free_imatrix(gf->plus,0,q-1,0,q-1);
+free_ivector(gf->xton,0,n-1);
+}
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/src/Bose/gfields.c
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/src/Bose/gfields.c	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/src/Bose/gfields.c	(revision 25745)
@@ -0,0 +1,120 @@
+#if defined(HAVE_CONFIG_H) && !defined(DISABLE_DAKOTA_CONFIG_H)
+  #include "ddace_config.h"
+#endif
+/*
+
+  These programs construct and manipulate orthogonal 
+arrays.  They were prepared by
+
+    Art Owen
+    Department of Statistics
+    Sequoia Hall
+    Stanford CA 94305
+
+  They may be freely used and shared.  This code comes
+with no warranty of any kind.  Use it at your own
+risk.
+
+  I thank the Semiconductor Research Corporation and
+the National Science Foundation for supporting this
+work.
+
+*/
+
+
+/*     Construction of specific Galois fields.  See galois.c 
+    for manipulation of generic Galois fields.
+
+       To add a new Galois field GF(q)=GF(p^n) it is necessary 
+    to find the polynomial representation of x^n, and use it to
+    include another *xtn--- vector like those used below.
+
+*/
+
+#include <math.h>
+#include <stdio.h>
+
+#include "galois.h"
+
+/* Fix for C99 */
+extern int isprime(int p); /* primes.c */
+extern void primepow(int q, int *p, int *n, int *isit); /* primes.c */
+extern int GF_ready(struct GF *gf, int p, int n, int *xton); /* galois.c */
+
+/*  Glossary:
+
+       xtn2t2              Polynomial representation of x^2 in gf2t2
+       xtn2t3              Polynomial representation of x^3 in gf2t3
+       . . .               Polynomial representation of p^n in gfptn
+       xtn13t2             Polynomial representation of x^2 in gf13t2
+
+       GF_set_fields       Initialize polynomial representations
+       GF_fields_are_set   Indicates initialization done
+       GF_getfield         Construct and return GF(q) if possible
+*/
+
+#include "xtndeclare.h"
+int *xtnpt1;
+
+int GF_fields_are_set = 0;
+
+GF_set_fields()
+{
+/* Brute force set up of defining vectors, from Carmichael */
+
+/* Declare x-to-the-power-n vectors, for GFs p-to-the-n */
+
+if(   GF_fields_are_set   )
+  fprintf(stderr,"Warning: Fields being re-initialized.  Possible memory waste.\n");
+
+
+#include "xtnset.h"
+
+xtnpt1 = ivector(0,0);
+xtnpt1[0] = 0; 
+GF_fields_are_set = 1;
+}
+
+
+GF_getfield( q, gf )
+int q;
+struct GF *gf;
+{
+int *xtn;
+int p,n,ispp;
+
+if(  !GF_fields_are_set  )
+  GF_set_fields();
+
+if(  q<1  ){      /* Impossible argument */
+  fprintf(stderr,"Field must have positive number of elements.\n");
+  return 0; }
+if(  q==1 ){      /* Pointless  argument */
+  fprintf(stderr,"Field with 1 element was requested.\n");
+  return 0; }
+
+primepow( q,&p,&n,&ispp  );
+if(  !ispp  ){
+  fprintf(stderr,"q=%d is not a prime power.\n",q);
+  return 0; }
+
+xtn = NULL;
+
+#include "xtndispatch.h"
+
+if(  isprime(q)  )xtn = xtnpt1;  /* Could have tested p=q, or n=1 */
+
+if(  xtn   ){
+  if(  GF_ready( gf,p,n,xtn )  )
+    return 1;
+  else{
+    fprintf(stderr,"Construction failed for GF(%d).\n",q);
+    return 0;
+  }
+}
+else {
+  fprintf(stderr,"GF(%d) = GF(%d^%d) is not included in this program.\n",q,p,n);
+  fprintf(stderr,"To add it, consider modifying gfields.c.\n");
+  return 0;
+}
+}
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/src/Bose/oa.c
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/src/Bose/oa.c	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/DDACE/src/Bose/oa.c	(revision 25745)
@@ -0,0 +1,664 @@
+#if defined(HAVE_CONFIG_H) && !defined(DISABLE_DAKOTA_CONFIG_H)
+  #include "ddace_config.h"
+#endif
+/**
+
+  These programs construct and manipulate orthogonal 
+arrays.  They were prepared by
+
+    Art Owen
+    Department of Statistics
+    Sequoia Hall
+    Stanford CA 94305
+
+  They may be freely used and shared.  This code comes
+with no warranty of any kind.  Use it at your own
+risk.
+
+  I thank the Semiconductor Research Corporation and
+the National Science Foundation for supporting this
+work.
+
+*/
+
+
+#include <stdio.h>
+/* for exit: */
+#include <stdlib.h>
+
+#include "oa.h"
+  
+int  **imatrix(), *ivector();
+
+/* Fix for C99 */
+extern int grow_imatrix_byrows(int ***imat, int oldrowsize, int newrowsize, int colsize); /* memory.c */
+extern void free_ivector(int *v, int nl, int nh); /* memory.c */
+extern int ipow(int a, int b); /* primes.c */
+
+/**
+
+   Glossary:
+
+    OA_put            write OA to standard output
+    OA_fput           write OA to stream
+    OA_get            get OA from standard input
+    OA_fget           get OA from stream
+
+    OA_parsein        read arguments q,nrow,ncol to OA "filter programs"
+    OA_strworkcheck   warn about large work loads in strength checking programs
+
+*/
+
+
+/*  OUTPUT    OUTPUT    OUTPUT    OUTPUT    OUTPUT    OUTPUT    OUTPUT  */
+
+OA_fput( stream,A,n,k,q )
+FILE *stream;
+int **A, n, k, q;
+{
+int   i,j;
+char* format;
+
+format = "%d%s";
+if(  q < 1000  )format = "%3d%s";
+if(  q < 100   )format = "%2d%s";
+if(  q < 10    )format = "%1d%s";
+if(  q < 0     )format = "%d%s";
+
+for(  i=0; i<n; i++  )
+for(  j=0; j<k; j++  )
+  fprintf(stream,format,A[i][j],(j==k-1)?"\n":" ");
+}
+
+OA_put( A,n,k,q )
+int **A, n, k, q;
+{
+OA_fput( stdout,A,n,k,q );
+}
+
+/*  INPUT    INPUT    INPUT    INPUT    INPUT    INPUT    INPUT    INPUT  */
+
+OA_fget( stream,A,n,k,q,eof_assert )
+FILE *stream;
+int **A, n, k, q, eof_assert;
+{
+int   i,j;
+for( i=0; i<n; i++ )
+for( j=0; j<k; j++ )
+  if( fscanf(stream,"%d",&A[i][j]) == EOF  ){
+    fprintf(stderr,"Unexpected end of input encountered.  Wanted to read\n");
+    fprintf(stderr,"%d rows of %d cols.  Failed trying for row %d, col %d.\n",
+      n,k,i,j);
+    return 0;
+  }else if(  A[i][j] >= q ){
+    fprintf(stderr,"Invalid array element %d.  All elements should be\n",
+      A[i][j]);
+    fprintf(stderr,"strictly less than q = %d.\n",q);
+    return 0;
+  }else if(  A[i][j] <0   ){
+    fprintf(stderr,"Invalid array element %d, should be >= 0.\n",A[i][j]);
+    return 0;
+  }
+
+if(  eof_assert  &&  fscanf(stream,"%d",&eof_assert) != EOF  ){
+    fprintf(stderr,"Input has more integers than expected.\n");
+    fprintf(stderr,"Perhaps the number of rows and/or columns is incorrect.\n");
+    return 0;
+  }
+return 1;
+}
+
+OA_get( A,n,k,q, eof_assert )
+int **A, n, k, q, eof_assert;
+{
+return OA_fget( stdin,A,n,k,q,eof_assert );
+}
+
+/*  READ    READ    READ    READ    READ    READ    READ    READ    READ  */
+
+/*  Read array and determine dimensions.   Inspired by approach
+taken in Xgobi.  */
+
+#define MAXK 5000
+#define ROWINC 1000
+int line0[ MAXK ];
+
+OA_fread( stream,A,n,k,q )
+FILE *stream;
+int ***A, *n, *k, *q;
+{
+int   i, j;
+char  c;
+
+*k = 0;
+
+while( (c = getc(stream)) != '\n'  ){
+  if(  c=='\t' || c==' '  )
+    ;
+  else{
+    ungetc(c,stream);
+    if(  *k >= MAXK  ){
+      fprintf(stderr,"Error: Input appears to have more than %d columns.\n",*k);
+      fprintf(stderr,"If such large input is desired, increase MAXK in oa.c\n");
+      fprintf(stderr,"and re-install the software.\n");
+      return 0;
+    }
+    if(  fscanf(stream,"%d",&line0[(*k)++]) <= 0  ){
+      fprintf(stderr,"Error: no newline character found.  Could be empty\n");
+      fprintf(stderr,"input or matrix all on one line.\n");
+      return 0;
+    }
+  }
+}
+
+*A = imatrix( 0,ROWINC-1, 0,*k-1 );
+if(  !(*A)  ){
+  fprintf(stderr,"Unable to allocate memory to read the array.\n");
+  return 0;
+}
+
+*n = 0;
+for(  j=0; j<*k; j++  )
+  A[0][*n][j] = line0[j];
+
+while( 1 ){
+  (*n)++;
+  if(  (*n % ROWINC)==0  )
+    if(  !grow_imatrix_byrows( A, (*n), (*n)+ROWINC, *k )  ){
+      fprintf(stderr,"Unable to allocate extra memory for row %d of the array.\n"
+	      ,*n);
+      return 0;
+    }
+
+  if(  fscanf(stream,"%d",&(A[0][*n][0])) == EOF  )
+    break;
+
+  for(  j=1; j<*k; j++  )
+    if( fscanf(stream,"%d",&(A[0][*n][j])) == EOF  ){
+      fprintf(stderr,"Unexpected end of input encountered.  Row %d only has\n",*n);
+      fprintf(stderr,"%d elements of %d expected.\n",j,*k);
+      return 0;
+    }
+}
+*q = 0;                   /* Assume that q = max(A)+1  */
+
+for(  i=0; i<*n; i++  )
+for(  j=0; j<*k; j++  )
+  if(  A[0][i][j] > *q  )
+    *q = A[0][i][j];
+*q = *q +1;
+
+return 1;
+}
+
+OA_read( A,n,k,q )
+int ***A, *n, *k, *q;
+{
+return OA_fread( stdin,A,n,k,q );
+}
+
+/*  PARSE    PARSE    PARSE    PARSE    PARSE    PARSE    PARSE    PARSE  */
+
+OA_parsein( argc,argv, q,nrow,ncol, A )
+int  argc;
+char *argv[];
+int *q, *nrow, *ncol, ***A;
+{
+if(  argc<=1  ){
+  if(  !OA_read( A,nrow,ncol,q )  ){
+    fprintf(stderr,"Fatal error while reading the array.\n");
+    exit(1);
+  }
+}
+else if( argc==2  ){
+  sscanf(argv[1],"%d",q);
+  scanf("%d %d",nrow,ncol);
+}else if( argc==3  ){
+  sscanf(argv[1],"%d",q);
+  sscanf(argv[2],"%d",nrow);
+  scanf("%d",ncol);
+}else{
+  sscanf(argv[1],"%d",q);
+  sscanf(argv[2],"%d",nrow);
+  sscanf(argv[3],"%d",ncol);
+}
+
+if(  *q<1  ){
+  fprintf(stderr,"Array has only %d symbol(s).  At least one\n",*q);
+  fprintf(stderr,"symbol is necessary in an orthogonal array.\n");
+  exit(1);
+}
+
+if(  *ncol<1  ){
+  fprintf(stderr,"Array has only %d column(s).  At least one\n",*ncol);
+  fprintf(stderr,"column is necessary in an orthogonal array.\n");
+  exit(1);
+}
+
+if(  *nrow<1  ){
+  fprintf(stderr,"Array has only %d rows.  At least one\n",*nrow);
+  fprintf(stderr,"row is necessary in an orthogonal array.\n");
+  exit(1);
+}
+
+
+if(  argc >1  ){
+  *A = imatrix( 0,*nrow-1,0,*ncol-1 );
+  if(  !(*A)  ){
+    fprintf(stderr,"The array is too large (%d by %d) to fit in memory.\n",nrow,ncol);
+    exit(1);
+  }
+  
+  if(  !OA_get( *A,*nrow,*ncol,*q, 1 )  ){/* Read 'em all */
+    fprintf(stderr,"Read error getting the orthogonal array.\n");
+    exit(1);
+  }
+}
+}
+
+
+/*  WORK    WORK    WORK    WORK    WORK    WORK    WORK    WORK    WORK  */
+
+OA_strworkcheck( work,str )
+double work;
+int    str;
+{
+if(  work > BIGWORK  ){
+  fprintf(stderr,"If the array has strength %d, %g comparisons will\n",
+	  str, work);
+  fprintf(stderr,"be required to prove it.  This might take a long time.\n");
+  fprintf(stderr,"This warning is triggered when more than %d comparisons\n",
+	  BIGWORK);
+  fprintf(stderr,"are required.  To avoid this warning increase BIGWORK in\n");
+  fprintf(stderr,"oa.h.  Intermediate results will be printed.\n\n");
+  fflush(stderr);
+}else if(  work > MEDWORK  ){
+  fprintf(stderr,"Since more than %d comparisons may be required to\n",MEDWORK);
+  fprintf(stderr,"to check whether the array has strength %d, intermediate\n",
+	  str);
+  fprintf(stderr,"results will be printed.  To avoid this warning increase\n");
+  fprintf(stderr,"MEDWORK in oa.h\n\n");
+  fflush(stderr);
+}
+}
+
+
+/*  STRENGTH    STRENGTH    STRENGTH    STRENGTH    STRENGTH  */
+
+/* Check strength 0 */
+OA_str0( q,nrow,ncol,A,verbose   )
+int      q,nrow,ncol,**A, verbose;
+{
+int  i, j1;
+
+for(  j1=0; j1<ncol; j1++  )
+for(  i=0; i<nrow; i++  )
+  if(  A[i][j1] < 0  || A[i][j1] >= q  ){
+    if(  verbose >= 2  ){
+      printf("Array is not even of strength 0, that is there are elements\n");
+      // BMA 20141204; added q-1 as argument to silence compiler warning
+      //printf("other than integers 0 through %d inclusive in it.\n");
+      printf("other than integers 0 through %d inclusive in it.\n", (q-1));
+      printf("The first exception is A[%d][%d] = %d.\n",i,j1,A[i][j1]);
+    }
+    return 0;
+  }
+if(  verbose >=2  )
+  printf("The array has strength (at least) 0.\n");
+return 1;
+}
+
+
+/* Check strength 1 */
+OA_str1( q,nrow,ncol,A,verbose   )
+int      q,nrow,ncol,**A, verbose;
+{
+int     i, j1, q1;
+int     lambda, count;
+double  work;
+
+if(  nrow%q  ){
+  if(  verbose >= 2  ){
+    printf("The array cannot have strength 1, because the number\n");
+    printf("of rows %d is not a multiple of q = %d.\n",nrow,q);
+  }
+  return 0;
+}
+
+lambda = nrow/q;
+work = nrow * ncol * q * 1.0;
+OA_strworkcheck( work,1 );
+for(  j1=0; j1<ncol; j1++  ){
+  for(  q1=0; q1<q; q1++  ){
+    count = 0;
+    for( i=0; i<nrow; i++  )
+      count += (A[i][j1]==q1);
+    if(  count != lambda   ){
+      if(  verbose >= 2  ){
+	printf("Array is not of strength 1.  The first violation arises for\n");
+	printf("the number of times A[,%d] = %d.\n",
+	       j1, q1);
+	printf("This happened in %d rows, it should have happened in %d rows.\n",
+	       count, lambda);
+      }
+      return 0;
+    }
+  }
+if(  work > MEDWORK && verbose > 0  )
+  fprintf(stderr,"No violation of strength 1 involves column %d.\n",j1);
+}
+if(  verbose >=2  )
+  printf("The array has strength (at least) 1.\n");
+return 1;
+}
+
+/* Check strength 2  */
+OA_str2( q,nrow,ncol,A,verbose   )
+int      q,nrow,ncol,**A, verbose;
+{
+int  i, j1,j2, q1,q2;
+int  lambda, count;
+double  work;
+
+if(  ncol<2  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"Array has only %d column(s).  At least two\n",ncol);
+    fprintf(stderr,"columns are necessary for strength 2 to make sense.\n");
+  }
+  return 0;
+}
+if(  nrow % (q*q)  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"The array cannot have strength 2, because the number\n");
+    fprintf(stderr,"of rows %d is not a multiple of q^2 = %d^2 = %d.\n",nrow,q,q*q);
+  }
+  return 0;
+}
+
+lambda = nrow/(q*q);
+work = nrow*ncol*(ncol-1.0)*q*q/2.0;
+OA_strworkcheck( work,2 );
+
+for(  j1=0;    j1<ncol; j1++  ){
+for(  j2=j1+1; j2<ncol; j2++  ){
+  for(  q1=0; q1<q; q1++  )
+  for(  q2=0; q2<q; q2++  ){
+    count = 0;
+    for( i=0; i<nrow; i++  )
+      count += (A[i][j1]==q1)&&(A[i][j2]==q2);
+    if(  count != lambda   ){
+      if(  verbose >= 2 ){
+	printf("Array is not of strength 2.  The first violation arises for\n");
+	printf("the number of times (A[,%d],A[,%d]) = (%d,%d).\n",
+	       j1,j2, q1,q2 );
+	printf("This happened in %d rows, it should have happened in %d rows.\n",
+	       count, lambda);
+      }
+      return 0;
+    }
+  }
+}
+if(  work > MEDWORK && verbose > 0 )
+  fprintf(stderr,"No violation of strength 2 involves column %d.\n",j1);
+}
+
+if(  verbose >=2  )
+  printf("The array has strength (at least) 2.\n");
+return 1;
+}
+
+
+
+/* Check strength 3  */
+OA_str3( q,nrow,ncol,A,verbose   )
+int      q,nrow,ncol,**A, verbose;
+{
+int  i, j1,j2,j3, q1,q2,q3;
+int  lambda, count;
+double  work;
+
+if(  ncol<3  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"Array has only %d column(s).  At least three\n",ncol);
+    fprintf(stderr,"columns are necessary for strength 3 to make sense.\n");
+  }
+  return 0;
+}
+if(  nrow % (q*q*q)  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"The array cannot have strength 3, because the number\n");
+    fprintf(stderr,"of rows %d is not a multiple of q^3 = %d^3 = %d.\n",nrow,q,q*q*q);
+  }
+  return 0;
+}
+
+lambda = nrow/(q*q*q);
+work = nrow*ncol*(ncol-1.0)*(ncol-2.0)*q*q*q/6.0;
+OA_strworkcheck( work,3 );
+
+for(  j1=0;    j1<ncol; j1++  ){
+for(  j2=j1+1; j2<ncol; j2++  )
+for(  j3=j2+1; j3<ncol; j3++  ){
+  for(  q1=0; q1<q; q1++  )
+  for(  q2=0; q2<q; q2++  )
+  for(  q3=0; q3<q; q3++  ){
+    count = 0;
+    for( i=0; i<nrow; i++  )
+      count += (A[i][j1]==q1)&&(A[i][j2]==q2)&&(A[i][j3]==q3);
+    if(  count != lambda   ){
+      if(  verbose >= 2 ){
+	printf("Array is not of strength 3.  The first violation arises for\n");
+	printf("the number of times (A[,%d],A[,%d],A[,%d]) = (%d,%d,%d).\n",
+	       j1,j2,j3,  q1,q2,q3 );
+	printf("This happened in %d rows, it should have happened in %d rows.\n",
+	       count, lambda);
+      }
+      return 0;
+    }
+  }
+}
+if(  work > MEDWORK && verbose > 0 )
+  fprintf(stderr,"No violation of strength 3 involves column %d.\n",j1);
+}
+if(  verbose >=2  )
+  printf("The array has strength (at least) 3.\n");
+return 1;
+}
+
+
+/* Check strength 4  */
+OA_str4( q,nrow,ncol,A,verbose   )
+int      q,nrow,ncol,**A, verbose;
+{
+int  i, j1,j2,j3,j4, q1,q2,q3,q4;
+int  lambda, count;
+double  work;
+
+if(  ncol<4  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"Array has only %d column(s).  At least four\n",ncol);
+    fprintf(stderr,"columns are necessary for strength 4 to make sense.\n");
+  }
+  return 0;
+}
+if(  nrow % (q*q*q*q)  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"The array cannot have strength 4, because the number\n");
+    fprintf(stderr,"of rows %d is not a multiple of q^4 = %d^4 = %d.\n",nrow,q,q*q*q*q);
+  }
+  return 0;
+}
+
+lambda = nrow/(q*q*q*q);
+work = nrow*ncol*(ncol-1.0)*(ncol-2.0)*(ncol-3.0)*q*q*q*q/24.0;
+OA_strworkcheck( work,4 );
+
+for(  j1=0;    j1<ncol; j1++  ){
+for(  j2=j1+1; j2<ncol; j2++  )
+for(  j3=j2+1; j3<ncol; j3++  )
+for(  j4=j3+1; j4<ncol; j4++  ){
+  for(  q1=0; q1<q; q1++  )
+  for(  q2=0; q2<q; q2++  )
+  for(  q3=0; q3<q; q3++  )
+  for(  q4=0; q4<q; q4++  ){
+    count = 0;
+    for( i=0; i<nrow; i++  )
+      count += (A[i][j1]==q1)&&(A[i][j2]==q2)&&(A[i][j3]==q3)&&(A[i][j4]==q4);
+    if(  count != lambda  ){
+      if(  verbose >= 2  ){
+	printf("Array is not of strength 4.  The first violation arises for\n");
+	printf("the number of times (A[,%d],A[,%d],A[,%d],A[,%d]) = (%d,%d,%d,%d).\n",
+	       j1,j2,j3,j4, q1,q2,q3,q4 );
+	printf("This happened in %d rows, it should have happened in %d rows.\n",
+	       count, lambda);
+      }
+      return 0;
+    }
+    }
+  }
+}
+if(  work > MEDWORK && verbose > 0 )
+  fprintf(stderr,"No violation of strength 4 involves column %d.\n",j1);
+
+if(  verbose >=2  )
+  printf("The array has strength (at least) 4.\n");
+return 1;
+}
+
+
+/* Check strength t  */
+OA_strt( q,nrow,ncol,A,t,verbose   )
+int      q,nrow,ncol,**A,t,verbose;
+{
+int  row, i, ic, iq, *clist, *qlist, ctuples, qtuples;
+int  lambda, count, match;
+double  work;
+
+if(  t<0  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"Don't know how to verify strength %d.  It doesn't\n",t);
+    fprintf(stderr,"make sense.\n");
+  }
+  return 0;
+}
+if(  ncol<t  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"Array has only %d column(s).  At least %d\n",ncol,t);
+    fprintf(stderr,"columns are necessary for strength %d to make sense.\n",t);
+  }
+  return 0;
+}
+if(  t==0  )
+  return OA_str0( q,nrow,ncol,A,verbose );
+if(  nrow % ipow(q,t)  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"The array cannot have strength %d, because the number\n",t);
+    fprintf(stderr,"of rows %d is not a multiple of q^%d = %d^%d = %d.\n",
+	    nrow,t,q,t,ipow(q,t));
+  }
+  return 0;
+}
+
+lambda = nrow/ipow(q,t);
+work   = nrow*ipow(q,t);
+ctuples = 1;
+
+clist = ivector( 0,t-1 );
+qlist = ivector( 0,t-1 );
+
+for(  i=0; i<t; i++  ){
+  work *= (ncol-i)/(i+1.0);
+  ctuples *= ncol-i;
+  qlist[i] = 0;
+  clist[i] = i;
+}
+for(  i=0; i<t; i++  )
+  ctuples /= (i+1);
+qtuples = ipow(q,t);
+
+OA_strworkcheck( work,t );
+
+for(  ic=0; ic<ctuples; ic++  ){   /* Loop over ordered tuples of columns */
+/*  for( i=0; i<t; i++  )
+    printf("%s %d%s",(i==0)?"Col":"",clist[i],(i==t-1)?"\n":" ");*/
+
+  for(  iq=0; iq<qtuples;   iq++  ){ /* Loop over unordered tuples of symbols */
+/*    for( i=0; i<t; i++  )
+      printf("  %s %d%s",(i==0)?"Sym":"",qlist[i],(i==t-1)?"\n":" ");*/
+    count = 0;
+    for( row=0; row<nrow; row++  ){
+      match = 1;
+      for(  i=0; i<t && match; i++  )
+	match *= A[row][clist[i]] == qlist[i];
+      count += match;
+    }
+    if(  count != lambda  ){
+      if(  verbose >= 2  ){
+	printf("Array is not of strength %d.  The first violation arises for\n",t);
+	printf("the number of times (");
+	for(  i=0; i<t; i++  )
+	  printf("A[,%d]%s",clist[i],(i==t-1)?")":",");
+	printf(" = (");
+	for(  i=0; i<t; i++  )
+	  printf("%d%s",qlist[i],(i==t-1)?").\n":",");
+	printf("This happened in %d rows, it should have happened in %d rows.\n",
+	       count, lambda);
+      }
+      return 0;
+    }
+    for( i=t-1; i>=0; i--  ){
+      qlist[i] = (qlist[i]+1) % q;
+      if(  qlist[i]  )break;
+    }
+  }
+
+  for( i= t-1; i>=0; i--  ){
+    clist[i] = (clist[i]+1) % (ncol+i-t+1);
+    if(  clist[i]  )break;
+  }
+
+  if(  work > MEDWORK && verbose > 0 && (t==1||t>1 && clist[1]==0)  )
+    fprintf(stderr,"No violation of strength %d involves column %d.\n",
+	    t,(clist[0]+ncol-1)%ncol);
+
+  for( i=1; i< t; i++  )
+    if(  clist[i] <= clist[i-1]  )
+      clist[i] = clist[i-1]+1;
+}
+
+if(  verbose >=2  )
+  printf("The array has strength (at least) %d.\n",t);
+
+/* Added by J Cramp on 07.02.04 to
+ * fix memory leak problems. */
+free_ivector(clist,0,t-1);
+free_ivector(qlist,0,t-1);
+
+return 1;
+}
+
+void OA_strength( q,nrow,ncol,A,str,verbose )
+int  q,nrow,ncol,**A,*str, verbose;
+/*
+     Calculate and return the strength of the array A.
+
+verbose = 0   =>   No printed output
+verbose = 1   =>   Only stderr output
+verbose = 2   =>   Output to both stdout and stderr
+
+*/
+{
+*str = -1;
+
+if(  OA_str0( q,nrow,ncol,A,verbose)   )
+  *str = 0;
+else
+  return;
+if(  OA_str1( q,nrow,ncol,A,verbose)   )
+  *str = 1;
+else
+  return;
+while( OA_strt( q,nrow,ncol,A,*str+1,verbose )  )
+  (*str)++;
+return;
+}
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/nidr/nidr-scanner.c
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/nidr/nidr-scanner.c	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/nidr/nidr-scanner.c	(revision 25745)
@@ -0,0 +1,2063 @@
+/* A lexical scanner generated by flex*/
+
+/* Scanner skeleton version:
+ * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
+ */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+
+#include <stdio.h>
+
+
+/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
+#ifdef c_plusplus
+#ifndef __cplusplus
+#define __cplusplus
+#endif
+#endif
+
+
+#ifdef __cplusplus
+
+#include <stdlib.h>
+
+/* Use prototypes in function declarations. */
+#define YY_USE_PROTOS
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else	/* ! __cplusplus */
+
+#if __STDC__
+
+#define YY_USE_PROTOS
+#define YY_USE_CONST
+
+#endif	/* __STDC__ */
+#endif	/* ! __cplusplus */
+
+#ifdef __TURBOC__
+ #pragma warn -rch
+ #pragma warn -use
+#include <io.h>
+#include <stdlib.h>
+#define YY_USE_CONST
+#define YY_USE_PROTOS
+#endif
+
+#ifdef YY_USE_CONST
+#define nidrconst const
+#else
+#define nidrconst
+#endif
+
+
+#ifdef YY_USE_PROTOS
+#define YY_PROTO(proto) proto
+#else
+#define YY_PROTO(proto) ()
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index.  If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition.  This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN nidr_start = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state.  The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START ((nidr_start - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE nidrrestart( nidrin )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#define YY_BUF_SIZE 16384
+
+typedef struct nidr_buffer_state *YY_BUFFER_STATE;
+
+extern int nidrleng;
+extern FILE *nidrin, *nidrout;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+/* The funky do-while in the following #define is used to turn the definition
+ * int a single C statement (which needs a semi-colon terminator).  This
+ * avoids problems with code like:
+ *
+ * 	if ( condition_holds )
+ *		nidrless( 5 );
+ *	else
+ *		do_something_else();
+ *
+ * Prior to using the do-while the compiler would get upset at the
+ * "else" because it interpreted the "if" statement as being all
+ * done when it reached the ';' after the nidrless() call.
+ */
+
+/* Return all but the first 'n' matched characters back to the input stream. */
+
+#define nidrless(n) \
+	do \
+		{ \
+		/* Undo effects of setting up nidrtext. */ \
+		*nidr_cp = nidr_hold_char; \
+		YY_RESTORE_YY_MORE_OFFSET \
+		nidr_c_buf_p = nidr_cp = nidr_bp + n - YY_MORE_ADJ; \
+		YY_DO_BEFORE_ACTION; /* set up nidrtext again */ \
+		} \
+	while ( 0 )
+
+#define unput(c) nidrunput( c, nidrtext_ptr )
+
+/* Some routines like nidr_flex_realloc() are emitted as static but are
+   not called by all lexers. This generates warnings in some compilers,
+   notably GCC. Arrange to suppress these. */
+#ifdef __GNUC__
+#define YY_MAY_BE_UNUSED __attribute__((unused))
+#else
+#define YY_MAY_BE_UNUSED
+#endif
+
+/* The following is because we cannot portably get our hands on size_t
+ * (without autoconf's help, which isn't available because we want
+ * flex-generated scanners to compile on their own).
+ */
+typedef unsigned int nidr_size_t;
+
+
+struct nidr_buffer_state
+	{
+	FILE *nidr_input_file;
+
+	char *nidr_ch_buf;		/* input buffer */
+	char *nidr_buf_pos;		/* current position in input buffer */
+
+	/* Size of input buffer in bytes, not including room for EOB
+	 * characters.
+	 */
+	nidr_size_t nidr_buf_size;
+
+	/* Number of characters read into nidr_ch_buf, not including EOB
+	 * characters.
+	 */
+	int nidr_n_chars;
+
+	/* Whether we "own" the buffer - i.e., we know we created it,
+	 * and can realloc() it to grow it, and should free() it to
+	 * delete it.
+	 */
+	int nidr_is_our_buffer;
+
+	/* Whether this is an "interactive" input source; if so, and
+	 * if we're using stdio for input, then we want to use getc()
+	 * instead of fread(), to make sure we stop fetching input after
+	 * each newline.
+	 */
+	int nidr_is_interactive;
+
+	/* Whether we're considered to be at the beginning of a line.
+	 * If so, '^' rules will be active on the next match, otherwise
+	 * not.
+	 */
+	int nidr_at_bol;
+
+	/* Whether to try to fill the input buffer when we reach the
+	 * end of it.
+	 */
+	int nidr_fill_buffer;
+
+	int nidr_buffer_status;
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+	/* When an EOF's been seen but there's still some text to process
+	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+	 * shouldn't try reading from the input source any more.  We might
+	 * still have a bunch of tokens to match, though, because of
+	 * possible backing-up.
+	 *
+	 * When we actually see the EOF, we change the status to "new"
+	 * (via nidrrestart()), so that the user can continue scanning by
+	 * just pointing nidrin at a new input file.
+	 */
+#define YY_BUFFER_EOF_PENDING 2
+	};
+
+static YY_BUFFER_STATE nidr_current_buffer = 0;
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ */
+#define YY_CURRENT_BUFFER nidr_current_buffer
+
+
+/* nidr_hold_char holds the character lost when nidrtext is formed. */
+static char nidr_hold_char;
+
+static int nidr_n_chars;		/* number of characters read into nidr_ch_buf */
+
+
+int nidrleng;
+
+/* Points to current character in buffer. */
+static char *nidr_c_buf_p = (char *) 0;
+static int nidr_init = 1;		/* whether we need to initialize */
+static int nidr_start = 0;	/* start state number */
+
+/* Flag which is used to allow nidrwrap()'s to do buffer switches
+ * instead of setting up a fresh nidrin.  A bit of a hack ...
+ */
+static int nidr_did_buffer_switch_on_eof;
+
+void nidrrestart YY_PROTO(( FILE *input_file ));
+
+void nidr_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
+void nidr_load_buffer_state YY_PROTO(( void ));
+YY_BUFFER_STATE nidr_create_buffer YY_PROTO(( FILE *file, int size ));
+void nidr_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+void nidr_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
+void nidr_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+#define YY_FLUSH_BUFFER nidr_flush_buffer( nidr_current_buffer )
+
+YY_BUFFER_STATE nidr_scan_buffer YY_PROTO(( char *base, nidr_size_t size ));
+YY_BUFFER_STATE nidr_scan_string YY_PROTO(( nidrconst char *nidr_str ));
+YY_BUFFER_STATE nidr_scan_bytes YY_PROTO(( nidrconst char *bytes, int len ));
+
+static void *nidr_flex_alloc YY_PROTO(( nidr_size_t ));
+static void *nidr_flex_realloc YY_PROTO(( void *, nidr_size_t )) YY_MAY_BE_UNUSED;
+static void nidr_flex_free YY_PROTO(( void * ));
+
+#define nidr_new_buffer nidr_create_buffer
+
+#define nidr_set_interactive(is_interactive) \
+	{ \
+	if ( ! nidr_current_buffer ) \
+		nidr_current_buffer = nidr_create_buffer( nidrin, YY_BUF_SIZE ); \
+	nidr_current_buffer->nidr_is_interactive = is_interactive; \
+	}
+
+#define nidr_set_bol(at_bol) \
+	{ \
+	if ( ! nidr_current_buffer ) \
+		nidr_current_buffer = nidr_create_buffer( nidrin, YY_BUF_SIZE ); \
+	nidr_current_buffer->nidr_at_bol = at_bol; \
+	}
+
+#define YY_AT_BOL() (nidr_current_buffer->nidr_at_bol)
+
+typedef unsigned char YY_CHAR;
+FILE *nidrin = (FILE *) 0, *nidrout = (FILE *) 0;
+typedef int nidr_state_type;
+extern char *nidrtext;
+#define nidrtext_ptr nidrtext
+
+static nidr_state_type nidr_get_previous_state YY_PROTO(( void ));
+static nidr_state_type nidr_try_NUL_trans YY_PROTO(( nidr_state_type current_state ));
+static int nidr_get_next_buffer YY_PROTO(( void ));
+static void nidr_fatal_error YY_PROTO(( nidrconst char msg[] ));
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up nidrtext.
+ */
+#define YY_DO_BEFORE_ACTION \
+	nidrtext_ptr = nidr_bp; \
+	nidrtext_ptr -= nidr_more_len; \
+	nidrleng = (int) (nidr_cp - nidrtext_ptr); \
+	nidr_hold_char = *nidr_cp; \
+	*nidr_cp = '\0'; \
+	nidr_c_buf_p = nidr_cp;
+
+#define YY_NUM_RULES 27
+#define YY_END_OF_BUFFER 28
+static nidrconst short int nidr_accept[125] =
+    {   0,
+        0,    0,    0,    0,   21,   21,   18,   18,   28,    6,
+        5,    2,   25,    4,    3,    3,    6,   16,   12,    2,
+       15,   25,   13,   26,   16,    8,   16,    9,   14,    7,
+       11,   11,   11,   16,   21,   21,   22,   22,   21,   21,
+       18,   18,   19,   18,   19,   18,    5,   25,    0,   25,
+       25,    4,   24,    3,    3,    0,   23,   12,    8,    7,
+        0,    9,    0,    0,   10,    9,    9,    9,    7,   11,
+       11,   11,   21,   21,   21,   21,   20,   21,   21,   21,
+       18,   18,   18,   18,   18,   18,   17,   18,   24,    3,
+        0,    0,   10,   10,    9,   10,    9,    9,   10,   10,
+
+       10,   21,   18,    1,   10,   10,   10,   10,   10,    9,
+       10,   11,    0,   10,   10,   11,    0,   11,    0,   11,
+        0,   10,   10,    0
+    } ;
+
+static nidrconst int nidr_ec[256] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    2,    1,    4,    5,    1,    1,    1,    6,    1,
+        1,    7,    8,    9,   10,   11,    1,   12,   12,   12,
+       12,   12,   12,   12,   12,   12,   12,    7,   13,    1,
+       14,    1,    1,   15,   16,   17,   17,   17,   18,   19,
+       17,   17,   20,   17,   17,   17,   17,   21,   17,   17,
+       17,   17,   17,   22,   17,   17,   17,   23,   24,   17,
+        1,   25,    1,    1,   26,    1,   16,   17,   17,   17,
+
+       18,   19,   17,   17,   20,   17,   17,   17,   17,   21,
+       17,   17,   17,   17,   17,   22,   17,   17,   17,   23,
+       24,   17,    1,    1,    1,   15,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1
+    } ;
+
+static nidrconst int nidr_meta[27] =
+    {   0,
+        1,    1,    2,    3,    1,    4,    1,    5,    1,    6,
+        6,    6,    1,    1,    7,    6,    6,    6,    6,    6,
+        6,    6,    6,    6,    1,    6
+    } ;
+
+static nidrconst short int nidr_base[137] =
+    {   0,
+        0,    0,   26,    0,   51,   75,   99,  123,  263,  264,
+       56,  264,   57,  264,    0,  239,   57,  264,  147,  264,
+      264,  236,  264,  264,  162,  264,  248,   53,  264,  257,
+        0,  237,  241,   64,    0,   67,  264,  252,   59,   71,
+        0,   81,  264,   62,  249,   86,   88,  229,   92,  228,
+       86,  227,  249,    0,  230,   94,  264,    0,  264,  247,
+      236,   96,  226,  230,   91,  233,   98,  107,  242,    0,
+      224,  212,    0,  116,  108,  120,  264,  126,  226,  129,
+        0,  132,  114,  133,  121,  224,  264,  140,  217,  191,
+      193,  178,  169,  150,  168,  126,  155,  167,  166,  157,
+
+        0,  174,  173,    0,  151,  264,  158,  157,  156,  147,
+      143,  133,  132,  138,  135,  125,  120,   76,   63,   51,
+       33,    0,  264,  264,  183,  190,  197,  199,  202,  203,
+      210,  217,  224,  231,  234,  236
+    } ;
+
+static nidrconst short int nidr_def[137] =
+    {   0,
+      124,    1,  124,    3,  125,  125,  126,  126,  124,  124,
+      124,  124,  127,  124,  128,  128,  124,  124,  124,  124,
+      124,  127,  124,  124,  124,  124,  124,  129,  124,  124,
+      130,  130,  130,  124,  131,  131,  124,  124,  132,  131,
+      133,  133,  124,  134,  124,  133,  124,  127,  124,  127,
+      127,  127,  124,  128,  128,  124,  124,   19,  124,  124,
+      124,  129,  124,  124,  135,  129,  136,  129,  124,  130,
+      130,  130,  131,  131,  132,  131,  124,  132,  131,  131,
+      133,  133,  134,  133,  134,  133,  124,  133,  124,  128,
+      124,  124,  135,  135,  136,  135,  136,  129,  135,  130,
+
+      130,  131,  133,  128,  124,  124,  135,  135,  135,  136,
+      135,  130,  124,  135,  135,  130,  124,  130,  124,  130,
+      124,  130,  124,    0,  124,  124,  124,  124,  124,  124,
+      124,  124,  124,  124,  124,  124
+    } ;
+
+static nidrconst short int nidr_nxt[291] =
+    {   0,
+       10,   11,   12,   10,   13,   10,   10,   10,   10,   10,
+       10,   10,   14,   10,   10,   15,   15,   16,   15,   15,
+       15,   15,   15,   15,   17,   10,   18,   19,   20,   21,
+       22,   23,   24,   25,   26,   25,   27,   28,   29,   30,
+       18,   31,   31,   31,   31,   32,   33,   31,   31,   31,
+       34,   18,   36,   37,   38,   39,  123,   47,   56,   57,
+       48,   51,   50,   67,   62,   56,   57,   50,   74,   52,
+       68,   75,   80,   57,  122,   40,   36,   37,   38,   39,
+       49,   53,   82,   79,  121,   83,   86,   88,   57,   47,
+       51,   76,   48,   56,   57,   56,   57,  120,   52,   40,
+
+       42,   43,   65,   44,   45,   84,   67,   62,   94,   96,
+       53,   50,   49,   68,   98,   97,   98,   74,   99,   50,
+       75,   80,   57,   46,   42,   43,   50,   44,   45,   50,
+       80,   57,   79,   82,   88,   57,   83,   96,   86,  119,
+       76,   88,   57,  109,  118,   86,  115,   46,   58,  115,
+       79,   48,  117,  116,  111,   59,   84,  107,  111,  107,
+       60,  108,  110,  114,  110,  114,  111,  115,  108,  108,
+      113,   49,   61,   62,  103,  102,  112,   99,   99,  124,
+      124,   63,   64,   35,   35,   35,   35,   35,   35,   35,
+       41,   41,   41,   41,   41,   41,   41,   50,  106,   50,
+
+       50,   50,   50,   50,   54,   54,   66,   66,   70,   70,
+       73,  105,  104,   73,   73,   73,   73,   78,   89,   78,
+       78,   78,   78,   78,   81,  103,   81,  102,   81,   81,
+       81,   85,  101,   85,   85,   85,   85,   85,   93,   93,
+       95,   95,  100,   69,  124,   92,   91,   65,   69,   90,
+       89,   53,   53,   53,   87,   77,   72,   71,   69,   65,
+       53,   55,  124,    9,  124,  124,  124,  124,  124,  124,
+      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
+      124,  124,  124,  124,  124,  124,  124,  124,  124,  124
+    } ;
+
+static nidrconst short int nidr_chk[291] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    3,    3,    3,    3,
+        3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
+        3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
+        3,    3,    5,    5,    5,    5,  121,   11,   17,   17,
+       11,   13,   39,   28,   28,   34,   34,   44,   36,   13,
+       28,   36,   40,   40,  120,    5,    6,    6,    6,    6,
+       11,   13,   42,   39,  119,   42,   44,   46,   46,   47,
+       51,   36,   47,   49,   49,   56,   56,  118,   51,    6,
+
+        7,    7,   65,    7,    7,   42,   62,   62,   65,   67,
+       51,   75,   47,   62,   68,   67,   68,   74,   68,   83,
+       74,   76,   76,    7,    8,    8,   85,    8,    8,   78,
+       80,   80,   75,   82,   84,   84,   82,   96,   83,  117,
+       74,   88,   88,   96,  116,   85,  115,    8,   19,  114,
+       78,   19,  113,  112,  111,   19,   82,   94,  110,   94,
+       19,   94,   97,  109,   97,  109,   97,  109,  108,  107,
+      105,   19,   25,   25,  103,  102,  100,   99,   98,   95,
+       93,   25,   25,  125,  125,  125,  125,  125,  125,  125,
+      126,  126,  126,  126,  126,  126,  126,  127,   92,  127,
+
+      127,  127,  127,  127,  128,  128,  129,  129,  130,  130,
+      131,   91,   90,  131,  131,  131,  131,  132,   89,  132,
+      132,  132,  132,  132,  133,   86,  133,   79,  133,  133,
+      133,  134,   72,  134,  134,  134,  134,  134,  135,  135,
+      136,  136,   71,   69,   66,   64,   63,   61,   60,   55,
+       53,   52,   50,   48,   45,   38,   33,   32,   30,   27,
+       22,   16,    9,  124,  124,  124,  124,  124,  124,  124,
+      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
+      124,  124,  124,  124,  124,  124,  124,  124,  124,  124
+    } ;
+
+static nidr_state_type nidr_last_accepting_state;
+static char *nidr_last_accepting_cpos;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+static int nidr_more_flag = 0;
+static int nidr_more_len = 0;
+#define nidrmore() (nidr_more_flag = 1)
+#define YY_MORE_ADJ nidr_more_len
+#define YY_RESTORE_YY_MORE_OFFSET
+char *nidrtext;
+/* #line 1 "nidrscan.l" */
+#define INITIAL 0
+/* #line 2 "nidrscan.l" */
+/*********************************************************************
+Copyright 2008, 2010 Sandia Corporation.  Under the terms of Contract
+DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
+retains certain rights in this software.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+* Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+* Neither the name of Sandia Corporation nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+***********************************************************************/
+
+#ifndef NIDR_H
+#include "nidr.h"
+#endif
+#ifndef NIDR_PARSER_H
+#include "nidr-parser.h"
+#endif
+#include <stdlib.h>	/* possibly redundant, but necessary for strtod on some systems */
+
+static int my_nidr_input(char*, int);
+extern char *nidr_KWscopy(const char*);
+
+#ifdef IDR_DEBUG
+static void print_token( char*, char*, char* );
+#else
+#define print_token(a,b,c) /*nothing*/
+#endif
+
+
+#define YY_INPUT(buf,result,maxsize) result = my_nidr_input(buf,maxsize)
+
+int	nidrLineNumber = 1;
+
+extern void	nidr_abort(void);
+extern void	(*nidr_comment)(const char*);
+extern KeyWord *(*nidr_identifier)(const char*);
+extern KeyWord *nidr_keyword(const char*);
+extern const char *nidr_keyword_name(void);
+/* Hardwire the now rarely used help text.  It truly is something the
+   application should provide, not NIDR, but had trouble with the
+   declaration/definition w.r.t. MSVS when building DAKOTA source.
+   Ultimately would want to pass it into nidr_parse(...) 
+extern char	nidr_please_refer[];
+*/
+char nidr_please_refer[] = 
+  "Please refer to the input specification reference for this application.";
+extern void	nidr_tolower(char*);
+static void	bad_number(const char*);
+static void	unput_string(char *, int);
+#define DATA 1
+
+#define DQ_STRING 2
+
+#define Q_STRING 3
+
+/* #line 545 "nidr-scanner.c" */
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int nidrwrap YY_PROTO(( void ));
+#else
+extern int nidrwrap YY_PROTO(( void ));
+#endif
+#endif
+
+#ifndef YY_NO_UNPUT
+static void nidrunput YY_PROTO(( int c, char *buf_ptr ));
+#endif
+
+#ifndef nidrtext_ptr
+static void nidr_flex_strncpy YY_PROTO(( char *, nidrconst char *, int ));
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int nidr_flex_strlen YY_PROTO(( nidrconst char * ));
+#endif
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+static int nidrinput YY_PROTO(( void ));
+#else
+static int input YY_PROTO(( void ));
+#endif
+#endif
+
+#if YY_STACK_USED
+static int nidr_start_stack_ptr = 0;
+static int nidr_start_stack_depth = 0;
+static int *nidr_start_stack = 0;
+#ifndef YY_NO_PUSH_STATE
+static void nidr_push_state YY_PROTO(( int new_state ));
+#endif
+#ifndef YY_NO_POP_STATE
+static void nidr_pop_state YY_PROTO(( void ));
+#endif
+#ifndef YY_NO_TOP_STATE
+static int nidr_top_state YY_PROTO(( void ));
+#endif
+
+#else
+#define YY_NO_PUSH_STATE 1
+#define YY_NO_POP_STATE 1
+#define YY_NO_TOP_STATE 1
+#endif
+
+#ifdef YY_MALLOC_DECL
+YY_MALLOC_DECL
+#else
+#if __STDC__
+#ifndef __cplusplus
+#include <stdlib.h>
+#endif
+#else
+/* Just try to get by without declaring the routines.  This will fail
+ * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
+ * or sizeof(void*) != sizeof(int).
+ */
+#endif
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO (void) fwrite( nidrtext, nidrleng, 1, nidrout )
+#endif
+
+/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+	if ( nidr_current_buffer->nidr_is_interactive ) \
+		{ \
+		int c = '*', n; \
+		for ( n = 0; n < max_size && \
+			     (c = getc( nidrin )) != EOF && c != '\n'; ++n ) \
+			buf[n] = (char) c; \
+		if ( c == '\n' ) \
+			buf[n++] = (char) c; \
+		if ( c == EOF && ferror( nidrin ) ) \
+			YY_FATAL_ERROR( "input in flex scanner failed" ); \
+		result = n; \
+		} \
+	else if ( ((result = fread( buf, 1, max_size, nidrin )) == 0) \
+		  && ferror( nidrin ) ) \
+		YY_FATAL_ERROR( "input in flex scanner failed" );
+#endif
+
+/* No semi-colon after return; correct usage is to write "nidrterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef nidrterminate
+#define nidrterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) nidr_fatal_error( msg )
+#endif
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL int nidrlex YY_PROTO(( void ))
+#endif
+
+/* Code executed at the beginning of each rule, after nidrtext and nidrleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+	YY_USER_ACTION
+
+YY_DECL
+	{
+	register nidr_state_type nidr_current_state;
+	register char *nidr_cp = NULL, *nidr_bp = NULL;
+	register int nidr_act;
+
+/* #line 85 "nidrscan.l" */
+
+
+
+	KeyWord	*identifier, *keyword;
+	char *se;
+
+
+/* #line 704 "nidr-scanner.c" */
+
+	if ( nidr_init )
+		{
+		nidr_init = 0;
+
+#ifdef YY_USER_INIT
+		YY_USER_INIT;
+#endif
+
+		if ( ! nidr_start )
+			nidr_start = 1;	/* first start state */
+
+		if ( ! nidrin )
+			nidrin = stdin;
+
+		if ( ! nidrout )
+			nidrout = stdout;
+
+		if ( ! nidr_current_buffer )
+			nidr_current_buffer =
+				nidr_create_buffer( nidrin, YY_BUF_SIZE );
+
+		nidr_load_buffer_state();
+		}
+
+	while ( 1 )		/* loops until end-of-file is reached */
+		{
+		nidr_more_len = 0;
+		if ( nidr_more_flag )
+			{
+			nidr_more_len = nidr_c_buf_p - nidrtext_ptr;
+			nidr_more_flag = 0;
+			}
+		nidr_cp = nidr_c_buf_p;
+
+		/* Support of nidrtext. */
+		*nidr_cp = nidr_hold_char;
+
+		/* nidr_bp points to the position in nidr_ch_buf of the start of
+		 * the current run.
+		 */
+		nidr_bp = nidr_cp;
+
+		nidr_current_state = nidr_start;
+nidr_match:
+		do
+			{
+			register YY_CHAR nidr_c = nidr_ec[YY_SC_TO_UI(*nidr_cp)];
+			if ( nidr_accept[nidr_current_state] )
+				{
+				nidr_last_accepting_state = nidr_current_state;
+				nidr_last_accepting_cpos = nidr_cp;
+				}
+			while ( nidr_chk[nidr_base[nidr_current_state] + nidr_c] != nidr_current_state )
+				{
+				nidr_current_state = (int) nidr_def[nidr_current_state];
+				if ( nidr_current_state >= 125 )
+					nidr_c = nidr_meta[(unsigned int) nidr_c];
+				}
+			nidr_current_state = nidr_nxt[nidr_base[nidr_current_state] + (unsigned int) nidr_c];
+			++nidr_cp;
+			}
+		while ( nidr_base[nidr_current_state] != 264 );
+
+nidr_find_action:
+		nidr_act = nidr_accept[nidr_current_state];
+		if ( nidr_act == 0 )
+			{ /* have to back up */
+			nidr_cp = nidr_last_accepting_cpos;
+			nidr_current_state = nidr_last_accepting_state;
+			nidr_act = nidr_accept[nidr_current_state];
+			}
+
+		YY_DO_BEFORE_ACTION;
+
+
+do_action:	/* This label is used only to access EOF actions. */
+
+
+		switch ( nidr_act )
+	{ /* beginning of action switch */
+			case 0: /* must back up */
+			/* undo the effects of YY_DO_BEFORE_ACTION */
+			*nidr_cp = nidr_hold_char;
+			nidr_cp = nidr_last_accepting_cpos;
+			nidr_current_state = nidr_last_accepting_state;
+			goto nidr_find_action;
+
+case 1:
+YY_RULE_SETUP
+/* #line 92 "nidrscan.l" */
+{
+			print_token("exit", NULL, "<INITIAL>" );
+			return 0;
+			}
+	YY_BREAK
+case 2:
+YY_RULE_SETUP
+/* #line 97 "nidrscan.l" */
+{
+			if (nidr_comment)
+				nidr_comment(nidrtext);
+			nidrLineNumber++;
+			}
+	YY_BREAK
+case 3:
+YY_RULE_SETUP
+/* #line 103 "nidrscan.l" */
+{
+			nidr_tolower(nidrtext);
+			keyword = nidr_keyword(nidrtext);
+
+			if  (keyword) {
+				print_token( "keyword", (char*) nidrtext, "<INITIAL>" );
+				if (keyword->kind & KWKind_Dynmult)
+					return END;
+				nidrlval.keyword = keyword;
+				BEGIN DATA;
+				return KEY_WORD;
+				}
+			print_token( "error", (char*) nidrtext, "<INITIAL>" );
+			nidrlval.string = nidrtext;
+			return KEYWORDERROR;
+			}
+	YY_BREAK
+case 4:
+YY_RULE_SETUP
+/* #line 120 "nidrscan.l" */
+{
+			if (*nidrtext == '#') {
+				if (nidr_comment)
+					nidr_comment(nidrtext);
+				}
+			else {
+				print_token( "end", NULL, "<INITIAL>" );
+				return END;
+				}
+			}
+	YY_BREAK
+case 5:
+YY_RULE_SETUP
+/* #line 131 "nidrscan.l" */
+{ print_token( "whitespace", (char*) nidrtext, "<INITIAL>" ); }
+	YY_BREAK
+case 6:
+YY_RULE_SETUP
+/* #line 133 "nidrscan.l" */
+{
+			print_token( "word", (char*) nidrtext, "<INITIAL>" );
+			nidrlval.string = nidr_KWscopy(nidrtext);
+			return STRING;
+			}
+	YY_BREAK
+case 7:
+YY_RULE_SETUP
+/* #line 138 "nidrscan.l" */
+{
+			print_token( "equals", NULL, "<DATA>" );
+			return EQUALS;
+			}
+	YY_BREAK
+case 8:
+YY_RULE_SETUP
+/* #line 142 "nidrscan.l" */
+{
+			print_token( "separator", NULL, "<DATA>" );
+			return SEPARATOR;
+			}
+	YY_BREAK
+case 9:
+YY_RULE_SETUP
+/* #line 146 "nidrscan.l" */
+{
+			print_token( "integer", (char*) nidrtext, "<DATA>" );
+			/* The following, old way has trouble with */
+			/* big floating-point numbers written without */
+			/* a decimal point */
+			/* nidrlval.integer = (int) atoi( (char*) nidrtext ); */
+			/* return INTEGER; */
+			nidrlval.real = strtod(nidrtext,&se);
+			if (*se)
+				bad_number(nidrtext);
+			return REAL;
+			}
+	YY_BREAK
+case 10:
+YY_RULE_SETUP
+/* #line 158 "nidrscan.l" */
+{
+			print_token( "real", (char*) nidrtext, "<DATA>" );
+			nidrlval.real = strtod(nidrtext,&se);
+			if (*se)
+				bad_number(nidrtext);
+			return REAL;
+			}
+	YY_BREAK
+case 11:
+YY_RULE_SETUP
+/* #line 165 "nidrscan.l" */
+{
+			nidr_tolower(nidrtext);
+			if (nidr_keyword(nidrtext)) {
+				unput_string(nidrtext, nidrleng);
+				BEGIN INITIAL;
+				return END;
+				}
+			identifier = nidr_identifier(nidrtext);
+
+			if (identifier) {
+				print_token( "identifier", (char*) nidrtext, "<DATA>");
+
+				nidrlval.identifier = identifier;
+				return IDENTIFIER;
+				}
+			else {
+				print_token( "word", (char*) nidrtext, "<DATA>" );
+				fprintf(stderr,"\n\tunrecognized identifier '%s'\n", nidrtext);
+				fprintf(stderr,"\tinput line %d, within %s keyword.\n",
+						nidrLineNumber, nidr_keyword_name());
+				fprintf(stderr, "%s\n", nidr_please_refer);
+				nidr_abort();
+				nidrlval.string = nidr_KWscopy(nidrtext);
+				return STRING;
+				}
+			}
+	YY_BREAK
+case 12:
+YY_RULE_SETUP
+/* #line 192 "nidrscan.l" */
+{ print_token( "whitespace", (char*) nidrtext, "<DATA>" ); }
+	YY_BREAK
+case 13:
+YY_RULE_SETUP
+/* #line 194 "nidrscan.l" */
+{
+			print_token( "opening quote", NULL, "<DATA>" );
+			BEGIN Q_STRING;
+			}
+	YY_BREAK
+case 14:
+YY_RULE_SETUP
+/* #line 198 "nidrscan.l" */
+{
+			print_token( "end", NULL, "<DATA>" );
+			BEGIN INITIAL;
+			return END;
+			}
+	YY_BREAK
+case 15:
+YY_RULE_SETUP
+/* #line 203 "nidrscan.l" */
+{
+			print_token( "double quote", NULL, "<DATA>" );
+			BEGIN DQ_STRING;
+			}
+	YY_BREAK
+case 16:
+YY_RULE_SETUP
+/* #line 207 "nidrscan.l" */
+{
+			print_token( "word", (char*) nidrtext, "<DATA>" );
+			fprintf(stderr, "Input line %d:  '%s' unexpected.\n",
+				nidrLineNumber, nidrtext);
+			nidr_abort();
+			nidrlval.string = nidr_KWscopy(nidrtext);
+			return STRING;
+			}
+	YY_BREAK
+case 17:
+YY_RULE_SETUP
+/* #line 215 "nidrscan.l" */
+{
+			print_token( "q:repeated quote", NULL, "<Q_STRING>" );
+			nidrtext[--nidrleng] = 0;
+			nidrmore();
+			}
+	YY_BREAK
+case 18:
+YY_RULE_SETUP
+/* #line 220 "nidrscan.l" */
+{
+			nidrmore();
+			print_token( "q:text", (char*) nidrtext, "<Q_STRING>" );
+			}
+	YY_BREAK
+case 19:
+YY_RULE_SETUP
+/* #line 224 "nidrscan.l" */
+{
+			print_token( "closing quote", NULL, "<Q_STRING>" );
+			if (nidrtext[--nidrleng] == '\n')
+				unput('\n');
+			nidrtext[nidrleng] = 0;
+			print_token( "quoted string", (char*) nidrtext, "<Q_STRING>" );
+			nidrlval.qstring = nidr_KWscopy(nidrtext);
+			BEGIN DATA;
+			return QUOTED_STRING;
+			}
+	YY_BREAK
+case 20:
+YY_RULE_SETUP
+/* #line 234 "nidrscan.l" */
+{
+			print_token( "q:repeated double quote", NULL, "<DQ_STRING>" );
+			nidrtext[--nidrleng] = 0;
+			nidrmore();
+			}
+	YY_BREAK
+case 21:
+YY_RULE_SETUP
+/* #line 239 "nidrscan.l" */
+{
+			nidrmore();
+			print_token( "q:text", (char*) nidrtext, "<DQ_STRING>" );
+			}
+	YY_BREAK
+case 22:
+YY_RULE_SETUP
+/* #line 243 "nidrscan.l" */
+{
+			print_token( "closing double quote", NULL, "<DQ_STRING>" );
+			if (nidrtext[--nidrleng] == '\n')
+				unput('\n');
+			nidrtext[nidrleng] = 0;
+			print_token( "quoted string", (char*) nidrtext, "<DQ_STRING>" );
+			nidrlval.qstring = nidr_KWscopy(nidrtext);
+			BEGIN DATA;
+			return QUOTED_STRING;
+			}
+	YY_BREAK
+case 23:
+YY_RULE_SETUP
+/* #line 253 "nidrscan.l" */
+{
+			print_token( "newline", NULL, NULL );
+			if (nidr_comment)
+				nidr_comment(nidrtext);
+			nidrLineNumber++;
+			}
+	YY_BREAK
+case 24:
+YY_RULE_SETUP
+/* #line 259 "nidrscan.l" */
+{
+			if (nidr_comment)
+				nidr_comment(nidrtext);
+			print_token( "comment - escaped newline", (char*) nidrtext, "<INITIAL>" );
+			unput( '\\' );
+			}
+	YY_BREAK
+case 25:
+YY_RULE_SETUP
+/* #line 265 "nidrscan.l" */
+{
+			if (nidr_comment)
+				nidr_comment(nidrtext);
+			print_token( "comment", (char*) nidrtext, "<INITIAL>" );
+			}
+	YY_BREAK
+case 26:
+YY_RULE_SETUP
+/* #line 270 "nidrscan.l" */
+{ return nidrtext[0]; }
+	YY_BREAK
+case 27:
+YY_RULE_SETUP
+/* #line 272 "nidrscan.l" */
+ECHO;
+	YY_BREAK
+/* #line 1074 "nidr-scanner.c" */
+case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(DATA):
+case YY_STATE_EOF(DQ_STRING):
+case YY_STATE_EOF(Q_STRING):
+	nidrterminate();
+
+	case YY_END_OF_BUFFER:
+		{
+		/* Amount of text matched not including the EOB char. */
+		int nidr_amount_of_matched_text = (int) (nidr_cp - nidrtext_ptr) - 1;
+
+		/* Undo the effects of YY_DO_BEFORE_ACTION. */
+		*nidr_cp = nidr_hold_char;
+		YY_RESTORE_YY_MORE_OFFSET
+
+		if ( nidr_current_buffer->nidr_buffer_status == YY_BUFFER_NEW )
+			{
+			/* We're scanning a new file or input source.  It's
+			 * possible that this happened because the user
+			 * just pointed nidrin at a new source and called
+			 * nidrlex().  If so, then we have to assure
+			 * consistency between nidr_current_buffer and our
+			 * globals.  Here is the right place to do so, because
+			 * this is the first action (other than possibly a
+			 * back-up) that will match for the new input source.
+			 */
+			nidr_n_chars = nidr_current_buffer->nidr_n_chars;
+			nidr_current_buffer->nidr_input_file = nidrin;
+			nidr_current_buffer->nidr_buffer_status = YY_BUFFER_NORMAL;
+			}
+
+		/* Note that here we test for nidr_c_buf_p "<=" to the position
+		 * of the first EOB in the buffer, since nidr_c_buf_p will
+		 * already have been incremented past the NUL character
+		 * (since all states make transitions on EOB to the
+		 * end-of-buffer state).  Contrast this with the test
+		 * in input().
+		 */
+		if ( nidr_c_buf_p <= &nidr_current_buffer->nidr_ch_buf[nidr_n_chars] )
+			{ /* This was really a NUL. */
+			nidr_state_type nidr_next_state;
+
+			nidr_c_buf_p = nidrtext_ptr + nidr_amount_of_matched_text;
+
+			nidr_current_state = nidr_get_previous_state();
+
+			/* Okay, we're now positioned to make the NUL
+			 * transition.  We couldn't have
+			 * nidr_get_previous_state() go ahead and do it
+			 * for us because it doesn't know how to deal
+			 * with the possibility of jamming (and we don't
+			 * want to build jamming into it because then it
+			 * will run more slowly).
+			 */
+
+			nidr_next_state = nidr_try_NUL_trans( nidr_current_state );
+
+			nidr_bp = nidrtext_ptr + YY_MORE_ADJ;
+
+			if ( nidr_next_state )
+				{
+				/* Consume the NUL. */
+				nidr_cp = ++nidr_c_buf_p;
+				nidr_current_state = nidr_next_state;
+				goto nidr_match;
+				}
+
+			else
+				{
+				nidr_cp = nidr_c_buf_p;
+				goto nidr_find_action;
+				}
+			}
+
+		else switch ( nidr_get_next_buffer() )
+			{
+			case EOB_ACT_END_OF_FILE:
+				{
+				nidr_did_buffer_switch_on_eof = 0;
+
+				if ( nidrwrap() )
+					{
+					/* Note: because we've taken care in
+					 * nidr_get_next_buffer() to have set up
+					 * nidrtext, we can now set up
+					 * nidr_c_buf_p so that if some total
+					 * hoser (like flex itself) wants to
+					 * call the scanner after we return the
+					 * YY_NULL, it'll still work - another
+					 * YY_NULL will get returned.
+					 */
+					nidr_c_buf_p = nidrtext_ptr + YY_MORE_ADJ;
+
+					nidr_act = YY_STATE_EOF(YY_START);
+					goto do_action;
+					}
+
+				else
+					{
+					if ( ! nidr_did_buffer_switch_on_eof )
+						YY_NEW_FILE;
+					}
+				break;
+				}
+
+			case EOB_ACT_CONTINUE_SCAN:
+				nidr_c_buf_p =
+					nidrtext_ptr + nidr_amount_of_matched_text;
+
+				nidr_current_state = nidr_get_previous_state();
+
+				nidr_cp = nidr_c_buf_p;
+				nidr_bp = nidrtext_ptr + YY_MORE_ADJ;
+				goto nidr_match;
+
+			case EOB_ACT_LAST_MATCH:
+				nidr_c_buf_p =
+				&nidr_current_buffer->nidr_ch_buf[nidr_n_chars];
+
+				nidr_current_state = nidr_get_previous_state();
+
+				nidr_cp = nidr_c_buf_p;
+				nidr_bp = nidrtext_ptr + YY_MORE_ADJ;
+				goto nidr_find_action;
+			}
+		break;
+		}
+
+	default:
+		YY_FATAL_ERROR(
+			"fatal flex scanner internal error--no action found" );
+	} /* end of action switch */
+		} /* end of scanning one token */
+	} /* end of nidrlex */
+
+
+/* nidr_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ *	EOB_ACT_LAST_MATCH -
+ *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ *	EOB_ACT_END_OF_FILE - end of file
+ */
+
+static int nidr_get_next_buffer()
+	{
+	register char *dest = nidr_current_buffer->nidr_ch_buf;
+	register char *source = nidrtext_ptr;
+	register int number_to_move, i;
+	int ret_val;
+
+	if ( nidr_c_buf_p > &nidr_current_buffer->nidr_ch_buf[nidr_n_chars + 1] )
+		YY_FATAL_ERROR(
+		"fatal flex scanner internal error--end of buffer missed" );
+
+	if ( nidr_current_buffer->nidr_fill_buffer == 0 )
+		{ /* Don't try to fill the buffer, so this is an EOF. */
+		if ( nidr_c_buf_p - nidrtext_ptr - YY_MORE_ADJ == 1 )
+			{
+			/* We matched a single character, the EOB, so
+			 * treat this as a final EOF.
+			 */
+			return EOB_ACT_END_OF_FILE;
+			}
+
+		else
+			{
+			/* We matched some text prior to the EOB, first
+			 * process it.
+			 */
+			return EOB_ACT_LAST_MATCH;
+			}
+		}
+
+	/* Try to read more data. */
+
+	/* First move last chars to start of buffer. */
+	number_to_move = (int) (nidr_c_buf_p - nidrtext_ptr) - 1;
+
+	for ( i = 0; i < number_to_move; ++i )
+		*(dest++) = *(source++);
+
+	if ( nidr_current_buffer->nidr_buffer_status == YY_BUFFER_EOF_PENDING )
+		/* don't do the read, it's not guaranteed to return an EOF,
+		 * just force an EOF
+		 */
+		nidr_current_buffer->nidr_n_chars = nidr_n_chars = 0;
+
+	else
+		{
+		int num_to_read =
+			nidr_current_buffer->nidr_buf_size - number_to_move - 1;
+
+		while ( num_to_read <= 0 )
+			{ /* Not enough room in the buffer - grow it. */
+#ifdef YY_USES_REJECT
+			YY_FATAL_ERROR(
+"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
+#else
+
+			/* just a shorter name for the current buffer */
+			YY_BUFFER_STATE b = nidr_current_buffer;
+
+			int nidr_c_buf_p_offset =
+				(int) (nidr_c_buf_p - b->nidr_ch_buf);
+
+			if ( b->nidr_is_our_buffer )
+				{
+				int new_size = b->nidr_buf_size * 2;
+
+				if ( new_size <= 0 )
+					b->nidr_buf_size += b->nidr_buf_size / 8;
+				else
+					b->nidr_buf_size *= 2;
+
+				b->nidr_ch_buf = (char *)
+					/* Include room in for 2 EOB chars. */
+					nidr_flex_realloc( (void *) b->nidr_ch_buf,
+							 b->nidr_buf_size + 2 );
+				}
+			else
+				/* Can't grow it, we don't own it. */
+				b->nidr_ch_buf = 0;
+
+			if ( ! b->nidr_ch_buf )
+				YY_FATAL_ERROR(
+				"fatal error - scanner input buffer overflow" );
+
+			nidr_c_buf_p = &b->nidr_ch_buf[nidr_c_buf_p_offset];
+
+			num_to_read = nidr_current_buffer->nidr_buf_size -
+						number_to_move - 1;
+#endif
+			}
+
+		if ( num_to_read > YY_READ_BUF_SIZE )
+			num_to_read = YY_READ_BUF_SIZE;
+
+		/* Read in more data. */
+		YY_INPUT( (&nidr_current_buffer->nidr_ch_buf[number_to_move]),
+			nidr_n_chars, num_to_read );
+
+		nidr_current_buffer->nidr_n_chars = nidr_n_chars;
+		}
+
+	if ( nidr_n_chars == 0 )
+		{
+		if ( number_to_move == YY_MORE_ADJ )
+			{
+			ret_val = EOB_ACT_END_OF_FILE;
+			nidrrestart( nidrin );
+			}
+
+		else
+			{
+			ret_val = EOB_ACT_LAST_MATCH;
+			nidr_current_buffer->nidr_buffer_status =
+				YY_BUFFER_EOF_PENDING;
+			}
+		}
+
+	else
+		ret_val = EOB_ACT_CONTINUE_SCAN;
+
+	nidr_n_chars += number_to_move;
+	nidr_current_buffer->nidr_ch_buf[nidr_n_chars] = YY_END_OF_BUFFER_CHAR;
+	nidr_current_buffer->nidr_ch_buf[nidr_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+
+	nidrtext_ptr = &nidr_current_buffer->nidr_ch_buf[0];
+
+	return ret_val;
+	}
+
+
+/* nidr_get_previous_state - get the state just before the EOB char was reached */
+
+static nidr_state_type nidr_get_previous_state()
+	{
+	register nidr_state_type nidr_current_state;
+	register char *nidr_cp;
+
+	nidr_current_state = nidr_start;
+
+	for ( nidr_cp = nidrtext_ptr + YY_MORE_ADJ; nidr_cp < nidr_c_buf_p; ++nidr_cp )
+		{
+		register YY_CHAR nidr_c = (*nidr_cp ? nidr_ec[YY_SC_TO_UI(*nidr_cp)] : 1);
+		if ( nidr_accept[nidr_current_state] )
+			{
+			nidr_last_accepting_state = nidr_current_state;
+			nidr_last_accepting_cpos = nidr_cp;
+			}
+		while ( nidr_chk[nidr_base[nidr_current_state] + nidr_c] != nidr_current_state )
+			{
+			nidr_current_state = (int) nidr_def[nidr_current_state];
+			if ( nidr_current_state >= 125 )
+				nidr_c = nidr_meta[(unsigned int) nidr_c];
+			}
+		nidr_current_state = nidr_nxt[nidr_base[nidr_current_state] + (unsigned int) nidr_c];
+		}
+
+	return nidr_current_state;
+	}
+
+
+/* nidr_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ *	next_state = nidr_try_NUL_trans( current_state );
+ */
+
+#ifdef YY_USE_PROTOS
+static nidr_state_type nidr_try_NUL_trans( nidr_state_type nidr_current_state )
+#else
+static nidr_state_type nidr_try_NUL_trans( nidr_current_state )
+nidr_state_type nidr_current_state;
+#endif
+	{
+	register int nidr_is_jam;
+	register char *nidr_cp = nidr_c_buf_p;
+
+	register YY_CHAR nidr_c = 1;
+	if ( nidr_accept[nidr_current_state] )
+		{
+		nidr_last_accepting_state = nidr_current_state;
+		nidr_last_accepting_cpos = nidr_cp;
+		}
+	while ( nidr_chk[nidr_base[nidr_current_state] + nidr_c] != nidr_current_state )
+		{
+		nidr_current_state = (int) nidr_def[nidr_current_state];
+		if ( nidr_current_state >= 125 )
+			nidr_c = nidr_meta[(unsigned int) nidr_c];
+		}
+	nidr_current_state = nidr_nxt[nidr_base[nidr_current_state] + (unsigned int) nidr_c];
+	nidr_is_jam = (nidr_current_state == 124);
+
+	return nidr_is_jam ? 0 : nidr_current_state;
+	}
+
+
+#ifndef YY_NO_UNPUT
+#ifdef YY_USE_PROTOS
+static void nidrunput( int c, register char *nidr_bp )
+#else
+static void nidrunput( c, nidr_bp )
+int c;
+register char *nidr_bp;
+#endif
+	{
+	register char *nidr_cp = nidr_c_buf_p;
+
+	/* undo effects of setting up nidrtext */
+	*nidr_cp = nidr_hold_char;
+
+	if ( nidr_cp < nidr_current_buffer->nidr_ch_buf + 2 )
+		{ /* need to shift things up to make room */
+		/* +2 for EOB chars. */
+		register int number_to_move = nidr_n_chars + 2;
+		register char *dest = &nidr_current_buffer->nidr_ch_buf[
+					nidr_current_buffer->nidr_buf_size + 2];
+		register char *source =
+				&nidr_current_buffer->nidr_ch_buf[number_to_move];
+
+		while ( source > nidr_current_buffer->nidr_ch_buf )
+			*--dest = *--source;
+
+		nidr_cp += (int) (dest - source);
+		nidr_bp += (int) (dest - source);
+		nidr_current_buffer->nidr_n_chars =
+			nidr_n_chars = nidr_current_buffer->nidr_buf_size;
+
+		if ( nidr_cp < nidr_current_buffer->nidr_ch_buf + 2 )
+			YY_FATAL_ERROR( "flex scanner push-back overflow" );
+		}
+
+	*--nidr_cp = (char) c;
+
+
+	nidrtext_ptr = nidr_bp;
+	nidr_hold_char = *nidr_cp;
+	nidr_c_buf_p = nidr_cp;
+	}
+#endif	/* ifndef YY_NO_UNPUT */
+
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+static int nidrinput()
+#else
+static int input()
+#endif
+	{
+	int c;
+
+	*nidr_c_buf_p = nidr_hold_char;
+
+	if ( *nidr_c_buf_p == YY_END_OF_BUFFER_CHAR )
+		{
+		/* nidr_c_buf_p now points to the character we want to return.
+		 * If this occurs *before* the EOB characters, then it's a
+		 * valid NUL; if not, then we've hit the end of the buffer.
+		 */
+		if ( nidr_c_buf_p < &nidr_current_buffer->nidr_ch_buf[nidr_n_chars] )
+			/* This was really a NUL. */
+			*nidr_c_buf_p = '\0';
+
+		else
+			{ /* need more input */
+			int offset = nidr_c_buf_p - nidrtext_ptr;
+			++nidr_c_buf_p;
+
+			switch ( nidr_get_next_buffer() )
+				{
+				case EOB_ACT_LAST_MATCH:
+					/* This happens because nidr_g_n_b()
+					 * sees that we've accumulated a
+					 * token and flags that we need to
+					 * try matching the token before
+					 * proceeding.  But for input(),
+					 * there's no matching to consider.
+					 * So convert the EOB_ACT_LAST_MATCH
+					 * to EOB_ACT_END_OF_FILE.
+					 */
+
+					/* Reset buffer status. */
+					nidrrestart( nidrin );
+
+					/* fall through */
+
+				case EOB_ACT_END_OF_FILE:
+					{
+					if ( nidrwrap() )
+						return EOF;
+
+					if ( ! nidr_did_buffer_switch_on_eof )
+						YY_NEW_FILE;
+#ifdef __cplusplus
+					return nidrinput();
+#else
+					return input();
+#endif
+					}
+
+				case EOB_ACT_CONTINUE_SCAN:
+					nidr_c_buf_p = nidrtext_ptr + offset;
+					break;
+				}
+			}
+		}
+
+	c = *(unsigned char *) nidr_c_buf_p;	/* cast for 8-bit char's */
+	*nidr_c_buf_p = '\0';	/* preserve nidrtext */
+	nidr_hold_char = *++nidr_c_buf_p;
+
+
+	return c;
+	}
+#endif /* YY_NO_INPUT */
+
+#ifdef YY_USE_PROTOS
+void nidrrestart( FILE *input_file )
+#else
+void nidrrestart( input_file )
+FILE *input_file;
+#endif
+	{
+	if ( ! nidr_current_buffer )
+		nidr_current_buffer = nidr_create_buffer( nidrin, YY_BUF_SIZE );
+
+	nidr_init_buffer( nidr_current_buffer, input_file );
+	nidr_load_buffer_state();
+	}
+
+
+#ifdef YY_USE_PROTOS
+void nidr_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+#else
+void nidr_switch_to_buffer( new_buffer )
+YY_BUFFER_STATE new_buffer;
+#endif
+	{
+	if ( nidr_current_buffer == new_buffer )
+		return;
+
+	if ( nidr_current_buffer )
+		{
+		/* Flush out information for old buffer. */
+		*nidr_c_buf_p = nidr_hold_char;
+		nidr_current_buffer->nidr_buf_pos = nidr_c_buf_p;
+		nidr_current_buffer->nidr_n_chars = nidr_n_chars;
+		}
+
+	nidr_current_buffer = new_buffer;
+	nidr_load_buffer_state();
+
+	/* We don't actually know whether we did this switch during
+	 * EOF (nidrwrap()) processing, but the only time this flag
+	 * is looked at is after nidrwrap() is called, so it's safe
+	 * to go ahead and always set it.
+	 */
+	nidr_did_buffer_switch_on_eof = 1;
+	}
+
+
+#ifdef YY_USE_PROTOS
+void nidr_load_buffer_state( void )
+#else
+void nidr_load_buffer_state()
+#endif
+	{
+	nidr_n_chars = nidr_current_buffer->nidr_n_chars;
+	nidrtext_ptr = nidr_c_buf_p = nidr_current_buffer->nidr_buf_pos;
+	nidrin = nidr_current_buffer->nidr_input_file;
+	nidr_hold_char = *nidr_c_buf_p;
+	}
+
+
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE nidr_create_buffer( FILE *file, int size )
+#else
+YY_BUFFER_STATE nidr_create_buffer( file, size )
+FILE *file;
+int size;
+#endif
+	{
+	YY_BUFFER_STATE b;
+
+	b = (YY_BUFFER_STATE) nidr_flex_alloc( sizeof( struct nidr_buffer_state ) );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in nidr_create_buffer()" );
+
+	b->nidr_buf_size = size;
+
+	/* nidr_ch_buf has to be 2 characters longer than the size given because
+	 * we need to put in 2 end-of-buffer characters.
+	 */
+	b->nidr_ch_buf = (char *) nidr_flex_alloc( b->nidr_buf_size + 2 );
+	if ( ! b->nidr_ch_buf )
+		YY_FATAL_ERROR( "out of dynamic memory in nidr_create_buffer()" );
+
+	b->nidr_is_our_buffer = 1;
+
+	nidr_init_buffer( b, file );
+
+	return b;
+	}
+
+
+#ifdef YY_USE_PROTOS
+void nidr_delete_buffer( YY_BUFFER_STATE b )
+#else
+void nidr_delete_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+	{
+	if ( ! b )
+		return;
+
+	if ( b == nidr_current_buffer )
+		nidr_current_buffer = (YY_BUFFER_STATE) 0;
+
+	if ( b->nidr_is_our_buffer )
+		nidr_flex_free( (void *) b->nidr_ch_buf );
+
+	nidr_flex_free( (void *) b );
+	}
+
+/* Fix for C99 */
+#ifndef __cplusplus
+extern int isatty(int);
+#endif /* __cplusplus */
+
+#ifdef YY_USE_PROTOS
+void nidr_init_buffer( YY_BUFFER_STATE b, FILE *file )
+#else
+void nidr_init_buffer( b, file )
+YY_BUFFER_STATE b;
+FILE *file;
+#endif
+
+
+	{
+	nidr_flush_buffer( b );
+
+	b->nidr_input_file = file;
+	b->nidr_fill_buffer = 1;
+
+#if YY_ALWAYS_INTERACTIVE
+	b->nidr_is_interactive = 1;
+#else
+#if YY_NEVER_INTERACTIVE
+	b->nidr_is_interactive = 0;
+#else
+	b->nidr_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+#endif
+#endif
+	}
+
+
+#ifdef YY_USE_PROTOS
+void nidr_flush_buffer( YY_BUFFER_STATE b )
+#else
+void nidr_flush_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+
+	{
+	if ( ! b )
+		return;
+
+	b->nidr_n_chars = 0;
+
+	/* We always need two end-of-buffer characters.  The first causes
+	 * a transition to the end-of-buffer state.  The second causes
+	 * a jam in that state.
+	 */
+	b->nidr_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+	b->nidr_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+	b->nidr_buf_pos = &b->nidr_ch_buf[0];
+
+	b->nidr_at_bol = 1;
+	b->nidr_buffer_status = YY_BUFFER_NEW;
+
+	if ( b == nidr_current_buffer )
+		nidr_load_buffer_state();
+	}
+
+
+#ifndef YY_NO_SCAN_BUFFER
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE nidr_scan_buffer( char *base, nidr_size_t size )
+#else
+YY_BUFFER_STATE nidr_scan_buffer( base, size )
+char *base;
+nidr_size_t size;
+#endif
+	{
+	YY_BUFFER_STATE b;
+
+	if ( size < 2 ||
+	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
+	     base[size-1] != YY_END_OF_BUFFER_CHAR )
+		/* They forgot to leave room for the EOB's. */
+		return 0;
+
+	b = (YY_BUFFER_STATE) nidr_flex_alloc( sizeof( struct nidr_buffer_state ) );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in nidr_scan_buffer()" );
+
+	b->nidr_buf_size = size - 2;	/* "- 2" to take care of EOB's */
+	b->nidr_buf_pos = b->nidr_ch_buf = base;
+	b->nidr_is_our_buffer = 0;
+	b->nidr_input_file = 0;
+	b->nidr_n_chars = b->nidr_buf_size;
+	b->nidr_is_interactive = 0;
+	b->nidr_at_bol = 1;
+	b->nidr_fill_buffer = 0;
+	b->nidr_buffer_status = YY_BUFFER_NEW;
+
+	nidr_switch_to_buffer( b );
+
+	return b;
+	}
+#endif
+
+
+#ifndef YY_NO_SCAN_STRING
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE nidr_scan_string( nidrconst char *nidr_str )
+#else
+YY_BUFFER_STATE nidr_scan_string( nidr_str )
+nidrconst char *nidr_str;
+#endif
+	{
+	int len;
+	for ( len = 0; nidr_str[len]; ++len )
+		;
+
+	return nidr_scan_bytes( nidr_str, len );
+	}
+#endif
+
+
+#ifndef YY_NO_SCAN_BYTES
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE nidr_scan_bytes( nidrconst char *bytes, int len )
+#else
+YY_BUFFER_STATE nidr_scan_bytes( bytes, len )
+nidrconst char *bytes;
+int len;
+#endif
+	{
+	YY_BUFFER_STATE b;
+	char *buf;
+	nidr_size_t n;
+	int i;
+
+	/* Get memory for full buffer, including space for trailing EOB's. */
+	n = len + 2;
+	buf = (char *) nidr_flex_alloc( n );
+	if ( ! buf )
+		YY_FATAL_ERROR( "out of dynamic memory in nidr_scan_bytes()" );
+
+	for ( i = 0; i < len; ++i )
+		buf[i] = bytes[i];
+
+	buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+
+	b = nidr_scan_buffer( buf, n );
+	if ( ! b )
+		YY_FATAL_ERROR( "bad buffer in nidr_scan_bytes()" );
+
+	/* It's okay to grow etc. this buffer, and we should throw it
+	 * away when we're done.
+	 */
+	b->nidr_is_our_buffer = 1;
+
+	return b;
+	}
+#endif
+
+
+#ifndef YY_NO_PUSH_STATE
+#ifdef YY_USE_PROTOS
+static void nidr_push_state( int new_state )
+#else
+static void nidr_push_state( new_state )
+int new_state;
+#endif
+	{
+	if ( nidr_start_stack_ptr >= nidr_start_stack_depth )
+		{
+		nidr_size_t new_size;
+
+		nidr_start_stack_depth += YY_START_STACK_INCR;
+		new_size = nidr_start_stack_depth * sizeof( int );
+
+		if ( ! nidr_start_stack )
+			nidr_start_stack = (int *) nidr_flex_alloc( new_size );
+
+		else
+			nidr_start_stack = (int *) nidr_flex_realloc(
+					(void *) nidr_start_stack, new_size );
+
+		if ( ! nidr_start_stack )
+			YY_FATAL_ERROR(
+			"out of memory expanding start-condition stack" );
+		}
+
+	nidr_start_stack[nidr_start_stack_ptr++] = YY_START;
+
+	BEGIN(new_state);
+	}
+#endif
+
+
+#ifndef YY_NO_POP_STATE
+static void nidr_pop_state()
+	{
+	if ( --nidr_start_stack_ptr < 0 )
+		YY_FATAL_ERROR( "start-condition stack underflow" );
+
+	BEGIN(nidr_start_stack[nidr_start_stack_ptr]);
+	}
+#endif
+
+
+#ifndef YY_NO_TOP_STATE
+static int nidr_top_state()
+	{
+	return nidr_start_stack[nidr_start_stack_ptr - 1];
+	}
+#endif
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+#ifdef YY_USE_PROTOS
+static void nidr_fatal_error( nidrconst char msg[] )
+#else
+static void nidr_fatal_error( msg )
+char msg[];
+#endif
+	{
+	(void) fprintf( stderr, "%s\n", msg );
+	exit( YY_EXIT_FAILURE );
+	}
+
+
+
+/* Redefine nidrless() so it works in section 3 code. */
+
+#undef nidrless
+#define nidrless(n) \
+	do \
+		{ \
+		/* Undo effects of setting up nidrtext. */ \
+		nidrtext[nidrleng] = nidr_hold_char; \
+		nidr_c_buf_p = nidrtext + n; \
+		nidr_hold_char = *nidr_c_buf_p; \
+		*nidr_c_buf_p = '\0'; \
+		nidrleng = n; \
+		} \
+	while ( 0 )
+
+
+/* Internal utility routines. */
+
+#ifndef nidrtext_ptr
+#ifdef YY_USE_PROTOS
+static void nidr_flex_strncpy( char *s1, nidrconst char *s2, int n )
+#else
+static void nidr_flex_strncpy( s1, s2, n )
+char *s1;
+nidrconst char *s2;
+int n;
+#endif
+	{
+	register int i;
+	for ( i = 0; i < n; ++i )
+		s1[i] = s2[i];
+	}
+#endif
+
+#ifdef YY_NEED_STRLEN
+#ifdef YY_USE_PROTOS
+static int nidr_flex_strlen( nidrconst char *s )
+#else
+static int nidr_flex_strlen( s )
+nidrconst char *s;
+#endif
+	{
+	register int n;
+	for ( n = 0; s[n]; ++n )
+		;
+
+	return n;
+	}
+#endif
+
+
+#ifdef YY_USE_PROTOS
+static void *nidr_flex_alloc( nidr_size_t size )
+#else
+static void *nidr_flex_alloc( size )
+nidr_size_t size;
+#endif
+	{
+	return (void *) malloc( size );
+	}
+
+#ifdef YY_USE_PROTOS
+static void *nidr_flex_realloc( void *ptr, nidr_size_t size )
+#else
+static void *nidr_flex_realloc( ptr, size )
+void *ptr;
+nidr_size_t size;
+#endif
+	{
+	/* The cast to (char *) in the following accommodates both
+	 * implementations that use char* generic pointers, and those
+	 * that use void* generic pointers.  It works with the latter
+	 * because both ANSI C and C++ allow castless assignment from
+	 * any pointer type to void*, and deal with argument conversions
+	 * as though doing an assignment.
+	 */
+	return (void *) realloc( (char *) ptr, size );
+	}
+
+#ifdef YY_USE_PROTOS
+static void nidr_flex_free( void *ptr )
+#else
+static void nidr_flex_free( ptr )
+void *ptr;
+#endif
+	{
+	free( ptr );
+	}
+
+#if YY_MAIN
+int main()
+	{
+	nidrlex();
+	return 0;
+	}
+#endif
+/* #line 272 "nidrscan.l" */
+
+
+ static int nidr_ateof = 0;
+ static const char *nidr_instring = 0;
+
+ void
+bad_number(const char *s)
+{
+	fprintf(stderr, "\n*** Invalid number \"%s\" on input line %d within "
+			"%s keyword.\n", s, nidrLineNumber, nidr_keyword_name());
+	nidr_abort();
+	}
+
+ void
+nidr_set_input_string(const char *s)
+{
+	nidr_instring = s;
+	}
+
+ static int
+my_nidr_input(char *buf, int bmax)
+{
+	int c, n;
+
+	if (nidr_ateof)
+		return 0;
+	n = 0;
+	if (nidr_instring) {
+		while(n < bmax && (c = *nidr_instring)) {
+			++nidr_instring;
+			if (c != '\r')
+				buf[n++] = c;
+			if (c == '\n')
+				break;
+			}
+		}
+	else if (nidr_current_buffer->nidr_is_interactive)
+		while(n < bmax) {
+		if ((c = getc(nidrin)) == EOF)
+			break;
+		if (c != '\r')
+			buf[n++] = c;
+		if (c == '\n')
+			break;
+		}
+	else
+		while(n < bmax) {
+		if ((c = getc(nidrin)) == EOF)
+			break;
+		if (c != '\r')
+			buf[n++] = c;
+		}
+	if (n <= 0) {
+		nidr_ateof = n = 1;
+		if (c == EOF) {
+			fclose(nidrin);
+			nidrin = NULL;
+			}
+		buf[0] = ';';
+		}
+	return n;
+	}
+
+ void
+reset_nidrlex_state(void)
+{
+	BEGIN INITIAL;
+	nidr_abort();
+	}
+
+ void
+unput_string(char *s, int len)
+{
+	while(--len >= 0)
+		unput(s[len]);
+	}
+
+ void
+nidr_reinit(void)
+{
+	nidr_init = 1;
+	nidr_ateof = 0;
+	if (nidr_current_buffer) {
+		free(nidr_current_buffer->nidr_ch_buf);
+		free(nidr_current_buffer);
+		nidr_current_buffer = 0;
+		}
+	}
+
+ int
+nidrwrap(void)
+{ return 1; }
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/nidr/nidr.c
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/nidr/nidr.c	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/mac/static/packages/nidr/nidr.c	(revision 25745)
@@ -0,0 +1,2427 @@
+/*********************************************************************
+Copyright 2008, 2010 Sandia Corporation.  Under the terms of Contract
+DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
+retains certain rights in this software.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+* Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+* Neither the name of Sandia Corporation nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+***********************************************************************/
+
+/* nidr.c */
+
+#ifndef NIDR_H	/* for $DAKOTA/src/nidr.c */
+#include "nidr.h"
+#endif
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "avltree.h"
+
+#ifndef NIDR_SQUAWKMAX
+#define NIDR_SQUAWKMAX 10
+#endif
+
+#ifndef NO_NIDR_DYNLIB /*{*/
+typedef KeyWord *(*KW_ADD)(void);
+static KeyWord *kwfind(const char *, KeyWord *, int, int *);
+static KeyWord *toomany(const char *, KeyWord *, int);
+#ifdef _WIN32 /*{{*/
+#include <windows.h>
+#define dlopen(x,y) LoadLibrary(x)
+#define find_dlsym(a,b,c) (a = (KW_ADD)GetProcAddress((HINSTANCE)(b),c))
+#define dlclose(x) FreeLibrary((HMODULE)x)
+#define NO_DLERROR
+#else /*}{*/
+#include <dlfcn.h>
+#include <unistd.h>
+#define find_dlsym(a,b,c) (a = (KW_ADD)dlsym(b,c))
+#undef NO_DLERROR
+#endif /*}}*/
+#endif /*}*/
+
+ extern KeyWord Dakota_Keyword_Top;
+ extern int nidrLineNumber;
+ static KeyWord* Keyword_Top = &Dakota_Keyword_Top;
+ static void *KW_g;
+ void (*nidr_comment)(const char*);
+ static void nidr_keyword_finish(void);
+ static Comment *OutsideComment;
+ static void kw_finish2(void), kw_finish3(void);
+ static void kw_setup1(KeyWord *);
+ static FILE *dumpfile;
+ static KeyWord **ToClear, **ToClear0, **ToClearEnd;
+ static int dumplev, nsquawk, nparse_errors, primary, strict;
+
+ int NIDR_disallow_missing_start = 1;
+
+ enum {n_KWStack0 = 64};
+
+ static KWinfo KWStack0[n_KWStack0];
+
+ static Uint n_KWStack = n_KWStack0;
+
+ static KeyWord *curid, *curkw;
+ static KWinfo	*KWStack = KWStack0,
+		*KWStackBot = KWStack0,
+		*KWStackEnd = KWStack0 + n_KWStack0;
+
+ static Values KWval, KWvalmax;
+ static Real *KWvalbuf;
+ static Uint nKWvalbuf;
+
+ typedef struct Sbuf Sbuf;
+ enum { n_KWsbuf = 8192 };
+ struct Sbuf {
+	char buf[n_KWsbuf];
+	Sbuf *next;
+	};
+
+ typedef struct KWseen KWseen;
+
+ struct
+KWseen {
+	const char *name;
+	KeyWord *kw;
+	KWseen *mnext, *mprev;	/* for identifiers so far unrequited when kw == 0 */
+				/* kw != 0 ==> mprev = first child, and mnext = next sibling */
+	KWseen *parent;
+	KWseen **lcn;		/* &mprev field of last child; lcn == 0 when this */
+				/* keyword was entered into the AVL tree because */
+				/* its parent was seen. */
+	Comment *comment;
+	char **svals;
+	Real *rvals;
+	size_t nvals;
+	};
+
+ static KWseen *KW_cur;
+ NIDR_KWlib *NIDR_Libs;
+
+ void
+nidr_lib_cleanup(void)
+{
+	KeyWord *kw;
+	NIDR_KWlib *L, *L1;
+
+	L1 = NIDR_Libs;
+	NIDR_Libs = 0;
+	while((L = L1)) {
+		if (L->oldtop)
+			Keyword_Top = L->oldtop;
+		if ((kw = L->kw0)) {
+			kw->f.vs = 0;
+			kw->kind &= ~KWKind_Loaded;
+			}
+#ifndef NO_NIDR_DYNLIB /*{{*/
+		dlclose(L->h);
+#else  /*}{*/
+		/* botch("dlclose is NOT SUPPORTED for current configuration"); */
+		fprintf(stderr, "\ndlclose is NOT SUPPORTED for current configuration");
+#endif /*}}*/
+		L1 = L->next;
+		free(L);
+		}
+	}
+
+ static Sbuf KWsbuf0, *KWsbuf = &KWsbuf0;
+ static char *KWsbuf1 = KWsbuf0.buf, *KWsbufe = KWsbuf0.buf + n_KWsbuf;
+ static KWseen *curkws;
+ static const char *valkind[3] = {"integer","numeric","string"};
+
+ int
+nidr_parse_error(void)
+{
+	int n;
+	if ((n = nsquawk - NIDR_SQUAWKMAX) > 0)
+		fprintf(stderr, "\n%d error message%s suppressed.\n",
+			n, "s" + (n == 1));
+	return nsquawk + nparse_errors;
+	}
+
+ void
+nidr_signal_parse_error(void)
+{ ++nparse_errors; }
+
+ void
+nidr_tolower(char *s)
+{
+	for(; *s; ++s)
+		*s = tolower(*s);
+	}
+
+ static void
+botch(const char *fmt, ...)
+{
+	va_list ap;
+	va_start(ap, fmt);
+	fprintf(stderr, "\nBotch:  ");
+	vfprintf(stderr, fmt, ap);
+	fputs(".\n", stderr);
+	va_end(ap);
+	exit(1);
+	}
+
+ static void
+squawk(const char *fmt, ...)
+{
+	va_list ap;
+	if (++nsquawk <= NIDR_SQUAWKMAX) {
+		fprintf(stderr, "Input line %d: ", nidrLineNumber);
+		va_start(ap, fmt);
+		vfprintf(stderr, fmt, ap);
+		fputs(".\n", stderr);
+		va_end(ap);
+		}
+	}
+
+#ifdef NIDR_MALLOC_DEBUG
+ typedef struct MallocDebug MallocDebug;
+ struct MallocDebug
+{
+	MallocDebug *next, *prev;
+	char *where;
+	int nalloc;
+	};
+
+ static MallocDebug MDtop = {&MDtop, &MDtop, 0, 0};
+ int MallocDebugCount, MallocDebugCount1;
+
+ static void*
+Alloc(const char *where, size_t len)
+{
+	MallocDebug *md = malloc(len + sizeof(MallocDebug));
+	if (!md) {
+		fprintf(stderr, "malloc(%lu) failure in %s\n", (unsigned long)len, where);
+		exit(1);
+		}
+	(md->next = MDtop.next)->prev = md;
+	(md->prev = &MDtop)->next = md;
+	md->where = where;
+	if ((md->nalloc = ++MallocDebugCount) == MallocDebugCount1)
+		printf("Hit %d\n", md->nalloc);
+	return (void*)(md + 1);
+	}
+
+ static void
+MallocDebugFree(void *v)
+{
+	MallocDebug *md = (MallocDebug *)v - 1;
+	md->next->prev = md->prev;
+	md->prev->next = md->next;
+	free(md);
+	}
+#define free MallocDebugFree
+
+#else //!NIDR_MALLOC_DEBUG
+ static void*
+Alloc(const char *where, size_t len)
+{
+	void *rv = malloc(len);
+	if (!rv) {
+		fprintf(stderr, "malloc(%lu) failure in %s\n", (unsigned long)len, where);
+		exit(1);
+		}
+	return rv;
+	}
+#endif //NIDR_MALLOC_DEBUG
+
+ const char *
+nidr_basename(const char *p)
+{
+	const char *b;
+
+#ifdef _WIN32
+	if (p[0] && p[1] == ':')
+		p += 2;
+	else if (p[0] == '\\' && p[1] == '\\')
+		for(p += 2; *p; )
+			switch(*p++) {
+			 case '/':
+			 case '\\':
+				goto break2;
+			}
+ break2:
+#endif
+	b = p;
+	while(*p)
+		switch(*p++) {
+		 case '/':
+#ifdef _WIN32
+		 case '\\':
+#endif
+			b = p;
+		}
+	return b;
+	}
+
+ const char *nidr_exedir;
+ int nidr_exedir_len = -1; /* allow resetting to -1 for debugging */
+
+#ifndef _WIN32
+ static int
+Is_executable(uid_t myuid, gid_t mygid, struct stat *sb)
+{
+	if (sb->st_uid == myuid) {
+		if (sb->st_mode & S_IXUSR)
+			return 1;
+		}
+	else if (sb->st_gid == mygid) {
+		if (sb->st_mode & S_IXGRP)
+			return 1;
+		}
+	else if (sb->st_mode & S_IXOTH)
+		return 1;
+	return 0;
+	}
+#endif
+
+ int
+nidr_save_exedir(const char *argv0, int pathadj)
+{
+	/* pathadj & 1 ==> add exedir to $PATH */
+	/* pathadj & 2 ==> add . to $PATH */
+	/* (in both cases if not already there) */
+
+    /* These conditionals don't seem to work (perhaps expected) for Cygwin 
+	   binaries run from Windows command prompt as the compile-time is 
+	   unix-style, but runtime the path is windows-like.  For now comment
+	   out warning when on Cygwin build */
+#ifdef _WIN32
+#define Pathname "Path"
+#define Sep ';'
+#define Slash '\\'
+#define Executable(x) !stat(x,&sb)
+#else
+#define Pathname "PATH"
+#define Sep ':'
+#define Slash '/'
+#define Executable(x) !stat(x,&sb) && Is_executable(myuid, mygid, &sb)
+#endif
+	char *buf, buf0[4096], *s;
+	const char *av0, *p, *p0, *p1, *p2;
+	int dotseen, finaldot, rc;
+	size_t buflen, L, L1, L2, L3;
+	struct stat sb;
+	static const char dotslash[3] = { '.', Slash, 0 };
+#ifdef _WIN32
+	int c;
+	pathadj &= 1;	/* . is implicitly in $PATH under _WIN32 */
+#else
+	gid_t mygid;
+	uid_t myuid;
+#endif
+	if (nidr_exedir_len != -1) {
+		fprintf(stderr, "\nIgnoring extra call on nidr_save_argv0()\n");
+		return 1;
+		}
+	nidr_exedir_len = 0;
+	if (!(av0 = argv0))
+		return 2;
+	if (!(p = getenv(Pathname))) {
+		fprintf(stderr, "\nnidr_save_exedir: no $%s\n", Pathname);
+		return 3;
+		}
+	dotseen = finaldot = rc = 0;
+	buf = buf0;
+	buflen = sizeof(buf0);
+	p0 = p2 = p;
+	p1 = nidr_basename(av0);
+	if ((L = p1 - av0) > 0) {
+		memcpy(s = (char*)Alloc("nidr_save_argv0", L+1), av0, L);
+		s[L] = 0;
+		nidr_exedir = s;
+		nidr_exedir_len = (int)L;
+#ifdef _WIN32
+		for(L1 = 0; L1 < L; ++L1)
+			if (s[L1] == '/')
+				s[L1] = '\\';
+#endif
+		if (!pathadj)
+			return 0;
+		if (*p == Sep)
+			dotseen = 1;
+		while(*p) {
+			if (*p == Sep && (p[1] == Sep || p[1] == 0)) {
+				dotseen = 1;
+				break;
+				}
+			++p;
+			}
+		if (s[0] == '.' && s[1] == Slash && L == 2) {
+#ifdef _WIN32
+			return 0;
+#else
+			if (!dotseen)
+				goto dot_add;
+#endif
+			}
+		L1 = L - 1;
+		for(p = p0;;) {
+			while(*p == Sep)
+				++p;
+			if (!*p)
+				break;
+			if (!strncmp(p, s, L1)) {
+#ifdef _WIN32
+				return 0;
+#else
+				if (!(pathadj &= ~1) || *p0 == Sep)
+					return 0;
+				for(p = p0;;) {
+					if (*p == Sep || (*p == '.' && p[1] == Sep))
+						return 0;
+					while(*p != Sep) {
+						if (!*p)
+							goto dot_add;
+						++p;
+						}
+					if (!*++p)
+						return 0;
+					}
+#endif
+				}
+			while(*++p != Sep)
+				if (!*p)
+					goto break2;
+			if (!*++p) {
+#ifdef _WIN32
+				finaldot = 1; /* leave at 0 for !_WIN32 */
+#endif
+				break;
+				}
+			}
+ break2:
+		L1 = strlen(Pathname);
+		L2 = strlen(p0);
+		if (!pathadj & 2)
+			dotseen = 1;
+		L3 = L1 + L2 + L + 3;
+		s = (char*)Alloc("nidr_save_argv0", L3);
+		memcpy(s, Pathname, L1);
+		s[L1++] = '=';
+		memcpy(s+L1, p0, L2);
+		L1 += L2;
+		if (!finaldot)
+			s[L1++] = Sep;
+		memcpy(s+L1, nidr_exedir, --L);
+		L1 += L;
+		if (!dotseen)
+			s[L1++] = Sep;
+		s[L1] = 0;	/* omit final slash */
+		putenv(s);
+		return 0;
+		}
+	L = strlen(av0);
+#ifdef _WIN32
+	if (L < 5 || av0[L-4] != '.'
+	|| ((c = av0[L-3]) != 'e' && c != 'E')
+	|| ((c = av0[L-2]) != 'x' && c != 'X')
+	|| ((c = av0[L-1]) != 'e' && c != 'E')) {
+		memcpy(s = (char*)Alloc("nidr_save_argv0", L + 5), av0, L);
+		strcpy(s+L, ".exe");
+		L += 4;
+		av0 = s;
+		}
+	if (Executable(av0)) {
+		/* handle implicit . */
+		dotseen = 1;
+		nidr_exedir = dotslash;
+		}
+	else /* do for loop */
+#else
+
+/* Fix for C99 */
+#ifndef __cplusplus
+extern uid_t geteuid(void);
+extern uid_t getegid(void);
+#endif /* __cplusplus */
+
+	myuid = geteuid();
+	mygid = getegid();
+#endif
+	for(; *p; p = p2) {
+		for(p1 = p;; ++p1) {
+			if (*p1 == Sep) {
+				p2 = p1 + 1;
+				if (!*p2)
+					finaldot = 1;
+				break;
+				}
+			if (!*p1) {
+				p2 = p1;
+				break;
+				}
+			}
+		if (p1 == p || (*p == '.' && p1 == p + 1)) {
+			if (!dotseen) {
+				dotseen = 1;
+				if (Executable(av0)) {
+					nidr_exedir = dotslash;
+					break;
+					}
+				}
+			}
+		else {
+			L1 = p1 - p;
+			L2 = L + L1 + 2;
+			if (L2 > buflen) {
+				if (buf != buf0)
+					free(buf);
+				buf = (char*)Alloc("nidr_save_argv0", L2);
+				buflen = L2;
+				}
+			memcpy(buf, p, L1);
+			buf[L1++] = Slash;
+			strcpy(buf+L1, av0);
+			if (Executable(buf)) {
+				s = (char*)Alloc("nidr_save_argv0", L1+1);
+				memcpy(s, buf, L1);
+				s[L1] = 0;
+				nidr_exedir = s;
+				nidr_exedir_len = (int)L1;
+				pathadj &= ~1;
+				break;
+				}
+			}
+		}
+	if (dotseen)
+		pathadj &= ~2;
+	if (!finaldot && *p2) {
+		while(p2[1])
+			++p2;
+		if (*p2 == Sep)
+			finaldot = 1;
+		}
+	if (finaldot && !dotseen && !nidr_exedir) {
+		dotseen = 1;
+		if (Executable(av0))
+			nidr_exedir = dotslash;
+		}
+	if (nidr_exedir == dotslash)
+		nidr_exedir_len = 2;
+	else {
+		if (pathadj & 2 && !finaldot) {
+#ifndef _WIN32
+ dot_add:
+#endif
+			L = strlen(p0);
+			L1 = strlen(Pathname);
+			L2 = L + L1 + 3;
+			s = (char*)Alloc("nidr_save_argv0", L2);
+			memcpy(s, Pathname, L1);
+			s[L1++] = '=';
+			memcpy(s+L1, p0, L);
+			s[L += L1] = Sep;
+			s[L+1] = 0;
+			putenv(s);
+			}
+		if (!nidr_exedir) {
+/* Suppress warning for Cygwin and Windows, where path isn't resolved correctly above */
+#if !defined(__CYGWIN__) && !defined(_MSC_VER)
+			fprintf(stderr, "\nnidr_save_exedir: could not find \"%s\" in $%s\n",
+				av0, Pathname);
+#endif
+			rc = 4;
+			}
+		}
+	if (buf != buf0)
+		free(buf);
+	return rc;
+	}
+
+ void *
+nidr_dlopen(const char *libname)
+{
+#ifdef NO_NIDR_DYNLIB /*{{*/
+	botch("dlopen for \"%s\" is NOT SUPPORTED", libname);
+	return (void*)libname;
+#else /*}{*/
+	char buf0[4096], *buf;
+	const char *b;
+	size_t buflen, L, L1;
+	void *h;
+
+	b = nidr_basename(libname);
+	if (b > libname)
+		return dlopen(libname, RTLD_NOW);
+	buf = buf0;
+	buflen = sizeof(buf0);
+	L = strlen(libname);
+	if (nidr_exedir) {
+		L1 = L + nidr_exedir_len + 1;
+		if (L1 > buflen) {
+			buf = (char*)Alloc("nidr_dlopen", L1);
+			buflen = L1;
+			}
+		memcpy(buf, nidr_exedir, nidr_exedir_len);
+		strcpy(buf + nidr_exedir_len, libname);
+		if ((h = dlopen(buf, RTLD_NOW)))
+			goto ret;
+		}
+	if (!(h = dlopen(libname, RTLD_NOW))) {
+		L1 = L + 3;
+		if (L1 > buflen) {
+			buf = (char*)Alloc("nidr_dlopen", L1);
+			buflen = L1;
+			}
+		buf[0] = '.';
+		buf[1] = Slash;
+		strcpy(buf+2, libname);
+		if (!(h = dlopen(buf, RTLD_NOW)))
+			h = dlopen(libname, RTLD_NOW); 	/* for dlerror */
+		}
+ ret:
+	if (buf != buf0)
+		free(buf);
+	return h;
+#endif  /*}}*/
+	}
+
+#undef Executable
+#undef Slash
+#undef Sep
+#undef Pathname
+
+
+ struct
+Comment {
+	int k;		/* subscript for comfree */
+	size_t avail;	/* bytes left (from tnext) */
+	char *text;	/* text of comment */
+	char *tnext;	/* null byte at end of comment */
+	Comment *fnext;	/* next free Comment */
+	};
+
+ enum { Comment_kmax = 7 };
+
+ static Comment *comfree[Comment_kmax+1];
+ static size_t Comment_maxlen[Comment_kmax+1];
+
+ static void
+comment_free(Comment *c)
+{
+	int k = c->k;
+
+	if (k > Comment_kmax)
+		free(c);
+	else {
+		c->fnext = comfree[k];
+		comfree[k] = c;
+		}
+	}
+
+ static Comment*
+alloc_comment(int k, size_t L)
+{
+	Comment *c;
+
+	for(; k <= Comment_kmax; ++k) {
+		if (L <= Comment_maxlen[k]) {
+			L = Comment_maxlen[k];
+			if ((c = comfree[k])) {
+				comfree[k] = c->fnext;
+				goto have_c;
+				}
+			break;
+			}
+		}
+	c = (Comment*)Alloc("save_comment", L + sizeof(Comment) + 1);
+	c->k = k;
+	c->text = (char*)(c+1);
+ have_c:
+	c->avail = L;
+	c->tnext = c->text;
+	return c;
+	}
+
+ static void
+save_comment(const char *s)
+{
+	Comment *c, *c1, **cp;
+	size_t L, L1;
+
+	L = strlen(s);
+	cp = curid ? &curid->comment : curkws ? &curkws->comment : &OutsideComment;
+	if ((c = *cp)) {
+		if (c->avail >= L)
+			goto cupdate;
+		L1 = c->tnext - c->text;
+		c1 = alloc_comment(c->k + 1, L + L1);
+		memcpy(c1->text, c->text, L1);
+		c1->tnext = c1->text + L1;
+		c1->avail -= L1;
+		comment_free(c);
+		c = c1;
+		}
+ 	else
+		c = alloc_comment(0, L);
+ cupdate:
+	memcpy(c->tnext, s, L+1);
+	c->tnext += L;
+	c->avail -= L;
+	*cp = c;
+	}
+
+ static void
+comment_setup(void)
+{
+	int i;
+	size_t L;
+	nidr_comment = save_comment;
+	/* "- 1" to allow for terminating '\0' */
+	for(L = 64; L <= sizeof(Comment) - 1; L <<= 1);
+	for(i = 0; i <= Comment_kmax; ++i, L <<= 1)
+		Comment_maxlen[i] = L - sizeof(Comment) - 1;
+	}
+
+ static void
+comment_reset(void)
+{
+	Comment *c, *c1;
+	int i;
+
+	for(i = 0; i <= Comment_kmax; ++i) {
+		c1 = comfree[i];
+		comfree[i] = 0;
+		while((c = c1)) {
+			c1 = c->fnext;
+			free(c);
+			}
+		}
+	nidr_comment = 0;
+	}
+
+ static void
+dumpcomment(Comment **cp)
+{
+	Comment *c = *cp;
+	*cp = 0;
+	fprintf(dumpfile, "%s", c->text);
+	comment_free(c);
+	}
+
+ static void
+dumpname(int hasval, KeyWord *kw)
+{
+	const char *fmt[2] = { "%s", "%s =" };
+	int i;
+	if (OutsideComment)
+		dumpcomment(&OutsideComment);
+	if (primary)
+		kw += kw->paoff;
+	for(i = 0; i < dumplev; ++i)
+		putc(' ', dumpfile);
+	fprintf(dumpfile,fmt[hasval],kw->name);
+	if (!hasval) {
+		if (kw->comment)
+			dumpcomment(&kw->comment);
+		else if (kw != curkw)
+			putc('\n', dumpfile);
+		}
+	}
+
+ static void
+dumpstring(const char *s0)
+{
+	const char *s;
+	int c, n1, n2, q;
+
+	n1 = n2 = 0;
+	for(s = s0;;)
+		switch(*s++) {
+		  case 0: goto break2;
+		  case '\'':
+			++n1;
+			break;
+		  case '"':
+			++n2;
+		  }
+ break2:
+	q = '\'';
+	if (n1 > n2)
+		q = '"';
+	putc(' ', dumpfile);
+	putc(q, dumpfile);
+	s = s0;
+	while((c = *s++)) {
+		if (c == q)
+			putc(q, dumpfile);
+		putc(c, dumpfile);
+		}
+	putc(q, dumpfile);
+	}
+
+ static void
+dumpvals0(KeyWord *kw)
+{
+	Real *r;
+	const char **sp;
+	int i, *ip, indent, j, n;
+
+	ip = 0; /* shut up warning of possible use without initialization */
+	sp = 0; /* ditto */
+	if (!(r = KWval.r) && !(ip = KWval.i) && !(sp = KWval.s))
+		return;
+	n = KWval.n;
+	putc((indent = n > 1) ? '\n' : ' ', dumpfile);
+	for(i = 0;;) {
+		if (indent) {
+			putc('\t', dumpfile);
+			for(j = 0; j < dumplev; ++j)
+				putc(' ', dumpfile);
+			}
+		if (r)
+			fprintf(dumpfile, "%.15g", r[i]);
+		else if (ip)
+			fprintf(dumpfile, "%d", ip[i]);
+		else
+			dumpstring(sp[i]);
+		if (++i >= n)
+			break;
+		indent = 1;
+		putc('\n', dumpfile);
+		}
+	if (kw->comment)
+		dumpcomment(&kw->comment);
+	else
+		putc('\n', dumpfile);
+	}
+
+ static void (*dumpvals)(KeyWord *kw) = dumpvals0;
+
+ static void
+dumpvals1(KeyWord *kw)
+{
+	Real *r;
+	const char **sp;
+	int i, *ip, n;
+
+	ip = 0; /* shut up warning of possible use without initialization */
+	sp = 0; /* ditto */
+	if ((r = KWval.r) || (ip = KWval.i) || (sp = KWval.s)) {
+		n = KWval.n;
+		for(i = 0; i < n; ++i) {
+			if (r)
+				fprintf(dumpfile, " %.15g", r[i]);
+			else if (ip)
+				fprintf(dumpfile, " %d", ip[i]);
+			else
+				dumpstring(sp[i]);
+			}
+		}
+	if (kw->comment)
+		dumpcomment(&kw->comment);
+	else
+		putc('\n', dumpfile);
+	}
+
+ char *
+nidr_KWscopy(const char *s)
+{
+	Sbuf *sb;
+	char *rv;
+
+	size_t L = strlen(s) + 1;
+	if (L >= n_KWsbuf)
+		botch("String too long in KWscopy");
+	if (KWsbufe - KWsbuf1 < L) {
+		if (!KWsbuf->next) {
+			KWsbuf->next = sb = (Sbuf*)Alloc("KWscopy", sizeof(Sbuf));
+			sb->next = 0;
+			}
+		KWsbuf = KWsbuf->next;
+		KWsbuf1 = KWsbuf->buf;
+		KWsbufe = KWsbuf1 + n_KWsbuf;
+		}
+	strcpy(KWsbuf1, s);
+	rv = KWsbuf1;
+	KWsbuf1 += L;
+	return rv;
+	}
+
+ static void
+KWvalbuf_inc(void)
+{
+	Real *r;
+	Uint n;
+
+	n = nKWvalbuf << 1;
+	r = (Real*)Alloc("KWvalbuf", n*sizeof(Real));
+	memcpy(r, KWvalbuf, nKWvalbuf*sizeof(Real));
+	free(KWvalbuf);
+	KWvalbuf = r;
+	nKWvalbuf = n;
+	KWvalmax.n <<= 1;
+	if (KWval.r) {
+		KWval.r = r;
+		KWvalmax.r = r + n;
+		}
+	else if (KWval.i) {
+		KWval.i = (int*) r;
+		KWvalmax.i = (int*)(r + n);
+		}
+	else if (KWval.s) {
+		KWval.s = (const char**)r;
+		KWvalmax.s = (const char**)(r + n);
+		}
+	else
+		botch("Unexpected case in KWvalbuf_inc");
+	}
+
+/* KWval.rstate values...
+ *	value	form seen
+ *	0	v
+ *	1	L:u
+ *	2	L:s:u
+ *	3	n*v
+ *	4	n*L:u
+ *	5	n*L:s:u
+ */
+
+ static void
+finish_rexpand(void)
+{
+	int i, k, n, os;
+	Real sgn, st, u, v, x;
+
+	os = KWval.rstate;
+	KWval.rstate = 0;
+	n = KWval.n;
+	k = 1;
+	if (os >= 3) {
+		KWval.n = n -= os-1;
+		k = KWval.r[n];
+		if (k != KWval.r[n]) {
+			squawk("Noninteger replication factor %.17g", KWval.r[n]);
+			return;
+			}
+		else if (k < 1) {
+			squawk("Nonpositive replication factor %d", k);
+			return;
+			}
+		++n;
+		os -= 3;
+		}
+	else
+		KWval.n = n -= os + 1;
+	v = KWval.r[n++];
+	u = st = 0.;	/* Shut up warning of not being initialized. */
+			/* Both will be assigned before being used. */
+	switch(os) {
+	  case 0:
+		n = KWval.n;
+		for(i = 0; i < k; ++i) {
+			if (n >= KWvalmax.n)
+				KWvalbuf_inc();
+			KWval.r[n++] = v;
+			}
+		KWval.n = n;
+		return;
+	  case 1:
+		st = 1;
+		u = KWval.r[n];
+		break;
+	  case 2:
+		st = KWval.r[n];
+		if (st == 0.) {
+			squawk("Invalid stride == zero.");
+			return;
+			}
+		u = KWval.r[n+1];
+	  }
+	sgn = 1.;
+	if (st < 0.)
+		sgn = -1.;
+	if (sgn*(u - v) < 0.) {
+		squawk("Empty sequence.");
+		return;
+		}
+	n = KWval.n;
+	do {
+		for(i = 0; sgn*(u - (x = v + i*st)) >= 0.; ++i) {
+			if (n >= KWvalmax.n)
+				KWvalbuf_inc();
+			KWval.r[n++] = x;
+			}
+		}
+		while(--k > 0);
+	KWval.n = n;
+	}
+
+ static void
+rexpand(int state)
+{
+	int os;
+
+	os = KWval.rstate;
+	KWval.rstate = 0;
+	switch(state) {
+	  case 1: /* just saw *v */
+		if (os == 0)
+			KWval.rstate = 3;
+		else
+			squawk("Unexpected '*'");
+		break;
+	  case 2: /* just saw :v */
+		if (os == 2 || os == 5)
+			squawk("Unexpected ':'");
+		else
+			KWval.rstate = os + 1;
+		break;
+	  }
+	}
+
+ static void
+nidr_bufr_strict(Real r, int state)
+{
+	int k, n;
+
+	if (KWval.s) {
+		squawk("expected a quoted string, but found a number");
+		return;
+		}
+	if (KWval.rstate && !state)
+		finish_rexpand();
+	if (!KWval.r && !KWval.i) {
+		squawk("No values may be specified for %s", KWStack->kw->name);
+		return;
+		}
+	if ((n = KWval.n) >= KWvalmax.n)
+		KWvalbuf_inc();
+	if (KWval.r)
+		KWval.r[n] = r;
+	else {
+		k = (int)r;
+		if (k != r)
+			squawk("truncating %.17g to %d", r, k);
+		KWval.i[n] = k;
+		}
+	++KWval.n;
+	if (state | KWval.rstate)
+		rexpand(state);
+	}
+
+ static void
+nidr_bufs_strict(const char *s)
+{
+	if (!KWval.s) {
+		if (KWval.r)
+			squawk("Expected a number, but found a quoted string");
+		else
+			squawk("Misplaced quoted string");
+		return;
+		}
+	if (KWval.n >= KWvalmax.n)
+		KWvalbuf_inc();
+	KWval.s[KWval.n++] = s;
+	}
+
+ void
+nidr_reset(void)
+{
+	/* Originally did this in case KWKind_Str of kw_setup(), */
+	/* but this leads to confusion with erroneous input. */
+	if (curkw)
+		nidr_keyword_finish();
+	KWsbuf = &KWsbuf0;
+	KWsbuf1 = KWsbuf0.buf;
+	KWsbufe = KWsbuf0.buf + n_KWsbuf;
+	}
+
+ NIDR_KWlib *
+nidr_lib_record(void *h, const char *libname)
+{
+	NIDR_KWlib *Lib;
+	size_t L;
+
+	L = strlen(libname) + 1;
+	Lib = (NIDR_KWlib*)Alloc("NIDR_lib_record", sizeof(NIDR_KWlib) + L);
+	memset(Lib, 0, sizeof(NIDR_KWlib));
+	memcpy(Lib->libname = (char*)(Lib+1), libname, L);
+	if (!(Lib->next = NIDR_Libs))
+		atexit(nidr_lib_cleanup);
+	NIDR_Libs = Lib;
+	Lib->h = h;
+	return Lib;
+	}
+
+ static KeyWord*
+kw_insert(KeyWord *kw, int *tryagain)
+{
+#ifdef NO_NIDR_DYNLIB /*{{*/
+	botch("Loading library \"%s\" for %s is disallowed",
+		kw->f.vf, kw->name);
+#else /*}{*/
+	KW_ADD kwa;
+	KeyWord *kw0, *kw1, *kw2;
+	NIDR_KWlib *Lib;
+	Uint u1, ui;
+	const char *lname, *s;
+	int newtop, nmatch;
+	void *h;
+
+	if (tryagain)
+		*tryagain = 0;
+	if (kw->kind & KWKind_Loaded)
+		return (KeyWord*)kw->f.vs;
+	h = nidr_dlopen(lname = (const char*)kw->f.vf);
+	if (!h) {
+#ifndef NO_DLERROR
+		if ((s = dlerror()))
+			botch("Cannot open library \"%s\" for %s:\n\t%s",
+				lname, kw->name, s);
+		else
+#endif
+			botch("Cannot open library \"%s\" for %s",
+				lname, kw->name);
+		}
+	if (!find_dlsym(kwa, h, "keyword_add"))
+		botch("dlsym(\"keyword_add\") failed for %s", lname);
+	kw1 = (*kwa)();
+	if (!(s = kw1->name)) {
+		s = "<NULL>";
+		goto namebotch;
+		}
+	newtop = 0;
+	if (strcmp(s, kw->name)) {
+		if (!KW_cur && !strcmp(s,"KeywordTop") && kw1->kind & KWKind_Dynmult)
+			newtop = 1;
+		else if (tryagain && kw1->nkw > 0
+		 && (kw2 = kwfind(kw->name, kw1->kw, kw1->nkw, &nmatch))) {
+			if (nmatch > 1) {
+				toomany(kw->name, kw1, nmatch);
+				botch("Too many matches in library %s", lname);
+				}
+			*tryagain = 1;
+			}
+		else
+ namebotch:
+			botch("Library %s: expected top keyword to be %s but got %s",
+				lname, kw->name, s);
+		}
+	ui = kw->kind  & (KWKind_Mask|KWKind_List);
+	u1 = kw1->kind & (KWKind_Mask|KWKind_List);
+	if (ui != u1)
+		botch("Library %s: expected kind %u for %s, but got %u",
+			lname, ui, s, u1);
+	Lib = nidr_lib_record(h, lname);
+	Lib->kw0 = kw0 = kw;
+	memcpy(&Lib->kw, kw, sizeof(KeyWord));
+	kw = &Lib->kw;
+	kw->kw = kw1->kw;
+	kw->nkw = kw1->nkw;
+	kw->f = kw1->f;
+	kw0->f.vs = (void*)kw;
+	kw0->kind |= KWKind_Loaded;
+	if (newtop) {
+		Lib->oldtop = Keyword_Top;
+		Keyword_Top = kw;
+		kw->kind |= KWKind_Dynmult;
+		}
+#endif	/*}}*/
+	return kw;
+	}
+
+ static void
+kwnext_setup(KeyWord *kw, Uint n)
+{
+	KeyWord *kwe;
+
+	if (kw->kwnext || (n <= 1 && kw->name))
+		return;
+#ifndef NO_NIDR_DYNLIB /*{*/
+	if (kw->kind & KWKind_Extended) {
+		KeyWordx *kx1, *kxe;
+		for(kx1 = (KeyWordx*)kw; !kx1->kw.name; ++kx1)
+			kx1->kw.kwnext = (KeyWord*)(kx1 + 1);
+		for(kxe = kx1 + n - 1; kx1 < kxe; ++kx1)
+			kx1->kw.kwnext = (KeyWord*)(kx1 + 1);
+		return;
+		}
+#endif
+	for(; !kw->name; ++kw)
+		kw->kwnext = kw + 1;
+	for(kwe = kw + n - 1; kw < kwe; ++kw)
+		kw->kwnext = kw + 1;
+	}
+
+ static void
+KWStack_inc(void)
+{
+	KWinfo *kwi;
+	Uint nn;
+	size_t len;
+
+	nn = n_KWStack << 1;
+	kwi = (KWinfo*)Alloc("kw_setup", len = nn*sizeof(KWinfo));
+	memcpy(kwi, KWStackBot, len >> 1);
+	if (KWStackBot != KWStack0)
+		free(KWStackBot);
+	KWStackBot = kwi;
+	KWStackEnd = kwi + nn;
+	KWStack = kwi + n_KWStack;
+	n_KWStack = nn;
+	}
+
+ static KeyWord*
+kw_setup(KeyWord *kw, void *g, const char *name)
+{
+	KWinfo *kwi;
+	KeyWord **alt, *kw1, **req;
+
+	Uint k, nalt, nn, nreq;
+	int *altct, deferred;
+	size_t len;
+
+	deferred = 0;
+	if (kw->kind & KWKind_Dynlib) {
+		if (kw->kw)
+			deferred = 1;
+		else
+			kw = kw_insert(kw, 0);
+		}
+ top:
+	if ((kw1 = kw->kw)) {
+		kwnext_setup(kw1, kw->nkw);
+		if (kw->kind & KWKind_Dynmult)
+			return kw;
+		while(!kw1->name) {
+			if (!(kw1->kind & KWKind_Stacked)) {
+				kw1->kind |= KWKind_Stacked;
+				kw_setup(kw1, g, name);
+				}
+			kw1 = kw1->kwnext;
+			}
+		}
+	if (!curkw) {
+		KWStack = KWStackBot = KWStack0;
+		KWStackEnd = KWStack0 + n_KWStack0;
+		curkw = kw;
+		}
+	else if (++KWStack >= KWStackEnd)
+		KWStack_inc();
+	kwi = KWStack;
+	kwi->name = name;
+	kwi->kw = kw;
+	kwi->kw1 = kw1;
+	nalt = nreq = 0;
+	if (kw1)
+		for(; kw1; kw1 = kw1->kwnext) {
+			if (nalt < kw1->alt)
+				nalt = kw1->alt;
+			if (nreq < kw1->req)
+				nreq = kw1->req;
+			}
+	kwi->nalt = nalt;
+	kwi->nreq = nreq;
+	alt = req = 0;
+	altct = 0;
+	if ((nn = nalt + nreq) > 0) {
+		nn += 2;
+		alt = (KeyWord**)Alloc("kw_setup(alt)",
+				len = nn*sizeof(KeyWord*) + (nalt+1)*sizeof(int));
+		memset(alt, 0, len);
+		req = alt + nalt + 1;
+		altct = (int*)(req + nreq + 1);
+		/* altct[0], alt[0] and req[0] = "don't care" slots */
+		}
+	kwi->alt = alt;
+	kwi->req = req;
+	kwi->altct = altct;
+	if (nreq)
+		for(kw1 = kwi->kw1; kw1; kw1 = kw1->kwnext)
+			req[kw1->req] = kw1;
+	if (nalt)
+		for(kw1 = kwi->kw1; kw1; kw1 = kw1->kwnext)
+			if (kw1->kind & KWKind_primary)
+				++altct[kw1->alt];
+	kwi->g = g;
+	KWval.n = 0;
+	KWval.i = 0;
+	KWval.r = 0;
+	KWval.s = 0;
+	if ((k = kw->kind & KWKind_Mask)) {
+		if (!KWvalmax.r)
+			KWvalbuf = (Real *)Alloc("kw_setup(KWvalbuf)",
+						(nKWvalbuf = 128)*sizeof(Real));
+		switch(k) {
+
+		  case KWKind_Int:
+			KWval.i = (int*)KWvalbuf;
+			KWvalmax.n = (nKWvalbuf*sizeof(Real))/sizeof(int);
+			KWvalmax.i = KWval.i + KWvalmax.n;
+			break;
+
+		  case KWKind_Real:
+			KWval.r = KWvalbuf;
+			KWvalmax.r = KWvalbuf + (KWvalmax.n = nKWvalbuf);
+			break;
+
+		  case KWKind_Str:
+			KWval.s = (const char**)KWvalbuf;
+			KWvalmax.n = (nKWvalbuf*sizeof(Real))/sizeof(char*);
+			KWvalmax.s = KWval.s + KWvalmax.n;
+		  }
+		}
+	if (deferred) {
+		kw = kw_insert(kw, 0);
+		deferred = 0;
+		goto top;
+		}
+	if (!(kwi->needstart = kw->kind & KWKind_Mask)) {
+		if (kw->name) {
+			if (dumpfile)
+				dumpname(0, kw);
+			++dumplev;
+			}
+		if (kw->f.start)
+			(*kw->f.start)(kw->name, 0, &KWStack->g, kw->f.vs);
+		}
+	else if (!kw->f.start && NIDR_disallow_missing_start)
+		botch("No start routine for %s", kw->name);
+	return kw;
+	}
+
+ static KeyWord *
+kwfind(const char *name, KeyWord *keywds, int n, int *nmatch)
+{
+	KeyWord *kn, *kn1;
+	int k, n0, n1, n2, nn;
+	size_t L;
+
+	*nmatch = 0;
+	if (n <= 0)
+		return 0;
+	L = strlen(name);
+	n0 = 0;
+	nn = n;
+#ifndef NO_NIDR_DYNLIB /*{*/
+	if (n > 0 && keywds->kind & KWKind_Extended) {
+	    while(n > 0) {
+		n1 = n >> 1;
+		kn = (KeyWord*)((KeyWordx*)keywds + n1);
+		k = strncmp(name, kn->name, L);
+		if (k < 0)
+			n = n1;
+		else if (k > 0) {
+			n -= ++n1;
+			n0 += n1;
+			keywds = (KeyWord*)((KeyWordx*)kn + 1);
+			}
+		else {
+			/* Found -- check for range of matches. */
+			/* Here we use linear search, as we expect */
+			/* the range to be small. */
+			n = n1 + n0;
+			n2 = n + 1;
+			if (kn->name[L]) {
+				for(kn1 = kn; n2 < nn; ++n2) {
+					kn1 = (KeyWord*)((KeyWordx*)kn1 + 1);
+					if (strncmp(name, kn1->name, L))
+						break;
+					if (!kn1->name[L])
+						goto found1;
+					}
+				kn1 = kn;
+				while(n > 0) {
+					kn1 = (KeyWord*)((KeyWordx*)kn1 - 1);
+					if (strncmp(name, kn1->name, L))
+						break;
+					if (!kn1->name[L])
+						goto found1;
+					--n;
+					kn = kn1;
+					}
+				}
+			*nmatch = n2 - n;
+			return kn;
+			}
+		}
+	    }
+	else
+#endif	/*}*/
+	while(n > 0) {
+		n1 = n >> 1;
+		kn = keywds + n1;
+		k = strncmp(name, kn->name, L);
+		if (k < 0)
+			n = n1;
+		else if (k > 0) {
+			n -= ++n1;
+			n0 += n1;
+			keywds = kn + 1;
+			}
+		else {
+			/* Found -- check for range of matches. */
+			/* Here we use linear search, as we expect */
+			/* the range to be small. */
+			n = n1 + n0;
+			n2 = n + 1;
+			if (kn->name[L]) {
+				for(kn1 = kn; n2 < nn; ++n2) {
+					++kn1;
+					if (strncmp(name, kn1->name, L))
+						break;
+					if (!kn1->name[L])
+						goto found1;
+					}
+				kn1 = kn;
+				while(n > 0) {
+					--kn1;
+					if (strncmp(name, kn1->name, L))
+						break;
+					if (!kn1->name[L]) {
+ found1:
+						*nmatch = 1;
+						return kn1;
+						}
+					--n;
+					kn = kn1;
+					}
+				}
+			*nmatch = n2 - n;
+			return kn;
+			}
+		}
+	return 0;	/* not found */
+	}
+
+ static KeyWord *
+toomany(const char *name, KeyWord *kw, int nmatch)
+{
+	int i;
+	squawk("\"%s\" is ambiguous; possible matches..", name);
+	if (nsquawk <=  NIDR_SQUAWKMAX)
+		for(i = 0; i < nmatch; i++, kw++)
+			fprintf(stderr, "\t%s\n", kw->name);
+	return 0;
+	}
+
+ KeyWord *
+nidr_keyword(const char *name)
+{
+	int nmatch;
+	KeyWord *kw, *kw1;
+
+	kw = kwfind(name, Keyword_Top->kw, Keyword_Top->nkw, &nmatch);
+	if (nmatch > 1)
+		return toomany(name, kw, nmatch);
+	else if (kw) {
+		if (!(kw1 = curkw)) {
+			kw = kw_setup(kw, KW_g, name);
+			if (kw->kind & KWKind_Dynmult)
+				return kw;
+			}
+		if (!strict) {
+			if (kw1)
+				nidr_keyword_finish();
+			kw_setup1(kw);
+			}
+		}
+	return kw;
+	}
+
+ static void
+valcheck(KeyWord *kw)
+{
+	Real *r;
+	int *z;
+	int i, k, n;
+
+	n = KWval.n;
+	switch(k = kw->kind & KWKind_Mask) {
+	  case KWKind_Int:
+		z = KWval.i;
+		if (kw->kind & KWKind_strictLb) {
+			for(i = 0; i < n; ++i)
+				if (z[i] <= kw->Lb) {
+					squawk("%s must be > %.0f", kw->name, kw->Lb);
+					break;
+					}
+				}
+		else if (kw->kind & KWKind_caneqLb) {
+			for(i = 0; i < n; ++i)
+				if (z[i] < kw->Lb) {
+					squawk("%s must be >= %.0f", kw->name, kw->Lb);
+					break;
+					}
+				}
+		if (kw->kind & KWKind_strictUb) {
+			for(i = 0; i < n; ++i)
+				if (z[i] >= kw->Ub) {
+					squawk("%s must be < %.0f", kw->name, kw->Ub);
+					break;
+					}
+				}
+		else if (kw->kind & KWKind_caneqUb) {
+			for(i = 0; i < n; ++i)
+				if (z[i] > kw->Ub) {
+					squawk("%s must be >= %.0f", kw->name, kw->Ub);
+					break;
+					}
+				}
+		break;
+	  case KWKind_Real:
+		r = KWval.r;
+		if (kw->kind & KWKind_strictLb) {
+			for(i = 0; i < n; ++i)
+				if (r[i] <= kw->Lb) {
+					squawk("%s must be > %g", kw->name, kw->Lb);
+					break;
+					}
+				}
+		else if (kw->kind & KWKind_caneqLb) {
+			for(i = 0; i < n; ++i)
+				if (r[i] < kw->Lb) {
+					squawk("%s must be >= %g", kw->name, kw->Lb);
+					break;
+					}
+				}
+		if (kw->kind & KWKind_strictUb) {
+			for(i = 0; i < n; ++i)
+				if (r[i] >= kw->Ub) {
+					squawk("%s must be < %g", kw->name, kw->Ub);
+					break;
+					}
+				}
+		else if (kw->kind & KWKind_caneqUb) {
+			for(i = 0; i < n; ++i)
+				if (r[i] > kw->Ub) {
+					squawk("%s must be >= %g", kw->name, kw->Ub);
+					break;
+					}
+				}
+		break;
+	  default:
+		botch("Bug: unexpected (kw->kind & KWKind_Mask) = %d in valcheck",n);
+	  }
+	}
+
+ static void
+read_lib(const char *libname, KeyWord *kw)
+{
+#ifdef NO_NIDR_DYNLIB /*{{*/
+	botch("LIBNAME is disallowed: cannot read \"%s\"", libname);
+#else /*}{*/
+	KeyWord *kw1;
+	KW_ADD kwa;
+	NIDR_KWlib *Lib;
+	void *h;
+
+	h = nidr_dlopen(libname);
+	if (!h) {
+#ifndef NO_DLERROR
+		const char *s;
+		if ((s = dlerror()))
+			botch("Cannot open library \"%s\":\n\t%s", libname, s);
+		else
+#endif
+			botch("Cannot open library \"%s\"", libname);
+		}
+	if (!find_dlsym(kwa, h, "keyword_add"))
+		botch("dlsym(\"keyword_add\") failed for %s", libname);
+	kw1 = (*kwa)();
+	Lib = nidr_lib_record(h, libname);
+	kw->nkw = kw1->nkw;
+	kw->kw = kw1->kw;
+	kw->f = kw1->f;
+	kw->kind |= KWKind_Loaded;
+#endif	/*}}*/
+	}
+
+ static void
+nidr_id_strict_finish(KWinfo *kwi, KeyWord *kw, const char *name)
+{
+	KeyWord *kw1;
+	int n;
+
+	if (kw->alt) {
+		if ((kw1 = kwi->alt[n = kw->alt])) {
+			if (strcmp(kw1->name, name))
+				squawk("%s and %s are mutually exclusive",
+					kw1->name, name);
+			else
+				squawk("%s was already specified", name);
+			}
+		else
+			kwi->alt[n] = kw;
+		}
+	if (kw->req) {
+		if (kwi->req[n = kw->req])
+			kwi->req[n] = 0;
+		else if (!kw->alt)
+			squawk("%s specified more than once", name);
+		}
+	}
+
+ static KWinfo *
+dispatch_val(KWinfo *kwi)
+{
+	KeyWord *kw = kwi->kw;
+
+	kwi->needstart = 0;
+	if (KWval.n) {
+		if (KWval.rstate)
+			finish_rexpand();
+		if (dumpfile) {
+			dumpname(1, kw);
+			dumpvals(kw);
+			}
+		if (kw->kind & (KWKind_Lb|KWKind_Ub))
+			valcheck(kw);
+		if (kw->f.start)
+			(*kw->f.start)(kw->name, &KWval, &kwi->g, kw->f.vs);
+		else if ((kw->kind & (KWKind_Libname | KWKind_Loaded)) == KWKind_Libname) {
+			read_lib(KWval.s[0], kw);
+			kw = kw_setup(kw, kwi->g, kw->name);
+			if (kw->f.start)
+				(*kw->f.start)(kw->name, &KWval, &kwi->g, kw->f.vs);
+			if (kw == kwi->kw) {
+				*kwi = *KWStack;
+				--KWStack;
+				}
+			else
+				kwi = KWStack;
+			}
+		KWval.n = 0;
+		}
+	else if ((kw->kind & (KWKind_Libname|KWKind_Loaded))
+			  != (KWKind_Libname|KWKind_Loaded))
+		squawk("expected %sone %s value for %s",
+			kw->kind & KWKind_List ? "at least " : "",
+			valkind[(kw->kind & KWKind_Mask)-1], kw->name);
+	++dumplev;
+	return kwi;
+	}
+
+ static void
+oneof(KeyWord *kw, int alt, int n)
+{
+	KeyWord *kw1;
+
+	squawk("One of the following %d entities\nmust be specified for %s..",
+		n, kw->name);
+	for(kw1 = kw->kw; !kw1->name; kw1 = kw1->kwnext);
+	for(; kw1; kw1 = kw1->kwnext)
+		if (kw1->alt == alt && kw1->kind & KWKind_primary)
+			fprintf(stderr, "\t%s\n", kw1->name);
+	}
+
+ static void
+missing_chk(KeyWord *kw1, KWinfo *kwi)
+{
+	KeyWord *kw0, *kw2, **req;
+	Uint a;
+	char seen0[1024], *seen;
+	const char *kwname;
+	int n;
+	size_t nreq;
+
+	/* only issue one error message per missing keyword */
+
+	nreq = 0;
+	for(kw0 = kw1; kw1; kw1 = kw1->kwnext)
+		if (nreq < kw1->req)
+			nreq = kw1->req;
+	seen = seen0;
+	if (++nreq > sizeof(seen0))
+		seen = (char*)Alloc("missing_chk", nreq);
+	memset(seen, 0, nreq);
+	req = kwi->req;
+	for(kw1 = kw0; kw1; kw1 = kw1->kwnext) {
+		if (kw1->req && req[kw1->req] && !seen[kw1->req] && kw1->kind & KWKind_primary) {
+			seen[kw1->req] = 1;
+			a = -1;
+			if (!kw1->alt || (n = kwi->altct[a = kw1->alt]) <= 1) {
+				if (!(kwname = kwi->name))
+					kwname = "<NIDRBUG>";
+				for(kw2 = kw1;;) {
+					if (kw2->alt == a && kw2->kind & KWKind_primary)
+						break;
+					if (!(kw2 = kw2->kwnext))
+						botch("Bug in missing_chk");
+					}
+				squawk("%s must be specified for %s",
+					kw2->name, kwname);
+				}
+			else
+				oneof(kwi->kw, kw1->alt, n);
+			}
+		}
+	if (seen != seen0)
+		free(seen);
+	}
+
+ static void
+finalize(KWinfo *kwi)
+{
+	KeyWord *kw, *kw1, **req;
+
+	kw = kwi->kw;
+	kw->kind &= ~KWKind_Stacked;
+	if (kwi->needstart)
+		kwi = dispatch_val(kwi);
+	if (kw->name)
+		--dumplev;
+	if (kw->f.final)
+		(*kw->f.final)(kw->name, 0, &kwi->g, kw->f.vf);
+	if (kwi->alt) {
+		if (kwi->nreq) {
+			req = kwi->req;
+			for(kw1 = kwi->kw1; kw1; kw1 = kw1->kwnext)
+				if (kw1->req && req[kw1->req]) {
+					missing_chk(kw1, kwi);
+					break;
+					}
+			}
+		free(kwi->alt);
+		}
+	}
+
+ static KeyWord *
+nidr_identifier_strict(const char *name)
+{
+	KWinfo *kwi, *kwi1;
+	KeyWord *kw, *kw1;
+	int nmatch;
+	size_t height;
+
+	if (!curkw)
+		botch("curkw = 0 in nidr_identifier");
+	kwi = KWStack;
+	if (kwi->needstart)
+		kwi = dispatch_val(kwi);
+	for(kwi1 = kwi;;) {
+		kw1 = kwi->kw;
+		if ((kw = kwfind(name, kwi->kw1, kw1->nkw, &nmatch)))
+			break;
+		if (kwi == KWStackBot)
+			return 0;
+		if ((--kwi)->kw->name && !(kwi->kw->kind & KWKind_Loaded))
+			kwi1 = kwi;
+		}
+	if (nmatch > 1)
+		return toomany(name, kw, nmatch);
+	while(KWStack > kwi1)
+		finalize(KWStack--);
+	if ((kw->kind & (KWKind_Libname | KWKind_Loaded)) == KWKind_Libname) {
+		nidr_id_strict_finish(kwi, kw, name);
+		if (!KWvalmax.r)
+			KWvalbuf = (Real *)Alloc("nidr_identifier_strict",
+						(nKWvalbuf = 128)*sizeof(Real));
+		if (++KWStack >= KWStackEnd)
+			KWStack_inc();
+		kwi = KWStack;
+		kwi->kw = kw;
+		kwi->needstart = 1;
+		KWval.s = (const char**)KWvalbuf;
+		KWvalmax.n = (nKWvalbuf*sizeof(Real))/sizeof(char*);
+		KWvalmax.s = KWval.s + KWvalmax.n;
+		}
+	else {
+		height = kwi - KWStackBot;
+		kw = kw_setup(kw, kwi->g, name);
+		kwi = KWStackBot + height; /* in case kw_setup reallocated KWStack */
+		nidr_id_strict_finish(kwi, kw, name);
+		}
+	return kw;
+	}
+
+ static void
+nidr_keyword_finish(void)
+{
+	if (!strict)
+		kw_finish2();
+	for(;;--KWStack) {
+		finalize(KWStack);
+		if (KWStack == KWStackBot)
+			break;
+		}
+	if (!strict)
+		kw_finish3();
+	curid = curkw = 0;
+	}
+
+ const char*
+nidr_keyword_name(void)
+{ return curkw ? curkw->name : "<none>"; }
+
+/* Some of the above assumes strict nesting according to dakota.input.nspec. */
+/* Code here is meant to relax this assumption, allowing more flexibility in */
+/* the order of identifiers within a DAKOTA "keyword". */
+
+ typedef struct KWpair KWpair;
+ typedef struct KWmblk KWmblk;
+
+ struct
+KWmblk {
+	KWmblk *next;
+	size_t len;
+	/* memory of length len immediately follows */
+	};
+
+ struct
+KWpair {
+	KeyWord *kw;
+	KWseen *kws;
+	};
+
+ enum{ KWmblk_gulp = 32000 };
+
+ static AVL_Tree *AVLT, *AVLKWP;
+ static KWseen **KW_p, **KW_pe, KWmissing, *KWs0;
+ static KWmblk *KWmblk0, *KWmblk1;
+ static const char *KWmem0, *KWmem1;
+
+ typedef struct
+AVLCmpInfo {
+	KWseen **found[2];
+	int nfound;
+	int inexact;
+	} AVLCmpInfo;
+
+ static int
+avlcmp(void *v, KWseen **a, KWseen **b)
+{
+	AVLCmpInfo *AI = (AVLCmpInfo*)v;
+	KWseen *ksa, *ksb;
+	const char *s, *t;
+
+	s = (ksa = *a)->name;
+	t = (ksb = *b)->name;
+	for(; *s == *t; ++s, ++t)
+		if (!*s)
+			return 0;
+	if ((!*s && !ksa->kw && ksb->kw)
+	  ||(!*t && !ksb->kw && ksa->kw)) {
+		/* inexact match */
+		if (AI->nfound == 0
+		|| (AI->nfound == 1 && AI->found[0] != b))
+			AI->found[AI->nfound++] = b;
+		return AI->inexact;
+		}
+	return *s - *t;
+	}
+
+ static int
+kwpcmp(void *v, KWpair *a, KWpair *b)
+{
+	if (a->kw == b->kw)
+		return 0;
+	return a->kw > b->kw ? 1 : -1;
+	}
+
+ static void
+KWmeminit(void)
+{
+	KWmblk0 = KWmblk1 = (KWmblk*)Alloc("KWmeminit",
+			sizeof(KWmblk) + KWmblk_gulp);
+	KWmem0 = (char*)(KWmblk0 + 1);
+	KWmem1 = KWmem0 + KWmblk_gulp;
+	KWmblk0->len = KWmblk_gulp;
+	KWmblk0->next = 0;
+	KWmissing.mnext = KWmissing.mprev = &KWmissing;
+	KW_cur = 0;
+	memset(&KWval, 0, sizeof(KWval));
+	KWvalbuf = (Real *)Alloc("kw_setup(KWValbuf)", (nKWvalbuf = 128)*sizeof(Real));
+	ToClear = ToClear0 = (KeyWord**)Alloc("kw_setup(ToClear)", 256*sizeof(KeyWord*));
+	ToClearEnd = ToClear0 + 256;
+	}
+
+ static void
+KWmembump(size_t L)
+{
+	KWmblk *mb, *mb1;
+	size_t L1;
+
+	for(L1 = KWmblk_gulp; L1 < L; L1 <<= 1);
+	if ((mb = mb1 = KWmblk1->next) && L1 <= mb->len)
+		L1 = mb->len;
+	else {
+		KWmblk1->next = mb = (KWmblk*)Alloc("KWmembump", L1 + sizeof(KWmblk));
+		mb->len = L1;
+		mb->next = mb1;
+		}
+	KWmblk1 = mb;
+	KWmem0 = (char*)(mb+1);
+	KWmem1 = KWmem0 + L1;
+	}
+
+ static void *
+KWgetmem(size_t L)	/* for aligned memory */
+{
+	void *rv;
+
+	L = (L + sizeof(Real) - 1) & ~(sizeof(Real) - 1);
+	if (KWmem1 - KWmem0 < L)
+		KWmembump(L);
+	rv = (void*)KWmem0;
+	KWmem0 += L;
+	return rv;
+	}
+
+ static KWseen **
+KWhash(const char *s, KeyWord *kw)
+{
+	AVLCmpInfo AI;
+	KWseen KW0, *KW0p, *kws, **kwsp;
+	char **ps;
+	const char *sa, *sb;
+
+	AI.nfound = 0;
+	AI.inexact = -1;
+	AVL_setv(AVLT, &AI);
+	KW0.name = s;
+	KW0.kw = kw;
+	KW0p = &KW0;
+	curkws = 0;
+	if ((kwsp = (KWseen**)AVL_find((const Element*)&KW0p, AVLT)))
+		return kwsp;
+	if (AI.nfound) {
+		if (AI.nfound == 1) {
+			AI.inexact = 1;
+			AVL_find((const Element*)&KW0p, AVLT);
+			if (AI.nfound == 1) {
+				if (kw && (kw->kind & (KWKind_Libname | KWKind_Loaded))
+						== KWKind_Libname
+				 && (ps = (*AI.found[0])->svals))
+					read_lib(ps[0], kw);
+				return AI.found[0];
+				}
+			}
+		sa = (*AI.found[0])->name;
+		sb = (*AI.found[1])->name;
+		if (kw)
+			squawk("Both '%s' and '%s' match '%s'",
+				sa, sb, s);
+		else
+			squawk("'%s' is ambiguous:\n\tit matches both '%s' and '%s'",
+				s, sa, sb);
+		return AI.found[0];
+		}
+	kws = (KWseen*)KWgetmem(sizeof(KWseen));
+	memset(kws, 0, sizeof(KWseen));
+	if ((kws->kw = kw))
+		s = kw->name;
+	else {
+		curkws = kws;
+		kws->mnext = &KWmissing;
+		KWmissing.mprev = (kws->mprev = KWmissing.mprev)->mnext = kws;
+		s = nidr_KWscopy(s);
+		}
+	kws->name = s;
+	if (KW_p >= KW_pe) {
+		KW_p = (KWseen**)KWgetmem(32*sizeof(KWseen*));
+		KW_pe = KW_p + 32;
+		}
+	*(kwsp = KW_p++) = kws;
+	AVL_insert((const Element*)kwsp, AVLT);
+	return kwsp;
+	}
+
+ static void
+mixed_squawk(void)
+{
+	squawk("values for %s cannot be both strings and numbers",
+		KW_cur->name);
+	}
+
+ static void
+nidr_bufr_relaxed(Real r, int state)
+{
+	int n;
+
+	if (KWval.rstate && !state)
+		finish_rexpand();
+	if (!(n = KWval.n)) {
+		KWval.r = KWvalbuf;
+		KWvalmax.r = KWvalbuf + (KWvalmax.n = nKWvalbuf);
+		}
+	else if (KWval.s) {
+		mixed_squawk();
+		return;
+		}
+	if (n >= KWvalmax.n)
+		KWvalbuf_inc();
+	KWval.r[KWval.n++] = r;
+	if (state | KWval.rstate)
+		rexpand(state);
+	}
+
+ static void
+nidr_bufs_relaxed(const char *s)
+{
+	int n;
+
+	if (!(n = KWval.n)) {
+		KWval.s = (const char**)KWvalbuf;
+		KWvalmax.n = (nKWvalbuf*sizeof(Real))/sizeof(char*);
+		KWvalmax.s = KWval.s + KWvalmax.n;
+		}
+	else if (KWval.r) {
+		mixed_squawk();
+		return;
+		}
+	if (n >= KWvalmax.n)
+		KWvalbuf_inc();
+	KWval.s[KWval.n++] = s;
+	}
+
+ static void kw_setup2(KWseen*);
+
+ static void
+kw_finish1(KWseen *kws)
+{
+	KeyWord *kw;
+	int n;
+	size_t L;
+
+	if (KWval.rstate)
+		finish_rexpand();
+	kws->nvals = n = KWval.n;
+	KWval.n = 0;
+	if (KWval.r) {
+		L = n*sizeof(Real);
+		memcpy(kws->rvals = (Real*)KWgetmem(L), KWval.r, L);
+		KWval.r = 0;
+		}
+	else if (KWval.s) {
+		L = n*sizeof(char*);
+		memcpy(kws->svals = (char**)KWgetmem(L), KWval.s, L);
+		if ((kw = kws->kw) && kw->kind & KWKind_Libname) {
+			read_lib(KWval.s[0], kw);
+			if (kw->kw)
+				kw_setup2(kws);
+			}
+		KWval.s = 0;
+		}
+	}
+
+ static void*
+Alloc1(size_t len)
+{
+	void *rv = malloc(len);
+	if (!rv) {
+		fprintf(stderr, "malloc(%lu) failure in Alloc1\n", (unsigned long)len);
+		exit(1);
+		}
+	return rv;
+	}
+
+ static void
+AVL_Clear(void)
+{
+	while(ToClear > ToClear0)
+		(*--ToClear)->kind &= ~KWKind_Hashed;
+	AVL_Tree_free(&AVLT);
+	if (AVLKWP)
+		AVL_Tree_free(&AVLKWP);
+	}
+
+ static void
+kw_setup1(KeyWord *kw)
+{
+	KWseen *kws, *kws1;
+	KeyWord *kw1;
+
+	if ((kw1 = kw->kw))
+		kwnext_setup(kw1, kw->nkw);
+	if (!KWmblk0)
+		KWmeminit();
+	if (AVLT)
+		AVL_Clear();
+	AVLT = AVL_Tree_alloc(0, (AVL_Elcomp)avlcmp, Alloc1);
+	KW_cur = KWs0 = kws = (KWseen*)KWgetmem(sizeof(KWseen));
+	memset(kws, 0, sizeof(KWseen));
+	kws->name = kw->name;
+	kws->kw = kw;
+	kws->lcn = &kws->mprev;
+	if (kw1) {
+		while(!kw1->name)
+			kw1 = kw1->kwnext;
+		for(; kw1; kw1 = kw1->kwnext) {
+			kws1 = *KWhash(kw1->name, kw1);
+			kws1->parent = kws;
+			}
+		}
+	}
+
+ static KWseen**
+kw_setup3(KWseen **kwtodo1, KWseen *kws, KeyWord *kw)
+{
+	KWseen *kws1, **kwsp;
+
+	for(; kw; kw = kw->kwnext) {
+		kwsp = KWhash(kw->name, kw);
+		kws1 = *kwsp;
+		if (kws1->comment) {
+			kw->comment = kws1->comment;
+			kws1->comment = 0;
+			}
+		if (kws1->parent) {
+			kws1 = (KWseen*)KWgetmem(sizeof(KWseen));
+			memset(kws1, 0, sizeof(KWseen));
+			kws1->kw = kw;
+			kws1->name = kw->name;
+			*kwsp = kws1;
+			}
+		kws1->parent = kws;
+		if (!kws1->kw) {
+			kws1->mprev->mnext = kws1->mnext;
+			kws1->mnext->mprev = kws1->mprev;
+			*kwtodo1 = kws1;
+			kwtodo1 = kws1->lcn = &kws1->mprev;
+			*kws->lcn = kws1;
+			kws->lcn = &kws1->mnext;
+			}
+		kws1->kw = kw;
+		}
+	return kwtodo1;
+	}
+
+ static void
+bumpToClear(void)
+{
+	KeyWord **ntc;
+	size_t L, L1;
+
+	L = ToClearEnd - ToClear0;
+	L1 = L << 1;
+	ntc = (KeyWord**)Alloc("bumpToClear", L1*sizeof(KeyWord*));
+	memcpy(ntc, ToClear0, L*sizeof(KeyWord*));
+	free(ToClear0);
+	ToClear0 = ntc;
+	ToClear  = ntc + L;
+	ToClearEnd = ntc + L1;
+	}
+
+ static void
+kw_setup2(KWseen *kws)
+{
+	KWpair kwp, *pkwp;
+	KWseen *kws1, *kws2, *kws3, *kwtodo, **kwtodo1, **pkws;
+	KeyWord *kw, *kw1;
+
+	kwtodo1 = &kwtodo;
+	for(;;) {
+		kw = kws->kw;
+		if ((kw1 = kw->kw)) {
+			kwnext_setup(kw1, kw->nkw);
+			kws2 = kws;
+			while(!kw1->name) {
+				if (!AVLKWP)
+					AVLKWP = AVL_Tree_alloc(0, (AVL_Elcomp)kwpcmp, Alloc1);
+				if (kw1->kind & KWKind_Hashed) {
+					kwp.kw = kw1->kw;
+					kwp.kws = 0;
+					pkwp = (KWpair*)AVL_find((const Element*)&kwp, AVLKWP);
+					kws2 = pkwp->kws;
+					}
+				else {
+					if (ToClear >= ToClearEnd)
+						bumpToClear();
+					*ToClear++ = kw1;
+					kw1->kind |= KWKind_Hashed;
+					pkwp = (KWpair*)KWgetmem(sizeof(KWpair) + sizeof(KWseen));
+					kws1 = (KWseen*)(pkwp + 1);
+					pkwp->kw = kw1->kw;
+					pkwp->kws = kws1;
+					memset(kws1, 0, sizeof(KWseen));
+					kws1->kw = kw1;
+					kws1->name = kws->name;
+					kws1->lcn = &kws1->mprev;
+					kws1->parent = kws2;
+					*kws2->lcn = 0;
+					for(pkws = &kws2->mprev;
+						(kws3 = *pkws) && !kws3->name;
+						pkws = &kws3->mnext);
+					kws1->mnext = *pkws;
+					if (pkws == kws2->lcn)
+						kws2->lcn = &kws1->mnext;
+					kws2 = *pkws = kws1;
+					kwnext_setup(kw1->kw, kw1->nkw);
+					kwtodo1 = kw_setup3(kwtodo1, kws1, kw1->kw);
+					AVL_insert((const Element*)pkwp, AVLKWP);
+					}
+				kw1 = kw1->kwnext;
+				}
+			if (kw->nkw)
+				kwtodo1 = kw_setup3(kwtodo1, kws2, kw1);
+			}
+		*kwtodo1 = 0;
+		if (!kwtodo)
+			break;
+		kws = kwtodo;
+		kw = kws->kw;
+		if (!(kwtodo = kwtodo->mprev))
+			kwtodo1 = &kwtodo;
+		}
+	}
+
+ static KeyWord *
+nidr_identifier_relaxed(const char *name)
+{
+	KWseen *kws, *kws1;
+	KeyWord *kw;
+	int tryagain;
+
+	kw_finish1(KW_cur);
+ top:
+	KW_cur = kws = *KWhash(name, 0);
+	if ((kw = kws->kw)) {
+		curid = kw;
+		if (kws->lcn)
+			squawk("'%s' already seen", kw->name);
+		else {
+			if (kws->comment) {
+				kw->comment = kws->comment;
+				kws->comment = 0;
+				}
+			kws->lcn = &kws->mprev;
+			kws1 = kws->parent;
+			*kws1->lcn = kws;
+			kws1->lcn = &kws->mnext;
+			if (kw->kw)
+				kw_setup2(kws);
+			if (kw->kind & KWKind_Dynlib) {
+				kw = kw_insert(kw, &tryagain);
+				if (kw->kw) {
+					kws->kw = kw;
+					kw_setup2(kws);
+					}
+				if (tryagain)
+					goto top;
+				}
+			}
+		}
+	return (KeyWord*)kws;	/* just needs to be nonzero; won't be dereferenced */
+	}
+
+ static void
+num_expected(KeyWord *kw, int n)
+{
+	squawk("expected numerical value%s for %s, not quoted strings",
+		"s" + (n == 1), kw->name);
+	}
+
+ static void
+kw_process(KWseen *kws)
+{
+	KWseen *kws1;
+	KeyWord *kw;
+	Real *r;
+	Uint k;
+	int i, n;
+
+	kw = kws->kw;
+	if (kw->name) {
+		if (kws != KWs0 && !nidr_identifier_strict(kw->name))
+			botch("nidr_identifier_strict did not find \"%s\"", kw->name);
+		if ((n = KWval.n = kws->nvals)) {
+			KWval.i = 0;
+			KWval.r = 0;
+			KWval.s = 0;
+			KWval.rstate = 0;
+			switch(k = kw->kind & KWKind_Mask) {
+			  case 0:
+				squawk("No values may be specified for %s", kw->name);
+				break;
+
+			  case KWKind_Int:
+				if (!(r = kws->rvals)) {
+					num_expected(kw,n);
+					break;
+					}
+				KWval.i = (int*)KWvalbuf;
+				for(i = 0; i < n; i++)
+					KWval.i[i] = (int)r[i];
+				break;
+
+			  case KWKind_Real:
+				if (!(r = kws->rvals)) {
+					num_expected(kw,n);
+					break;
+					}
+				KWval.r = r;
+				break;
+
+			  case KWKind_Str:
+				if (!(KWval.s = (const char **)kws->svals))
+					squawk("expected string value%s for %s",
+						"s" + (n == 1), kw->name);
+			  }
+			}
+		}
+	*kws->lcn = 0;
+	for(kws1 = kws->mprev; kws1; kws1 = kws1->mnext)
+		kw_process(kws1);
+	}
+
+ static void
+kw_finish2(void)
+{
+	KWseen *kws, *kwe;
+
+	kw_finish1(KW_cur);
+	kwe = &KWmissing;
+	for(kws = KWmissing.mnext; kws != kwe; kws = kws->mnext) {
+		squawk("unrecognized identifier '%s'", kws->name);
+		}
+	KWmissing.mnext = KWmissing.mprev = &KWmissing;
+	kw_process(KWs0);
+	KWs0 = 0;
+	AVL_Clear();
+	}
+
+ static void
+kw_finish3(void)
+{
+	KWmblk1 = KWmblk0;
+	KWmem0 = (char*)(KWmblk0 + 1);
+	KWmem1 = KWmem0 + KWmblk_gulp;
+	KW_p = KW_pe = 0;
+	}
+
+ void (*nidr_bufr)(Real,int) = nidr_bufr_relaxed;
+ void (*nidr_bufs)(const char*) = nidr_bufs_relaxed;
+ KeyWord *(*nidr_identifier)(const char*) = nidr_identifier_relaxed;
+
+ void
+nidr_set_strict(int n)
+{
+	if ((strict = n)) {
+		nidr_bufr = nidr_bufr_strict;
+		nidr_bufs = nidr_bufs_strict;
+		nidr_identifier = nidr_identifier_strict;
+		}
+	else {
+		nidr_bufr = nidr_bufr_relaxed;
+		nidr_bufs = nidr_bufs_relaxed;
+		nidr_identifier = nidr_identifier_relaxed;
+		}
+	}
+
+ int
+nidr_cleanup(void)
+{
+	KWmblk *mb, *mb1;
+	Sbuf *sb, *sb1;
+
+	if (curkw)
+		nidr_keyword_finish();
+	if (dumpfile) {
+		if (OutsideComment)
+			dumpcomment(&OutsideComment);
+		if (dumpfile != stdout) {
+			fclose(dumpfile);
+			dumpfile = 0;
+			}
+		if (nidr_comment)
+			comment_reset();
+		}
+	if (ToClear0) {
+		free(ToClear0);
+		ToClear = ToClear0 = 0;
+		}
+	if ((mb1 = KWmblk0)) {
+		KWmblk0 = 0;
+		do {
+			mb = mb1;
+			mb1 = mb->next;
+			free(mb);
+			} while(mb1);
+		}
+	if (KWvalbuf) {
+		free(KWvalbuf);
+		KWvalbuf = 0;
+		}
+	if ((sb1 = KWsbuf0.next)) {
+		KWsbuf0.next = 0;
+		do {
+			sb = sb1;
+			sb1 = sb->next;
+			free(sb);
+			} while(sb1);
+		}
+	if (AVLT)
+		AVL_Clear();
+	return nidr_parse_error();
+	}
+
+ void
+nidr_setup(const char *parser, FILE *df)
+{
+	const char *s;
+	int comkeep, oneline;
+
+	if (!(s = parser))
+		return;
+	if (!strncmp(s,"nidr",4))
+		s += 4;
+	if (!strncmp(parser,"strict",6)) {
+		nidr_set_strict(1);
+		s += 6;
+		}
+	comkeep = oneline = 0;
+	if (*s == '-') for(;;) {
+		switch(*++s) {
+		  case '1':
+			++oneline;
+			continue;
+		  case 'p':
+			++primary;
+			continue;
+		  case 'c':
+			++comkeep;
+			continue;
+		  }
+		break;
+		}
+	if (df)
+		dumpfile = df;
+	else if (s[0] == ':' && s[1]) {
+		if (s[1] == '-' && !s[2])
+			dumpfile = df = stdout;
+		else {
+			dumpfile = df = fopen(++s,"w");
+			if (!dumpfile) {
+				fprintf(stderr, "Cannot open \"%s\"\n", s);
+				exit(1);
+				}
+			}
+		}
+	if (df) {
+		if (oneline)
+			dumpvals = dumpvals1;
+		if (comkeep)
+			comment_setup();
+		}
+	}
Index: /issm/trunk-jpl/externalpackages/dakota/install-6.2-mac-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/install-6.2-mac-static.sh	(revision 25744)
+++ /issm/trunk-jpl/externalpackages/dakota/install-6.2-mac-static.sh	(revision 25745)
@@ -59,4 +59,16 @@
 cp configs/${VER}/mac/packages/VPISparseGrid/src/sandia_rules.cpp ${DAK_SRC}/packages/VPISparseGrid/src
 
+# Uncomment to copy the following customized source files if using C99 or later 
+# standard. If uncommented, adding -Wno-error=implicit-function-declaration 
+# option to CFLAGS is not needed.
+# cp configs/${VER}/mac/static/packages/DDACE/include/xtndispatch.h ${DAK_SRC}/packages/DDACE/include
+# cp configs/${VER}/mac/static/packages/DDACE/src/Bose/Boselink.c ${DAK_SRC}/packages/DDACE/src/Bose
+# cp configs/${VER}/mac/static/packages/DDACE/src/Bose/construct.c ${DAK_SRC}/packages/DDACE/src/Bose
+# cp configs/${VER}/mac/static/packages/DDACE/src/Bose/galois.c ${DAK_SRC}/packages/DDACE/src/Bose
+# cp configs/${VER}/mac/static/packages/DDACE/src/Bose/gfields.c ${DAK_SRC}/packages/DDACE/src/Bose
+# cp configs/${VER}/mac/static/packages/DDACE/src/Bose/oa.c ${DAK_SRC}/packages/DDACE/src/Bose
+# cp configs/${VER}/mac/static/packages/nidr/nidr.c ${DAK_SRC}/packages/nidr
+# cp configs/${VER}/mac/static/packages/nidr/nidr-scanner.c ${DAK_SRC}/packages/nidr
+
 # Configure
 cd ${DAK_BUILD}
@@ -67,5 +79,5 @@
 	-DCMAKE_CXX_COMPILER=${MPI_HOME}/bin/mpicxx \
 	-DCMAKE_Fortran_COMPILER=${MPI_HOME}/bin/mpif77 \
-	-DCMAKE_C_FLAGS="-fPIC" \
+	-DCMAKE_C_FLAGS="-fPIC -Wno-error=implicit-function-declaration" \
 	-DCMAKE_CXX_FLAGS="-fPIC -fdelayed-template-parsing" \
 	-DCMAKE_Fortran_FLAGS="-fPIC" \
Index: /issm/trunk-jpl/externalpackages/gdal/install-3-netcdf-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/gdal/install-3-netcdf-static.sh	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/gdal/install-3-netcdf-static.sh	(revision 25745)
@@ -0,0 +1,63 @@
+#!/bin/bash
+set -eu
+
+
+# TODO
+# - May want to supply path to Python instead of, effectively, using result of 
+#	`which python`
+#
+
+## Constants
+#
+VER="3.1.1"
+
+HDF5_ROOT="${ISSM_DIR}/externalpackages/petsc/install"
+NETCDF_ROOT="${ISSM_DIR}/externalpackages/netcdf/install"
+PROJ_ROOT="${ISSM_DIR}/externalpackages/proj/install"
+ZLIB_ROOT="${ISSM_DIR}/externalpackages/petsc/install"
+
+## Environment
+#
+export CC=mpicc
+export CXX=mpicxx
+export LDFLAGS="-L${HDF5_ROOT}/lib" # Need to do this so HDF5 symbols referenced in NETCDF library are found at link time
+export LIBS="-lhdf5_hl -lhdf5" # Need to do this so HDF5 symbols referenced in NETCDF library are found at link time
+export PREFIX="${ISSM_DIR}/externalpackages/gdal/install" # Need this to properly set destination root for Python libraries on macOS (should not affect Linux build; do not need for this configuration, but including it for consistency)
+
+# Cleanup
+rm -rf install src
+mkdir install src
+
+# Download source
+$ISSM_DIR/scripts/DownloadExternalPackage.sh "http://issm.jpl.nasa.gov/files/externalpackages/gdal-${VER}.tar.gz" "gdal-${VER}.tar.gz"
+
+# Unpack source
+tar -zxvf gdal-$VER.tar.gz
+
+# Move source into 'src' directory
+mv gdal-$VER/* src
+rm -rf gdal-$VER
+
+# Configure
+cd src
+./configure \
+	--prefix="${PREFIX}" \
+	--enable-fast-install \
+	--disable-shared \
+	--without-ld-shared \
+	--enable-static \
+	--with-pic \
+	--with-libz="${ZLIB_ROOT}" \
+	--with-hdf5="${HDF5_ROOT}" \
+	--with-netcdf="${NETCDF_ROOT}" \
+	--with-proj="${PROJ_ROOT}" \
+	--with-pg=no
+
+# Compile and install
+if [ $# -eq 0 ]; then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
Index: /issm/trunk-jpl/externalpackages/gdal/install-3-python-netcdf-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/gdal/install-3-python-netcdf-static.sh	(revision 25744)
+++ /issm/trunk-jpl/externalpackages/gdal/install-3-python-netcdf-static.sh	(revision 25745)
@@ -3,6 +3,7 @@
 
 
-## TODO
-#	- May want to supply path to Python instead of, effectively, using result of `which python`
+# TODO
+# - May want to supply path to Python instead of, effectively, using result of 
+#	`which python`
 #
 
@@ -51,5 +52,6 @@
 	--with-hdf5="${HDF5_ROOT}" \
 	--with-netcdf="${NETCDF_ROOT}" \
-	--with-proj="${PROJ_ROOT}"
+	--with-proj="${PROJ_ROOT}" \
+	--with-pg=no
 
 # Compile and install
Index: /issm/trunk-jpl/externalpackages/gmsh/configs/4.5.6/mac/static/CMakeLists.txt
===================================================================
--- /issm/trunk-jpl/externalpackages/gmsh/configs/4.5.6/mac/static/CMakeLists.txt	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/gmsh/configs/4.5.6/mac/static/CMakeLists.txt	(revision 25745)
@@ -0,0 +1,2141 @@
+# Gmsh - Copyright (C) 1997-2020 C. Geuzaine, J.-F. Remacle
+#
+# See the LICENSE.txt file for license information. Please report all
+# issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
+
+cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
+
+# do not warn about non-definition of WIN32 on Cygwin
+set(CMAKE_LEGACY_CYGWIN_WIN32 0)
+
+# if CMAKE_BUILD_TYPE is specified use it; otherwise set the default
+# build type to "RelWithDebInfo" ("-O2 -g" with gcc) prior to calling
+# project()
+if(DEFINED CMAKE_BUILD_TYPE)
+  set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose build type")
+else()
+  set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose build type")
+endif()
+
+project(gmsh CXX C)
+
+# this variable controls the default value of the options which are normally set
+# to ON (useful if you want to configure a minimal version of Gmsh: e.g. "cmake
+# -DDEFAULT=0 -DENABLE_POST=1 -DENABLE_PARSER=1")
+set(DEFAULT ON CACHE INTERNAL "Default value for enabled-by-default options")
+
+macro(opt OPTION HELP VALUE)
+  option(ENABLE_${OPTION} ${HELP} ${VALUE})
+  set(OPT_TEXI "${OPT_TEXI}\n@item ENABLE_${OPTION}\n${HELP} (default: ${VALUE})")
+endmacro()
+
+opt(3M "Enable proprietary 3M extension" OFF)
+opt(ACIS "Enable ACIS geometrical models (experimental)" ${DEFAULT})
+opt(ALGLIB "Enable ALGLIB (used by some mesh optimizers)" ${DEFAULT})
+opt(ANN "Enable ANN (used for fast point search in mesh/post)" ${DEFAULT})
+opt(BAMG "Enable Bamg 2D anisotropic mesh generator" ${DEFAULT})
+opt(BLAS_LAPACK "Enable BLAS/Lapack for linear algebra (required for meshing)" ON)
+opt(BLOSSOM "Enable Blossom algorithm (needed for full quad meshing)" ${DEFAULT})
+opt(BUILD_LIB "Enable 'lib' target for building static Gmsh library" OFF)
+opt(BUILD_SHARED "Enable 'shared' target for building shared Gmsh library" OFF)
+opt(BUILD_DYNAMIC "Enable dynamic Gmsh executable (linked with shared library)" OFF)
+opt(BUILD_ANDROID "Enable Android NDK library target (experimental)" OFF)
+opt(BUILD_IOS "Enable iOS library target (experimental)" OFF)
+opt(CGNS "Enable CGNS import/export (experimental)" ${DEFAULT})
+opt(CGNS_CPEX0045 "Enable high-order CGNS import/export following CPEX0045 (experimental)" OFF)
+opt(CAIRO "Enable Cairo to render fonts (experimental)" ${DEFAULT})
+opt(CXX11 "Enable C++11" ON)
+opt(C99 "Enable C99" ON)
+opt(PROFILE "Enable profiling compiler flags" OFF)
+opt(DINTEGRATION "Enable discrete integration (needed for levelsets)" ${DEFAULT})
+opt(DOMHEX "Enable experimental DOMHEX code" ${DEFAULT})
+opt(FLTK "Enable FLTK graphical user interface (requires mesh/post)" ${DEFAULT})
+opt(GETDP "Enable GetDP solver (linked as a library, experimental)" ${DEFAULT})
+opt(GMM "Enable GMM linear solvers (simple alternative to PETSc)" ${DEFAULT})
+opt(GMP "Enable GMP for Kbipack (advanced)" ON)
+opt(GRAPHICS "Enable building graphics lib even without GUI (advanced)" OFF)
+opt(HXT "Enable HXT library (for reparametrization and meshing)" ${DEFAULT})
+opt(KBIPACK "Enable Kbipack (neeeded by homology solver)" ${DEFAULT})
+opt(MATHEX "Enable Mathex expression parser (used by plugins and options)" ${DEFAULT})
+opt(MED "Enable MED mesh and post file formats" ${DEFAULT})
+opt(MESH "Enable mesh module (required by GUI)" ${DEFAULT})
+opt(METIS "Enable Metis mesh partitioner" ${DEFAULT})
+opt(MMG3D "Enable MMG3D 3D anisotropic mesh refinement" ${DEFAULT})
+opt(MPEG_ENCODE "Enable built-in MPEG movie encoder" ${DEFAULT})
+opt(MPI "Enable MPI (experimental, not used for meshing)" OFF)
+opt(MSVC_STATIC_RUNTIME "Enable static Visual C++ runtime" OFF)
+opt(MUMPS "Enable MUMPS sparse direct linear solver" OFF)
+opt(NETGEN "Enable Netgen 3D frontal mesh generator" ${DEFAULT})
+opt(NUMPY "Enable fullMatrix and numpy array conversion for private API" OFF)
+opt(PETSC4PY "Enable petsc4py wrappers for petsc matrices for private API" OFF)
+opt(OCC "Enable OpenCASCADE CAD kernel" ${DEFAULT})
+opt(OCC_CAF "Enable OpenCASCADE CAF module (for STEP/IGES attributes)" ${DEFAULT})
+opt(OCC_STATIC "Link OpenCASCADE static instead of dynamic libraries (requires ENABLE_OCC)" OFF)
+opt(OCC_TBB "Add TBB libraries in list of OCC libraries" OFF)
+opt(ONELAB "Enable ONELAB solver interface" ${DEFAULT})
+opt(ONELAB_METAMODEL "Enable ONELAB metamodels (experimental)" ${DEFAULT})
+opt(OPENACC "Enable OpenACC" OFF)
+opt(OPENMP "Enable OpenMP" OFF)
+opt(OPTHOM "Enable high-order mesh optimization tools" ${DEFAULT})
+opt(OS_SPECIFIC_INSTALL "Enable OS-specific (e.g. app bundle) installation" OFF)
+opt(OSMESA "Enable OSMesa for offscreen rendering (experimental)" OFF)
+opt(P4EST "Enable p4est for enabling automatic mesh size firld (experimental)" OFF)
+opt(PACKAGE_STRIP "Strip symbols in install packages to reduce install size" ON)
+opt(PARSER "Enable GEO file parser (required for .geo/.pos files)" ${DEFAULT})
+opt(PETSC "Enable PETSc linear solvers (required for SLEPc)" OFF)
+opt(PLUGINS "Enable post-processing plugins" ${DEFAULT})
+opt(POST "Enable post-processing module (required by GUI)" ${DEFAULT})
+opt(POPPLER "Enable Poppler for displaying PDF documents (experimental)" OFF)
+opt(PRIVATE_API "Enable private API" OFF)
+opt(QUADTRI "Enable QuadTri structured meshing extensions" ${DEFAULT})
+opt(REVOROPT "Enable Revoropt (used for CVT remeshing)" OFF)
+opt(SLEPC "Enable SLEPc eigensolvers" OFF)
+opt(SOLVER "Enable built-in finite element solvers (required for compounds)" ${DEFAULT})
+opt(SYSTEM_CONTRIB "Use system versions of contrib libraries, when possible" OFF)
+opt(TCMALLOC "Enable libtcmalloc (fast malloc that does not release memory)" OFF)
+opt(TOUCHBAR "Enable Apple Touch bar" ${DEFAULT})
+opt(VISUDEV "Enable additional visualization capabilities for development purposes" OFF)
+opt(VOROPP "Enable voro++ (for hex meshing, experimental)" ${DEFAULT})
+opt(WRAP_JAVA "Enable generation of Java wrappers for private API" OFF)
+opt(WRAP_PYTHON "Enable generation of Python wrappers for private API" OFF)
+opt(ZIPPER "Enable Zip file compression/decompression" OFF)
+
+set(GMSH_MAJOR_VERSION 4)
+set(GMSH_MINOR_VERSION 5)
+set(GMSH_PATCH_VERSION 6)
+set(GMSH_EXTRA_VERSION "")
+set(GMSH_EXTRA_VERSION_TEXI "${GMSH_EXTRA_VERSION}")
+
+if(NOT GMSH_RELEASE)
+  find_package(Git)
+  if(GIT_FOUND)
+    execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
+                    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ERROR_QUIET
+                    OUTPUT_VARIABLE GIT_COMMIT_HASH
+                    OUTPUT_STRIP_TRAILING_WHITESPACE)
+  endif()
+  if(GIT_COMMIT_HASH)
+    set(GMSH_EXTRA_VERSION "${GMSH_EXTRA_VERSION}-git-${GIT_COMMIT_HASH}")
+  endif()
+  set(GMSH_EXTRA_VERSION_TEXI "${GMSH_EXTRA_VERSION_TEXI} (development version)")
+endif()
+
+set(GMSH_VERSION "${GMSH_MAJOR_VERSION}.${GMSH_MINOR_VERSION}")
+set(GMSH_VERSION "${GMSH_VERSION}.${GMSH_PATCH_VERSION}${GMSH_EXTRA_VERSION}")
+set(GMSH_SHORT_LICENSE "GNU General Public License")
+
+set(GMSH_API api/gmsh.h api/gmshc.h api/gmsh.h_cwrap)
+
+if(ENABLE_PRIVATE_API)
+  message(WARNING "The private API is unsupported and undocumented. It is meant "
+          "for expert Gmsh developers, not for regular Gmsh users, who should rely "
+          "on the stable public API (gmsh/api) instead. If you are repackaging Gmsh, "
+          "e.g. for a Linux distribution, please DO NOT distribute the private API "
+          "(i.e. all the internal headers) and ship the stable public API instead "
+          "(i.e. only the headers and modules in gmsh/api).")
+  file(GLOB_RECURSE HEADERS Common/*.h Numeric/*.h Geo/*.h Mesh/*.h Solver/*.h
+    Post/*.h Graphics/*.h contrib/kbipack/*.h contrib/DiscreteIntegration/*.h
+    contrib/HighOrderMeshOptimizer/*.h contrib/MeshOptimizer/*.h
+    contrib/MeshQualityOptimizer/*.h)
+  set(GMSH_PRIVATE_API ${CMAKE_CURRENT_BINARY_DIR}/Common/GmshConfig.h
+      ${CMAKE_CURRENT_BINARY_DIR}/Common/GmshVersion.h ${HEADERS})
+  get_property(IAMCHILD DIRECTORY PROPERTY PARENT_DIRECTORY)
+  if(IAMCHILD)
+    set(GMSH_PRIVATE_API ${GMSH_PRIVATE_API} PARENT_SCOPE)
+  endif()
+endif()
+
+set(ONELAB_PY contrib/onelab/python/onelab.py)
+set(GMSH_PY api/gmsh.py)
+set(GMSH_JL api/gmsh.jl)
+
+if(${CMAKE_MAJOR_VERSION} GREATER 2)
+  string(TIMESTAMP DATE "%Y%m%d")
+else()
+  execute_process(COMMAND date "+%Y%m%d" OUTPUT_VARIABLE DATE
+                  OUTPUT_STRIP_TRAILING_WHITESPACE)
+endif()
+
+if(NOT DATE)
+  set(DATE "unknown")
+endif()
+set(GMSH_DATE "${DATE}")
+
+if(NOT GMSH_HOST)
+  execute_process(COMMAND hostname OUTPUT_VARIABLE HOSTNAME
+                  OUTPUT_STRIP_TRAILING_WHITESPACE)
+  if(NOT HOSTNAME)
+    set(HOSTNAME "unknown")
+  endif()
+  set(GMSH_HOST "${HOSTNAME}")
+endif()
+
+if(NOT GMSH_PACKAGER)
+  execute_process(COMMAND whoami OUTPUT_VARIABLE PACKAGER
+                  OUTPUT_STRIP_TRAILING_WHITESPACE)
+  if(NOT PACKAGER)
+    set(PACKAGER "unknown")
+  endif()
+  string(REPLACE "\\" " " PACKAGER ${PACKAGER})
+  set(GMSH_PACKAGER "${PACKAGER}")
+endif()
+
+if(APPLE)
+  set(GMSH_OS "MacOSX")
+elseif(CYGWIN OR MSYS)
+  # detect if we use the MinGW compilers on Cygwin - if we do, handle the build
+  # as a pure Windows build
+  if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
+     CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+    execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
+                    OUTPUT_VARIABLE CXX_COMPILER_MACHINE
+                    OUTPUT_STRIP_TRAILING_WHITESPACE)
+    if(CXX_COMPILER_MACHINE MATCHES "mingw")
+      set(GMSH_OS "Windows")
+      set(WIN32 1)
+      add_definitions(-DWIN32)
+    endif()
+  endif()
+else()
+  set(GMSH_OS "${CMAKE_SYSTEM_NAME}")
+endif()
+
+include(CheckTypeSize)
+include(CheckFunctionExists)
+include(CheckIncludeFile)
+include(CheckCXXCompilerFlag)
+include(CheckCCompilerFlag)
+
+macro(set_config_option VARNAME STRING)
+  set(${VARNAME} TRUE)
+  list(APPEND CONFIG_OPTIONS ${STRING})
+  message(STATUS "Found " ${STRING})
+endmacro()
+
+# check if the machine is 64 bits (this is more reliable than using
+# CMAKE_SIZEOF_VOID_P, which does not seem to work e.g. on some Suse
+# machines)
+check_type_size("void*" SIZEOF_VOID_P)
+if(SIZEOF_VOID_P EQUAL 8)
+  set_config_option(HAVE_64BIT_SIZE_T "64Bit")
+endif()
+
+# append 32/64 to the build name on Linux and Windows
+if(NOT APPLE)
+  if(HAVE_64BIT_SIZE_T)
+    set(GMSH_OS "${GMSH_OS}64")
+  else()
+    set(GMSH_OS "${GMSH_OS}32")
+  endif()
+endif()
+
+if(NOT ENABLE_BUILD_SHARED)
+  if(ENABLE_WRAP_PYTHON OR ENABLE_WRAP_JAVA)
+    set(ENABLE_BUILD_DYNAMIC ON)
+  endif()
+endif()
+
+if(ENABLE_BUILD_DYNAMIC)
+  set(GMSH_OS "${GMSH_OS}-sdk")
+endif()
+
+if(APPLE)
+  # FIXME: change this once we understand rpaths - the options below do not work
+  set(CMAKE_MACOSX_RPATH 0)
+else()
+  # make sure that dynamic libraries can be found when installing/ displacing the
+  # binaries: from https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/
+  # RPATH-handling:
+
+  # use, i.e. don't skip the full RPATH for the build tree
+  set(CMAKE_SKIP_BUILD_RPATH  FALSE)
+
+  # when building, don't use the install RPATH already (but later on when
+  # installing)
+  set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
+  set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
+
+  # add the automatically determined parts of the RPATH which point to
+  # directories outside the build tree to the install RPATH
+  set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+
+  # the RPATH to be used when installing, but only if it's not a system directory
+  list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib"
+       isSystemDir)
+  if("${isSystemDir}" STREQUAL "-1")
+     set(CMAKE_INSTALL_RPATH "\\\$ORIGIN/../lib")
+  endif()
+endif()
+
+if(MSVC)
+  # remove annoying warning about bool/int cast performance
+  set(GMSH_CONFIG_PRAGMAS "#pragma warning(disable:4800 4244 4267)")
+  foreach(VAR
+          CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+          CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
+          CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
+          CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
+    if(ENABLE_MSVC_STATIC_RUNTIME AND ${VAR} MATCHES "/MD")
+      string(REGEX REPLACE "/MD" "/MT" ${VAR} "${${VAR}}")
+    endif()
+    if(NOT ${VAR} MATCHES "/MP") # enable parallel compilation
+      set(${VAR} "${${VAR}} /MP")
+    endif()
+  endforeach()
+  if(ENABLE_PRIVATE_API)
+    if(ENABLE_BUILD_DYNAMIC OR ENABLE_BUILD_SHARED)
+      # automatically export .def file with all symbols (requires CMake 3.4);
+      # depending on the compiling options this might lead to more than 64k export
+      # symbols; just trim the .def file to keep the ones you need
+      set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
+    endif()
+  endif()
+endif()
+
+if(ENABLE_OPENMP)
+  find_package(OpenMP)
+  if(OpenMP_FOUND)
+    set_config_option(HAVE_OPENMP "OpenMP")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+  elseif(APPLE AND EXISTS "/opt/local/lib/libomp")
+    # just for testing the official Apple compiler with macports' libomp
+    set_config_option(HAVE_OPENMP "OpenMP[MacPorts]")
+    set(CMAKE_C_FLAGS
+        "${CMAKE_C_FLAGS} -Xpreprocessor -fopenmp -I/opt/local/include/libomp")
+    set(CMAKE_CXX_FLAGS
+        "${CMAKE_CXX_FLAGS} -Xpreprocessor -fopenmp -I/opt/local/include/libomp")
+    list(APPEND EXTERNAL_LIBRARIES "-L/opt/local/lib/libomp -lomp")
+  elseif(APPLE AND EXISTS "/usr/local/lib/libomp.dylib")
+    set_config_option(HAVE_OPENMP "OpenMP[usr/local]")
+    set(CMAKE_C_FLAGS
+        "${CMAKE_C_FLAGS} -Xpreprocessor -fopenmp")
+    set(CMAKE_CXX_FLAGS
+        "${CMAKE_CXX_FLAGS} -Xpreprocessor -fopenmp")
+    list(APPEND EXTERNAL_LIBRARIES "-lomp")
+  endif()
+endif()
+
+if(ENABLE_OPENACC)
+  find_package(OpenACC)
+  if(OpenACC_C_FOUND AND OpenACC_CXX_FOUND)
+    set_config_option(HAVE_OPENACC "OpenACC")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenACC_C_FLAGS}")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenACC_CXX_FLAGS}")
+  endif()
+endif()
+
+if(ENABLE_CXX11)
+  # in recent cmake versions we could do e.g. set(CMAKE_CXX_STANDARD 11)
+  check_cxx_compiler_flag("-std=c++11" STDCXX11)
+  if(STDCXX11)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+  endif()
+endif()
+
+if(ENABLE_C99)
+  # in recent cmake versions we could do e.g. set(CMAKE_C_STANDARD 99)
+  check_c_compiler_flag("-std=c99" STDC99)
+  if(STDC99)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
+  endif()
+endif()
+
+if(ENABLE_PROFILE)
+    # Using the perf set of profiling tools doesn't work without the frame
+    # pointer and a common optimisation is to remove it
+    check_cxx_compiler_flag("-fno-omit-frame-pointer" FNOFP)
+    if(FNOFP)
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
+    endif()
+endif()
+
+macro(append_gmsh_src DIRNAME FILES)
+  foreach(FILE ${FILES})
+    list(APPEND LIST ${DIRNAME}/${FILE})
+  endforeach()
+  set(GMSH_SRC ${GMSH_SRC};${LIST} PARENT_SCOPE)
+  set(GMSH_DIRS ${GMSH_DIRS};${DIRNAME} PARENT_SCOPE)
+endmacro()
+
+macro(find_all_libraries VARNAME LISTNAME PATH SUFFIX)
+  set(${VARNAME})
+  list(LENGTH ${LISTNAME} NUM_LIST)
+  foreach(LIB ${${LISTNAME}})
+    if("${PATH}" STREQUAL "")
+      find_library(FOUND_LIB ${LIB} PATH_SUFFIXES ${SUFFIX})
+    else()
+      find_library(FOUND_LIB ${LIB} PATHS ${PATH} NO_DEFAULT_PATH)
+    endif()
+    if(FOUND_LIB)
+      list(APPEND ${VARNAME} ${FOUND_LIB})
+    endif()
+    unset(FOUND_LIB CACHE)
+  endforeach()
+  list(LENGTH ${VARNAME} NUM_FOUND_LIBRARIES)
+  if(NUM_FOUND_LIBRARIES LESS NUM_LIST)
+    set(${VARNAME})
+  endif()
+endmacro()
+
+macro(set_compile_flags LISTNAME FLAGS)
+  foreach(FILE ${${LISTNAME}})
+    get_source_file_property(PROP ${FILE} COMPILE_FLAGS)
+    if(PROP)
+      set_source_files_properties(${FILE} PROPERTIES COMPILE_FLAGS "${PROP} ${FLAGS}")
+    else()
+      set_source_files_properties(${FILE} PROPERTIES COMPILE_FLAGS "${FLAGS}")
+    endif()
+  endforeach()
+endmacro()
+
+if(ENABLE_BLAS_LAPACK)
+  if(BLAS_LAPACK_LIBRARIES)
+    # use libs as specified in the BLAS_LAPACK_LIBRARIES variable
+    set_config_option(HAVE_BLAS "Blas[custom]")
+    set_config_option(HAVE_LAPACK "Lapack[custom]")
+    set(LAPACK_LIBRARIES ${BLAS_LAPACK_LIBRARIES})
+  else()
+    if(MSVC)
+      # on Windows with Visual C++ try really hard to find blas/lapack *without*
+      # requiring a Fortran compiler: 1) try to find the Intel MKL libs using
+      # the standard search path; if not found 2) try to get the reference
+      # blas/lapack libs (useful for users with no Fortran compiler and no MKL
+      # license, who can just download our precompiled "gmsh-dep" package)
+      if(HAVE_64BIT_SIZE_T)
+        set(MKL_PATH em64t/lib)
+        set(MKL_LIBS_REQUIRED libguide40 mkl_intel_lp64 mkl_intel_thread mkl_core)
+      else()
+        set(MKL_PATH ia32/lib)
+        set(MKL_LIBS_REQUIRED libguide40 mkl_intel_c mkl_intel_thread mkl_core)
+      endif()
+      find_all_libraries(LAPACK_LIBRARIES MKL_LIBS_REQUIRED "" ${MKL_PATH})
+      if(LAPACK_LIBRARIES)
+        set_config_option(HAVE_BLAS "Blas[mkl]")
+        set_config_option(HAVE_LAPACK "Lapack[mkl]")
+      else()
+        set(REFLAPACK_LIBS_REQUIRED lapack blas g2c gcc)
+        find_all_libraries(LAPACK_LIBRARIES REFLAPACK_LIBS_REQUIRED "" "")
+        if(LAPACK_LIBRARIES)
+          set_config_option(HAVE_BLAS "Blas[ref]")
+          set_config_option(HAVE_LAPACK "Lapack[ref]")
+        endif()
+      endif()
+    elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+      # on Linux try to find the Intel MKL without a Fortran compiler
+      if(HAVE_64BIT_SIZE_T)
+        set(MKL_PATH lib/em64t)
+      else()
+        set(MKL_PATH lib/32)
+      endif()
+      set(MKL_LIBS_REQUIRED mkl_gf_lp64 iomp5 mkl_gnu_thread mkl_core guide pthread)
+      find_all_libraries(LAPACK_LIBRARIES MKL_LIBS_REQUIRED "" ${MKL_PATH})
+      if(NOT LAPACK_LIBRARIES)
+        # match lapack 9.0 on 64bit
+        set(MKL_LIBS_REQUIRED mkl_lapack mkl_em64t guide)
+        find_all_libraries(LAPACK_LIBRARIES MKL_LIBS_REQUIRED "" ${MKL_PATH})
+      endif()
+      if(LAPACK_LIBRARIES)
+        set_config_option(HAVE_BLAS "Blas[mkl]")
+        set_config_option(HAVE_LAPACK "Lapack[mkl]")
+      else()
+        # on Linux also try to find ATLAS without a Fortran compiler, because
+        # cmake ships with a buggy FindBLAS e.g. on Ubuntu Lucid Lynx
+        set(ATLAS_LIBS_REQUIRED lapack f77blas cblas atlas)
+        find_all_libraries(LAPACK_LIBRARIES ATLAS_LIBS_REQUIRED "" "")
+        if(LAPACK_LIBRARIES)
+          set_config_option(HAVE_BLAS "Blas[atlas]")
+          set_config_option(HAVE_LAPACK "Lapack[atlas]")
+        else()
+          # try with generic names
+          set(GENERIC_LIBS_REQUIRED lapack blas pthread)
+          find_all_libraries(LAPACK_LIBRARIES GENERIC_LIBS_REQUIRED "" "")
+          if(LAPACK_LIBRARIES)
+            set_config_option(HAVE_BLAS "Blas[generic]")
+            set_config_option(HAVE_LAPACK "Lapack[generic]")
+            find_library(GFORTRAN_LIB gfortran)
+            if(GFORTRAN_LIB)
+              list(APPEND LAPACK_LIBRARIES ${GFORTRAN_LIB})
+            endif()
+          endif()
+        endif()
+      endif()
+    elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
+      # on SunOS we know blas and lapack are available in sunperf
+      set(LAPACK_LIBRARIES -library=sunperf)
+      set_config_option(HAVE_BLAS "Blas[sunperf]")
+      set_config_option(HAVE_LAPACK "Lapack[sunperf]")
+    elseif(APPLE)
+      # on Mac we also know that blas and lapack are available
+      set(LAPACK_LIBRARIES "-llapack -lblas")
+      set_config_option(HAVE_BLAS "Blas[veclib]")
+      set_config_option(HAVE_LAPACK "Lapack[veclib]")
+    endif()
+
+    if(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
+      # if we haven't found blas and lapack check for OpenBlas
+      set(OPENBLAS_LIBS_REQUIRED openblas)
+      find_all_libraries(LAPACK_LIBRARIES OPENBLAS_LIBS_REQUIRED "" "")
+      if(LAPACK_LIBRARIES)
+        set_config_option(HAVE_BLAS "Blas[openblas]")
+        set_config_option(HAVE_LAPACK "Lapack[openblas]")
+        find_library(GFORTRAN_LIB gfortran)
+        if(GFORTRAN_LIB)
+          list(APPEND LAPACK_LIBRARIES ${GFORTRAN_LIB})
+        endif()
+      endif()
+    endif()
+
+    if(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
+      # if we still haven't found blas and lapack, use the standard cmake tests,
+      # which require a working Fortran compiler
+      enable_language(Fortran)
+      find_package(BLAS)
+      if(BLAS_FOUND)
+        set_config_option(HAVE_BLAS "Blas")
+        find_package(LAPACK)
+        if(LAPACK_FOUND)
+          set_config_option(HAVE_LAPACK "Lapack")
+        else()
+          set(LAPACK_LIBRARIES ${BLAS_LIBRARIES})
+        endif()
+        if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
+          if(CMAKE_Fortran_COMPILER MATCHES "gfortran")
+            list(APPEND LAPACK_LIBRARIES gfortran)
+          elseif(CMAKE_Fortran_COMPILER MATCHES "f95")
+            list(APPEND LAPACK_LIBRARIES gfortran)
+          elseif(CMAKE_Fortran_COMPILER MATCHES "g77")
+            list(APPEND LAPACK_LIBRARIES g2c)
+          endif()
+        elseif(CMAKE_Fortran_COMPILER MATCHES "pgi")
+          list(APPEND LAPACK_LIBRARIES -pgf77libs)
+        endif()
+      endif()
+    endif()
+
+    if(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
+      message(WARNING "Could not find Blas or Lapack: most meshing algorithms "
+              "will not be functional")
+    endif()
+
+  endif()
+endif()
+
+if(ENABLE_TCMALLOC)
+  find_library(TCMALLOC tcmalloc)
+  if(TCMALLOC)
+    set_config_option(HAVE_TCMALLOC "TCMalloc")
+    list(APPEND EXTERNAL_LIBRARIES ${TCMALLOC})
+  endif()
+endif()
+
+add_subdirectory(Common)
+add_subdirectory(Numeric)
+add_subdirectory(Geo)
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Mesh AND ENABLE_MESH)
+  add_subdirectory(Mesh)
+  set_config_option(HAVE_MESH "Mesh")
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Solver AND ENABLE_SOLVER)
+  add_subdirectory(Solver)
+  set_config_option(HAVE_SOLVER "Solver")
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Post AND ENABLE_POST)
+  add_subdirectory(Post)
+  set_config_option(HAVE_POST "Post")
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Plugin AND ENABLE_PLUGINS)
+    add_subdirectory(Plugin)
+    set_config_option(HAVE_PLUGINS "Plugins")
+  endif()
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Parser AND ENABLE_PARSER)
+  add_subdirectory(Parser)
+  set_config_option(HAVE_PARSER "Parser")
+endif()
+
+if(ENABLE_VISUDEV)
+  set_config_option(HAVE_VISUDEV "VisuDev")
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Fltk AND ENABLE_FLTK)
+  # first, try to use fltk-config for fltk >= 1.3 (FindFLTK is buggy on Unix,
+  # where e.g. xft and xinerama options are not dealt with)
+  find_program(FLTK_CONFIG_SCRIPT fltk-config)
+  if(FLTK_CONFIG_SCRIPT)
+    execute_process(COMMAND ${FLTK_CONFIG_SCRIPT} --api-version
+                    OUTPUT_VARIABLE FLTK_VERSION)
+    string(STRIP "${FLTK_VERSION}" FLTK_VERSION)
+    if(FLTK_VERSION VERSION_GREATER 1.1)
+      add_subdirectory(Fltk)
+      set_config_option(HAVE_FLTK "Fltk")
+      message(STATUS "Using fltk-config script for Fltk " ${FLTK_VERSION})
+      execute_process(COMMAND ${FLTK_CONFIG_SCRIPT} --use-gl --use-images --includedir
+                      OUTPUT_VARIABLE FLTK_INCLUDE_DIR)
+      string(STRIP ${FLTK_INCLUDE_DIR} FLTK_INCLUDE_DIR)
+      list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR})
+      # On linux (at least OpenSuSE) the following directories are
+      # not existing (everything is in /usr/include). To avoid warnings
+      # check existance of these directories before adding them
+      if(EXISTS ${FLTK_INCLUDE_DIR}/FL/images)
+        list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR}/FL/images)
+      endif()
+      if(EXISTS ${FLTK_INCLUDE_DIR}/jpeg)
+        list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR}/jpeg)
+      endif()
+      if(EXISTS ${FLTK_INCLUDE_DIR}/zlib)
+        list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR}/zlib)
+      endif()
+      if(EXISTS ${FLTK_INCLUDE_DIR}/png)
+        list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR}/png)
+      endif()
+      execute_process(COMMAND ${FLTK_CONFIG_SCRIPT} --use-gl --use-images --ldflags
+                      OUTPUT_VARIABLE FLTK_LIBRARIES)
+      string(STRIP ${FLTK_LIBRARIES} FLTK_LIBRARIES)
+      string(REGEX MATCH "fltk[_ ]jpeg" FLTK_JPEG ${FLTK_LIBRARIES})
+      string(REGEX MATCH "fltk[_ ]z" FLTK_Z ${FLTK_LIBRARIES})
+      string(REGEX MATCH "fltk[_ ]png" FLTK_PNG ${FLTK_LIBRARIES})
+    endif()
+  endif()
+  # then try the built-in FindFLTK module
+  if(NOT HAVE_FLTK)
+    set(FLTK_SKIP_FORMS TRUE)
+    set(FLTK_SKIP_FLUID TRUE)
+    find_package(FLTK)
+    if(FLTK_FOUND)
+      add_subdirectory(Fltk)
+      set_config_option(HAVE_FLTK "Fltk")
+      list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR})
+      # find fltk jpeg
+      find_library(FLTK_JPEG NAMES fltk_jpeg fltkjpeg)
+      if(FLTK_JPEG)
+        list(APPEND EXTERNAL_LIBRARIES ${FLTK_JPEG})
+        foreach(DIR ${FLTK_INCLUDE_DIR})
+          list(APPEND EXTERNAL_INCLUDES ${DIR}/FL/images ${DIR}/jpeg)
+        endforeach()
+      endif()
+      # find fltk zlib
+      find_library(FLTK_Z NAMES fltk_z fltkz)
+      if(FLTK_Z)
+        list(APPEND EXTERNAL_LIBRARIES ${FLTK_Z})
+        foreach(DIR ${FLTK_INCLUDE_DIR})
+          list(APPEND EXTERNAL_INCLUDES ${DIR}/FL/images ${DIR}/zlib)
+        endforeach()
+      endif()
+      # find fltk png
+      find_library(FLTK_PNG NAMES fltk_png fltkpng)
+      if(FLTK_PNG)
+        list(APPEND EXTERNAL_LIBRARIES ${FLTK_PNG})
+        foreach(DIR ${FLTK_INCLUDE_DIR})
+          list(APPEND EXTERNAL_INCLUDES ${DIR}/FL/images ${DIR}/png)
+        endforeach()
+      endif()
+    endif()
+  endif()
+  # workaround for Fedora/Suse messing up fltk-config (see issue #417)
+  if(HAVE_FLTK AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+    string(REGEX MATCH "X11" FLTK_X11 ${FLTK_LIBRARIES})
+    if(NOT FLTK_X11)
+      find_package(X11)
+      if(X11_FOUND)
+        list(APPEND EXTERNAL_INCLUDES ${X11_INCLUDE_DIR})
+        list(APPEND EXTERNAL_LIBRARIES ${X11_LIBRARIES})
+      endif()
+    endif()
+  endif()
+endif()
+
+if(APPLE AND HAVE_FLTK AND ENABLE_TOUCHBAR)
+  if(CMAKE_OSX_DEPLOYMENT_TARGET)
+    if(${CMAKE_OSX_DEPLOYMENT_TARGET} VERSION_GREATER 10.11)
+      set(GMSH_SRC ${GMSH_SRC};Fltk/touchBar.mm)
+      set_config_option(HAVE_TOUCHBAR "TouchBar")
+    endif()
+  endif()
+endif()
+
+if(ENABLE_ONELAB)
+  set_config_option(HAVE_ONELAB "ONELAB")
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/onelab)
+    if(ENABLE_ONELAB_METAMODEL)
+      add_subdirectory(contrib/onelab)
+      include_directories(contrib/onelab)
+      set_config_option(HAVE_ONELAB_METAMODEL "ONELABMetamodel")
+    endif()
+    file(COPY ${ONELAB_PY} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+  endif()
+endif()
+
+if(ENABLE_BUILD_IOS)
+  find_file(CMAKE_TOOLCHAIN_FILE "ios.cmake")
+  if(NOT CMAKE_TOOLCHAIN_FILE)
+    message(FATAL_ERROR "Cannot compile Gmsh for iOS without a toolchain")
+  endif()
+  add_definitions(-DBUILD_IOS)
+endif()
+
+if(HAVE_FLTK OR ENABLE_GRAPHICS)
+  if(NOT HAVE_MESH OR NOT HAVE_POST OR NOT HAVE_PLUGINS OR NOT HAVE_ONELAB)
+    message(SEND_ERROR "Cannot compile GUI without Mesh, Post, Plugin and ONELAB")
+  endif()
+
+  if(FLTK_JPEG)
+    set_config_option(HAVE_LIBJPEG "Jpeg[fltk]")
+  else()
+    find_package(JPEG)
+    if(JPEG_FOUND)
+      set_config_option(HAVE_LIBJPEG "Jpeg")
+      list(APPEND EXTERNAL_LIBRARIES ${JPEG_LIBRARIES})
+      list(APPEND EXTERNAL_INCLUDES ${JPEG_INCLUDE_DIR})
+    endif()
+  endif()
+
+  if(FLTK_Z)
+    set_config_option(HAVE_LIBZ "Zlib[fltk]")
+  else()
+    find_package(ZLIB)
+    if(ZLIB_FOUND)
+      set_config_option(HAVE_LIBZ "Zlib")
+      list(APPEND EXTERNAL_LIBRARIES ${ZLIB_LIBRARIES})
+      list(APPEND EXTERNAL_INCLUDES ${ZLIB_INCLUDE_DIR})
+    endif()
+  endif()
+
+  if(HAVE_LIBZ)
+    if(FLTK_PNG)
+      set_config_option(HAVE_LIBPNG "Png[fltk]")
+    else()
+      find_package(PNG)
+      if(PNG_FOUND)
+        set_config_option(HAVE_LIBPNG "Png")
+        list(APPEND EXTERNAL_LIBRARIES ${PNG_LIBRARIES})
+        list(APPEND EXTERNAL_INCLUDES ${PNG_INCLUDE_DIR})
+      endif()
+    endif()
+  endif()
+
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/mpeg_encode AND
+     ENABLE_MPEG_ENCODE)
+    add_subdirectory(contrib/mpeg_encode)
+    include_directories(contrib/mpeg_encode/headers)
+    set_config_option(HAVE_MPEG_ENCODE "Mpeg")
+  endif()
+
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/3M AND ENABLE_3M)
+    add_subdirectory(contrib/3M)
+    include_directories(contrib/3M)
+    set_config_option(HAVE_3M "3M")
+  endif()
+
+  if(ENABLE_OSMESA)
+    find_library(OSMESA_LIB OSMesa)
+    if(OSMESA_LIB)
+      set_config_option(HAVE_OSMESA "OSMesa")
+      list(APPEND EXTERNAL_LIBRARIES ${OSMESA_LIB})
+    endif()
+  endif()
+
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Graphics)
+    set(OpenGL_GL_PREFERENCE "LEGACY")
+    find_package(OpenGL REQUIRED)
+    if(OPENGL_GLU_FOUND AND OPENGL_FOUND)
+      add_subdirectory(Graphics)
+      set_config_option(HAVE_OPENGL "OpenGL")
+    else()
+      message(SEND_ERROR "Could not find GLU: disabling OpenGL support")
+    endif()
+  endif()
+endif()
+
+if(ENABLE_ANN)
+  find_library(ANN_LIB ANN PATH_SUFFIXES lib)
+  find_path(ANN_INC "ANN.h" PATH_SUFFIXES src include ANN)
+  if(ENABLE_SYSTEM_CONTRIB AND ANN_LIB AND ANN_INC)
+    message(STATUS "Using system version of ANN")
+    list(APPEND EXTERNAL_LIBRARIES ${ANN_LIB})
+    list(APPEND EXTERNAL_INCLUDES ${ANN_INC})
+    set_config_option(HAVE_ANN "Ann[system]")
+  elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/ANN)
+    add_subdirectory(contrib/ANN)
+    include_directories(contrib/ANN/include)
+    set_config_option(HAVE_ANN "Ann")
+  endif()
+endif()
+
+if(ENABLE_ALGLIB)
+  find_library(ALGLIB_LIB alglib PATH_SUFFIXES lib)
+  find_path(ALGLIB_INC "stdafx.h" PATH_SUFFIXES include)
+  if(ENABLE_SYSTEM_CONTRIB AND ALGLIB_LIB AND ALGLIB_INC)
+    list(APPEND EXTERNAL_LIBRARIES ${ALGLIB_LIB})
+    list(APPEND EXTERNAL_INCLUDES ${ALGLIB_INC})
+    set_config_option(HAVE_ALGLIB "ALGLIB[system]")
+  elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/ALGLIB)
+    add_subdirectory(contrib/ALGLIB)
+    include_directories(contrib/ALGLIB)
+    set_config_option(HAVE_ALGLIB "ALGLIB")
+  endif()
+endif()
+
+if(HAVE_FLTK AND ENABLE_CAIRO)
+  find_library(CAIRO_LIB cairo)
+  find_path(CAIRO_INC "cairo/cairo.h" PATH_SUFFIXES include)
+  if(CAIRO_INC AND CAIRO_LIB)
+     set_config_option(HAVE_CAIRO "Cairo")
+     list(APPEND EXTERNAL_LIBRARIES ${CAIRO_LIB})
+     list(APPEND EXTERNAL_INCLUDES ${CAIRO_INC})
+  endif()
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/DiscreteIntegration AND
+   ENABLE_DINTEGRATION)
+  add_subdirectory(contrib/DiscreteIntegration)
+  include_directories(contrib/DiscreteIntegration)
+  set_config_option(HAVE_DINTEGRATION "DIntegration")
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/HighOrderMeshOptimizer AND
+   EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/MeshOptimizer AND
+   EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/MeshQualityOptimizer AND
+   ENABLE_OPTHOM AND HAVE_MESH)
+  add_subdirectory(contrib/HighOrderMeshOptimizer)
+  include_directories(contrib/HighOrderMeshOptimizer)
+  add_subdirectory(contrib/MeshOptimizer)
+  include_directories(contrib/MeshOptimizer)
+  include_directories(${CMAKE_CURRENT_BINARY_DIR}/contrib/MeshOptimizer)
+  add_subdirectory(contrib/MeshQualityOptimizer)
+  include_directories(contrib/MeshQualityOptimizer)
+  set_config_option(HAVE_OPTHOM "OptHom")
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/domhex AND
+   ENABLE_DOMHEX AND HAVE_MESH)
+  add_subdirectory(contrib/domhex)
+  include_directories(contrib/domhex)
+  set_config_option(HAVE_DOMHEX "DomHex")
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/QuadTri AND
+   ENABLE_QUADTRI AND HAVE_MESH)
+  add_subdirectory(contrib/QuadTri)
+  include_directories(contrib/QuadTri)
+  set_config_option(HAVE_QUADTRI "QuadTri")
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/kbipack AND ENABLE_KBIPACK)
+  set_config_option(HAVE_KBIPACK "Kbipack")
+  add_subdirectory(contrib/kbipack)
+  include_directories(contrib/kbipack)
+  if(ENABLE_GMP)
+    find_library(GMP_LIB libgmp.a)
+    find_path(GMP_INC "gmp.h" PATH_SUFFIXES src include)
+  endif()
+  if(GMP_LIB AND GMP_INC)
+    set_config_option(HAVE_GMP "GMP")
+    list(APPEND EXTERNAL_LIBRARIES ${GMP_LIB})
+    list(APPEND EXTERNAL_INCLUDES ${GMP_INC})
+  else()
+    message(STATUS "GMP not found: Kbipack uses long int")
+  endif()
+endif()
+
+if(ENABLE_MATHEX)
+  find_library(MATHEX_LIB mathex PATH_SUFFIXES lib)
+  find_path(MATHEX_INC "mathex.h" PATH_SUFFIXES src include)
+  if(ENABLE_SYSTEM_CONTRIB AND MATHEX_LIB AND MATHEX_INC)
+    list(APPEND EXTERNAL_LIBRARIES ${MATHEX_LIB})
+    list(APPEND EXTERNAL_INCLUDES ${MATHEX_INC})
+    set_config_option(HAVE_MATHEX "MathEx[system]")
+  elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/MathEx)
+    add_subdirectory(contrib/MathEx)
+    include_directories(contrib/MathEx)
+    set_config_option(HAVE_MATHEX "MathEx")
+  endif()
+endif()
+
+if(ENABLE_MPI)
+  find_package(MPI)
+  if(MPI_FOUND)
+    set_config_option(HAVE_MPI "MPI")
+    list(APPEND EXTERNAL_INCLUDES ${MPI_CXX_INCLUDE_PATH})
+    list(APPEND EXTERNAL_LIBRARIES ${MPI_CXX_LIBRARIES})
+    set(CMAKE_C_COMPILER ${MPI_C_COMPILER})
+    set(CMAKE_CXX_COMPILER ${MPI_CXX_COMPILER})
+    set(CMAKE_Fortran_COMPILER ${MPI_Fortran_COMPILER})
+  endif()
+endif()
+
+if(ENABLE_POPPLER)
+  find_library(POPPLER_LIB poppler)
+  find_library(POPPLER_CPP_LIB poppler-cpp)
+  find_path(POPPLER_INC "poppler/cpp/poppler-document.h" PATH_SUFFIXES src include)
+  if(POPPLER_LIB AND POPPLER_INC)
+    set_config_option(HAVE_POPPLER "Poppler")
+    list(APPEND EXTERNAL_LIBRARIES ${POPPLER_LIB})
+    list(APPEND EXTERNAL_LIBRARIES ${POPPLER_CPP_LIB})
+    list(APPEND EXTERNAL_INCLUDES ${POPPLER_INC})
+  endif()
+endif()
+
+if(ENABLE_P4EST)
+  find_library(P4EST_LIB p4est)
+  find_path(P4EST_INC "p4est.h" PATH_SUFFIXES src)
+  find_library(SC_LIB sc)
+  if(P4EST_LIB AND P4EST_INC AND SC_LIB)
+    set_config_option(HAVE_P4EST "P4est")
+    list(APPEND EXTERNAL_LIBRARIES ${P4EST_LIB} ${SC_LIB})
+    list(APPEND EXTERNAL_INCLUDES ${P4EST_INC})
+  endif()
+endif()
+
+if(HAVE_MESH OR HAVE_SOLVER)
+  if(ENABLE_METIS)
+    if(METIS_ROOT)
+      find_library(METIS_LIB metis PATHS ${METIS_ROOT} PATH_SUFFIXES lib)
+      find_path(METIS_INC "metis.h" PATHS ${METIS_ROOT} PATH_SUFFIXES include)
+      list(APPEND EXTERNAL_LIBRARIES ${METIS_LIB})
+      list(APPEND EXTERNAL_INCLUDES ${METIS_INC})
+      set_config_option(HAVE_METIS "Metis")
+    else()
+      find_library(METIS_LIB metis PATH_SUFFIXES lib)
+      find_path(METIS_INC "metis.h" PATH_SUFFIXES include)
+      if(ENABLE_SYSTEM_CONTRIB AND METIS_LIB AND METIS_INC)
+        message(STATUS "Using system version of METIS")
+        list(APPEND EXTERNAL_LIBRARIES ${METIS_LIB})
+        list(APPEND EXTERNAL_INCLUDES ${METIS_INC})
+        set_config_option(HAVE_METIS "Metis[system]")
+      elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/metis)
+        add_definitions(-DUSE_GKREGEX)
+        add_subdirectory(contrib/metis)
+        include_directories(contrib/metis/include contrib/metis/libmetis
+                          contrib/metis/GKlib)
+        set_config_option(HAVE_METIS "Metis")
+      endif()
+    endif()
+  endif()
+endif()
+
+if(HAVE_MESH)
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Mesh/tetgenBR.cxx)
+    set_config_option(HAVE_TETGENBR "TetGen/BR")
+  endif()
+
+  if(ENABLE_VOROPP)
+    find_library(VOROPP_LIB voro++ PATH_SUFFIXES lib)
+    find_path(VOROPP_INC "voro++.hh" PATH_SUFFIXES include)
+    if(ENABLE_SYSTEM_CONTRIB AND VOROPP_LIB AND VOROPP_INC)
+      message(STATUS "Using system version of voro++")
+      list(APPEND EXTERNAL_LIBRARIES ${VOROPP_LIB})
+      list(APPEND EXTERNAL_INCLUDES ${VOROPP_INC})
+      set_config_option(HAVE_VOROPP "Voro++[system]")
+    elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/voro++)
+      add_subdirectory(contrib/voro++)
+      include_directories(contrib/voro++/src)
+      set_config_option(HAVE_VOROPP "Voro++")
+    endif()
+  endif()
+
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/blossom AND ENABLE_BLOSSOM)
+    add_subdirectory(contrib/blossom)
+    include_directories(contrib/blossom/MATCH contrib/blossom/concorde97
+                        contrib/blossom/concorde97/INCLUDE)
+    set_config_option(HAVE_BLOSSOM "Blossom")
+  endif()
+
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Netgen AND ENABLE_NETGEN)
+    add_subdirectory(contrib/Netgen)
+    include_directories(contrib/Netgen contrib/Netgen/libsrc/include
+                        contrib/Netgen/nglib)
+    set_config_option(HAVE_NETGEN "Netgen")
+    add_definitions(-DNO_PARALLEL_THREADS -DNOTCL)
+  endif()
+
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/bamg AND ENABLE_BAMG)
+    add_subdirectory(contrib/bamg)
+    include_directories(contrib/bamg contrib/bamg/bamglib)
+    set_config_option(HAVE_BAMG "Bamg")
+  endif()
+
+  if(ENABLE_MMG3D)
+    find_library(MMG3D_LIB mmg3d PATH_SUFFIXES lib)
+    find_path(MMG3D_INC "libmmg3d.h" PATH_SUFFIXES src include)
+    if(ENABLE_SYSTEM_CONTRIB AND MMG3D_LIB AND MMG3D_INC)
+      list(APPEND EXTERNAL_LIBRARIES ${MMG3D_LIB})
+      list(APPEND EXTERNAL_INCLUDES ${MMG3D_INC})
+      set_config_option(HAVE_MMG3D "Mmg3d[system]")
+    elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/mmg3d)
+      add_subdirectory(contrib/mmg3d)
+      include_directories(contrib/mmg3d/build/sources)
+      set_config_option(HAVE_MMG3D "Mmg3d")
+    endif()
+  endif()
+endif()
+
+if(ENABLE_MED OR ENABLE_CGNS)
+  find_package(HDF5)
+  if(HDF5_FOUND)
+    set(HDF5_LIB "${HDF5_C_LIBRARIES}")
+    list(APPEND EXTERNAL_INCLUDES ${HDF5_INCLUDE_DIRS})
+    if(ENABLE_MED)
+      find_library(MED_LIB medC)
+      if(MED_LIB)
+        set_config_option(HAVE_MED "Med")
+        list(APPEND EXTERNAL_LIBRARIES ${MED_LIB})
+      endif()
+    endif()
+    if(ENABLE_CGNS)
+      find_library(CGNS_LIB cgns HINTS ENV CGNS_ROOT PATH_SUFFIXES lib)
+      find_path(CGNS_INC "cgnslib.h" HINTS ENV CGNS_ROOT PATH_SUFFIXES include)
+      if(CGNS_LIB AND CGNS_INC)
+        set_config_option(HAVE_LIBCGNS "Cgns")
+        list(APPEND EXTERNAL_LIBRARIES ${CGNS_LIB})
+        list(APPEND EXTERNAL_INCLUDES ${CGNS_INC})
+        if(ENABLE_CGNS_CPEX0045)
+          set_config_option(HAVE_LIBCGNS_CPEX0045 "Cgns_CPEX0045")
+        endif()
+      endif()
+    endif()
+    if(MED_LIB OR CGNS_LIB)
+      list(APPEND EXTERNAL_LIBRARIES ${HDF5_LIB})
+      find_library(SZ_LIB NAMES szlib sz)
+      if(SZ_LIB)
+        list(APPEND EXTERNAL_LIBRARIES ${SZ_LIB})
+      endif()
+      if(NOT HAVE_LIBZ) # necessary for non-GUI builds
+        find_package(ZLIB)
+        if(ZLIB_FOUND)
+          set_config_option(HAVE_LIBZ "Zlib")
+          list(APPEND EXTERNAL_LIBRARIES ${ZLIB_LIBRARIES})
+        endif()
+      endif()
+    endif()
+  else()
+    message(STATUS "HDF5 not found")
+  endif()
+endif()
+
+if(HAVE_SOLVER)
+  if(ENABLE_GMM)
+    find_path(GMM_INC "gmm.h" PATH_SUFFIXES src include include/gmm)
+    if(ENABLE_SYSTEM_CONTRIB AND GMM_INC)
+      message(STATUS "Using system version of GMM")
+      list(APPEND EXTERNAL_INCLUDES ${GMM_INC})
+      set_config_option(HAVE_GMM "Gmm[system]")
+    elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/gmm)
+      include_directories(contrib/gmm)
+      set_config_option(HAVE_GMM "Gmm")
+    endif()
+  endif()
+
+  if(ENABLE_PETSC)
+    if(PETSC_DIR)
+      set(ENV_PETSC_DIR ${PETSC_DIR})
+    else()
+      set(ENV_PETSC_DIR $ENV{PETSC_DIR})
+    endif()
+    if(PETSC_ARCH)
+      set(ENV_PETSC_ARCH ${PETSC_ARCH})
+    else()
+      set(ENV_PETSC_ARCH $ENV{PETSC_ARCH})
+    endif()
+    set(PETSC_POSSIBLE_CONF_FILES
+        ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/conf/petscvariables
+        ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib/petsc-conf/petscvariables
+        ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib/petsc/conf/petscvariables)
+    foreach(FILE ${PETSC_POSSIBLE_CONF_FILES})
+      if(EXISTS ${FILE})
+        # old-style PETSc installations (using PETSC_DIR and PETSC_ARCH)
+        message(STATUS "Using PETSc dir: ${ENV_PETSC_DIR}")
+        message(STATUS "Using PETSc arch: ${ENV_PETSC_ARCH}")
+        # find includes by parsing the petscvariables file
+        file(STRINGS ${FILE} PETSC_VARIABLES NEWLINE_CONSUME)
+      endif()
+    endforeach()
+    if(PETSC_VARIABLES)
+      # try to find PETSC_CC_INCLUDES for PETSc >= 3.4
+      string(REGEX MATCH "PETSC_CC_INCLUDES = [^\n\r]*" PETSC_PACKAGES_INCLUDES
+             ${PETSC_VARIABLES})
+      if(PETSC_PACKAGES_INCLUDES)
+        string(REPLACE "PETSC_CC_INCLUDES = " "" PETSC_PACKAGES_INCLUDES
+               ${PETSC_PACKAGES_INCLUDES})
+      else()
+        # try to find PETSC_PACKAGES_INCLUDES in older versions
+        list(APPEND EXTERNAL_INCLUDES ${ENV_PETSC_DIR}/include)
+        list(APPEND EXTERNAL_INCLUDES ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/include)
+        string(REGEX MATCH "PACKAGES_INCLUDES = [^\n\r]*" PETSC_PACKAGES_INCLUDES
+               ${PETSC_VARIABLES})
+        string(REPLACE "PACKAGES_INCLUDES = " "" PETSC_PACKAGES_INCLUDES
+               ${PETSC_PACKAGES_INCLUDES})
+      endif()
+      if(PETSC_PACKAGES_INCLUDES)
+        if(PETSC_PACKAGES_INCLUDES)
+          string(REPLACE "-I" "" PETSC_PACKAGES_INCLUDES ${PETSC_PACKAGES_INCLUDES})
+          string(REPLACE " " ";" PETSC_PACKAGES_INCLUDES ${PETSC_PACKAGES_INCLUDES})
+          foreach(VAR ${PETSC_PACKAGES_INCLUDES})
+            # seem to include unexisting directories (/usr/include/lib64)
+	    # check to avoid warnings
+	    if(EXISTS ${VAR})
+	      list(APPEND EXTERNAL_INCLUDES ${VAR})
+            endif()
+          endforeach()
+        endif()
+      endif()
+      # find libraries (<= 3.0)
+      set(PETSC_LIBS_REQUIRED petscksp petscdm petscmat petscvec petsc)
+      find_all_libraries(PETSC_LIBS PETSC_LIBS_REQUIRED
+                         ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib "")
+      # petsc 3.1 creates only one library (libpetsc)
+      if(NOT PETSC_LIBS)
+        find_library(PETSC_LIBS petsc PATHS ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib
+                     NO_DEFAULT_PATH)
+      endif()
+      if(PETSC_LIBS)
+        set_config_option(HAVE_PETSC "PETSc")
+	if(NOT HAVE_BLAS)
+          set_config_option(HAVE_BLAS "Blas[petsc]")
+        endif()
+	if(NOT HAVE_LAPACK)
+          set_config_option(HAVE_LAPACK "Lapack[petsc]")
+        endif()
+      endif()
+      # find slepc (needs to be linked in before petsc)
+      if(ENABLE_SLEPC)
+        if(SLEPC_DIR)
+          set(ENV_SLEPC_DIR ${SLEPC_DIR})
+         else()
+          set(ENV_SLEPC_DIR $ENV{SLEPC_DIR})
+        endif()
+        find_library(SLEPC_LIB slepc PATHS ${ENV_SLEPC_DIR}/${ENV_PETSC_ARCH}/lib
+                     NO_DEFAULT_PATH)
+        if(SLEPC_LIB)
+          find_path(SLEPC_INC "slepc.h" PATHS ${ENV_SLEPC_DIR} PATH_SUFFIXES include
+                    ${ENV_PETSC_ARCH}/include include/slepc NO_DEFAULT_PATH)
+          if(SLEPC_INC)
+            message(STATUS "Using SLEPc dir: ${ENV_SLEPC_DIR}")
+            set_config_option(HAVE_SLEPC "SLEPc")
+            list(APPEND EXTERNAL_LIBRARIES ${SLEPC_LIB})
+            list(APPEND EXTERNAL_INCLUDES ${SLEPC_INC})
+            find_path(SLEPC_INC2 "slepcconf.h" PATHS ${ENV_SLEPC_DIR}
+                      PATH_SUFFIXES ${ENV_PETSC_ARCH}/include NO_DEFAULT_PATH)
+            if(SLEPC_INC2)
+              list(APPEND EXTERNAL_INCLUDES ${SLEPC_INC2})
+            endif()
+          endif()
+        endif()
+      endif()
+      list(APPEND EXTERNAL_LIBRARIES ${PETSC_LIBS})
+      # find additional libraries to link with
+      string(REGEX MATCH "PACKAGES_LIBS = [^\n\r]*" PLIBS ${PETSC_VARIABLES})
+      if(PLIBS)
+        string(REPLACE "PACKAGES_LIBS = " "" PLIBS ${PLIBS})
+        string(STRIP ${PLIBS} PLIBS)
+        list(APPEND EXTERNAL_LIBRARIES "${PLIBS}")
+      endif()
+      string(REGEX MATCH "PETSC_EXTERNAL_LIB_BASIC = [^\n\r]*" PLIBS_BASIC ${PETSC_VARIABLES})
+      if(PLIBS_BASIC)
+        string(REPLACE "PETSC_EXTERNAL_LIB_BASIC = " "" PLIBS_BASIC ${PLIBS_BASIC})
+        string(STRIP ${PLIBS_BASIC} PLIBS_BASIC)
+        separate_arguments(PLIBS_BASIC)
+        list(APPEND EXTERNAL_LIBRARIES "${PLIBS_BASIC}")
+      endif()
+      string(REGEX MATCH "PCC_LINKER_LIBS = [^\n\r]*" LLIBS ${PETSC_VARIABLES})
+      if(LLIBS)
+        string(REPLACE "PCC_LINKER_LIBS = " "" LLIBS ${LLIBS})
+        string(STRIP ${LLIBS} LLIBS)
+        list(APPEND EXTERNAL_LIBRARIES "${LLIBS}")
+      endif()
+    else()
+      # new-style PETSc installations (in standard system directories)
+      find_library(PETSC_LIBS petsc)
+      find_path(PETSC_INC "petsc.h" PATH_SUFFIXES include/petsc)
+      if(PETSC_LIBS AND PETSC_INC)
+        set_config_option(HAVE_PETSC "PETSc")
+        if(ENABLE_SLEPC)
+          find_library(SLEPC_LIB slepc)
+          find_path(SLEPC_INC "slepc.h" PATH_SUFFIXES include/slepc)
+          if(SLEPC_LIB AND SLEPC_INC)
+            set_config_option(HAVE_SLEPC "SLEPc")
+            list(APPEND EXTERNAL_LIBRARIES ${SLEPC_LIB})
+            list(APPEND EXTERNAL_INCLUDES ${SLEPC_INC})
+          endif()
+        endif()
+        list(APPEND EXTERNAL_LIBRARIES ${PETSC_LIBS})
+        list(APPEND EXTERNAL_INCLUDES ${PETSC_INC})
+      endif()
+    endif()
+  endif()
+
+  if(ENABLE_MUMPS AND HAVE_BLAS AND HAVE_LAPACK)
+    set(MUMPS_LIBS_REQUIRED smumps dmumps cmumps zmumps mumps_common pord)
+    if(NOT ENABLE_MPI)
+      list(APPEND MUMPS_LIBS_REQUIRED mpiseq)
+    endif()
+    find_all_libraries(MUMPS_LIBRARIES MUMPS_LIBS_REQUIRED "" "lib")
+    find_path(SMUMPS_INC "smumps_c.h" PATH_SUFFIXES src include)
+    find_path(DMUMPS_INC "dmumps_c.h" PATH_SUFFIXES src include)
+    find_path(CMUMPS_INC "cmumps_c.h" PATH_SUFFIXES src include)
+    find_path(ZMUMPS_INC "zmumps_c.h" PATH_SUFFIXES src include)
+    if(MUMPS_LIBRARIES AND SMUMPS_INC AND DMUMPS_INC AND CMUMPS_INC AND ZMUMPS_INC)
+      set_config_option(HAVE_MUMPS "MUMPS")
+      list(APPEND EXTERNAL_LIBRARIES ${MUMPS_LIBRARIES})
+      list(APPEND EXTERNAL_INCLUDES ${SMUMPS_INC})
+      list(APPEND EXTERNAL_INCLUDES ${DMUMPS_INC})
+      list(APPEND EXTERNAL_INCLUDES ${CMUMPS_INC})
+      list(APPEND EXTERNAL_INCLUDES ${ZMUMPS_INC})
+      find_library(GFORTRAN_LIB gfortran)
+      if(GFORTRAN_LIB)
+        list(APPEND EXTERNAL_LIBRARIES ${GFORTRAN_LIB})
+      endif()
+      if(ENABLE_GMM) # use GMM/MUMPS interface
+        add_definitions(-DGMM_USES_MUMPS)
+      endif()
+    endif()
+  endif()
+
+  if(ENABLE_GETDP)
+    find_library(GETDP_LIB GetDP)
+    find_path(GETDP_INC "GetDP.h" PATH_SUFFIXES getdp)
+    if(GETDP_LIB AND GETDP_INC)
+      set_config_option(HAVE_GETDP "GetDP")
+      list(APPEND EXTERNAL_LIBRARIES ${GETDP_LIB})
+      list(APPEND EXTERNAL_INCLUDES ${GETDP_INC})
+    endif()
+  endif()
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/hxt AND
+   ENABLE_HXT AND HAVE_METIS)
+  set_config_option(HAVE_HXT "Hxt")
+  add_subdirectory(contrib/hxt)
+  include_directories(BEFORE contrib/hxt)
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/hxt/hxt_tetDelaunay.c)
+    set_config_option(HAVE_HXT3D "Hxt3D")
+  endif()
+  if(MSVC)
+    # Visual C++ does not support C99 - force compilation as C++ code
+    file(GLOB_RECURSE HXT_SRC contrib/hxt/*.c)
+    set_compile_flags(HXT_SRC "/TP")
+  endif()
+  check_include_file("immintrin.h" HAVE_IMMINTRIN_H)
+  if(NOT HAVE_IMMINTRIN_H)
+    add_definitions(-DHAVE_NO_IMMINTRIN_H)
+  endif()
+  if(HAVE_PETSC)
+    add_definitions(-DHXT_HAVE_PETSC)
+  endif()
+  if(CMAKE_C_COMPILER MATCHES "pgi")
+    add_definitions(-DHAVE_NO_OPENMP_SIMD)
+  endif()
+endif()
+
+if(ENABLE_OCC)
+  set(OCC_MINIMAL_VERSION "6.9.1")
+  if(WIN32)
+    if(HAVE_64BIT_SIZE_T)
+      set(OCC_SYS_NAME win64)
+    else()
+      set(OCC_SYS_NAME win32)
+    endif()
+  else()
+    set(OCC_SYS_NAME ${CMAKE_SYSTEM_NAME})
+  endif()
+  find_path(OCC_INC "Standard_Version.hxx" HINTS ENV CASROOT PATH_SUFFIXES
+            inc include include/oce opencascade include/opencascade
+            occt include/occt)
+  if(OCC_INC)
+    file(STRINGS ${OCC_INC}/Standard_Version.hxx
+         OCC_MAJOR REGEX "#define OCC_VERSION_MAJOR.*")
+    file(STRINGS ${OCC_INC}/Standard_Version.hxx
+         OCC_MINOR REGEX "#define OCC_VERSION_MINOR.*")
+    file(STRINGS ${OCC_INC}/Standard_Version.hxx
+         OCC_MAINT REGEX "#define OCC_VERSION_MAINTENANCE.*")
+    if(OCC_MAJOR AND OCC_MINOR AND OCC_MAINT)
+      string(REGEX MATCH "[0-9]+" OCC_MAJOR "${OCC_MAJOR}")
+      string(REGEX MATCH "[0-9]+" OCC_MINOR "${OCC_MINOR}")
+      string(REGEX MATCH "[0-9]+" OCC_MAINT "${OCC_MAINT}")
+      set(OCC_VERSION "${OCC_MAJOR}.${OCC_MINOR}.${OCC_MAINT}")
+      message(STATUS "Found OpenCASCADE version ${OCC_VERSION} in ${OCC_INC}")
+    endif()
+  endif()
+  if(OCC_VERSION AND OCC_VERSION STRLESS ${OCC_MINIMAL_VERSION})
+    message(WARNING "Gmsh requires OpenCASCADE >= ${OCC_MINIMAL_VERSION}. "
+        "Use CMAKE_PREFIX_PATH or the CASROOT environment variable "
+        "to explicitely specify the installation path of OpenCASCADE")
+  elseif(OCC_INC)
+    set(OCC_LIBS_REQUIRED
+	# subset of DataExchange
+      	TKSTEP TKSTEP209 TKSTEPAttr TKSTEPBase TKIGES TKXSBase
+      	# ModelingAlgorithms
+      	TKOffset TKFeat TKFillet TKBool TKMesh TKHLR TKBO TKPrim TKShHealing
+      	TKTopAlgo TKGeomAlgo
+      	# ModelingData
+      	TKBRep TKGeomBase TKG3d TKG2d
+      	# FoundationClasses
+      	TKMath TKernel)
+    if(ENABLE_OCC_TBB)
+      list(APPEND OCC_LIBS_REQUIRED tbb tbbmalloc)
+    endif()
+    list(LENGTH OCC_LIBS_REQUIRED NUM_OCC_LIBS_REQUIRED)
+    if(OCC_LIBS)
+      message(STATUS "OCC libraries specified explicitly: " ${OCC_LIBS})
+      list(LENGTH OCC_LIBS_REQUIRED NUM_OCC_LIBS)
+    else()
+      set(OCC_LIBS)
+      foreach(OCC ${OCC_LIBS_REQUIRED})
+        if(ENABLE_OCC_STATIC)
+          set(LIBNAME lib${OCC}.a)
+        else()
+          set(LIBNAME ${OCC})
+        endif()
+        find_library(OCC_LIB ${LIBNAME} HINTS ENV CASROOT PATH_SUFFIXES
+                     lib ${OCC_SYS_NAME}/lib ${OCC_SYS_NAME}/vc8/lib)
+        if(OCC_LIB)
+	  list(APPEND OCC_LIBS ${OCC_LIB})
+        else()
+          message(STATUS "OCC lib " ${LIBNAME} " not Found")
+        endif()
+        unset(OCC_LIB CACHE)
+      endforeach()
+      list(LENGTH OCC_LIBS NUM_OCC_LIBS)
+    endif()
+  endif()
+
+  # additional OCC libraries to handle reading of STEP/IGES attributes. Oh my...
+  if(ENABLE_OCC_CAF)
+    find_package(Freetype)
+    if(FREETYPE_FOUND)
+      set(OCC_CAF_LIBS_REQUIRED
+          TKXDESTEP TKXDEIGES TKXCAF TKLCAF TKVCAF TKCAF TKV3d TKService TKCDF)
+      list(LENGTH OCC_CAF_LIBS_REQUIRED NUM_OCC_CAF_LIBS_REQUIRED)
+      set(OCC_CAF_LIBS)
+      foreach(OCC ${OCC_CAF_LIBS_REQUIRED})
+        find_library(OCC_CAF_LIB ${OCC} HINTS ENV CASROOT PATH_SUFFIXES
+                     lib ${OCC_SYS_NAME}/lib ${OCC_SYS_NAME}/vc8/lib)
+        if(OCC_CAF_LIB)
+          list(APPEND OCC_CAF_LIBS ${OCC_CAF_LIB})
+        else()
+          message(STATUS "OCC CAF lib " ${OCC} " not Found")
+        endif()
+        unset(OCC_CAF_LIB CACHE)
+      endforeach()
+      list(LENGTH OCC_CAF_LIBS NUM_OCC_CAF_LIBS)
+    endif()
+  endif()
+
+  # append OCC CAF libraries first...
+  if(NUM_OCC_CAF_LIBS EQUAL NUM_OCC_CAF_LIBS_REQUIRED)
+    set_config_option(HAVE_OCC_CAF "OpenCASCADE-CAF")
+    list(APPEND EXTERNAL_LIBRARIES ${OCC_CAF_LIBS} ${FREETYPE_LIBRARIES})
+    list(APPEND EXTERNAL_INCLUDES ${FREETYPE_INCLUDE_DIRS})
+    if(WIN32)
+      list(APPEND EXTERNAL_LIBRARIES "windowscodecs")
+      list(APPEND EXTERNAL_LIBRARIES "ole32")
+    endif()
+  endif()
+
+  # then append OCC libraries
+  if(NUM_OCC_LIBS EQUAL NUM_OCC_LIBS_REQUIRED)
+    set_config_option(HAVE_OCC "OpenCASCADE")
+    list(APPEND EXTERNAL_LIBRARIES ${OCC_LIBS})
+    list(APPEND EXTERNAL_INCLUDES ${OCC_INC})
+    if(HAVE_64BIT_SIZE_T)
+      add_definitions(-D_OCC64)
+    endif()
+    if(WIN32)
+      list(APPEND EXTERNAL_LIBRARIES "winspool")
+      add_definitions(-DOCC_CONVERT_SIGNALS)
+    elseif(MSVC)
+      add_definitions(-DWNT)
+    endif()
+  endif()
+endif()
+
+if(ENABLE_ACIS)
+  find_library(ACIS_LIB SpaACIS PATH_SUFFIXES bin/maci386)
+  if(ACIS_LIB)
+    find_path(ACIS_INC "kernapi.hxx" PATH_SUFFIXES include)
+    if(ACIS_INC)
+      set_config_option(HAVE_ACIS "Acis")
+      list(APPEND EXTERNAL_LIBRARIES ${ACIS_LIB})
+      list(APPEND EXTERNAL_INCLUDES ${ACIS_INC})
+    endif()
+  endif()
+endif()
+
+if(ENABLE_ZIPPER)
+  if(ENABLE_BUILD_IOS)
+    set_config_option(HAVE_LIBZ "Zlib")
+  endif()
+  if(NOT HAVE_LIBZ) # necessary for non-GUI builds
+    find_package(ZLIB)
+    if(ZLIB_FOUND)
+      set_config_option(HAVE_LIBZ "Zlib")
+      list(APPEND EXTERNAL_LIBRARIES ${ZLIB_LIBRARIES})
+      list(APPEND EXTERNAL_INCLUDES ${ZLIB_INCLUDE_DIR})
+    endif()
+  endif()
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/zipper AND HAVE_LIBZ)
+    add_subdirectory(contrib/zipper)
+    include_directories(contrib/zipper)
+    set_config_option(HAVE_ZIPPER "Zipper")
+  endif()
+endif()
+
+if(ENABLE_PRIVATE_API AND ENABLE_WRAP_PYTHON)
+  find_package(SWIG REQUIRED)
+  include(${SWIG_USE_FILE})
+  find_package(PythonLibs)
+  if(SWIG_FOUND AND PYTHONLIBS_FOUND)
+    message(STATUS "Found SWIG version " ${SWIG_VERSION})
+    find_package(PythonInterp)
+    string(SUBSTRING ${SWIG_VERSION} 0 1 SWIG_MAJOR_VERSION)
+    if(SWIG_MAJOR_VERSION EQUAL 1)
+      message(WARNING "Python bindings require SWIG >= 2: disabling Python")
+    else()
+      set_config_option(HAVE_PYTHON "Python")
+      mark_as_advanced(CLEAR PYTHON_LIBRARY PYTHON_INCLUDE_DIR)
+      if(ENABLE_NUMPY)
+        if (NOT NUMPY_INC)
+          EXEC_PROGRAM (${PYTHON_EXECUTABLE}
+            ARGS "-c \"import numpy; print(numpy.get_include())\""
+            OUTPUT_VARIABLE NUMPY_INC
+            RETURN_VALUE NUMPY_NOT_FOUND)
+        endif()
+        if(NUMPY_INC)
+          list(APPEND EXTERNAL_INCLUDES ${NUMPY_INC})
+          set_config_option(HAVE_NUMPY "Numpy")
+        endif()
+      endif()
+      if(HAVE_PETSC)
+        if(ENABLE_PETSC4PY)
+          EXECUTE_PROCESS(
+            COMMAND ${PYTHON_EXECUTABLE} -c "import petsc4py; print(petsc4py.get_include())"
+            OUTPUT_VARIABLE PETSC4PY_INC
+            RESULT_VARIABLE PETSC4PY_NOT_FOUND
+            ERROR_QUIET
+            OUTPUT_STRIP_TRAILING_WHITESPACE)
+          if(PETSC4PY_INC)
+            list(APPEND EXTERNAL_INCLUDES ${PETSC4PY_INC})
+            set_config_option(HAVE_PETSC4PY "PETSc4py")
+          endif()
+        endif()
+      endif()
+    endif()
+  endif()
+endif()
+
+check_function_exists(vsnprintf HAVE_VSNPRINTF)
+if(NOT HAVE_VSNPRINTF AND NOT ENABLE_BUILD_IOS AND NOT ENABLE_BUILD_ANDROID)
+  set_config_option(HAVE_NO_VSNPRINTF "NoVsnprintf")
+endif()
+
+check_include_file(sys/socket.h HAVE_SYS_SOCKET_H)
+if(HAVE_SYS_SOCKET_H)
+  set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
+endif()
+check_type_size(socklen_t SOCKLEN_T_SIZE)
+set(CMAKE_EXTRA_INCLUDE_FILES)
+if(NOT SOCKLEN_T_SIZE AND NOT ENABLE_BUILD_IOS AND NOT ENABLE_BUILD_ANDROID)
+  set_config_option(HAVE_NO_SOCKLEN_T "NoSocklenT")
+endif()
+
+check_include_file(stdint.h HAVE_STDINT_H)
+if(HAVE_STDINT_H)
+  set(CMAKE_EXTRA_INCLUDE_FILES stdint.h)
+else()
+  set_config_option(HAVE_NO_STDINT_H "NoStdintH")
+endif()
+check_type_size(intptr_t INTPTR_T_SIZE)
+set(CMAKE_EXTRA_INCLUDE_FILES)
+if(NOT INTPTR_T_SIZE AND NOT ENABLE_BUILD_IOS AND NOT ENABLE_BUILD_ANDROID)
+  set_config_option(HAVE_NO_INTPTR_T "NoIntptrT")
+endif()
+
+check_include_file(dlfcn.h DLFCN_H)
+if(DLFCN_H)
+  set_config_option(HAVE_DLOPEN "Dlopen")
+  list(APPEND EXTERNAL_LIBRARIES ${CMAKE_DL_LIBS})
+endif()
+
+if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+  check_include_file(linux/joystick.h LINUX_JOYSTICK_H)
+  if(LINUX_JOYSTICK_H)
+    set_config_option(HAVE_LINUX_JOYSTICK "LinuxJoystick")
+  endif()
+endif()
+
+if(WIN32)
+  add_definitions(-D_USE_MATH_DEFINES)
+  list(APPEND EXTERNAL_LIBRARIES winmm wsock32 ws2_32 psapi)
+endif()
+
+if(MSVC)
+  add_definitions(-DNOMINMAX -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE)
+endif()
+
+# add C functions API
+set(GMSH_SRC ${GMSH_SRC};api/gmshc.cpp)
+
+# force full warnings to encourage everybody to write clean(er) code
+check_cxx_compiler_flag("-Wall" WALL)
+if(WALL AND NOT MSVC)
+  file(GLOB_RECURSE WALL_SRC Common/*.cpp Fltk/*.cpp FunctionSpace/*.cpp
+       Geo/*.cpp Graphics/*.cpp Mesh/*.cpp Numeric/*.cpp Parser/*.cpp
+       Plugin/*.cpp Post/*.cpp Solver/*.cpp)
+  set(WF "-Wall")
+  check_cxx_compiler_flag("-Wint-to-void-pointer-cast" WCAST)
+  if(WCAST)
+    set(WF "${WF} -Wno-int-to-void-pointer-cast")
+  endif()
+  check_cxx_compiler_flag("-Wdeprecated-declarations" WDEPREC)
+  if(WDEPREC)
+    # FIXME: remove this when we have fixed the deprecated GLU code for OpenGL3
+    set(WF "${WF} -Wno-deprecated-declarations")
+  endif()
+  check_cxx_compiler_flag("-Wmisleading-indentation" WIND)
+  if(WIND)
+    set(WF "${WF} -Wno-misleading-indentation")
+  endif()
+  set_compile_flags(WALL_SRC ${WF})
+endif()
+
+# don't issue warnings for contributed libraries
+check_cxx_compiler_flag("-w" NOWARN)
+if(NOWARN)
+  file(GLOB_RECURSE NOWARN_SRC contrib/*.cpp contrib/*.cc contrib/*.cxx contrib/*.c)
+  set_compile_flags(NOWARN_SRC "-w")
+endif()
+
+# disable compile optimization on some known problematic files
+check_cxx_compiler_flag("-O0" NOOPT)
+if(NOOPT OR ENABLE_BUILD_IOS)
+  if(ENABLE_BUILD_IOS) # optimized iOS 10 64 bits screws somewhere in Geo
+    file(GLOB_RECURSE NOOPT_SRC Numeric/robustPredicates.cpp Geo/G*.cpp Mesh/BDS.cpp
+         Parser/Gmsh.tab.cpp contrib/blossom/* Mesh/Background*)
+  else()
+    file(GLOB_RECURSE NOOPT_SRC Numeric/robustPredicates.cpp Mesh/BDS.cpp
+         Parser/Gmsh.tab.cpp contrib/blossom/* contrib/bamg/* Mesh/Background*)
+  endif()
+  set_compile_flags(NOOPT_SRC "-O0")
+endif()
+
+# do not use arithmetic contraction in predicates.cpp
+# if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
+#   set_source_files_properties(Numeric/robustPredicates.cpp PROPERTIES
+#     COMPILE_FLAGS "/fp:strict")
+# elseif(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
+#   set_source_files_properties(Numeric/robustPredicates.cpp PROPERTIES
+#     COMPILE_FLAGS "-fno-unsafe-math-optimizations -ffp-contract=off")
+# elseif(CMAKE_C_COMPILER_ID STREQUAL "Intel")
+#   set_source_files_properties(Numeric/robustPredicates.cpp PROPERTIES
+#     COMPILE_FLAGS "-fp-model strict")
+# endif()
+
+# enable Revoropt and set compile flags for the corresponding plugin
+if(ENABLE_REVOROPT)
+  find_path(EIGEN3_INC "eigen3/Eigen/Dense")
+  if(EIGEN3_INC AND HAVE_MESH AND HAVE_PLUGINS AND HAVE_ANN AND HAVE_ALGLIB)
+    list(APPEND EXTERNAL_INCLUDES ${EIGEN3_INC} contrib/Revoropt/include)
+    message(STATUS "using contrib/Revoropt")
+    set_config_option(HAVE_REVOROPT "Revoropt")
+    add_definitions(-DUSE_ANN)
+    get_source_file_property(PROP Plugin/CVTRemesh.cpp COMPILE_FLAGS)
+    if(PROP)
+      set_source_files_properties(Plugin/CVTRemesh.cpp PROPERTIES
+                                  COMPILE_FLAGS "${PROP} -std=c++11")
+    else()
+      set_source_files_properties(Plugin/CVTRemesh.cpp PROPERTIES
+                                  COMPILE_FLAGS "-std=c++11")
+    endif()
+  else()
+    message(WARNING "Revoropt requires Eigen3, Mesh, Plugins, ANN and ALGLIB")
+  endif()
+endif()
+
+list(SORT CONFIG_OPTIONS)
+set(GMSH_CONFIG_OPTIONS "")
+foreach(OPT ${CONFIG_OPTIONS})
+  set(GMSH_CONFIG_OPTIONS "${GMSH_CONFIG_OPTIONS} ${OPT}")
+endforeach()
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Common/GmshConfig.h.in
+               ${CMAKE_CURRENT_BINARY_DIR}/Common/GmshConfig.h)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Common/GmshVersion.h.in
+               ${CMAKE_CURRENT_BINARY_DIR}/Common/GmshVersion.h)
+
+# the texi version file is modified in the source directory (not ideal, but
+# since git tracks the contents of the file this is acceptable as it will only
+# change when the actual version is changed - not for each git hash)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/texinfo/version.texi.in
+               ${CMAKE_CURRENT_SOURCE_DIR}/doc/texinfo/version.texi)
+
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/version.txt
+     ${GMSH_MAJOR_VERSION}.${GMSH_MINOR_VERSION}.${GMSH_PATCH_VERSION})
+
+# process cmake environment variables so we can append them to the -I include
+# commands. This is not recommended (we should only use the cache variables) but
+# it is very convenient: otherwise we have to remember providing the
+# -D... options to cmake for each new build.
+set(ENV_CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
+set(ENV_CMAKE_INCLUDE_PATH $ENV{CMAKE_INCLUDE_PATH})
+if(UNIX)
+  if(ENV_CMAKE_PREFIX_PATH)
+    string(REPLACE ":" ";" ENV_CMAKE_PREFIX_PATH ${ENV_CMAKE_PREFIX_PATH})
+  endif()
+  if(ENV_CMAKE_INCLUDE_PATH)
+    string(REPLACE ":" ";" ENV_CMAKE_INCLUDE_PATH ${ENV_CMAKE_INCLUDE_PATH})
+  endif()
+endif()
+list(APPEND EXTERNAL_INCLUDES ${CMAKE_INCLUDE_PATH} ${ENV_CMAKE_INCLUDE_PATH})
+list(APPEND EXTERNAL_INCLUDES ${CMAKE_PREFIX_PATH} ${ENV_CMAKE_PREFIX_PATH})
+foreach(DIR ${CMAKE_PREFIX_PATH} ${ENV_CMAKE_PREFIX_PATH})
+  list(APPEND EXTERNAL_INCLUDES ${DIR}/include)
+endforeach()
+
+if(EXTERNAL_INCLUDES)
+  list(REMOVE_DUPLICATES EXTERNAL_INCLUDES)
+endif()
+
+if(HAVE_FLTK)
+  set(LINK_LIBRARIES ${FLTK_LIBRARIES} ${EXTERNAL_LIBRARIES}
+                     ${OPENGL_LIBRARIES} ${LAPACK_LIBRARIES})
+elseif(HAVE_OPENGL)
+  set(LINK_LIBRARIES ${EXTERNAL_LIBRARIES} ${OPENGL_LIBRARIES}
+                     ${LAPACK_LIBRARIES})
+else()
+  set(LINK_LIBRARIES ${EXTERNAL_LIBRARIES} ${LAPACK_LIBRARIES})
+endif()
+
+# try to use static gfortran on static builds (cannot do this on dynamic builds
+# as e.g. Debian compiles libgfortran.a without -fPIC: sigh...)
+if(NOT ENABLE_BUILD_DYNAMIC AND NOT ENABLE_BUILD_SHARED)
+  find_library(GFORTRAN_STATIC libgfortran.a)
+  if(GFORTRAN_STATIC)
+    set(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES)
+    message(STATUS "Using static libgfortran")
+    foreach(STR ${LINK_LIBRARIES})
+      string(REPLACE "-lgfortran" ${GFORTRAN_STATIC} STR2 ${STR})
+      list(APPEND LINK_LIBRARIES2 ${STR2})
+    endforeach()
+    set(LINK_LIBRARIES ${LINK_LIBRARIES2})
+  endif()
+endif()
+
+# Linux-specific linking
+if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+  if(HAVE_OCC)
+    find_library(RT_LIB rt)
+    if(RT_LIB)
+      list(APPEND LINK_LIBRARIES ${RT_LIB})
+    endif()
+  endif()
+  if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Intel")
+    add_definitions(-fPIC)
+  endif()
+endif()
+
+# we could specify include dirs more selectively, but this is simpler
+include_directories(Common Fltk Geo Graphics Mesh Solver Numeric Parser
+  Plugin Post api ${EXTERNAL_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR}/Common)
+
+# set this for external codes that might include this CMakeList file
+set(GMSH_EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDES} CACHE
+    STRING "External include directories" FORCE)
+set(GMSH_EXTERNAL_LIBRARIES ${LINK_LIBRARIES} CACHE
+    STRING "External libraries" FORCE)
+
+# group sources for easier navigation in IDEs
+foreach(DIR ${GMSH_DIRS})
+  string(REGEX REPLACE "\\+" "\\\\+" DIR ${DIR})
+  source_group(${DIR} REGULAR_EXPRESSION ${DIR}/.*)
+endforeach()
+
+# static library target
+if(ENABLE_BUILD_LIB)
+  add_library(lib STATIC ${GMSH_SRC})
+  set_target_properties(lib PROPERTIES OUTPUT_NAME gmsh)
+  if(MSVC)
+    set_target_properties(lib PROPERTIES DEBUG_POSTFIX d)
+    if(ENABLE_MSVC_STATIC_RUNTIME)
+      set_target_properties(lib PROPERTIES LINK_FLAGS_RELEASE "/nodefaultlib:LIBCMT")
+    endif()
+  endif()
+endif()
+
+# shared library target
+if(ENABLE_BUILD_SHARED OR ENABLE_BUILD_DYNAMIC)
+  add_library(shared SHARED ${GMSH_SRC})
+  set_target_properties(shared PROPERTIES OUTPUT_NAME gmsh
+     VERSION ${GMSH_MAJOR_VERSION}.${GMSH_MINOR_VERSION}.${GMSH_PATCH_VERSION}
+     SOVERSION ${GMSH_MAJOR_VERSION}.${GMSH_MINOR_VERSION})
+  if(WIN32)
+    set_target_properties(shared PROPERTIES PREFIX "" IMPORT_PREFIX ""
+      IMPORT_SUFFIX ".lib" COMPILE_FLAGS "-DGMSH_DLL -DGMSH_DLL_EXPORT")
+  endif()
+  target_link_libraries(shared ${LINK_LIBRARIES})
+  if(MSVC AND ENABLE_MSVC_STATIC_RUNTIME)
+    message(STATUS "Note: By enabling ENABLE_MSVC_STATIC_RUNTIME, shared library "
+            "won't link. In MSVC change /MT to /MD in the shared project properties")
+  endif()
+endif()
+
+# binary targets
+if(HAVE_FLTK)
+  if(ENABLE_BUILD_DYNAMIC)
+    add_executable(gmsh WIN32 Common/Main.cpp)
+    target_link_libraries(gmsh shared)
+  else()
+    add_executable(gmsh WIN32 Common/Main.cpp ${GMSH_SRC})
+  endif()
+  # we could add this to create a minimal app bundle even without install
+  # if(APPLE AND NOT ENABLE_OS_SPECIFIC_INSTALL)
+  #  set_target_properties(gmsh PROPERTIES MACOSX_BUNDLE ON
+  #    MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/utils/misc/gmsh_dev.plist)
+  # endif()
+else()
+  if(ENABLE_BUILD_DYNAMIC)
+    add_executable(gmsh Common/Main.cpp)
+    target_link_libraries(gmsh shared)
+  else()
+    add_executable(gmsh Common/Main.cpp ${GMSH_SRC})
+  endif()
+endif()
+target_link_libraries(gmsh ${LINK_LIBRARIES})
+
+# Windows specific linker options
+if(WIN32 AND NOT MSVC)
+  set(FLAGS "-Wl,--stack,16777216 -mwindows")
+  if(HAVE_64BIT_SIZE_T)
+    set(FLAGS "${FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/Fltk/Win64Icon.res")
+  else()
+    set(FLAGS "${FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/Fltk/Win32Icon.res")
+  endif()
+  set_target_properties(gmsh PROPERTIES LINK_FLAGS "${FLAGS} -static")
+  if(ENABLE_BUILD_DYNAMIC OR ENABLE_BUILD_SHARED)
+    set_target_properties(shared PROPERTIES LINK_FLAGS -static)
+  endif()
+  # remove -Wl,-Bdynamic flags
+  set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS)
+  set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
+elseif(MSVC)
+  set_target_properties(gmsh PROPERTIES LINK_FLAGS "/STACK:16777216 /SAFESEH:NO")
+endif()
+
+# android target
+if(ENABLE_BUILD_ANDROID)
+  find_file(CMAKE_TOOLCHAIN_FILE "android.toolchain.cmake")
+  if(NOT CMAKE_TOOLCHAIN_FILE)
+    message(FATAL_ERROR "Cannot compile Gmsh for android without android-cmake")
+  endif()
+  add_definitions(-D_GLIBCXX_USE_C99_MATH=1)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+  set(CMAKE_BUILD_TYPE Release)
+  set(LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_CURRENT_BINARY_DIR})
+  set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/libs/)
+  add_definitions(-DBUILD_ANDROID)
+  add_definitions(-DPICOJSON_USE_LOCALE=0)
+  add_library(androidGmsh SHARED ${GMSH_SRC})
+  set_target_properties(androidGmsh PROPERTIES OUTPUT_NAME gmsh)
+  target_link_libraries(androidGmsh ${EXTERNAL_LIBRARIES} ${LAPACK_LIBRARIES})
+  add_custom_command(TARGET androidGmsh POST_BUILD COMMAND
+                     ${CMAKE_STRIP} ${LIBRARY_OUTPUT_PATH}/libgmsh.so)
+endif()
+
+# parser target
+find_program(BISON bison)
+find_program(FLEX flex)
+if(BISON AND FLEX)
+  add_custom_target(parser
+                    COMMAND ${BISON} -p gmsh_yy --output Gmsh.tab.cpp -d Gmsh.y
+                    COMMAND ${FLEX} -P gmsh_yy -o Gmsh.yy.cpp Gmsh.l
+                    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Parser)
+endif()
+
+if(UNIX)
+  # cannot use cmake's file search functions here (they would only find files
+  # existing at configuration time)
+  add_custom_target(purge
+                    COMMAND rm -f `find . -name *~ -o -name *~~`
+                    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+  add_custom_target(etags
+                    COMMAND etags `find . -name *.cpp -o -name *.h -o -name *.y`
+                    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+endif()
+
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
+   CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
+                  OUTPUT_VARIABLE CXX_COMPILER_VERSION
+                  OUTPUT_STRIP_TRAILING_WHITESPACE)
+else()
+  set(CXX_COMPILER_VERSION "Unknown")
+endif()
+
+set(WELCOME_FILE ${CMAKE_CURRENT_SOURCE_DIR}/doc/WELCOME.txt)
+set(SDK_FILE ${CMAKE_CURRENT_SOURCE_DIR}/doc/SDK.txt)
+set(LICENSE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt)
+set(CREDITS_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CREDITS.txt)
+set(CHANGELOG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG.txt)
+file(GLOB TUTORIAL_GEO_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tutorial/?*.*)
+file(GLOB TUTORIAL_CPP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tutorial/c++/?*.*)
+file(GLOB TUTORIAL_C_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tutorial/c/?*.*)
+file(GLOB TUTORIAL_PY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tutorial/python/?*.*)
+file(GLOB TUTORIAL_JL_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tutorial/julia/?*.*)
+file(GLOB DEMOS ${CMAKE_CURRENT_SOURCE_DIR}/demos/*)
+foreach(SUBDIR ${DEMOS})
+  if(IS_DIRECTORY ${SUBDIR})
+    list(APPEND DEMOS_DIRS ${SUBDIR})
+  endif()
+endforeach()
+set(TEX_DIR ${CMAKE_CURRENT_SOURCE_DIR}/doc/texinfo)
+file(GLOB TEX_SRC ${TEX_DIR}/*.texi)
+set(TEX_OBJ ${TEX_DIR}/gmsh.aux ${TEX_DIR}/gmsh.cp ${TEX_DIR}/gmsh.cps
+    ${TEX_DIR}/gmsh.fn ${TEX_DIR}/gmsh.html ${TEX_DIR}/gmsh.info ${TEX_DIR}/gmsh.ky
+    ${TEX_DIR}/gmsh.log ${TEX_DIR}/gmsh.pdf ${TEX_DIR}/gmsh.pg ${TEX_DIR}/gmsh.toc
+    ${TEX_DIR}/gmsh.tp ${TEX_DIR}/gmsh.tps ${TEX_DIR}/gmsh.txt ${TEX_DIR}/gmsh.vr)
+
+macro(unix2dos VARNAME)
+  file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unix2dos)
+  set(UNIX2DOS_FILES)
+  foreach(FILE ${${VARNAME}})
+    file(READ ${FILE} F0)
+    get_filename_component(N ${FILE} NAME)
+    if(CYGWIN)
+      string(REGEX REPLACE "\n" "\r\n" F1 "${F0}")
+      file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/unix2dos/${N} "${F1}")
+    else() # if not in Cygwin, cmake adds '\r's automatically
+      file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/unix2dos/${N} "${F0}")
+    endif()
+    list(APPEND UNIX2DOS_FILES ${CMAKE_CURRENT_BINARY_DIR}/unix2dos/${N})
+  endforeach()
+  set(${VARNAME} ${UNIX2DOS_FILES})
+endmacro()
+
+if(WIN32)
+  if(ENABLE_OS_SPECIFIC_INSTALL)
+    set(GMSH_BIN .)
+    set(GMSH_LIB .)
+    set(GMSH_DOC .)
+    set(GMSH_MAN .)
+    set(GMSH_INC .)
+  else()
+    include(GNUInstallDirs)
+    set(GMSH_BIN ${CMAKE_INSTALL_BINDIR})
+    set(GMSH_LIB ${CMAKE_INSTALL_LIBDIR})
+    set(GMSH_DOC ${CMAKE_INSTALL_DOCDIR})
+    set(GMSH_MAN ${CMAKE_INSTALL_MANDIR}/man1)
+    set(GMSH_INC ${CMAKE_INSTALL_INCLUDEDIR})
+  endif()
+  if(CYGWIN)
+    unix2dos(GMSH_API)
+    if(ENABLE_PRIVATE_API)
+      unix2dos(GMSH_PRIVATE_API)
+    endif()
+    unix2dos(WELCOME_FILE)
+    unix2dos(SDK_FILE)
+    unix2dos(LICENSE_FILE)
+    unix2dos(CREDITS_FILE)
+    unix2dos(CHANGELOG_FILE)
+    unix2dos(TUTORIAL_GEO_FILES)
+    unix2dos(TUTORIAL_CPP_FILES)
+    unix2dos(TUTORIAL_C_FILES)
+    unix2dos(TUTORIAL_PY_FILES)
+    unix2dos(TUTORIAL_JL_FILES)
+    foreach(DIR ${DEMOS_DIRS})
+      file(GLOB DEMO_FILES ${DIR}/?*.*)
+      unix2dos(DEMO_FILES)
+    endforeach()
+  endif()
+elseif(APPLE AND ENABLE_OS_SPECIFIC_INSTALL)
+  # set these so that the files get installed nicely in the MacOSX
+  # .app bundle
+  set(GMSH_BIN ../MacOS)
+  set(GMSH_LIB ../MacOS)
+  set(GMSH_DOC ../../..)
+  set(GMSH_MAN ../../..)
+  set(GMSH_INC ../MacOS)
+else()
+  include(GNUInstallDirs)
+  set(GMSH_BIN ${CMAKE_INSTALL_BINDIR})
+  set(GMSH_LIB ${CMAKE_INSTALL_LIBDIR})
+  set(GMSH_DOC ${CMAKE_INSTALL_DOCDIR})
+  set(GMSH_MAN ${CMAKE_INSTALL_MANDIR}/man1)
+  set(GMSH_INC ${CMAKE_INSTALL_INCLUDEDIR})
+endif()
+
+# FIXME: change this once we understand rpaths
+if(APPLE)
+  if(ENABLE_BUILD_DYNAMIC OR ENABLE_BUILD_SHARED)
+    set_target_properties(shared PROPERTIES INSTALL_NAME_DIR
+                          ${CMAKE_INSTALL_PREFIX}/${GMSH_LIB})
+  endif()
+endif()
+
+# mark targets as optional so we can install them separately if needed
+# (e.g. "make lib" or "make shared" followed by "make install/fast")
+install(TARGETS gmsh DESTINATION ${GMSH_BIN} OPTIONAL)
+if(ENABLE_BUILD_LIB)
+  install(TARGETS lib DESTINATION ${GMSH_LIB} OPTIONAL)
+endif()
+if(ENABLE_BUILD_SHARED OR ENABLE_BUILD_DYNAMIC)
+  install(TARGETS shared DESTINATION ${GMSH_LIB} OPTIONAL)
+endif()
+
+if(ENABLE_ONELAB)
+  install(FILES ${ONELAB_PY} DESTINATION ${GMSH_BIN})
+endif()
+if(ENABLE_BUILD_LIB OR ENABLE_BUILD_SHARED OR ENABLE_BUILD_DYNAMIC)
+  install(FILES ${GMSH_API} DESTINATION ${GMSH_INC})
+  install(FILES ${GMSH_PY} DESTINATION ${GMSH_LIB})
+  install(FILES ${GMSH_JL} DESTINATION ${GMSH_LIB})
+  if(ENABLE_PRIVATE_API)
+    install(FILES ${GMSH_PRIVATE_API} DESTINATION ${GMSH_INC}/gmsh)
+  endif()
+endif()
+if(INSTALL_SDK_README)
+  configure_file(${SDK_FILE} ${CMAKE_CURRENT_BINARY_DIR}/README.txt)
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/README.txt DESTINATION .)
+endif()
+install(FILES ${WELCOME_FILE} DESTINATION ${GMSH_DOC} RENAME README.txt)
+install(FILES ${LICENSE_FILE} DESTINATION ${GMSH_DOC})
+install(FILES ${CREDITS_FILE} DESTINATION ${GMSH_DOC})
+install(FILES ${CHANGELOG_FILE} DESTINATION ${GMSH_DOC})
+install(FILES ${TUTORIAL_GEO_FILES} DESTINATION ${GMSH_DOC}/tutorial)
+install(FILES ${TUTORIAL_CPP_FILES} DESTINATION ${GMSH_DOC}/tutorial/c++)
+install(FILES ${TUTORIAL_C_FILES} DESTINATION ${GMSH_DOC}/tutorial/c)
+install(FILES ${TUTORIAL_PY_FILES} DESTINATION ${GMSH_DOC}/tutorial/python)
+install(FILES ${TUTORIAL_JL_FILES} DESTINATION ${GMSH_DOC}/tutorial/julia)
+foreach(DIR ${DEMOS_DIRS})
+  get_filename_component(DEMOS_DIR_NAME ${DIR} NAME)
+  file(GLOB DEMO_FILES ${DIR}/?*.*)
+  install(FILES ${DEMO_FILES} DESTINATION ${GMSH_DOC}/demos/${DEMOS_DIR_NAME})
+endforeach()
+if(UNIX AND NOT CYGWIN)
+  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/doc/gmsh.1 DESTINATION ${GMSH_MAN})
+endif()
+
+add_custom_target(get_headers
+  COMMAND ${CMAKE_COMMAND} -E make_directory Headers/gmsh
+  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+foreach(FILE ${GMSH_API})
+  add_custom_command(TARGET get_headers POST_BUILD COMMAND ${CMAKE_COMMAND}
+    -E copy_if_different ${FILE} ${CMAKE_CURRENT_BINARY_DIR}/Headers/
+    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+endforeach()
+if(ENABLE_PRIVATE_API)
+  foreach(FILE ${GMSH_PRIVATE_API})
+    add_custom_command(TARGET get_headers POST_BUILD COMMAND ${CMAKE_COMMAND}
+      -E copy_if_different ${FILE} ${CMAKE_CURRENT_BINARY_DIR}/Headers/gmsh/
+      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+  endforeach()
+endif()
+
+find_program(MAKEINFO makeinfo)
+if(MAKEINFO)
+  add_custom_command(OUTPUT ${TEX_DIR}/gmsh.info DEPENDS ${TEX_SRC}
+                     COMMAND ${MAKEINFO} --split-size 1000000
+                     ARGS ${TEX_DIR}/gmsh.texi WORKING_DIRECTORY ${TEX_DIR})
+  add_custom_target(info DEPENDS ${TEX_DIR}/gmsh.info)
+  add_custom_command(OUTPUT ${TEX_DIR}/gmsh.txt DEPENDS ${TEX_SRC}
+                     COMMAND ${MAKEINFO} --plaintext -o gmsh.txt
+                     ARGS ${TEX_DIR}/gmsh.texi WORKING_DIRECTORY ${TEX_DIR})
+  add_custom_target(txt DEPENDS ${TEX_DIR}/gmsh.txt)
+  add_custom_command(OUTPUT ${TEX_DIR}/gmsh.html DEPENDS ${TEX_SRC}
+    COMMAND ${MAKEINFO} --html --css-ref=http://gmsh.info/gmsh.css
+    --no-split --set-customization-variable
+    EXTRA_HEAD='<meta name="viewport" content="width=device-width,initial-scale=1.0">'
+    ARGS ${TEX_DIR}/gmsh.texi WORKING_DIRECTORY ${TEX_DIR})
+  add_custom_target(html DEPENDS ${TEX_DIR}/gmsh.html)
+  install(FILES ${TEX_DIR}/gmsh.html DESTINATION ${GMSH_DOC} OPTIONAL)
+else()
+  add_custom_target(html COMMAND ${CMAKE_COMMAND} -E touch ${TEX_DIR}/gmsh.html)
+endif()
+
+find_program(TEXI2PDF texi2pdf)
+if(TEXI2PDF)
+  add_custom_command(OUTPUT ${TEX_DIR}/gmsh.pdf DEPENDS ${TEX_SRC}
+                     COMMAND ${TEXI2PDF} ARGS gmsh.texi
+                     WORKING_DIRECTORY ${TEX_DIR})
+  add_custom_target(pdf DEPENDS ${TEX_DIR}/gmsh.pdf)
+  install(FILES ${TEX_DIR}/gmsh.pdf DESTINATION ${GMSH_DOC} OPTIONAL)
+endif()
+
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+  "@c This file was generated by cmake: do not edit manually!\n${OPT_TEXI}"
+  OUTPUT_FILE cmake_options.texi)
+
+if(MAKEINFO AND TEXI2PDF)
+  add_custom_target(doc COMMAND ${CMAKE_COMMAND} -E tar zcf
+                    ${CMAKE_CURRENT_BINARY_DIR}/gmsh-${GMSH_VERSION}-doc.tgz
+                    CREDITS.txt LICENSE.txt CHANGELOG.txt
+                    doc/gmsh.1 doc/texinfo/gmsh.html doc/texinfo/gmsh.info
+                    doc/texinfo/gmsh.pdf doc/texinfo/gmsh.txt
+                    COMMAND ${CMAKE_COMMAND} -E remove ${TEX_OBJ}
+                    DEPENDS ${TEX_DIR}/gmsh.info ${TEX_DIR}/gmsh.txt
+                    ${TEX_DIR}/gmsh.html ${TEX_DIR}/gmsh.pdf
+                    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+endif()
+
+if(MAKEINFO OR TEXI2PDF)
+  add_custom_target(clean_doc COMMAND ${CMAKE_COMMAND} -E remove ${TEX_OBJ})
+endif()
+
+if(APPLE AND ENABLE_BUILD_LIB)
+  file(READ ${CMAKE_CURRENT_SOURCE_DIR}/utils/misc/gmsh_framework.plist F0)
+  string(REPLACE GMSH_VERSION "${GMSH_VERSION}" F1 "${F0}")
+  file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Info_framework.plist "${F1}")
+  get_target_property(LIBNAME lib LOCATION) # depracated
+  #set(LIBNAME $<TARGET_FILE:lib>) # FIXME: use this in the future
+  add_custom_target(framework DEPENDS lib
+    COMMAND ${CMAKE_COMMAND} -E remove_directory gmsh.framework
+    COMMAND ${CMAKE_COMMAND} -E make_directory gmsh.framework/Headers
+    COMMAND ${CMAKE_COMMAND} -E make_directory gmsh.framework/Resources
+    COMMAND ${CMAKE_COMMAND} -E copy ${LIBNAME} gmsh.framework/gmsh
+    COMMAND ${CMAKE_COMMAND} -E copy Info_framework.plist
+                                     gmsh.framework/Resources/Info.plist
+    COMMAND ${CMAKE_COMMAND} -E create_symlink . gmsh.framework/Headers/gmsh
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+  foreach(FILE ${GMSH_API})
+    add_custom_command(TARGET framework POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
+        ${FILE} ${CMAKE_CURRENT_BINARY_DIR}/gmsh.framework/Headers/
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+  endforeach()
+  if(ENABLE_PRIVATE_API)
+    foreach(FILE ${GMSH_PRIVATE_API})
+      add_custom_command(TARGET framework POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
+          ${FILE} ${CMAKE_CURRENT_BINARY_DIR}/gmsh.framework/Headers/
+          WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+    endforeach()
+  endif()
+endif()
+
+set(CPACK_PACKAGE_VENDOR "Christophe Geuzaine and Jean-Francois Remacle")
+set(CPACK_PACKAGE_VERSION_MAJOR ${GMSH_MAJOR_VERSION})
+set(CPACK_PACKAGE_VERSION_MINOR ${GMSH_MINOR_VERSION})
+set(CPACK_PACKAGE_VERSION_PATCH ${GMSH_PATCH_VERSION})
+set(CPACK_PACKAGE_DESCRIPTION_FILE ${WELCOME_FILE})
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
+    "3D finite element mesh generator with built-in CAD engine and post-processor")
+if(GMSH_EXTRA_VERSION MATCHES "-git.*") # so that we'll overwrite the archives
+  set(CPACK_PACKAGE_FILE_NAME gmsh-git-${GMSH_OS})
+  set(CPACK_SOURCE_PACKAGE_FILE_NAME gmsh-git-source)
+else()
+  set(CPACK_PACKAGE_FILE_NAME gmsh-${GMSH_VERSION}-${GMSH_OS})
+  set(CPACK_SOURCE_PACKAGE_FILE_NAME gmsh-${GMSH_VERSION}-source)
+endif()
+set(CPACK_PACKAGE_INSTALL_DIRECTORY "gmsh")
+set(CPACK_RESOURCE_FILE_LICENSE ${LICENSE_FILE})
+set(CPACK_RESOURCE_FILE_README ${WELCOME_FILE})
+set(CPACK_RESOURCE_FILE_WELCOME ${WELCOME_FILE})
+set(CPACK_PACKAGE_EXECUTABLE "gmsh")
+if(ENABLE_PACKAGE_STRIP)
+  set(CPACK_STRIP_FILES TRUE)
+else()
+  set(CPACK_STRIP_FILES FALSE)
+endif()
+set(CPACK_SOURCE_GENERATOR TGZ)
+set(CPACK_SOURCE_IGNORE_FILES "${CMAKE_CURRENT_BINARY_DIR}" "/CVS/" "/.svn" "/.git"
+    "~$" "DS_Store$" "GmshConfig.h$" "GmshVersion.h$" "/benchmarks/" "/tmp/"
+    "/bin/" "/lib/" "/nightly/" "GPATH" "GRTAGS" "GSYMS" "GTAGS" "/HTML/"
+    "/contrib/3M/" "/contrib/Parasolid/")
+
+if(UNIX)
+  # make sure we remove previous installs before doing the next one (on Mac for
+  # example "make package; make package_source" would lead to huge file lists
+  # getting generated due to the 'Applications' symlink in the bundle)
+  set(CPACK_INSTALL_COMMANDS "rm -rf ${CMAKE_CURRENT_BINARY_DIR}/_CPack_Packages")
+endif()
+
+if(APPLE AND ENABLE_OS_SPECIFIC_INSTALL)
+  set(CPACK_GENERATOR Bundle)
+  set(CPACK_BUNDLE_NAME Gmsh)
+  file(READ ${CMAKE_CURRENT_SOURCE_DIR}/utils/misc/gmsh_app.plist F0)
+  string(REPLACE GMSH_VERSION "${GMSH_VERSION}" F1 "${F0}")
+  file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Info.plist "${F1}")
+  set(CPACK_BUNDLE_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
+  set(CPACK_BUNDLE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/Fltk/MacIcons.icns)
+  if(PACKAGER STREQUAL "geuzaine - removed: we sign on a separate machine")
+    # codesigning requires CMake >= 3.2
+    set(CPACK_BUNDLE_APPLE_CERT_APP "Developer ID Application: Christophe Geuzaine")
+  endif()
+  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Fltk/MacIconsGeo.icns DESTINATION .
+          RENAME GmshGeo.icns)
+  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Fltk/MacIconsMsh.icns DESTINATION .
+          RENAME GmshMsh.icns)
+  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Fltk/MacIconsSol.icns DESTINATION .
+          RENAME GmshSol.icns)
+  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Fltk/MacIconsPos.icns DESTINATION .
+          RENAME GmshPos.icns)
+  set(CPACK_PACKAGE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/Fltk/MacIcons.icns)
+elseif(WIN32)
+  set(CPACK_GENERATOR ZIP)
+else()
+  set(CPACK_GENERATOR TGZ)
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/utils/wrappers/gmshpy AND
+   ENABLE_PRIVATE_API AND ENABLE_WRAP_PYTHON AND HAVE_PYTHON)
+  add_subdirectory(utils/wrappers/gmshpy)
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/utils/wrappers/java AND
+   ENABLE_PRIVATE_API AND ENABLE_WRAP_JAVA)
+  add_subdirectory(utils/wrappers/java)
+endif()
+
+include(CPack)
+
+if(NOT DISABLE_GMSH_TESTS)
+  # disabling tests is useful when including this CMakeLists in an external project
+  include(CTest)
+  file(GLOB_RECURSE TESTFILES
+       tutorial/*.geo demos/*.geo benchmarks/?d/*.geo benchmarks/extrude/*.geo
+       benchmarks/occ/*.geo)
+  # disable this test for now on our Linux32 machine - the current config
+  # crashes on the OCC STL generation
+  if(${GMSH_OS} MATCHES "Linux32")
+    list(REMOVE_ITEM TESTFILES ${CMAKE_CURRENT_SOURCE_DIR}/tutorial/t18.geo)
+  endif()
+  foreach(TESTFILE ${TESTFILES})
+    # use relative path for Cygwin/MinGW (the pure win exe built with the MinGW
+    # compilers does not understand a full Cygwin-style path)
+    FILE(RELATIVE_PATH TEST ${CMAKE_CURRENT_BINARY_DIR} ${TESTFILE})
+    if(HAVE_OCC OR NOT ${TEST} MATCHES "boolean" OR NOT ${TEST} MATCHES "occ")
+      add_test(${TEST} ./gmsh ${TEST} -3 -nopopup -o ./tmp.msh)
+    endif()
+  endforeach()
+  # test c++ api tutorials with dynamic builds (except on 32 bit windows for
+  # now: our win32 setup does not currently handle exceptions)
+  if(ENABLE_BUILD_DYNAMIC AND NOT ${GMSH_OS} MATCHES "Windows32")
+    file(GLOB_RECURSE TESTFILES tutorial/c++/*.cpp)
+    foreach(TESTFILE ${TESTFILES})
+      get_filename_component(TEST ${TESTFILE} NAME_WE)
+      add_executable(${TEST} WIN32 ${TESTFILE})
+      target_link_libraries(${TEST} shared)
+      if(WIN32 AND NOT MSVC)
+        set_target_properties(${TEST} PROPERTIES LINK_FLAGS "-mwindows -static")
+      endif()
+      add_test(${TEST}_cpp ${TEST})
+    endforeach()
+  endif()
+endif()
+
+message(STATUS "")
+message(STATUS "Gmsh ${GMSH_VERSION} has been configured for ${GMSH_OS}")
+message(STATUS "")
+message(STATUS " * Build options:" ${GMSH_CONFIG_OPTIONS})
+message(STATUS " * Build type: " ${CMAKE_BUILD_TYPE})
+message(STATUS " * C compiler: " ${CMAKE_C_COMPILER})
+message(STATUS " * C++ compiler: " ${CMAKE_CXX_COMPILER})
+message(STATUS " * Install prefix: " ${CMAKE_INSTALL_PREFIX})
+message(STATUS "")
+
+mark_as_advanced(GMSH_EXTRA_VERSION
+                 ACIS_LIB ANN_INC ANN_LIB CAIRO_LIB CAIRO_INC CGNS_INC GMM_INC
+                 GMP_INC GMP_LIB MMG3D_INC MMG3D_LIB HDF5_LIB
+                 MED_LIB OCC_INC SZ_LIB
+                 PETSC_LIBS SLEPC_INC SLEPC_INC2 SLEPC_LIB
+                 BISON FLEX MAKEINFO TEXI2PDF FLTK_CONFIG_SCRIPT
+                 GMSH_EXTERNAL_INCLUDE_DIRS GMSH_EXTERNAL_LIBRARIES)
Index: /issm/trunk-jpl/externalpackages/gmsh/configs/4.7.0/mac/static/CMakeLists.txt
===================================================================
--- /issm/trunk-jpl/externalpackages/gmsh/configs/4.7.0/mac/static/CMakeLists.txt	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/gmsh/configs/4.7.0/mac/static/CMakeLists.txt	(revision 25745)
@@ -0,0 +1,2191 @@
+# Gmsh - Copyright (C) 1997-2020 C. Geuzaine, J.-F. Remacle
+#
+# See the LICENSE.txt file for license information. Please report all
+# issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
+
+cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
+
+# if CMAKE_BUILD_TYPE is specified use it; otherwise set the default
+# build type to "RelWithDebInfo" ("-O2 -g" with gcc) prior to calling
+# project()
+if(DEFINED CMAKE_BUILD_TYPE)
+  set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose build type")
+else()
+  set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose build type")
+endif()
+
+project(gmsh CXX C)
+
+# require C++11 and request C99
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_C_STANDARD 99)
+
+# this variable controls the default value of the options which are normally set
+# to ON (useful if you want to configure a minimal version of Gmsh: e.g. "cmake
+# -DDEFAULT=0 -DENABLE_POST=1 -DENABLE_PARSER=1")
+set(DEFAULT ON CACHE INTERNAL "Default value for enabled-by-default options")
+
+macro(opt OPTION HELP VALUE)
+  option(ENABLE_${OPTION} ${HELP} ${VALUE})
+  set(OPT_TEXI "${OPT_TEXI}\n@item ENABLE_${OPTION}\n${HELP} (default: ${VALUE})")
+endmacro()
+
+opt(3M "Enable proprietary 3M extension" OFF)
+opt(ALGLIB "Enable ALGLIB (used by some mesh optimizers)" ${DEFAULT})
+opt(ANN "Enable ANN (used for fast point search in mesh/post)" ${DEFAULT})
+opt(BAMG "Enable Bamg 2D anisotropic mesh generator" ${DEFAULT})
+opt(BLAS_LAPACK "Enable BLAS/Lapack for linear algebra (if Eigen if disabled)" OFF)
+opt(BLOSSOM "Enable Blossom algorithm (needed for full quad meshing)" ${DEFAULT})
+opt(BUILD_LIB "Enable 'lib' target for building static Gmsh library" OFF)
+opt(BUILD_SHARED "Enable 'shared' target for building shared Gmsh library" OFF)
+opt(BUILD_DYNAMIC "Enable dynamic Gmsh executable (linked with shared library)" OFF)
+opt(BUILD_ANDROID "Enable Android NDK library target (experimental)" OFF)
+opt(BUILD_IOS "Enable iOS library target (experimental)" OFF)
+opt(CGNS "Enable CGNS import/export (experimental)" ${DEFAULT})
+opt(CGNS_CPEX0045 "Enable high-order CGNS import/export following CPEX0045 (experimental)" OFF)
+opt(CAIRO "Enable Cairo to render fonts (experimental)" ${DEFAULT})
+opt(PROFILE "Enable profiling compiler flags" OFF)
+opt(DINTEGRATION "Enable discrete integration (needed for levelsets)" ${DEFAULT})
+opt(DOMHEX "Enable experimental DOMHEX code" ${DEFAULT})
+opt(EIGEN "Enable Eigen for linear algebra (instead of Blas/Lapack)" ON)
+opt(FLTK "Enable FLTK graphical user interface (requires mesh/post)" ${DEFAULT})
+opt(GETDP "Enable GetDP solver (linked as a library, experimental)" ${DEFAULT})
+opt(GMM "Enable GMM linear solvers (simple alternative to PETSc)" ${DEFAULT})
+opt(GMP "Enable GMP for Kbipack (advanced)" ON)
+opt(GRAPHICS "Enable building graphics lib even without GUI (advanced)" OFF)
+opt(HXT "Enable HXT library (for reparametrization and meshing)" ${DEFAULT})
+opt(KBIPACK "Enable Kbipack (neeeded by homology solver)" ${DEFAULT})
+opt(MATHEX "Enable Mathex expression parser (used by plugins and options)" ${DEFAULT})
+opt(MED "Enable MED mesh and post file formats" ${DEFAULT})
+opt(MESH "Enable mesh module (required by GUI)" ${DEFAULT})
+opt(METIS "Enable Metis mesh partitioner" ${DEFAULT})
+opt(MMG "Enable Mmg mesh adaptation interface" ${DEFAULT})
+opt(MPEG_ENCODE "Enable built-in MPEG movie encoder" ${DEFAULT})
+opt(MPI "Enable MPI (experimental, not used for meshing)" OFF)
+opt(MSVC_STATIC_RUNTIME "Enable static Visual C++ runtime" OFF)
+opt(MUMPS "Enable MUMPS sparse direct linear solver" OFF)
+opt(NETGEN "Enable Netgen 3D frontal mesh generator" ${DEFAULT})
+opt(NUMPY "Enable fullMatrix and numpy array conversion for private API" OFF)
+opt(PETSC4PY "Enable petsc4py wrappers for petsc matrices for private API" OFF)
+opt(OCC "Enable OpenCASCADE CAD kernel" ${DEFAULT})
+opt(OCC_CAF "Enable OpenCASCADE CAF module (for STEP/IGES attributes)" ${DEFAULT})
+opt(OCC_STATIC "Link OpenCASCADE static instead of dynamic libraries (requires ENABLE_OCC)" OFF)
+opt(OCC_TBB "Add TBB libraries in list of OCC libraries" OFF)
+opt(ONELAB "Enable ONELAB solver interface" ${DEFAULT})
+opt(ONELAB_METAMODEL "Enable ONELAB metamodels (experimental)" ${DEFAULT})
+opt(OPENACC "Enable OpenACC" OFF)
+opt(OPENMP "Enable OpenMP" OFF)
+opt(OPTHOM "Enable high-order mesh optimization tools" ${DEFAULT})
+opt(OS_SPECIFIC_INSTALL "Enable OS-specific (e.g. app bundle) installation" OFF)
+opt(OSMESA "Enable OSMesa for offscreen rendering (experimental)" OFF)
+opt(P4EST "Enable p4est for enabling automatic mesh size field (experimental)" OFF)
+opt(PACKAGE_STRIP "Strip symbols in install packages to reduce install size" ON)
+opt(PARSER "Enable GEO file parser (required for .geo/.pos scripts)" ${DEFAULT})
+opt(PETSC "Enable PETSc linear solvers (required for SLEPc)" OFF)
+opt(PLUGINS "Enable post-processing plugins" ${DEFAULT})
+opt(POST "Enable post-processing module (required by GUI)" ${DEFAULT})
+opt(POPPLER "Enable Poppler for displaying PDF documents (experimental)" OFF)
+opt(PRIVATE_API "Enable private API" OFF)
+opt(PRO "Enable PRO extensions" ${DEFAULT})
+opt(QUADTRI "Enable QuadTri structured meshing extensions" ${DEFAULT})
+opt(REVOROPT "Enable Revoropt (used for CVT remeshing)" OFF)
+opt(RPATH "Use RPATH in dynamically linked targets" ON)
+opt(SLEPC "Enable SLEPc eigensolvers" OFF)
+opt(SOLVER "Enable built-in finite element solvers (required for reparametrization)" ${DEFAULT})
+opt(SYSTEM_CONTRIB "Use system versions of contrib libraries, when possible" OFF)
+opt(TCMALLOC "Enable libtcmalloc (fast malloc that does not release memory)" OFF)
+opt(TOUCHBAR "Enable Apple Touch bar" ${DEFAULT})
+opt(VISUDEV "Enable additional visualization capabilities for development purposes" OFF)
+opt(VOROPP "Enable voro++ (for hex meshing, experimental)" ${DEFAULT})
+opt(WRAP_JAVA "Generate SWIG Java wrappers for private API" OFF)
+opt(WRAP_PYTHON "Generate SWIG Python wrappers for private API (not used by public API)" OFF)
+opt(ZIPPER "Enable Zip file compression/decompression" OFF)
+
+set(GMSH_MAJOR_VERSION 4)
+set(GMSH_MINOR_VERSION 7)
+set(GMSH_PATCH_VERSION 0)
+if(NOT GMSH_EXTRA_VERSION)
+  set(GMSH_EXTRA_VERSION "")
+endif()
+set(GMSH_EXTRA_VERSION_TEXI "${GMSH_EXTRA_VERSION}")
+set(GMSH_EXTRA_VERSION_ORIG ${GMSH_EXTRA_VERSION})
+
+if(NOT GMSH_RELEASE)
+  find_package(Git)
+  if(GIT_FOUND)
+    execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
+                    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ERROR_QUIET
+                    OUTPUT_VARIABLE GIT_COMMIT_HASH
+                    OUTPUT_STRIP_TRAILING_WHITESPACE)
+  endif()
+  if(GIT_COMMIT_HASH)
+    set(GMSH_EXTRA_VERSION "${GMSH_EXTRA_VERSION}-git-${GIT_COMMIT_HASH}")
+  endif()
+  set(GMSH_EXTRA_VERSION_TEXI "${GMSH_EXTRA_VERSION_TEXI} (development version)")
+endif()
+
+set(GMSH_SHORT_VERSION
+    "${GMSH_MAJOR_VERSION}.${GMSH_MINOR_VERSION}.${GMSH_PATCH_VERSION}")
+set(GMSH_VERSION "${GMSH_SHORT_VERSION}${GMSH_EXTRA_VERSION}")
+set(GMSH_SHORT_LICENSE "GNU General Public License")
+
+set(GMSH_GITLAB_PREFIX "https://gitlab.onelab.info/gmsh/gmsh")
+if(GMSH_RELEASE)
+  set(GMSH_GITLAB_PREFIX "${GMSH_GITLAB_PREFIX}/blob/gmsh_${GMSH_SHORT_VERSION}")
+else()
+  set(GMSH_GITLAB_PREFIX "${GMSH_GITLAB_PREFIX}/blob/master")
+endif()
+
+set(GMSH_API api/gmsh.h api/gmshc.h api/gmsh.h_cwrap)
+
+if(ENABLE_PRIVATE_API)
+  message(WARNING "The private API is unsupported and undocumented. It is meant "
+          "for expert Gmsh developers, not for regular Gmsh users, who should rely "
+          "on the stable public API (gmsh/api) instead.")
+  file(GLOB_RECURSE HEADERS Common/*.h Numeric/*.h Geo/*.h Mesh/*.h Solver/*.h
+    Post/*.h Plugin/*.h Graphics/*.h contrib/kbipack/*.h
+    contrib/DiscreteIntegration/*.h contrib/HighOrderMeshOptimizer/*.h
+    contrib/MeshOptimizer/*.h contrib/MeshQualityOptimizer/*.h)
+  set(GMSH_PRIVATE_API ${CMAKE_CURRENT_BINARY_DIR}/Common/GmshConfig.h
+      ${CMAKE_CURRENT_BINARY_DIR}/Common/GmshVersion.h ${HEADERS})
+  get_property(IAMCHILD DIRECTORY PROPERTY PARENT_DIRECTORY)
+  if(IAMCHILD)
+    set(GMSH_PRIVATE_API ${GMSH_PRIVATE_API} PARENT_SCOPE)
+  endif()
+  if(ENABLE_WRAP_PYTHON OR ENABLE_WRAP_JAVA)
+    set(ENABLE_BUILD_DYNAMIC ON)
+    message(WARNING "SWIG wrappers for the private API are unsupported and "
+            "undocumented. The stable public Python API does not required SWIG.")
+  endif()
+endif()
+
+set(ONELAB_PY contrib/onelab/python/onelab.py)
+set(GMSH_PY api/gmsh.py)
+set(GMSH_JL api/gmsh.jl)
+
+if(${CMAKE_MAJOR_VERSION} GREATER 2)
+  string(TIMESTAMP DATE "%Y%m%d")
+else()
+  execute_process(COMMAND date "+%Y%m%d" OUTPUT_VARIABLE DATE
+                  OUTPUT_STRIP_TRAILING_WHITESPACE)
+endif()
+
+if(NOT DATE)
+  set(DATE "unknown")
+endif()
+set(GMSH_DATE "${DATE}")
+
+if(NOT GMSH_HOST)
+  execute_process(COMMAND hostname OUTPUT_VARIABLE HOST
+                  OUTPUT_STRIP_TRAILING_WHITESPACE)
+  if(NOT HOST)
+    set(HOST "unknown")
+  endif()
+  set(GMSH_HOST "${HOST}")
+endif()
+
+if(NOT GMSH_PACKAGER)
+  execute_process(COMMAND whoami OUTPUT_VARIABLE PACKAGER
+                  OUTPUT_STRIP_TRAILING_WHITESPACE)
+  if(NOT PACKAGER)
+    set(PACKAGER "unknown")
+  endif()
+  string(REPLACE "\\" " " PACKAGER ${PACKAGER})
+  set(GMSH_PACKAGER "${PACKAGER}")
+endif()
+
+if(APPLE)
+  set(GMSH_OS "MacOSX")
+elseif(CYGWIN OR MSYS)
+  # detect if we use the MinGW compilers on Cygwin - if we do, handle the build
+  # as a pure Windows build and make cmake find pure Windows import libraries
+  # (.lib)
+  if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
+     CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+    execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
+                    OUTPUT_VARIABLE CXX_COMPILER_MACHINE
+                    OUTPUT_STRIP_TRAILING_WHITESPACE)
+    if(CXX_COMPILER_MACHINE MATCHES "mingw")
+      set(GMSH_OS "Windows")
+      set(WIN32 1)
+      add_definitions(-DWIN32)
+      set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")
+      set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".so" ".lib" ".LIB" ".dll" ".DLL" ".dll.a")
+    endif()
+  endif()
+else()
+  set(GMSH_OS "${CMAKE_SYSTEM_NAME}")
+endif()
+
+include(CheckTypeSize)
+include(CheckFunctionExists)
+include(CheckIncludeFile)
+include(CheckCXXCompilerFlag)
+include(CheckCCompilerFlag)
+
+macro(set_config_option VARNAME STRING)
+  set(${VARNAME} TRUE)
+  list(APPEND CONFIG_OPTIONS ${STRING})
+  message(STATUS "Found " ${STRING})
+endmacro()
+
+# check the size of size_t
+check_type_size("size_t" SIZEOF_SIZE_T)
+if(SIZEOF_SIZE_T EQUAL 8)
+  set_config_option(HAVE_64BIT_SIZE_T "64Bit")
+endif()
+
+# append 32/64 to the build name on Linux and Windows
+if(NOT APPLE)
+  if(HAVE_64BIT_SIZE_T)
+    set(GMSH_OS "${GMSH_OS}64")
+  else()
+    set(GMSH_OS "${GMSH_OS}32")
+  endif()
+endif()
+
+if(ENABLE_BUILD_DYNAMIC)
+  set(GMSH_OS "${GMSH_OS}-sdk")
+endif()
+
+if(ENABLE_RPATH)
+  set(CMAKE_MACOSX_RPATH 1)
+
+  # make sure that dynamic libraries can be found when installing/ displacing
+  # the binaries: from https://gitlab.kitware.com/cmake/community/wikis/doc/
+  # cmake/RPATH-handling:
+
+  # use, i.e. don't skip the full RPATH for the build tree
+  set(CMAKE_SKIP_BUILD_RPATH FALSE)
+
+  # when building, don't use the install RPATH already (but later on when
+  # installing)
+  set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
+  set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
+
+  # add the automatically determined parts of the RPATH which point to
+  # directories outside the build tree to the install RPATH
+  set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+
+  # the RPATH to be used when installing, but only if it's not a system directory
+  list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib"
+       isSystemDir)
+  if("${isSystemDir}" STREQUAL "-1")
+    if(APPLE)
+      set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
+    else()
+      set(CMAKE_INSTALL_RPATH "\\\$ORIGIN/../lib")
+    endif()
+  endif()
+else()
+  set(CMAKE_MACOSX_RPATH 0)
+  set(CMAKE_SKIP_BUILD_RPATH TRUE)
+endif()
+
+if(MSVC)
+  # remove annoying warning about bool/int cast performance
+  set(GMSH_CONFIG_PRAGMAS "#pragma warning(disable:4800 4244 4267)")
+  foreach(VAR
+          CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+          CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
+          CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
+          CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
+    if(ENABLE_MSVC_STATIC_RUNTIME AND ${VAR} MATCHES "/MD")
+      string(REGEX REPLACE "/MD" "/MT" ${VAR} "${${VAR}}")
+    endif()
+    if(NOT ${VAR} MATCHES "/MP") # enable parallel compilation
+      set(${VAR} "${${VAR}} /MP")
+    endif()
+  endforeach()
+  if(ENABLE_PRIVATE_API)
+    if(ENABLE_BUILD_DYNAMIC OR ENABLE_BUILD_SHARED)
+      # automatically export .def file with all symbols (requires CMake 3.4);
+      # depending on the compiling options this might lead to more than 64k export
+      # symbols; just trim the .def file to keep the ones you need
+      set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
+    endif()
+  endif()
+endif()
+
+# reduce memory usage of GCC on 32 bit systems
+if(NOT HAVE_64BIT_SIZE_T AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+  set(CMAKE_CXX_FLAGS
+      "${CMAKE_CXX_FLAGS} --param ggc-min-expand=1 --param ggc-min-heapsize=512000")
+endif()
+
+if(ENABLE_OPENMP)
+  find_package(OpenMP)
+  if(OpenMP_FOUND OR OPENMP_FOUND)
+    set_config_option(HAVE_OPENMP "OpenMP")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+  elseif(APPLE AND EXISTS "/opt/local/lib/libomp")
+    # official Apple compiler with macports' libomp
+    set_config_option(HAVE_OPENMP "OpenMP[MacPorts]")
+    set(CMAKE_C_FLAGS
+        "${CMAKE_C_FLAGS} -Xpreprocessor -fopenmp -I/opt/local/include/libomp")
+    set(CMAKE_CXX_FLAGS
+        "${CMAKE_CXX_FLAGS} -Xpreprocessor -fopenmp -I/opt/local/include/libomp")
+    list(APPEND EXTERNAL_LIBRARIES "-L/opt/local/lib/libomp -lomp")
+  elseif(APPLE AND EXISTS "/usr/local/lib/libomp.dylib")
+    # official Apple compiler with homebrew's libomp
+    set_config_option(HAVE_OPENMP "OpenMP[Homebrew]")
+    set(CMAKE_C_FLAGS
+        "${CMAKE_C_FLAGS} -Xpreprocessor -fopenmp")
+    set(CMAKE_CXX_FLAGS
+        "${CMAKE_CXX_FLAGS} -Xpreprocessor -fopenmp")
+    list(APPEND EXTERNAL_LIBRARIES "-L/usr/local/lib -lomp")
+  endif()
+endif()
+
+if(ENABLE_OPENACC)
+  find_package(OpenACC)
+  if(OpenACC_C_FOUND AND OpenACC_CXX_FOUND)
+    set_config_option(HAVE_OPENACC "OpenACC")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenACC_C_FLAGS}")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenACC_CXX_FLAGS}")
+  endif()
+endif()
+
+if(ENABLE_PROFILE)
+    # Using the perf set of profiling tools doesn't work without the frame
+    # pointer and a common optimisation is to remove it
+    check_cxx_compiler_flag("-fno-omit-frame-pointer" FNOFP)
+    if(FNOFP)
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
+    endif()
+endif()
+
+macro(append_gmsh_src DIRNAME FILES)
+  foreach(FILE ${FILES})
+    list(APPEND LIST ${DIRNAME}/${FILE})
+  endforeach()
+  set(GMSH_SRC ${GMSH_SRC};${LIST} PARENT_SCOPE)
+  set(GMSH_DIRS ${GMSH_DIRS};${DIRNAME} PARENT_SCOPE)
+endmacro()
+
+macro(find_all_libraries VARNAME LISTNAME PATH SUFFIX)
+  set(${VARNAME})
+  list(LENGTH ${LISTNAME} NUM_LIST)
+  foreach(LIB ${${LISTNAME}})
+    if("${PATH}" STREQUAL "")
+      find_library(FOUND_LIB ${LIB} PATH_SUFFIXES ${SUFFIX})
+    else()
+      find_library(FOUND_LIB ${LIB} PATHS ${PATH} NO_DEFAULT_PATH)
+    endif()
+    if(FOUND_LIB)
+      list(APPEND ${VARNAME} ${FOUND_LIB})
+    endif()
+    unset(FOUND_LIB CACHE)
+  endforeach()
+  list(LENGTH ${VARNAME} NUM_FOUND_LIBRARIES)
+  if(NUM_FOUND_LIBRARIES LESS NUM_LIST)
+    set(${VARNAME})
+  endif()
+endmacro()
+
+macro(set_compile_flags LISTNAME FLAGS)
+  foreach(FILE ${${LISTNAME}})
+    get_source_file_property(PROP ${FILE} COMPILE_FLAGS)
+    if(PROP)
+      set_source_files_properties(${FILE} PROPERTIES COMPILE_FLAGS "${PROP} ${FLAGS}")
+    else()
+      set_source_files_properties(${FILE} PROPERTIES COMPILE_FLAGS "${FLAGS}")
+    endif()
+  endforeach()
+endmacro()
+
+if(ENABLE_EIGEN)
+  if(ENABLE_SYSTEM_CONTRIB)
+    find_path(EIGEN_INC "Eigen/Dense" HINTS eigen3)
+    if(EIGEN_INC)
+      include_directories(${EIGEN_INC})
+      set_config_option(HAVE_EIGEN "Eigen[system]")
+    endif()
+  endif()
+  if(NOT HAVE_EIGEN)
+    include_directories(contrib/eigen)
+    set_config_option(HAVE_EIGEN "Eigen")
+  endif()
+  # We could also add an option to use BLAS with Eigen
+  # add_definitions(-DEIGEN_USE_BLAS)
+elseif(ENABLE_BLAS_LAPACK)
+  if(BLAS_LAPACK_LIBRARIES)
+    # use libs as specified in the BLAS_LAPACK_LIBRARIES variable
+    set_config_option(HAVE_BLAS "Blas[custom]")
+    set_config_option(HAVE_LAPACK "Lapack[custom]")
+    set(LAPACK_LIBRARIES ${BLAS_LAPACK_LIBRARIES})
+  else()
+    if(MSVC)
+      # on Windows with Visual C++ try really hard to find blas/lapack *without*
+      # requiring a Fortran compiler: 1) try to find the Intel MKL libs using
+      # the standard search path; if not found 2) try to get the reference
+      # blas/lapack libs (useful for users with no Fortran compiler and no MKL
+      # license, who can just download our precompiled "gmsh-dep" package)
+      if(HAVE_64BIT_SIZE_T)
+        set(MKL_PATH em64t/lib)
+        set(MKL_LIBS_REQUIRED libguide40 mkl_intel_lp64 mkl_intel_thread mkl_core)
+      else()
+        set(MKL_PATH ia32/lib)
+        set(MKL_LIBS_REQUIRED libguide40 mkl_intel_c mkl_intel_thread mkl_core)
+      endif()
+      find_all_libraries(LAPACK_LIBRARIES MKL_LIBS_REQUIRED "" ${MKL_PATH})
+      if(LAPACK_LIBRARIES)
+        set_config_option(HAVE_BLAS "Blas[mkl]")
+        set_config_option(HAVE_LAPACK "Lapack[mkl]")
+      else()
+        set(REFLAPACK_LIBS_REQUIRED lapack blas g2c gcc)
+        find_all_libraries(LAPACK_LIBRARIES REFLAPACK_LIBS_REQUIRED "" "")
+        if(LAPACK_LIBRARIES)
+          set_config_option(HAVE_BLAS "Blas[ref]")
+          set_config_option(HAVE_LAPACK "Lapack[ref]")
+        endif()
+      endif()
+    elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+      # on Linux try to find the Intel MKL without a Fortran compiler
+      if(HAVE_64BIT_SIZE_T)
+        set(MKL_PATH lib/em64t)
+      else()
+        set(MKL_PATH lib/32)
+      endif()
+      set(MKL_LIBS_REQUIRED mkl_gf_lp64 iomp5 mkl_gnu_thread mkl_core guide pthread)
+      find_all_libraries(LAPACK_LIBRARIES MKL_LIBS_REQUIRED "" ${MKL_PATH})
+      if(NOT LAPACK_LIBRARIES)
+        # match lapack 9.0 on 64bit
+        set(MKL_LIBS_REQUIRED mkl_lapack mkl_em64t guide)
+        find_all_libraries(LAPACK_LIBRARIES MKL_LIBS_REQUIRED "" ${MKL_PATH})
+      endif()
+      if(LAPACK_LIBRARIES)
+        set_config_option(HAVE_BLAS "Blas[mkl]")
+        set_config_option(HAVE_LAPACK "Lapack[mkl]")
+      else()
+        # on Linux also try to find ATLAS without a Fortran compiler, because
+        # cmake ships with a buggy FindBLAS e.g. on Ubuntu Lucid Lynx
+        set(ATLAS_LIBS_REQUIRED lapack f77blas cblas atlas)
+        find_all_libraries(LAPACK_LIBRARIES ATLAS_LIBS_REQUIRED "" "")
+        if(LAPACK_LIBRARIES)
+          set_config_option(HAVE_BLAS "Blas[atlas]")
+          set_config_option(HAVE_LAPACK "Lapack[atlas]")
+        else()
+          # try with generic names
+          set(GENERIC_LIBS_REQUIRED lapack blas pthread)
+          find_all_libraries(LAPACK_LIBRARIES GENERIC_LIBS_REQUIRED "" "")
+          if(LAPACK_LIBRARIES)
+            set_config_option(HAVE_BLAS "Blas[generic]")
+            set_config_option(HAVE_LAPACK "Lapack[generic]")
+            find_library(GFORTRAN_LIB gfortran)
+            if(GFORTRAN_LIB)
+              list(APPEND LAPACK_LIBRARIES ${GFORTRAN_LIB})
+            endif()
+          endif()
+        endif()
+      endif()
+    elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
+      # on SunOS we know blas and lapack are available in sunperf
+      set(LAPACK_LIBRARIES -library=sunperf)
+      set_config_option(HAVE_BLAS "Blas[sunperf]")
+      set_config_option(HAVE_LAPACK "Lapack[sunperf]")
+    elseif(APPLE)
+      # on Mac we also know that blas and lapack are available
+      set(LAPACK_LIBRARIES "-llapack -lblas")
+      set_config_option(HAVE_BLAS "Blas[veclib]")
+      set_config_option(HAVE_LAPACK "Lapack[veclib]")
+    endif()
+
+    if(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
+      # if we haven't found blas and lapack check for OpenBlas
+      set(OPENBLAS_LIBS_REQUIRED openblas)
+      find_all_libraries(LAPACK_LIBRARIES OPENBLAS_LIBS_REQUIRED "" "")
+      if(LAPACK_LIBRARIES)
+        set_config_option(HAVE_BLAS "Blas[openblas]")
+        set_config_option(HAVE_LAPACK "Lapack[openblas]")
+        find_library(GFORTRAN_LIB gfortran)
+        if(GFORTRAN_LIB)
+          list(APPEND LAPACK_LIBRARIES ${GFORTRAN_LIB})
+        endif()
+      endif()
+    endif()
+
+    if(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
+      # if we still haven't found blas and lapack, use the standard cmake tests,
+      # which require a working Fortran compiler
+      enable_language(Fortran)
+      find_package(BLAS)
+      if(BLAS_FOUND)
+        set_config_option(HAVE_BLAS "Blas")
+        find_package(LAPACK)
+        if(LAPACK_FOUND)
+          set_config_option(HAVE_LAPACK "Lapack")
+        else()
+          set(LAPACK_LIBRARIES ${BLAS_LIBRARIES})
+        endif()
+        if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
+          if(CMAKE_Fortran_COMPILER MATCHES "gfortran")
+            list(APPEND LAPACK_LIBRARIES gfortran)
+          elseif(CMAKE_Fortran_COMPILER MATCHES "f95")
+            list(APPEND LAPACK_LIBRARIES gfortran)
+          elseif(CMAKE_Fortran_COMPILER MATCHES "g77")
+            list(APPEND LAPACK_LIBRARIES g2c)
+          endif()
+        elseif(CMAKE_Fortran_COMPILER MATCHES "pgi")
+          list(APPEND LAPACK_LIBRARIES -pgf77libs)
+        endif()
+      endif()
+    endif()
+  endif()
+endif()
+
+if(ENABLE_TCMALLOC)
+  find_library(TCMALLOC tcmalloc)
+  if(TCMALLOC)
+    set_config_option(HAVE_TCMALLOC "TCMalloc")
+    list(APPEND EXTERNAL_LIBRARIES ${TCMALLOC})
+  endif()
+endif()
+
+add_subdirectory(Common)
+add_subdirectory(Numeric)
+add_subdirectory(Geo)
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Mesh AND ENABLE_MESH)
+  add_subdirectory(Mesh)
+  set_config_option(HAVE_MESH "Mesh")
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Solver AND ENABLE_SOLVER)
+  add_subdirectory(Solver)
+  set_config_option(HAVE_SOLVER "Solver")
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Post AND ENABLE_POST)
+  add_subdirectory(Post)
+  set_config_option(HAVE_POST "Post")
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Plugin AND ENABLE_PLUGINS)
+    add_subdirectory(Plugin)
+    set_config_option(HAVE_PLUGINS "Plugins")
+  endif()
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Parser AND ENABLE_PARSER)
+  add_subdirectory(Parser)
+  set_config_option(HAVE_PARSER "Parser")
+endif()
+
+if(ENABLE_VISUDEV)
+  set_config_option(HAVE_VISUDEV "VisuDev")
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Fltk AND ENABLE_FLTK)
+  # first, try to use fltk-config for fltk >= 1.3 (FindFLTK is buggy on Unix,
+  # where e.g. xft and xinerama options are not dealt with)
+  find_program(FLTK_CONFIG_SCRIPT fltk-config)
+  if(FLTK_CONFIG_SCRIPT)
+    execute_process(COMMAND ${FLTK_CONFIG_SCRIPT} --api-version
+                    OUTPUT_VARIABLE FLTK_VERSION)
+    string(STRIP "${FLTK_VERSION}" FLTK_VERSION)
+    if(FLTK_VERSION VERSION_GREATER 1.1)
+      add_subdirectory(Fltk)
+      set_config_option(HAVE_FLTK "Fltk")
+      message(STATUS "Using fltk-config script for Fltk " ${FLTK_VERSION})
+      execute_process(COMMAND ${FLTK_CONFIG_SCRIPT} --use-gl --use-images --includedir
+                      OUTPUT_VARIABLE FLTK_INCLUDE_DIR)
+      string(STRIP ${FLTK_INCLUDE_DIR} FLTK_INCLUDE_DIR)
+      list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR})
+      # On linux (at least OpenSuSE) the following directories are
+      # not existing (everything is in /usr/include). To avoid warnings
+      # check existance of these directories before adding them
+      if(EXISTS ${FLTK_INCLUDE_DIR}/FL/images)
+        list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR}/FL/images)
+      endif()
+      if(EXISTS ${FLTK_INCLUDE_DIR}/jpeg)
+        list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR}/jpeg)
+      endif()
+      if(EXISTS ${FLTK_INCLUDE_DIR}/zlib)
+        list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR}/zlib)
+      endif()
+      if(EXISTS ${FLTK_INCLUDE_DIR}/png)
+        list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR}/png)
+      endif()
+      execute_process(COMMAND ${FLTK_CONFIG_SCRIPT} --use-gl --use-images --ldflags
+                      OUTPUT_VARIABLE FLTK_LIBRARIES)
+      string(STRIP ${FLTK_LIBRARIES} FLTK_LIBRARIES)
+      string(REGEX MATCH "fltk[_ ]jpeg" FLTK_JPEG ${FLTK_LIBRARIES})
+      string(REGEX MATCH "fltk[_ ]z" FLTK_Z ${FLTK_LIBRARIES})
+      string(REGEX MATCH "fltk[_ ]png" FLTK_PNG ${FLTK_LIBRARIES})
+    endif()
+  endif()
+  # then try the built-in FindFLTK module
+  if(NOT HAVE_FLTK)
+    set(FLTK_SKIP_FORMS TRUE)
+    set(FLTK_SKIP_FLUID TRUE)
+    find_package(FLTK)
+    if(FLTK_FOUND)
+      add_subdirectory(Fltk)
+      set_config_option(HAVE_FLTK "Fltk")
+      list(APPEND EXTERNAL_INCLUDES ${FLTK_INCLUDE_DIR})
+      # find fltk jpeg
+      find_library(FLTK_JPEG NAMES fltk_jpeg fltkjpeg)
+      if(FLTK_JPEG)
+        list(APPEND EXTERNAL_LIBRARIES ${FLTK_JPEG})
+        foreach(DIR ${FLTK_INCLUDE_DIR})
+          list(APPEND EXTERNAL_INCLUDES ${DIR}/FL/images ${DIR}/jpeg)
+        endforeach()
+      endif()
+      # find fltk zlib
+      find_library(FLTK_Z NAMES fltk_z fltkz)
+      if(FLTK_Z)
+        list(APPEND EXTERNAL_LIBRARIES ${FLTK_Z})
+        foreach(DIR ${FLTK_INCLUDE_DIR})
+          list(APPEND EXTERNAL_INCLUDES ${DIR}/FL/images ${DIR}/zlib)
+        endforeach()
+      endif()
+      # find fltk png
+      find_library(FLTK_PNG NAMES fltk_png fltkpng)
+      if(FLTK_PNG)
+        list(APPEND EXTERNAL_LIBRARIES ${FLTK_PNG})
+        foreach(DIR ${FLTK_INCLUDE_DIR})
+          list(APPEND EXTERNAL_INCLUDES ${DIR}/FL/images ${DIR}/png)
+        endforeach()
+      endif()
+    endif()
+  endif()
+  # workaround for Fedora/Suse messing up fltk-config (see issue #417)
+  if(HAVE_FLTK AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+    string(REGEX MATCH "X11" FLTK_X11 ${FLTK_LIBRARIES})
+    if(NOT FLTK_X11)
+      find_package(X11)
+      if(X11_FOUND)
+        list(APPEND EXTERNAL_INCLUDES ${X11_INCLUDE_DIR})
+        list(APPEND EXTERNAL_LIBRARIES ${X11_LIBRARIES})
+      endif()
+    endif()
+  endif()
+endif()
+
+if(APPLE AND HAVE_FLTK AND ENABLE_TOUCHBAR)
+  STRING(REGEX MATCH "([0-9]+.[0-9]+)" OSX_SDK_VERSION "${CMAKE_OSX_SYSROOT}")
+  if(OSX_SDK_VERSION)
+    if(${OSX_SDK_VERSION} VERSION_GREATER 10.11)
+      set(GMSH_SRC ${GMSH_SRC};Fltk/touchBar.mm)
+      set_config_option(HAVE_TOUCHBAR "TouchBar")
+    endif()
+  endif()
+endif()
+
+if(ENABLE_ONELAB)
+  set_config_option(HAVE_ONELAB "ONELAB")
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/onelab)
+    if(ENABLE_ONELAB_METAMODEL)
+      add_subdirectory(contrib/onelab)
+      include_directories(contrib/onelab)
+      set_config_option(HAVE_ONELAB_METAMODEL "ONELABMetamodel")
+    endif()
+    file(COPY ${ONELAB_PY} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+  endif()
+endif()
+
+if(ENABLE_BUILD_IOS)
+  find_file(CMAKE_TOOLCHAIN_FILE "ios.cmake")
+  if(NOT CMAKE_TOOLCHAIN_FILE)
+    message(FATAL_ERROR "Cannot compile Gmsh for iOS without a toolchain")
+  endif()
+  add_definitions(-DBUILD_IOS)
+endif()
+
+if(HAVE_FLTK OR ENABLE_GRAPHICS)
+  if(NOT HAVE_MESH OR NOT HAVE_POST OR NOT HAVE_PLUGINS OR NOT HAVE_ONELAB)
+    message(SEND_ERROR "Cannot compile GUI without Mesh, Post, Plugin and ONELAB")
+  endif()
+
+  if(FLTK_JPEG)
+    set_config_option(HAVE_LIBJPEG "Jpeg[fltk]")
+  else()
+    find_package(JPEG)
+    if(JPEG_FOUND)
+      set_config_option(HAVE_LIBJPEG "Jpeg")
+      list(APPEND EXTERNAL_LIBRARIES ${JPEG_LIBRARIES})
+      list(APPEND EXTERNAL_INCLUDES ${JPEG_INCLUDE_DIR})
+    endif()
+  endif()
+
+  if(FLTK_Z)
+    set_config_option(HAVE_LIBZ "Zlib[fltk]")
+  else()
+    find_package(ZLIB)
+    if(ZLIB_FOUND)
+      set_config_option(HAVE_LIBZ "Zlib")
+      list(APPEND EXTERNAL_LIBRARIES ${ZLIB_LIBRARIES})
+      list(APPEND EXTERNAL_INCLUDES ${ZLIB_INCLUDE_DIR})
+    endif()
+  endif()
+
+  if(HAVE_LIBZ)
+    if(FLTK_PNG)
+      set_config_option(HAVE_LIBPNG "Png[fltk]")
+    else()
+      find_package(PNG)
+      if(PNG_FOUND)
+        set_config_option(HAVE_LIBPNG "Png")
+        list(APPEND EXTERNAL_LIBRARIES ${PNG_LIBRARIES})
+        list(APPEND EXTERNAL_INCLUDES ${PNG_INCLUDE_DIR})
+      endif()
+    endif()
+  endif()
+
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/mpeg_encode AND
+     ENABLE_MPEG_ENCODE)
+    add_subdirectory(contrib/mpeg_encode)
+    include_directories(contrib/mpeg_encode/headers)
+    set_config_option(HAVE_MPEG_ENCODE "Mpeg")
+  endif()
+
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/3M AND ENABLE_3M)
+    add_subdirectory(contrib/3M)
+    include_directories(contrib/3M)
+    set_config_option(HAVE_3M "3M")
+  endif()
+
+  if(ENABLE_OSMESA)
+    find_library(OSMESA_LIB OSMesa)
+    if(OSMESA_LIB)
+      set_config_option(HAVE_OSMESA "OSMesa")
+      list(APPEND EXTERNAL_LIBRARIES ${OSMESA_LIB})
+    endif()
+  endif()
+
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Graphics)
+    set(OpenGL_GL_PREFERENCE "LEGACY")
+    find_package(OpenGL REQUIRED)
+    if(OPENGL_GLU_FOUND AND OPENGL_FOUND)
+      add_subdirectory(Graphics)
+      set_config_option(HAVE_OPENGL "OpenGL")
+    else()
+      message(SEND_ERROR "Could not find GLU: disabling OpenGL support")
+    endif()
+  endif()
+endif()
+
+if(ENABLE_ANN)
+  find_library(ANN_LIB ANN PATH_SUFFIXES lib)
+  find_path(ANN_INC "ANN.h" PATH_SUFFIXES src include ANN)
+  if(ENABLE_SYSTEM_CONTRIB AND ANN_LIB AND ANN_INC)
+    message(STATUS "Using system version of ANN")
+    list(APPEND EXTERNAL_LIBRARIES ${ANN_LIB})
+    list(APPEND EXTERNAL_INCLUDES ${ANN_INC})
+    set_config_option(HAVE_ANN "ANN[system]")
+  elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/ANN)
+    add_subdirectory(contrib/ANN)
+    include_directories(contrib/ANN/include)
+    set_config_option(HAVE_ANN "ANN")
+  endif()
+endif()
+
+if(ENABLE_ALGLIB)
+  find_library(ALGLIB_LIB alglib)
+  find_path(ALGLIB_INC "stdafx.h" PATH_SUFFIXES libalglib)
+  if(ENABLE_SYSTEM_CONTRIB AND ALGLIB_LIB AND ALGLIB_INC)
+    list(APPEND EXTERNAL_LIBRARIES ${ALGLIB_LIB})
+    list(APPEND EXTERNAL_INCLUDES ${ALGLIB_INC})
+    set_config_option(HAVE_ALGLIB "ALGLIB[system]")
+  elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/ALGLIB)
+    add_subdirectory(contrib/ALGLIB)
+    include_directories(contrib/ALGLIB)
+    set_config_option(HAVE_ALGLIB "ALGLIB")
+  endif()
+endif()
+
+if(HAVE_FLTK AND ENABLE_CAIRO)
+  find_library(CAIRO_LIB cairo)
+  find_path(CAIRO_INC "cairo/cairo.h" PATH_SUFFIXES include)
+  if(CAIRO_INC AND CAIRO_LIB)
+     set_config_option(HAVE_CAIRO "Cairo")
+     list(APPEND EXTERNAL_LIBRARIES ${CAIRO_LIB})
+     list(APPEND EXTERNAL_INCLUDES ${CAIRO_INC})
+  endif()
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/DiscreteIntegration AND
+   ENABLE_DINTEGRATION)
+  add_subdirectory(contrib/DiscreteIntegration)
+  include_directories(contrib/DiscreteIntegration)
+  set_config_option(HAVE_DINTEGRATION "DIntegration")
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/HighOrderMeshOptimizer AND
+   EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/MeshOptimizer AND
+   EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/MeshQualityOptimizer AND
+   ENABLE_OPTHOM AND HAVE_MESH)
+  add_subdirectory(contrib/HighOrderMeshOptimizer)
+  include_directories(contrib/HighOrderMeshOptimizer)
+  add_subdirectory(contrib/MeshOptimizer)
+  include_directories(contrib/MeshOptimizer)
+  include_directories(${CMAKE_CURRENT_BINARY_DIR}/contrib/MeshOptimizer)
+  add_subdirectory(contrib/MeshQualityOptimizer)
+  include_directories(contrib/MeshQualityOptimizer)
+  set_config_option(HAVE_OPTHOM "OptHom")
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/domhex AND
+   ENABLE_DOMHEX AND HAVE_MESH)
+  add_subdirectory(contrib/domhex)
+  include_directories(contrib/domhex)
+  set_config_option(HAVE_DOMHEX "DomHex")
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/QuadTri AND
+   ENABLE_QUADTRI AND HAVE_MESH)
+  add_subdirectory(contrib/QuadTri)
+  include_directories(contrib/QuadTri)
+  set_config_option(HAVE_QUADTRI "QuadTri")
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/kbipack AND ENABLE_KBIPACK)
+  set_config_option(HAVE_KBIPACK "Kbipack")
+  add_subdirectory(contrib/kbipack)
+  include_directories(contrib/kbipack)
+  if(ENABLE_GMP)
+    find_library(GMP_LIB libgmp.a)
+    find_path(GMP_INC "gmp.h" PATH_SUFFIXES src include)
+  endif()
+  if(GMP_LIB AND GMP_INC)
+    set_config_option(HAVE_GMP "GMP")
+    list(APPEND EXTERNAL_LIBRARIES ${GMP_LIB})
+    list(APPEND EXTERNAL_INCLUDES ${GMP_INC})
+  else()
+    message(STATUS "GMP not found: Kbipack uses long int")
+  endif()
+endif()
+
+if(ENABLE_MATHEX)
+  find_library(MATHEX_LIB mathex PATH_SUFFIXES lib)
+  find_path(MATHEX_INC "mathex.h" PATH_SUFFIXES src include)
+  if(ENABLE_SYSTEM_CONTRIB AND MATHEX_LIB AND MATHEX_INC)
+    list(APPEND EXTERNAL_LIBRARIES ${MATHEX_LIB})
+    list(APPEND EXTERNAL_INCLUDES ${MATHEX_INC})
+    set_config_option(HAVE_MATHEX "MathEx[system]")
+  elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/MathEx)
+    add_subdirectory(contrib/MathEx)
+    include_directories(contrib/MathEx)
+    set_config_option(HAVE_MATHEX "MathEx")
+  endif()
+endif()
+
+if(ENABLE_MPI)
+  find_package(MPI)
+  if(MPI_FOUND)
+    set_config_option(HAVE_MPI "MPI")
+    list(APPEND EXTERNAL_INCLUDES ${MPI_CXX_INCLUDE_PATH})
+    list(APPEND EXTERNAL_LIBRARIES ${MPI_CXX_LIBRARIES})
+    set(CMAKE_C_COMPILER ${MPI_C_COMPILER})
+    set(CMAKE_CXX_COMPILER ${MPI_CXX_COMPILER})
+    set(CMAKE_Fortran_COMPILER ${MPI_Fortran_COMPILER})
+  endif()
+endif()
+
+if(ENABLE_POPPLER)
+  find_library(POPPLER_LIB poppler)
+  find_library(POPPLER_CPP_LIB poppler-cpp)
+  find_path(POPPLER_INC "poppler/cpp/poppler-document.h" PATH_SUFFIXES src include)
+  if(POPPLER_LIB AND POPPLER_INC)
+    set_config_option(HAVE_POPPLER "Poppler")
+    list(APPEND EXTERNAL_LIBRARIES ${POPPLER_LIB})
+    list(APPEND EXTERNAL_LIBRARIES ${POPPLER_CPP_LIB})
+    list(APPEND EXTERNAL_INCLUDES ${POPPLER_INC})
+  endif()
+endif()
+
+if(ENABLE_P4EST)
+  find_library(P4EST_LIB p4est)
+  find_path(P4EST_INC "p4est.h" PATH_SUFFIXES src)
+  find_library(SC_LIB sc)
+  if(P4EST_LIB AND P4EST_INC AND SC_LIB)
+    set_config_option(HAVE_P4EST "P4est")
+    list(APPEND EXTERNAL_LIBRARIES ${P4EST_LIB} ${SC_LIB})
+    list(APPEND EXTERNAL_INCLUDES ${P4EST_INC})
+  endif()
+endif()
+
+if(HAVE_MESH OR HAVE_SOLVER)
+  if(ENABLE_METIS)
+    if(METIS_LIB AND METIS_INC)
+      list(APPEND EXTERNAL_LIBRARIES ${METIS_LIB})
+      list(APPEND EXTERNAL_INCLUDES ${METIS_INC})
+      set_config_option(HAVE_METIS "Metis")
+    else()
+      find_library(METIS_LIB metis PATH_SUFFIXES lib)
+      find_path(METIS_INC "metis.h" PATH_SUFFIXES include)
+      if(ENABLE_SYSTEM_CONTRIB AND METIS_LIB AND METIS_INC)
+        message(STATUS "Using system version of METIS")
+        list(APPEND EXTERNAL_LIBRARIES ${METIS_LIB})
+        list(APPEND EXTERNAL_INCLUDES ${METIS_INC})
+        set_config_option(HAVE_METIS "Metis[system]")
+      elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/metis)
+        add_definitions(-DUSE_GKREGEX)
+        add_subdirectory(contrib/metis)
+        include_directories(contrib/metis/include contrib/metis/libmetis
+                          contrib/metis/GKlib)
+        set_config_option(HAVE_METIS "Metis")
+      endif()
+    endif()
+  endif()
+endif()
+
+if(HAVE_MESH)
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Mesh/tetgenBR.cxx)
+    set_config_option(HAVE_TETGENBR "TetGen/BR")
+  endif()
+
+  if(ENABLE_VOROPP)
+    find_library(VOROPP_LIB voro++)
+    find_path(VOROPP_INC "voro++.hh" PATH_SUFFIXES voro++)
+    if(ENABLE_SYSTEM_CONTRIB AND VOROPP_LIB AND VOROPP_INC)
+      message(STATUS "Using system version of voro++")
+      list(APPEND EXTERNAL_LIBRARIES ${VOROPP_LIB})
+      list(APPEND EXTERNAL_INCLUDES ${VOROPP_INC})
+      set_config_option(HAVE_VOROPP "Voro++[system]")
+    elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/voro++)
+      add_subdirectory(contrib/voro++)
+      include_directories(contrib/voro++/src)
+      set_config_option(HAVE_VOROPP "Voro++")
+    endif()
+  endif()
+
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/blossom AND ENABLE_BLOSSOM)
+    add_subdirectory(contrib/blossom)
+    include_directories(contrib/blossom/MATCH contrib/blossom/concorde97
+                        contrib/blossom/concorde97/INCLUDE)
+    set_config_option(HAVE_BLOSSOM "Blossom")
+  endif()
+
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Netgen AND ENABLE_NETGEN)
+    add_subdirectory(contrib/Netgen)
+    include_directories(contrib/Netgen contrib/Netgen/libsrc/include
+                        contrib/Netgen/nglib)
+    set_config_option(HAVE_NETGEN "Netgen")
+    add_definitions(-DNO_PARALLEL_THREADS -DNOTCL)
+  endif()
+
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/bamg AND ENABLE_BAMG)
+    add_subdirectory(contrib/bamg)
+    include_directories(contrib/bamg contrib/bamg/bamglib)
+    set_config_option(HAVE_BAMG "Bamg")
+  endif()
+
+  if(ENABLE_MMG)
+    find_library(MMG_LIB NAMES Mmg mmg)
+    find_path(MMG_INC "libmmg.h" PATH_SUFFIXES mmg)
+    if(MMG_LIB AND MMG_INC)
+      list(APPEND EXTERNAL_LIBRARIES ${MMG_LIB})
+      list(APPEND EXTERNAL_INCLUDES ${MMG_INC})
+      set_config_option(HAVE_MMG "Mmg")
+    endif()
+  endif()
+endif()
+
+if(ENABLE_MED OR ENABLE_CGNS)
+  find_package(HDF5)
+  if(HDF5_FOUND)
+    set(HDF5_LIB "${HDF5_C_LIBRARIES}")
+    list(APPEND EXTERNAL_INCLUDES ${HDF5_INCLUDE_DIRS})
+    if(ENABLE_MED)
+      find_library(MED_LIB medC)
+      if(MED_LIB)
+        set_config_option(HAVE_MED "Med")
+        list(APPEND EXTERNAL_LIBRARIES ${MED_LIB})
+      endif()
+    endif()
+    if(ENABLE_CGNS)
+      find_library(CGNS_LIB cgns HINTS ENV CGNS_ROOT PATH_SUFFIXES lib)
+      find_path(CGNS_INC "cgnslib.h" HINTS ENV CGNS_ROOT PATH_SUFFIXES include)
+      if(CGNS_LIB AND CGNS_INC)
+        set_config_option(HAVE_LIBCGNS "Cgns")
+        list(APPEND EXTERNAL_LIBRARIES ${CGNS_LIB})
+        list(APPEND EXTERNAL_INCLUDES ${CGNS_INC})
+        if(ENABLE_CGNS_CPEX0045)
+          set_config_option(HAVE_LIBCGNS_CPEX0045 "Cgns_CPEX0045")
+        endif()
+      endif()
+    endif()
+    if(MED_LIB OR CGNS_LIB)
+      list(APPEND EXTERNAL_LIBRARIES ${HDF5_LIB})
+      find_library(SZ_LIB NAMES szlib sz)
+      if(SZ_LIB)
+        list(APPEND EXTERNAL_LIBRARIES ${SZ_LIB})
+      endif()
+      if(NOT HAVE_LIBZ) # necessary for non-GUI builds
+        find_package(ZLIB)
+        if(ZLIB_FOUND)
+          set_config_option(HAVE_LIBZ "Zlib")
+          list(APPEND EXTERNAL_LIBRARIES ${ZLIB_LIBRARIES})
+        endif()
+      endif()
+    endif()
+  else()
+    message(STATUS "HDF5 not found")
+  endif()
+endif()
+
+if(HAVE_SOLVER)
+  if(ENABLE_GMM)
+    find_path(GMM_INC "gmm.h" PATH_SUFFIXES src include include/gmm)
+    if(ENABLE_SYSTEM_CONTRIB AND GMM_INC)
+      message(STATUS "Using system version of GMM")
+      list(APPEND EXTERNAL_INCLUDES ${GMM_INC})
+      set_config_option(HAVE_GMM "Gmm[system]")
+    elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/gmm)
+      include_directories(contrib/gmm)
+      set_config_option(HAVE_GMM "Gmm")
+    endif()
+  endif()
+
+  if(ENABLE_PETSC)
+    if(PETSC_DIR)
+      set(ENV_PETSC_DIR ${PETSC_DIR})
+    else()
+      set(ENV_PETSC_DIR $ENV{PETSC_DIR})
+    endif()
+    if(PETSC_ARCH)
+      set(ENV_PETSC_ARCH ${PETSC_ARCH})
+    else()
+      set(ENV_PETSC_ARCH $ENV{PETSC_ARCH})
+    endif()
+    set(PETSC_POSSIBLE_CONF_FILES
+        ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/conf/petscvariables
+        ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib/petsc-conf/petscvariables
+        ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib/petsc/conf/petscvariables)
+    foreach(FILE ${PETSC_POSSIBLE_CONF_FILES})
+      if(EXISTS ${FILE})
+        # old-style PETSc installations (using PETSC_DIR and PETSC_ARCH)
+        message(STATUS "Using PETSc dir: ${ENV_PETSC_DIR}")
+        message(STATUS "Using PETSc arch: ${ENV_PETSC_ARCH}")
+        # find includes by parsing the petscvariables file
+        file(STRINGS ${FILE} PETSC_VARIABLES NEWLINE_CONSUME)
+      endif()
+    endforeach()
+    if(PETSC_VARIABLES)
+      # try to find PETSC_CC_INCLUDES for PETSc >= 3.4
+      string(REGEX MATCH "PETSC_CC_INCLUDES = [^\n\r]*" PETSC_PACKAGES_INCLUDES
+             ${PETSC_VARIABLES})
+      if(PETSC_PACKAGES_INCLUDES)
+        string(REPLACE "PETSC_CC_INCLUDES = " "" PETSC_PACKAGES_INCLUDES
+               ${PETSC_PACKAGES_INCLUDES})
+      else()
+        # try to find PETSC_PACKAGES_INCLUDES in older versions
+        list(APPEND EXTERNAL_INCLUDES ${ENV_PETSC_DIR}/include)
+        list(APPEND EXTERNAL_INCLUDES ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/include)
+        string(REGEX MATCH "PACKAGES_INCLUDES = [^\n\r]*" PETSC_PACKAGES_INCLUDES
+               ${PETSC_VARIABLES})
+        string(REPLACE "PACKAGES_INCLUDES = " "" PETSC_PACKAGES_INCLUDES
+               ${PETSC_PACKAGES_INCLUDES})
+      endif()
+      if(PETSC_PACKAGES_INCLUDES)
+        if(PETSC_PACKAGES_INCLUDES)
+          string(REPLACE "-I" "" PETSC_PACKAGES_INCLUDES ${PETSC_PACKAGES_INCLUDES})
+          string(REPLACE " " ";" PETSC_PACKAGES_INCLUDES ${PETSC_PACKAGES_INCLUDES})
+          foreach(VAR ${PETSC_PACKAGES_INCLUDES})
+            # seem to include unexisting directories (/usr/include/lib64)
+	    # check to avoid warnings
+	    if(EXISTS ${VAR})
+	      list(APPEND EXTERNAL_INCLUDES ${VAR})
+            endif()
+          endforeach()
+        endif()
+      endif()
+      # find libraries (<= 3.0)
+      set(PETSC_LIBS_REQUIRED petscksp petscdm petscmat petscvec petsc)
+      find_all_libraries(PETSC_LIBS PETSC_LIBS_REQUIRED
+                         ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib "")
+      # petsc 3.1 creates only one library (libpetsc)
+      if(NOT PETSC_LIBS)
+        find_library(PETSC_LIBS petsc PATHS ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib
+                     NO_DEFAULT_PATH)
+      endif()
+      if(PETSC_LIBS)
+        set_config_option(HAVE_PETSC "PETSc")
+	if(NOT HAVE_BLAS)
+          set_config_option(HAVE_BLAS "Blas[petsc]")
+        endif()
+	if(NOT HAVE_LAPACK)
+          set_config_option(HAVE_LAPACK "Lapack[petsc]")
+        endif()
+      endif()
+      # find slepc (needs to be linked in before petsc)
+      if(ENABLE_SLEPC)
+        if(SLEPC_DIR)
+          set(ENV_SLEPC_DIR ${SLEPC_DIR})
+         else()
+          set(ENV_SLEPC_DIR $ENV{SLEPC_DIR})
+        endif()
+        find_library(SLEPC_LIB slepc PATHS ${ENV_SLEPC_DIR}/${ENV_PETSC_ARCH}/lib
+                     NO_DEFAULT_PATH)
+        if(SLEPC_LIB)
+          find_path(SLEPC_INC "slepc.h" PATHS ${ENV_SLEPC_DIR} PATH_SUFFIXES include
+                    ${ENV_PETSC_ARCH}/include include/slepc NO_DEFAULT_PATH)
+          if(SLEPC_INC)
+            message(STATUS "Using SLEPc dir: ${ENV_SLEPC_DIR}")
+            set_config_option(HAVE_SLEPC "SLEPc")
+            list(APPEND EXTERNAL_LIBRARIES ${SLEPC_LIB})
+            list(APPEND EXTERNAL_INCLUDES ${SLEPC_INC})
+            find_path(SLEPC_INC2 "slepcconf.h" PATHS ${ENV_SLEPC_DIR}
+                      PATH_SUFFIXES ${ENV_PETSC_ARCH}/include NO_DEFAULT_PATH)
+            if(SLEPC_INC2)
+              list(APPEND EXTERNAL_INCLUDES ${SLEPC_INC2})
+            endif()
+          endif()
+        endif()
+      endif()
+      list(APPEND EXTERNAL_LIBRARIES ${PETSC_LIBS})
+      # find additional libraries to link with
+      string(REGEX MATCH "PACKAGES_LIBS = [^\n\r]*" PLIBS ${PETSC_VARIABLES})
+      if(PLIBS)
+        string(REPLACE "PACKAGES_LIBS = " "" PLIBS ${PLIBS})
+        string(STRIP ${PLIBS} PLIBS)
+        list(APPEND EXTERNAL_LIBRARIES "${PLIBS}")
+      endif()
+      string(REGEX MATCH "PETSC_EXTERNAL_LIB_BASIC = [^\n\r]*" PLIBS_BASIC ${PETSC_VARIABLES})
+      if(PLIBS_BASIC)
+        string(REPLACE "PETSC_EXTERNAL_LIB_BASIC = " "" PLIBS_BASIC ${PLIBS_BASIC})
+        string(STRIP ${PLIBS_BASIC} PLIBS_BASIC)
+        separate_arguments(PLIBS_BASIC)
+        list(APPEND EXTERNAL_LIBRARIES "${PLIBS_BASIC}")
+      endif()
+      string(REGEX MATCH "PCC_LINKER_LIBS = [^\n\r]*" LLIBS ${PETSC_VARIABLES})
+      if(LLIBS)
+        string(REPLACE "PCC_LINKER_LIBS = " "" LLIBS ${LLIBS})
+        string(STRIP ${LLIBS} LLIBS)
+        list(APPEND EXTERNAL_LIBRARIES "${LLIBS}")
+      endif()
+    else()
+      # new-style PETSc installations (in standard system directories)
+      find_library(PETSC_LIBS petsc)
+      find_path(PETSC_INC "petsc.h" PATH_SUFFIXES include/petsc)
+      if(PETSC_LIBS AND PETSC_INC)
+        set_config_option(HAVE_PETSC "PETSc")
+        if(ENABLE_SLEPC)
+          find_library(SLEPC_LIB slepc)
+          find_path(SLEPC_INC "slepc.h" PATH_SUFFIXES include/slepc)
+          if(SLEPC_LIB AND SLEPC_INC)
+            set_config_option(HAVE_SLEPC "SLEPc")
+            list(APPEND EXTERNAL_LIBRARIES ${SLEPC_LIB})
+            list(APPEND EXTERNAL_INCLUDES ${SLEPC_INC})
+          endif()
+        endif()
+        list(APPEND EXTERNAL_LIBRARIES ${PETSC_LIBS})
+        list(APPEND EXTERNAL_INCLUDES ${PETSC_INC})
+      endif()
+    endif()
+  endif()
+
+  if(ENABLE_MUMPS AND HAVE_BLAS AND HAVE_LAPACK)
+    set(MUMPS_LIBS_REQUIRED smumps dmumps cmumps zmumps mumps_common pord)
+    if(NOT ENABLE_MPI)
+      list(APPEND MUMPS_LIBS_REQUIRED mpiseq)
+    endif()
+    find_all_libraries(MUMPS_LIBRARIES MUMPS_LIBS_REQUIRED "" "lib")
+    find_path(SMUMPS_INC "smumps_c.h" PATH_SUFFIXES src include)
+    find_path(DMUMPS_INC "dmumps_c.h" PATH_SUFFIXES src include)
+    find_path(CMUMPS_INC "cmumps_c.h" PATH_SUFFIXES src include)
+    find_path(ZMUMPS_INC "zmumps_c.h" PATH_SUFFIXES src include)
+    if(MUMPS_LIBRARIES AND SMUMPS_INC AND DMUMPS_INC AND CMUMPS_INC AND ZMUMPS_INC)
+      set_config_option(HAVE_MUMPS "MUMPS")
+      list(APPEND EXTERNAL_LIBRARIES ${MUMPS_LIBRARIES})
+      list(APPEND EXTERNAL_INCLUDES ${SMUMPS_INC})
+      list(APPEND EXTERNAL_INCLUDES ${DMUMPS_INC})
+      list(APPEND EXTERNAL_INCLUDES ${CMUMPS_INC})
+      list(APPEND EXTERNAL_INCLUDES ${ZMUMPS_INC})
+      find_library(GFORTRAN_LIB gfortran)
+      if(GFORTRAN_LIB)
+        list(APPEND EXTERNAL_LIBRARIES ${GFORTRAN_LIB})
+      endif()
+      if(ENABLE_GMM) # use GMM/MUMPS interface
+        add_definitions(-DGMM_USES_MUMPS)
+      endif()
+    endif()
+  endif()
+
+  if(ENABLE_GETDP)
+    find_library(GETDP_LIB GetDP)
+    find_path(GETDP_INC "GetDP.h" PATH_SUFFIXES getdp)
+    if(GETDP_LIB AND GETDP_INC)
+      set_config_option(HAVE_GETDP "GetDP")
+      list(APPEND EXTERNAL_LIBRARIES ${GETDP_LIB})
+      list(APPEND EXTERNAL_INCLUDES ${GETDP_INC})
+    endif()
+  endif()
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/hxt AND ENABLE_HXT)
+  add_subdirectory(contrib/hxt)
+  include_directories(BEFORE ${HXT_INC_DIRS})
+  set_config_option(HAVE_HXT "Hxt")
+  # do not use arithmetic contraction in predicates.c
+  if(MSVC OR (CMAKE_C_COMPILER_ID STREQUAL "Intel" AND WIN32))
+    set_source_files_properties(
+        "${CMAKE_CURRENT_SOURCE_DIR}/contrib/hxt/predicates/src/predicates.c"
+        PROPERTIES COMPILE_FLAGS "/fp:strict")
+  elseif(CMAKE_C_COMPILER_ID STREQUAL "Intel")
+    set_source_files_properties(
+        "${CMAKE_CURRENT_SOURCE_DIR}/contrib/hxt/predicates/src/predicates.c"
+        PROPERTIES COMPILE_FLAGS "-fp-model strict")
+  elseif(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
+    set_source_files_properties(
+        "${CMAKE_CURRENT_SOURCE_DIR}/contrib/hxt/predicates/src/predicates.c"
+        PROPERTIES COMPILE_FLAGS  "-fno-unsafe-math-optimizations -ffp-contract=off")
+  else()
+    message(WARNING
+      "Unsupported compiler !
+       Make sure compiled functions from predicates.c
+       do NOT use extended double precision and follow IEEE754 standard.
+       It is crucial for the robustness of geometric predicates.")
+  endif()
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/pro AND ENABLE_PRO)
+  add_subdirectory(pro)
+endif()
+
+if(ENABLE_OCC)
+  set(OCC_MINIMAL_VERSION "6.9.1")
+  if(WIN32)
+    if(HAVE_64BIT_SIZE_T)
+      set(OCC_SYS_NAME win64)
+    else()
+      set(OCC_SYS_NAME win32)
+    endif()
+  else()
+    set(OCC_SYS_NAME ${CMAKE_SYSTEM_NAME})
+  endif()
+  find_path(OCC_INC "Standard_Version.hxx" HINTS ENV CASROOT PATH_SUFFIXES
+            inc include include/oce opencascade include/opencascade
+            occt include/occt)
+  if(OCC_INC)
+    file(STRINGS ${OCC_INC}/Standard_Version.hxx
+         OCC_MAJOR REGEX "#define OCC_VERSION_MAJOR.*")
+    file(STRINGS ${OCC_INC}/Standard_Version.hxx
+         OCC_MINOR REGEX "#define OCC_VERSION_MINOR.*")
+    file(STRINGS ${OCC_INC}/Standard_Version.hxx
+         OCC_MAINT REGEX "#define OCC_VERSION_MAINTENANCE.*")
+    if(OCC_MAJOR AND OCC_MINOR AND OCC_MAINT)
+      string(REGEX MATCH "[0-9]+" OCC_MAJOR "${OCC_MAJOR}")
+      string(REGEX MATCH "[0-9]+" OCC_MINOR "${OCC_MINOR}")
+      string(REGEX MATCH "[0-9]+" OCC_MAINT "${OCC_MAINT}")
+      set(OCC_VERSION "${OCC_MAJOR}.${OCC_MINOR}.${OCC_MAINT}")
+      message(STATUS "Found OpenCASCADE version ${OCC_VERSION} in ${OCC_INC}")
+    endif()
+  endif()
+  if(OCC_VERSION AND OCC_VERSION STRLESS ${OCC_MINIMAL_VERSION})
+    message(WARNING "Gmsh requires OpenCASCADE >= ${OCC_MINIMAL_VERSION}. "
+        "Use CMAKE_PREFIX_PATH or the CASROOT environment variable "
+        "to explicitely specify the installation path of OpenCASCADE")
+  elseif(OCC_INC)
+    set(OCC_LIBS_REQUIRED
+	# subset of DataExchange
+      	TKSTEP TKSTEP209 TKSTEPAttr TKSTEPBase TKIGES TKXSBase
+      	# ModelingAlgorithms
+      	TKOffset TKFeat TKFillet TKBool TKMesh TKHLR TKBO TKPrim TKShHealing
+      	TKTopAlgo TKGeomAlgo
+      	# ModelingData
+      	TKBRep TKGeomBase TKG3d TKG2d
+      	# FoundationClasses
+      	TKMath TKernel)
+    if(ENABLE_OCC_TBB)
+      list(APPEND OCC_LIBS_REQUIRED tbb tbbmalloc)
+    endif()
+    list(LENGTH OCC_LIBS_REQUIRED NUM_OCC_LIBS_REQUIRED)
+    if(OCC_LIBS)
+      message(STATUS "OCC libraries specified explicitly: " ${OCC_LIBS})
+      list(LENGTH OCC_LIBS_REQUIRED NUM_OCC_LIBS)
+    else()
+      set(OCC_LIBS)
+      foreach(OCC ${OCC_LIBS_REQUIRED})
+        find_library(OCC_LIB ${OCC} HINTS ENV CASROOT PATH_SUFFIXES
+                     lib ${OCC_SYS_NAME}/lib ${OCC_SYS_NAME}/vc8/lib
+                     ${OCC_SYS_NAME}/gcc/lib ${OCC_SYS_NAME}/gcc/bin)
+        if(OCC_LIB)
+	  list(APPEND OCC_LIBS ${OCC_LIB})
+        else()
+          message(STATUS "OCC lib " ${OCC} " not Found")
+        endif()
+        unset(OCC_LIB CACHE)
+      endforeach()
+      list(LENGTH OCC_LIBS NUM_OCC_LIBS)
+    endif()
+  endif()
+
+  # additional OCC libraries to handle reading of STEP/IGES attributes. Oh my...
+  if(ENABLE_OCC_CAF)
+    find_package(Freetype)
+    if(FREETYPE_FOUND)
+      set(OCC_CAF_LIBS_REQUIRED
+          TKXDESTEP TKXDEIGES TKXCAF TKLCAF TKVCAF TKCAF TKV3d TKService TKCDF)
+      list(LENGTH OCC_CAF_LIBS_REQUIRED NUM_OCC_CAF_LIBS_REQUIRED)
+      set(OCC_CAF_LIBS)
+      foreach(OCC ${OCC_CAF_LIBS_REQUIRED})
+        find_library(OCC_CAF_LIB ${OCC} HINTS ENV CASROOT PATH_SUFFIXES
+                     lib ${OCC_SYS_NAME}/lib ${OCC_SYS_NAME}/vc8/lib
+                     ${OCC_SYS_NAME}/gcc/lib ${OCC_SYS_NAME}/gcc/bin)
+        if(OCC_CAF_LIB)
+          list(APPEND OCC_CAF_LIBS ${OCC_CAF_LIB})
+        else()
+          message(STATUS "OCC CAF lib " ${OCC} " not Found")
+        endif()
+        unset(OCC_CAF_LIB CACHE)
+      endforeach()
+      list(LENGTH OCC_CAF_LIBS NUM_OCC_CAF_LIBS)
+    endif()
+  endif()
+
+  if(NUM_OCC_LIBS EQUAL NUM_OCC_LIBS_REQUIRED)
+    # append OCC CAF libraries first...
+    if(NUM_OCC_CAF_LIBS EQUAL NUM_OCC_CAF_LIBS_REQUIRED)
+      set_config_option(HAVE_OCC_CAF "OpenCASCADE-CAF")
+      list(APPEND EXTERNAL_LIBRARIES ${OCC_CAF_LIBS} ${FREETYPE_LIBRARIES})
+      list(APPEND EXTERNAL_INCLUDES ${FREETYPE_INCLUDE_DIRS})
+      if(WIN32)
+        list(APPEND EXTERNAL_LIBRARIES "windowscodecs")
+        list(APPEND EXTERNAL_LIBRARIES "ole32")
+      endif()
+    endif()
+    # then append OCC libraries
+    set_config_option(HAVE_OCC "OpenCASCADE")
+    list(APPEND EXTERNAL_LIBRARIES ${OCC_LIBS})
+    list(APPEND EXTERNAL_INCLUDES ${OCC_INC})
+    if(HAVE_64BIT_SIZE_T)
+      add_definitions(-D_OCC64)
+    endif()
+    if(WIN32)
+      list(APPEND EXTERNAL_LIBRARIES "winspool")
+      add_definitions(-DOCC_CONVERT_SIGNALS)
+    elseif(MSVC)
+      add_definitions(-DWNT)
+    endif()
+  endif()
+endif()
+
+if(ENABLE_ZIPPER)
+  if(ENABLE_BUILD_IOS)
+    set_config_option(HAVE_LIBZ "Zlib")
+  endif()
+  if(NOT HAVE_LIBZ) # necessary for non-GUI builds
+    find_package(ZLIB)
+    if(ZLIB_FOUND)
+      set_config_option(HAVE_LIBZ "Zlib")
+      list(APPEND EXTERNAL_LIBRARIES ${ZLIB_LIBRARIES})
+      list(APPEND EXTERNAL_INCLUDES ${ZLIB_INCLUDE_DIR})
+    endif()
+  endif()
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/zipper AND HAVE_LIBZ)
+    add_subdirectory(contrib/zipper)
+    include_directories(contrib/zipper)
+    set_config_option(HAVE_ZIPPER "Zipper")
+  endif()
+endif()
+
+if(ENABLE_PRIVATE_API AND ENABLE_WRAP_PYTHON)
+  find_package(SWIG REQUIRED)
+  include(${SWIG_USE_FILE})
+  find_package(PythonLibs)
+  if(SWIG_FOUND AND PYTHONLIBS_FOUND)
+    message(STATUS "Found SWIG version " ${SWIG_VERSION})
+    find_package(PythonInterp)
+    string(SUBSTRING ${SWIG_VERSION} 0 1 SWIG_MAJOR_VERSION)
+    if(SWIG_MAJOR_VERSION EQUAL 1)
+      message(WARNING "Python bindings require SWIG >= 2: disabling Python")
+    else()
+      set_config_option(HAVE_PYTHON "Python")
+      mark_as_advanced(CLEAR PYTHON_LIBRARY PYTHON_INCLUDE_DIR)
+      if(ENABLE_NUMPY)
+        if (NOT NUMPY_INC)
+          EXEC_PROGRAM (${PYTHON_EXECUTABLE}
+            ARGS "-c \"import numpy; print(numpy.get_include())\""
+            OUTPUT_VARIABLE NUMPY_INC
+            RETURN_VALUE NUMPY_NOT_FOUND)
+        endif()
+        if(NUMPY_INC)
+          list(APPEND EXTERNAL_INCLUDES ${NUMPY_INC})
+          set_config_option(HAVE_NUMPY "Numpy")
+        endif()
+      endif()
+      if(HAVE_PETSC)
+        if(ENABLE_PETSC4PY)
+          EXECUTE_PROCESS(
+            COMMAND ${PYTHON_EXECUTABLE} -c "import petsc4py; print(petsc4py.get_include())"
+            OUTPUT_VARIABLE PETSC4PY_INC
+            RESULT_VARIABLE PETSC4PY_NOT_FOUND
+            ERROR_QUIET
+            OUTPUT_STRIP_TRAILING_WHITESPACE)
+          if(PETSC4PY_INC)
+            list(APPEND EXTERNAL_INCLUDES ${PETSC4PY_INC})
+            set_config_option(HAVE_PETSC4PY "PETSc4py")
+          endif()
+        endif()
+      endif()
+    endif()
+  endif()
+endif()
+
+check_function_exists(vsnprintf HAVE_VSNPRINTF)
+if(NOT HAVE_VSNPRINTF AND NOT ENABLE_BUILD_IOS AND NOT ENABLE_BUILD_ANDROID)
+  set_config_option(HAVE_NO_VSNPRINTF "NoVsnprintf")
+endif()
+
+check_include_file(sys/socket.h HAVE_SYS_SOCKET_H)
+if(HAVE_SYS_SOCKET_H)
+  set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
+endif()
+check_type_size(socklen_t SOCKLEN_T_SIZE)
+set(CMAKE_EXTRA_INCLUDE_FILES)
+if(NOT SOCKLEN_T_SIZE AND NOT ENABLE_BUILD_IOS AND NOT ENABLE_BUILD_ANDROID)
+  set_config_option(HAVE_NO_SOCKLEN_T "NoSocklenT")
+endif()
+
+check_include_file(stdint.h HAVE_STDINT_H)
+if(HAVE_STDINT_H)
+  set(CMAKE_EXTRA_INCLUDE_FILES stdint.h)
+else()
+  set_config_option(HAVE_NO_STDINT_H "NoStdintH")
+endif()
+check_type_size(intptr_t INTPTR_T_SIZE)
+set(CMAKE_EXTRA_INCLUDE_FILES)
+if(NOT INTPTR_T_SIZE AND NOT ENABLE_BUILD_IOS AND NOT ENABLE_BUILD_ANDROID)
+  set_config_option(HAVE_NO_INTPTR_T "NoIntptrT")
+endif()
+
+check_include_file(dlfcn.h DLFCN_H)
+if(DLFCN_H)
+  set_config_option(HAVE_DLOPEN "Dlopen")
+  list(APPEND EXTERNAL_LIBRARIES ${CMAKE_DL_LIBS})
+endif()
+
+if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+  check_include_file(linux/joystick.h LINUX_JOYSTICK_H)
+  if(LINUX_JOYSTICK_H)
+    set_config_option(HAVE_LINUX_JOYSTICK "LinuxJoystick")
+  endif()
+endif()
+
+if(WIN32)
+  add_definitions(-D_USE_MATH_DEFINES)
+  list(APPEND EXTERNAL_LIBRARIES winmm wsock32 ws2_32 psapi)
+endif()
+
+if(MSVC)
+  add_definitions(-DNOMINMAX -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE)
+endif()
+
+# add C functions API
+set(GMSH_SRC ${GMSH_SRC};api/gmshc.cpp)
+
+# force full warnings to encourage everybody to write clean(er) code
+check_cxx_compiler_flag("-Wall" WALL)
+if(WALL AND NOT MSVC)
+  file(GLOB_RECURSE WALL_SRC Common/*.cpp Fltk/*.cpp FunctionSpace/*.cpp
+       Geo/*.cpp Graphics/*.cpp Mesh/*.cpp Numeric/*.cpp Parser/*.cpp
+       Plugin/*.cpp Post/*.cpp Solver/*.cpp)
+  set(WF "-Wall")
+  check_cxx_compiler_flag("-Wint-to-void-pointer-cast" WCAST)
+  if(WCAST)
+    set(WF "${WF} -Wno-int-to-void-pointer-cast")
+  endif()
+  check_cxx_compiler_flag("-Wdeprecated-declarations" WDEPREC)
+  if(WDEPREC)
+    # FIXME: remove this when we have fixed the deprecated GLU code for OpenGL3
+    set(WF "${WF} -Wno-deprecated-declarations")
+  endif()
+  check_cxx_compiler_flag("-Wmisleading-indentation" WIND)
+  if(WIND)
+    set(WF "${WF} -Wno-misleading-indentation")
+  endif()
+  check_cxx_compiler_flag("-Wno-attributes" WATTR)
+  if(WATTR)
+    # FIXME: remove this when GCC behaves more intelligently
+    set(WF "${WF} -Wno-attributes")
+  endif()
+  set_compile_flags(WALL_SRC ${WF})
+endif()
+
+# don't issue warnings for contributed libraries
+check_cxx_compiler_flag("-w" NOWARN)
+if(NOWARN)
+  file(GLOB_RECURSE NOWARN_SRC contrib/*.cpp contrib/*.cc contrib/*.cxx contrib/*.c)
+  set_compile_flags(NOWARN_SRC "-w")
+endif()
+
+# disable compile optimization on some known problematic files
+check_cxx_compiler_flag("-O0" NOOPT)
+if(NOOPT OR ENABLE_BUILD_IOS)
+  if(ENABLE_BUILD_IOS) # optimized iOS 10 64 bits screws somewhere in Geo
+    file(GLOB_RECURSE NOOPT_SRC Numeric/robustPredicates.cpp Geo/G*.cpp Mesh/BDS.cpp
+         Parser/Gmsh.tab.cpp contrib/blossom/* Mesh/Background*)
+  else()
+    file(GLOB_RECURSE NOOPT_SRC Numeric/robustPredicates.cpp Mesh/BDS.cpp
+         Parser/Gmsh.tab.cpp contrib/blossom/* contrib/bamg/* Mesh/Background*)
+  endif()
+  set_compile_flags(NOOPT_SRC "-O0")
+endif()
+
+# do not use arithmetic contraction in predicates.cpp
+# if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
+#   set_source_files_properties(Numeric/robustPredicates.cpp PROPERTIES
+#     COMPILE_FLAGS "/fp:strict")
+# elseif(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
+#   set_source_files_properties(Numeric/robustPredicates.cpp PROPERTIES
+#     COMPILE_FLAGS "-fno-unsafe-math-optimizations -ffp-contract=off")
+# elseif(CMAKE_C_COMPILER_ID STREQUAL "Intel")
+#   set_source_files_properties(Numeric/robustPredicates.cpp PROPERTIES
+#     COMPILE_FLAGS "-fp-model strict")
+# endif()
+
+# enable Revoropt and set compile flags for the corresponding plugin
+if(ENABLE_REVOROPT)
+  if(HAVE_EIGEN AND HAVE_MESH AND HAVE_PLUGINS AND HAVE_ANN AND HAVE_ALGLIB)
+    list(APPEND EXTERNAL_INCLUDES contrib/Revoropt/include)
+    set_config_option(HAVE_REVOROPT "Revoropt")
+    add_definitions(-DUSE_ANN)
+  else()
+    message(WARNING "Revoropt requires Eigen, Mesh, Plugins, ANN and ALGLIB")
+  endif()
+endif()
+
+if(HAVE_MESH AND NOT HAVE_EIGEN AND NOT HAVE_LAPACK)
+  message(WARNING "Most meshing algorithms will not be functional without "
+          "Eigen or Lapack")
+endif()
+
+list(SORT CONFIG_OPTIONS)
+set(GMSH_CONFIG_OPTIONS "")
+foreach(OPT ${CONFIG_OPTIONS})
+  set(GMSH_CONFIG_OPTIONS "${GMSH_CONFIG_OPTIONS} ${OPT}")
+endforeach()
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Common/GmshConfig.h.in
+               ${CMAKE_CURRENT_BINARY_DIR}/Common/GmshConfig.h)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Common/GmshVersion.h.in
+               ${CMAKE_CURRENT_BINARY_DIR}/Common/GmshVersion.h)
+
+# the texi and pypi version files are modified in the source directory (not
+# ideal for version.texi, but since git tracks the contents of the file this is
+# acceptable as it will only change when the actual version is changed - not for
+# each git hash; setup.py is not under version control)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/texinfo/version.texi.in
+               ${CMAKE_CURRENT_SOURCE_DIR}/doc/texinfo/version.texi)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/utils/pypi/gmsh/setup.py.in
+               ${CMAKE_CURRENT_SOURCE_DIR}/utils/pypi/gmsh/setup.py)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/utils/pypi/gmsh-dev/setup.py.in
+               ${CMAKE_CURRENT_SOURCE_DIR}/utils/pypi/gmsh-dev/setup.py)
+
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/version.txt ${GMSH_SHORT_VERSION})
+
+# process cmake environment variables so we can append them to the -I include
+# commands. This is not recommended (we should only use the cache variables) but
+# it is very convenient: otherwise we have to remember providing the
+# -D... options to cmake for each new build.
+set(ENV_CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
+set(ENV_CMAKE_INCLUDE_PATH $ENV{CMAKE_INCLUDE_PATH})
+if(UNIX)
+  if(ENV_CMAKE_PREFIX_PATH)
+    string(REPLACE ":" ";" ENV_CMAKE_PREFIX_PATH ${ENV_CMAKE_PREFIX_PATH})
+  endif()
+  if(ENV_CMAKE_INCLUDE_PATH)
+    string(REPLACE ":" ";" ENV_CMAKE_INCLUDE_PATH ${ENV_CMAKE_INCLUDE_PATH})
+  endif()
+endif()
+list(APPEND EXTERNAL_INCLUDES ${CMAKE_INCLUDE_PATH} ${ENV_CMAKE_INCLUDE_PATH})
+list(APPEND EXTERNAL_INCLUDES ${CMAKE_PREFIX_PATH} ${ENV_CMAKE_PREFIX_PATH})
+foreach(DIR ${CMAKE_PREFIX_PATH} ${ENV_CMAKE_PREFIX_PATH})
+  list(APPEND EXTERNAL_INCLUDES ${DIR}/include)
+endforeach()
+
+if(EXTERNAL_INCLUDES)
+  list(REMOVE_DUPLICATES EXTERNAL_INCLUDES)
+endif()
+
+if(HAVE_FLTK)
+  set(LINK_LIBRARIES ${FLTK_LIBRARIES} ${EXTERNAL_LIBRARIES}
+                     ${OPENGL_LIBRARIES} ${LAPACK_LIBRARIES})
+elseif(HAVE_OPENGL)
+  set(LINK_LIBRARIES ${EXTERNAL_LIBRARIES} ${OPENGL_LIBRARIES}
+                     ${LAPACK_LIBRARIES})
+else()
+  set(LINK_LIBRARIES ${EXTERNAL_LIBRARIES} ${LAPACK_LIBRARIES})
+endif()
+
+# try to use static gfortran on static builds (cannot do this on dynamic builds
+# as e.g. Debian compiles libgfortran.a without -fPIC: sigh...)
+if(NOT ENABLE_BUILD_DYNAMIC AND NOT ENABLE_BUILD_SHARED)
+  find_library(GFORTRAN_STATIC libgfortran.a)
+  if(GFORTRAN_STATIC)
+    set(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES)
+    message(STATUS "Using static libgfortran")
+    foreach(STR ${LINK_LIBRARIES})
+      string(REPLACE "-lgfortran" ${GFORTRAN_STATIC} STR2 ${STR})
+      list(APPEND LINK_LIBRARIES2 ${STR2})
+    endforeach()
+    set(LINK_LIBRARIES ${LINK_LIBRARIES2})
+  endif()
+endif()
+
+# Linux-specific linker options
+if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+  if(HAVE_OCC)
+    find_library(RT_LIB rt)
+    if(RT_LIB)
+      list(APPEND LINK_LIBRARIES ${RT_LIB})
+    endif()
+  endif()
+  if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Intel")
+    add_definitions(-fPIC)
+  endif()
+endif()
+
+# we could specify include dirs more selectively, but this is simpler
+include_directories(Common Fltk Geo Graphics Mesh Solver Numeric Parser
+  Plugin Post api ${EXTERNAL_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR}/Common)
+
+# set this for external codes that might include this CMakeList file
+set(GMSH_EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDES} CACHE
+    STRING "External include directories" FORCE)
+set(GMSH_EXTERNAL_LIBRARIES ${LINK_LIBRARIES} CACHE
+    STRING "External libraries" FORCE)
+
+# group sources for easier navigation in IDEs
+foreach(DIR ${GMSH_DIRS})
+  string(REGEX REPLACE "\\+" "\\\\+" DIR ${DIR})
+  source_group(${DIR} REGULAR_EXPRESSION ${DIR}/.*)
+endforeach()
+
+# static library target
+if(ENABLE_BUILD_LIB)
+  add_library(lib STATIC ${GMSH_SRC})
+  set_target_properties(lib PROPERTIES OUTPUT_NAME gmsh)
+  if(MSVC)
+    set_target_properties(lib PROPERTIES DEBUG_POSTFIX d)
+    if(ENABLE_MSVC_STATIC_RUNTIME)
+      set_target_properties(lib PROPERTIES LINK_FLAGS_RELEASE "/nodefaultlib:LIBCMT")
+    endif()
+  endif()
+endif()
+
+# shared library target
+if(ENABLE_BUILD_SHARED OR ENABLE_BUILD_DYNAMIC)
+  add_library(shared SHARED ${GMSH_SRC})
+  set_target_properties(shared PROPERTIES OUTPUT_NAME gmsh
+     VERSION ${GMSH_MAJOR_VERSION}.${GMSH_MINOR_VERSION}.${GMSH_PATCH_VERSION}
+     SOVERSION ${GMSH_MAJOR_VERSION}.${GMSH_MINOR_VERSION})
+  if(WIN32)
+    set_target_properties(shared PROPERTIES PREFIX "" IMPORT_PREFIX ""
+      IMPORT_SUFFIX ".lib" COMPILE_FLAGS "-DGMSH_DLL -DGMSH_DLL_EXPORT")
+  endif()
+  target_link_libraries(shared ${LINK_LIBRARIES})
+  # don't define LC_RPATH in dylib for development, to not get endless warnings
+  # about code signing
+  if(APPLE AND NOT GMSH_RELEASE)
+    set_target_properties(shared PROPERTIES INSTALL_RPATH "")
+  endif()
+  if(MSVC AND ENABLE_MSVC_STATIC_RUNTIME)
+    message(STATUS "Note: By enabling ENABLE_MSVC_STATIC_RUNTIME, shared library "
+            "won't link. In MSVC change /MT to /MD in the shared project properties")
+  endif()
+endif()
+
+# binary targets
+if(HAVE_FLTK)
+  if(ENABLE_BUILD_DYNAMIC)
+    add_executable(gmsh WIN32 Common/Main.cpp)
+    target_link_libraries(gmsh shared)
+  else()
+    add_executable(gmsh WIN32 Common/Main.cpp ${GMSH_SRC})
+  endif()
+  # we could add this to create a minimal app bundle even without install
+  # if(APPLE AND NOT ENABLE_OS_SPECIFIC_INSTALL)
+  #  set_target_properties(gmsh PROPERTIES MACOSX_BUNDLE ON
+  #    MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/utils/misc/gmsh_dev.plist)
+  # endif()
+else()
+  if(ENABLE_BUILD_DYNAMIC)
+    add_executable(gmsh Common/Main.cpp)
+    target_link_libraries(gmsh shared)
+  else()
+    add_executable(gmsh Common/Main.cpp ${GMSH_SRC})
+  endif()
+endif()
+target_link_libraries(gmsh ${LINK_LIBRARIES})
+
+# Windows specific linker options
+if(WIN32 AND NOT MSVC)
+  set(FLAGS "-Wl,--stack,16777216 -static -municode")
+  if(HAVE_FLTK)
+    set(FLAGS "${FLAGS} -mwindows")
+  else()
+    set(FLAGS "${FLAGS} -mconsole")
+  endif()
+  if(HAVE_64BIT_SIZE_T)
+    set(FLAGS "${FLAGS} \"${CMAKE_CURRENT_SOURCE_DIR}/Fltk/Win64Icon.res\"")
+  else()
+    set(FLAGS "${FLAGS} \"${CMAKE_CURRENT_SOURCE_DIR}/Fltk/Win32Icon.res\"")
+  endif()
+  set_target_properties(gmsh PROPERTIES LINK_FLAGS "${FLAGS}")
+  if(ENABLE_BUILD_DYNAMIC OR ENABLE_BUILD_SHARED)
+    set_target_properties(shared PROPERTIES LINK_FLAGS -static)
+  endif()
+  # remove -Wl,-Bdynamic flags
+  set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS)
+  set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
+elseif(MSVC)
+  set_target_properties(gmsh PROPERTIES LINK_FLAGS "/STACK:16777216 /SAFESEH:NO")
+endif()
+
+# android target
+if(ENABLE_BUILD_ANDROID)
+  find_file(CMAKE_TOOLCHAIN_FILE "android.toolchain.cmake")
+  if(NOT CMAKE_TOOLCHAIN_FILE)
+    message(FATAL_ERROR "Cannot compile Gmsh for android without android-cmake")
+  endif()
+  add_definitions(-D_GLIBCXX_USE_C99_MATH=1)
+  set(CMAKE_BUILD_TYPE Release)
+  set(LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_CURRENT_BINARY_DIR})
+  set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/libs/)
+  add_definitions(-DBUILD_ANDROID)
+  add_definitions(-DPICOJSON_USE_LOCALE=0)
+  add_library(androidGmsh SHARED ${GMSH_SRC})
+  set_target_properties(androidGmsh PROPERTIES OUTPUT_NAME gmsh)
+  target_link_libraries(androidGmsh ${EXTERNAL_LIBRARIES} ${LAPACK_LIBRARIES})
+  add_custom_command(TARGET androidGmsh POST_BUILD COMMAND
+                     ${CMAKE_STRIP} ${LIBRARY_OUTPUT_PATH}/libgmsh.so)
+endif()
+
+# parser target
+find_program(BISON bison)
+find_program(FLEX flex)
+if(BISON AND FLEX)
+  add_custom_target(parser
+                    COMMAND ${BISON} -p gmsh_yy --output Gmsh.tab.cpp -d Gmsh.y
+                    COMMAND ${FLEX} -P gmsh_yy -o Gmsh.yy.cpp Gmsh.l
+                    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Parser)
+endif()
+
+if(UNIX)
+  # cannot use cmake's file search functions here (they would only find files
+  # existing at configuration time)
+  add_custom_target(purge
+                    COMMAND rm -f `find . -name *~ -o -name *~~`
+                    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+  add_custom_target(etags
+                    COMMAND etags `find . -name *.cpp -o -name *.h -o -name *.y`
+                    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+endif()
+
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
+   CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
+                  OUTPUT_VARIABLE CXX_COMPILER_VERSION
+                  OUTPUT_STRIP_TRAILING_WHITESPACE)
+else()
+  set(CXX_COMPILER_VERSION "Unknown")
+endif()
+
+set(WELCOME_FILE ${CMAKE_CURRENT_SOURCE_DIR}/doc/WELCOME.txt)
+set(SDK_FILE ${CMAKE_CURRENT_SOURCE_DIR}/doc/SDK.txt)
+set(LICENSE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt)
+set(CREDITS_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CREDITS.txt)
+set(CHANGELOG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG.txt)
+file(GLOB TUTORIAL_GEO_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tutorial/?*.*)
+file(GLOB TUTORIAL_CPP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tutorial/c++/?*.*)
+file(GLOB TUTORIAL_C_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tutorial/c/?*.*)
+file(GLOB TUTORIAL_PY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tutorial/python/?*.*)
+file(GLOB TUTORIAL_JL_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tutorial/julia/?*.*)
+file(GLOB DEMOS ${CMAKE_CURRENT_SOURCE_DIR}/demos/*)
+foreach(SUBDIR ${DEMOS})
+  if(IS_DIRECTORY ${SUBDIR})
+    list(APPEND DEMOS_DIRS ${SUBDIR})
+  endif()
+endforeach()
+set(TEX_DIR ${CMAKE_CURRENT_SOURCE_DIR}/doc/texinfo)
+file(GLOB TEX_SRC ${TEX_DIR}/*.texi)
+set(TEX_OBJ ${TEX_DIR}/gmsh.aux ${TEX_DIR}/gmsh.cp ${TEX_DIR}/gmsh.cps
+    ${TEX_DIR}/gmsh.fn ${TEX_DIR}/gmsh.html ${TEX_DIR}/gmsh.info ${TEX_DIR}/gmsh.ky
+    ${TEX_DIR}/gmsh.log ${TEX_DIR}/gmsh.pdf ${TEX_DIR}/gmsh.pg ${TEX_DIR}/gmsh.toc
+    ${TEX_DIR}/gmsh.tp ${TEX_DIR}/gmsh.tps ${TEX_DIR}/gmsh.txt ${TEX_DIR}/gmsh.vr)
+
+macro(unix2dos VARNAME)
+  file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unix2dos)
+  set(UNIX2DOS_FILES)
+  foreach(FILE ${${VARNAME}})
+    file(READ ${FILE} F0)
+    get_filename_component(N ${FILE} NAME)
+    if(CYGWIN)
+      string(REGEX REPLACE "\n" "\r\n" F1 "${F0}")
+      file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/unix2dos/${N} "${F1}")
+    else() # if not in Cygwin, cmake adds '\r's automatically
+      file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/unix2dos/${N} "${F0}")
+    endif()
+    list(APPEND UNIX2DOS_FILES ${CMAKE_CURRENT_BINARY_DIR}/unix2dos/${N})
+  endforeach()
+  set(${VARNAME} ${UNIX2DOS_FILES})
+endmacro()
+
+if(WIN32)
+  if(ENABLE_OS_SPECIFIC_INSTALL)
+    set(GMSH_BIN .)
+    set(GMSH_LIB .)
+    set(GMSH_DOC .)
+    set(GMSH_MAN .)
+    set(GMSH_INC .)
+  else()
+    include(GNUInstallDirs)
+    set(GMSH_BIN ${CMAKE_INSTALL_BINDIR})
+    set(GMSH_LIB ${CMAKE_INSTALL_LIBDIR})
+    set(GMSH_DOC ${CMAKE_INSTALL_DOCDIR})
+    set(GMSH_MAN ${CMAKE_INSTALL_MANDIR}/man1)
+    set(GMSH_INC ${CMAKE_INSTALL_INCLUDEDIR})
+  endif()
+  if(CYGWIN)
+    unix2dos(GMSH_API)
+    if(ENABLE_PRIVATE_API)
+      unix2dos(GMSH_PRIVATE_API)
+    endif()
+    unix2dos(WELCOME_FILE)
+    unix2dos(SDK_FILE)
+    unix2dos(LICENSE_FILE)
+    unix2dos(CREDITS_FILE)
+    unix2dos(CHANGELOG_FILE)
+    unix2dos(TUTORIAL_GEO_FILES)
+    unix2dos(TUTORIAL_CPP_FILES)
+    unix2dos(TUTORIAL_C_FILES)
+    unix2dos(TUTORIAL_PY_FILES)
+    unix2dos(TUTORIAL_JL_FILES)
+    foreach(DIR ${DEMOS_DIRS})
+      file(GLOB DEMO_FILES ${DIR}/?*.*)
+      unix2dos(DEMO_FILES)
+    endforeach()
+  endif()
+elseif(APPLE AND ENABLE_OS_SPECIFIC_INSTALL)
+  # set these so that the files get installed nicely in the MacOSX
+  # .app bundle
+  set(GMSH_BIN ../MacOS)
+  set(GMSH_LIB ../MacOS)
+  set(GMSH_DOC ../../..)
+  set(GMSH_MAN ../../..)
+  set(GMSH_INC ../MacOS)
+else()
+  include(GNUInstallDirs)
+  set(GMSH_BIN ${CMAKE_INSTALL_BINDIR})
+  set(GMSH_LIB ${CMAKE_INSTALL_LIBDIR})
+  set(GMSH_DOC ${CMAKE_INSTALL_DOCDIR})
+  set(GMSH_MAN ${CMAKE_INSTALL_MANDIR}/man1)
+  set(GMSH_INC ${CMAKE_INSTALL_INCLUDEDIR})
+endif()
+
+# mark targets as optional so we can install them separately if needed
+# (e.g. "make lib" or "make shared" followed by "make install/fast")
+install(TARGETS gmsh DESTINATION ${GMSH_BIN} OPTIONAL)
+if(ENABLE_BUILD_LIB)
+  install(TARGETS lib DESTINATION ${GMSH_LIB} OPTIONAL)
+endif()
+if(ENABLE_BUILD_SHARED OR ENABLE_BUILD_DYNAMIC)
+  install(TARGETS shared DESTINATION ${GMSH_LIB} OPTIONAL)
+endif()
+
+if(ENABLE_ONELAB)
+  install(FILES ${ONELAB_PY} DESTINATION ${GMSH_BIN})
+endif()
+if(ENABLE_BUILD_LIB OR ENABLE_BUILD_SHARED OR ENABLE_BUILD_DYNAMIC)
+  install(FILES ${GMSH_API} DESTINATION ${GMSH_INC})
+  install(FILES ${GMSH_PY} DESTINATION ${GMSH_LIB})
+  install(FILES ${GMSH_JL} DESTINATION ${GMSH_LIB})
+  if(ENABLE_PRIVATE_API)
+    install(FILES ${GMSH_PRIVATE_API} DESTINATION ${GMSH_INC}/gmsh)
+  endif()
+endif()
+if(INSTALL_SDK_README)
+  configure_file(${SDK_FILE} ${CMAKE_CURRENT_BINARY_DIR}/README.txt)
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/README.txt DESTINATION .)
+endif()
+install(FILES ${WELCOME_FILE} DESTINATION ${GMSH_DOC} RENAME README.txt)
+install(FILES ${LICENSE_FILE} DESTINATION ${GMSH_DOC})
+install(FILES ${CREDITS_FILE} DESTINATION ${GMSH_DOC})
+install(FILES ${CHANGELOG_FILE} DESTINATION ${GMSH_DOC})
+install(FILES ${TUTORIAL_GEO_FILES} DESTINATION ${GMSH_DOC}/tutorial)
+install(FILES ${TUTORIAL_CPP_FILES} DESTINATION ${GMSH_DOC}/tutorial/c++)
+install(FILES ${TUTORIAL_C_FILES} DESTINATION ${GMSH_DOC}/tutorial/c)
+install(FILES ${TUTORIAL_PY_FILES} DESTINATION ${GMSH_DOC}/tutorial/python)
+install(FILES ${TUTORIAL_JL_FILES} DESTINATION ${GMSH_DOC}/tutorial/julia)
+foreach(DIR ${DEMOS_DIRS})
+  get_filename_component(DEMOS_DIR_NAME ${DIR} NAME)
+  file(GLOB DEMO_FILES ${DIR}/?*.*)
+  install(FILES ${DEMO_FILES} DESTINATION ${GMSH_DOC}/demos/${DEMOS_DIR_NAME})
+endforeach()
+if(UNIX AND NOT CYGWIN)
+  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/doc/gmsh.1 DESTINATION ${GMSH_MAN})
+endif()
+
+add_custom_target(get_headers
+  COMMAND ${CMAKE_COMMAND} -E make_directory Headers/gmsh
+  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+foreach(FILE ${GMSH_API})
+  add_custom_command(TARGET get_headers POST_BUILD COMMAND ${CMAKE_COMMAND}
+    -E copy_if_different ${FILE} ${CMAKE_CURRENT_BINARY_DIR}/Headers/
+    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+endforeach()
+if(ENABLE_PRIVATE_API)
+  foreach(FILE ${GMSH_PRIVATE_API})
+    add_custom_command(TARGET get_headers POST_BUILD COMMAND ${CMAKE_COMMAND}
+      -E copy_if_different ${FILE} ${CMAKE_CURRENT_BINARY_DIR}/Headers/gmsh/
+      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+  endforeach()
+endif()
+
+find_program(MAKEINFO makeinfo)
+if(MAKEINFO)
+  add_custom_command(OUTPUT ${TEX_DIR}/gmsh.info DEPENDS ${TEX_SRC}
+                     COMMAND ${MAKEINFO} --split-size 1000000
+                     ARGS ${TEX_DIR}/gmsh.texi WORKING_DIRECTORY ${TEX_DIR})
+  add_custom_target(info DEPENDS ${TEX_DIR}/gmsh.info)
+  add_custom_command(OUTPUT ${TEX_DIR}/gmsh.txt DEPENDS ${TEX_SRC}
+                     COMMAND ${MAKEINFO} --plaintext -o gmsh.txt
+                     ARGS ${TEX_DIR}/gmsh.texi WORKING_DIRECTORY ${TEX_DIR})
+  add_custom_target(txt DEPENDS ${TEX_DIR}/gmsh.txt)
+  add_custom_command(OUTPUT ${TEX_DIR}/gmsh.html DEPENDS ${TEX_SRC}
+    COMMAND ${MAKEINFO} --html --css-ref=/gmsh.css
+    --no-split --set-customization-variable
+    EXTRA_HEAD='<meta name="viewport" content="width=device-width,initial-scale=1.0">'
+    ARGS ${TEX_DIR}/gmsh.texi WORKING_DIRECTORY ${TEX_DIR})
+  add_custom_target(html DEPENDS ${TEX_DIR}/gmsh.html)
+  install(FILES ${TEX_DIR}/gmsh.html DESTINATION ${GMSH_DOC} OPTIONAL)
+else()
+  add_custom_target(html COMMAND ${CMAKE_COMMAND} -E touch ${TEX_DIR}/gmsh.html)
+endif()
+
+find_program(TEXI2PDF texi2pdf)
+if(TEXI2PDF)
+  add_custom_command(OUTPUT ${TEX_DIR}/gmsh.pdf DEPENDS ${TEX_SRC}
+                     COMMAND ${TEXI2PDF} ARGS gmsh.texi
+                     WORKING_DIRECTORY ${TEX_DIR})
+  add_custom_target(pdf DEPENDS ${TEX_DIR}/gmsh.pdf)
+  install(FILES ${TEX_DIR}/gmsh.pdf DESTINATION ${GMSH_DOC} OPTIONAL)
+endif()
+
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+  "@c This file was generated by cmake: do not edit manually!\n${OPT_TEXI}"
+  OUTPUT_FILE cmake_options.texi)
+
+if(MAKEINFO AND TEXI2PDF)
+  add_custom_target(doc COMMAND ${CMAKE_COMMAND} -E tar zcf
+                    ${CMAKE_CURRENT_BINARY_DIR}/gmsh-${GMSH_VERSION}-doc.tgz
+                    CREDITS.txt LICENSE.txt CHANGELOG.txt
+                    doc/gmsh.1 doc/texinfo/gmsh.html doc/texinfo/gmsh.info
+                    doc/texinfo/gmsh.pdf doc/texinfo/gmsh.txt
+                    COMMAND ${CMAKE_COMMAND} -E remove ${TEX_OBJ}
+                    DEPENDS ${TEX_DIR}/gmsh.info ${TEX_DIR}/gmsh.txt
+                    ${TEX_DIR}/gmsh.html ${TEX_DIR}/gmsh.pdf
+                    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+endif()
+
+if(MAKEINFO OR TEXI2PDF)
+  add_custom_target(clean_doc COMMAND ${CMAKE_COMMAND} -E remove ${TEX_OBJ})
+endif()
+
+if(APPLE AND ENABLE_BUILD_LIB)
+  file(READ ${CMAKE_CURRENT_SOURCE_DIR}/utils/misc/gmsh_framework.plist F0)
+  string(REPLACE GMSH_VERSION "${GMSH_VERSION}" F1 "${F0}")
+  file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Info_framework.plist "${F1}")
+  set(LIBNAME $<TARGET_FILE:lib>)
+  add_custom_target(framework DEPENDS lib
+    COMMAND ${CMAKE_COMMAND} -E remove_directory gmsh.framework
+    COMMAND ${CMAKE_COMMAND} -E make_directory gmsh.framework/Headers
+    COMMAND ${CMAKE_COMMAND} -E make_directory gmsh.framework/Resources
+    COMMAND ${CMAKE_COMMAND} -E copy ${LIBNAME} gmsh.framework/gmsh
+    COMMAND ${CMAKE_COMMAND} -E copy Info_framework.plist
+                                     gmsh.framework/Resources/Info.plist
+    COMMAND ${CMAKE_COMMAND} -E create_symlink . gmsh.framework/Headers/gmsh
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+  foreach(FILE ${GMSH_API})
+    add_custom_command(TARGET framework POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
+        ${FILE} ${CMAKE_CURRENT_BINARY_DIR}/gmsh.framework/Headers/
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+  endforeach()
+  if(ENABLE_PRIVATE_API)
+    foreach(FILE ${GMSH_PRIVATE_API})
+      add_custom_command(TARGET framework POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
+          ${FILE} ${CMAKE_CURRENT_BINARY_DIR}/gmsh.framework/Headers/
+          WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+    endforeach()
+  endif()
+endif()
+
+set(CPACK_PACKAGE_VENDOR "Christophe Geuzaine and Jean-Francois Remacle")
+set(CPACK_PACKAGE_VERSION_MAJOR ${GMSH_MAJOR_VERSION})
+set(CPACK_PACKAGE_VERSION_MINOR ${GMSH_MINOR_VERSION})
+set(CPACK_PACKAGE_VERSION_PATCH ${GMSH_PATCH_VERSION})
+set(CPACK_PACKAGE_DESCRIPTION_FILE ${WELCOME_FILE})
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
+    "3D finite element mesh generator with built-in CAD engine and post-processor")
+if(GMSH_EXTRA_VERSION MATCHES "-git.*") # so that we'll overwrite the archives
+  set(CPACK_PACKAGE_FILE_NAME gmsh${GMSH_EXTRA_VERSION_ORIG}-git-${GMSH_OS})
+  set(CPACK_SOURCE_PACKAGE_FILE_NAME gmsh${GMSH_EXTRA_VERSION_ORIG}-git-source)
+else()
+  set(CPACK_PACKAGE_FILE_NAME gmsh-${GMSH_VERSION}-${GMSH_OS})
+  set(CPACK_SOURCE_PACKAGE_FILE_NAME gmsh-${GMSH_VERSION}-source)
+endif()
+set(CPACK_PACKAGE_INSTALL_DIRECTORY "gmsh")
+set(CPACK_RESOURCE_FILE_LICENSE ${LICENSE_FILE})
+set(CPACK_RESOURCE_FILE_README ${WELCOME_FILE})
+set(CPACK_RESOURCE_FILE_WELCOME ${WELCOME_FILE})
+set(CPACK_PACKAGE_EXECUTABLE "gmsh")
+if(ENABLE_PACKAGE_STRIP)
+  set(CPACK_STRIP_FILES TRUE)
+else()
+  set(CPACK_STRIP_FILES FALSE)
+endif()
+set(CPACK_SOURCE_GENERATOR TGZ)
+set(CPACK_SOURCE_IGNORE_FILES "${CMAKE_CURRENT_BINARY_DIR}" "/CVS/" "/.svn" "/.git"
+    "~$" "DS_Store$" "GmshConfig.h$" "GmshVersion.h$" "/benchmarks/" "/tmp/"
+    "/bin/" "/lib/" "/nightly/" "GPATH" "GRTAGS" "GSYMS" "GTAGS" "/HTML/"
+    "/contrib/3M/" "/contrib/Parasolid/")
+
+if(UNIX)
+  # make sure we remove previous installs before doing the next one (on Mac for
+  # example "make package; make package_source" would lead to huge file lists
+  # getting generated due to the 'Applications' symlink in the bundle)
+  set(CPACK_INSTALL_COMMANDS "rm -rf ${CMAKE_CURRENT_BINARY_DIR}/_CPack_Packages")
+endif()
+
+if(APPLE AND ENABLE_OS_SPECIFIC_INSTALL)
+  set(CPACK_GENERATOR Bundle)
+  set(CPACK_BUNDLE_NAME Gmsh)
+  file(READ ${CMAKE_CURRENT_SOURCE_DIR}/utils/misc/gmsh_app.plist F0)
+  string(REPLACE GMSH_VERSION "${GMSH_VERSION}" F1 "${F0}")
+  file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Info.plist "${F1}")
+  set(CPACK_BUNDLE_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
+  set(CPACK_BUNDLE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/Fltk/MacIcons.icns)
+  if(PACKAGER STREQUAL "geuzaine - removed: we sign on a separate machine")
+    # codesigning requires CMake >= 3.2
+    set(CPACK_BUNDLE_APPLE_CERT_APP "Developer ID Application: Christophe Geuzaine")
+  endif()
+  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Fltk/MacIconsGeo.icns DESTINATION .
+          RENAME GmshGeo.icns)
+  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Fltk/MacIconsMsh.icns DESTINATION .
+          RENAME GmshMsh.icns)
+  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Fltk/MacIconsSol.icns DESTINATION .
+          RENAME GmshSol.icns)
+  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Fltk/MacIconsPos.icns DESTINATION .
+          RENAME GmshPos.icns)
+  set(CPACK_PACKAGE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/Fltk/MacIcons.icns)
+elseif(WIN32)
+  set(CPACK_GENERATOR ZIP)
+else()
+  set(CPACK_GENERATOR TGZ)
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/utils/wrappers/gmshpy AND
+   ENABLE_PRIVATE_API AND ENABLE_WRAP_PYTHON AND HAVE_PYTHON)
+  add_subdirectory(utils/wrappers/gmshpy)
+endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/utils/wrappers/java AND
+   ENABLE_PRIVATE_API AND ENABLE_WRAP_JAVA)
+  add_subdirectory(utils/wrappers/java)
+endif()
+
+include(CPack)
+
+macro(filter_tests IN OUT)
+  unset(${OUT})
+  foreach(FILE ${IN})
+    unset(BAD1)
+    unset(BAD2)
+    unset(BAD3)
+    # OS-specific
+    if(${GMSH_OS} MATCHES "Linux32")
+      # OCC STL generation crashes on our Linux32 docker
+      string(REGEX MATCH "t18" BAD1 ${FILE})
+    endif()
+    # OpenCASCADE
+    if(NOT HAVE_OCC AND NOT BAD1 AND NOT BAD2 AND NOT BAD3)
+      file(STRINGS ${FILE} BAD1 REGEX "^SetFactory.*OpenCASCADE.*")
+      file(STRINGS ${FILE} BAD2 REGEX ".*occ\\.synchronize.*")
+      file(STRINGS ${FILE} BAD3 REGEX ".*occ::synchronize.*")
+    endif()
+    # Metis
+    if(NOT HAVE_METIS AND NOT BAD1 AND NOT BAD2 AND NOT BAD3)
+      file(STRINGS ${FILE} BAD1 REGEX ".*PartitionMesh.*")
+      file(STRINGS ${FILE} BAD2 REGEX ".*mesh\\.partition.*")
+      file(STRINGS ${FILE} BAD3 REGEX ".*mesh::partition.*")
+    endif()
+    if(BAD1 OR BAD2 OR BAD3)
+      message("Skipping test " ${FILE})
+    else()
+      list(APPEND ${OUT} ${FILE})
+    endif()
+  endforeach()
+endmacro()
+
+if(NOT DISABLE_GMSH_TESTS)
+  # disabling tests is useful when including this CMakeLists in an external project
+  include(CTest)
+  file(GLOB_RECURSE ALLFILES
+       tutorial/*.geo demos/*.geo benchmarks/?d/*.geo benchmarks/extrude/*.geo
+       benchmarks/occ/*.geo)
+  filter_tests("${ALLFILES}" TESTFILES)
+  foreach(TESTFILE ${TESTFILES})
+    # use relative path for Cygwin/MinGW (the pure win exe built with the MinGW
+    # compilers does not understand a full Cygwin-style path)
+    FILE(RELATIVE_PATH TEST ${CMAKE_CURRENT_BINARY_DIR} ${TESTFILE})
+    add_test(${TEST} ./gmsh ${TEST} -3 -nopopup -o ./tmp.msh)
+  endforeach()
+  # test c++ api tutorials with dynamic builds (except on 32 bit windows for
+  # now: our win32 setup does not currently handle exceptions)
+  if(ENABLE_BUILD_DYNAMIC AND NOT ${GMSH_OS} MATCHES "Windows32")
+    file(GLOB_RECURSE ALLFILES tutorial/c++/*.cpp)
+    filter_tests("${ALLFILES}" TESTFILES)
+    foreach(TESTFILE ${TESTFILES})
+      get_filename_component(TEST ${TESTFILE} NAME_WE)
+      add_executable(${TEST} WIN32 ${TESTFILE})
+      target_link_libraries(${TEST} shared)
+      if(WIN32 AND NOT MSVC)
+        set(FLAGS "-static")
+        if(HAVE_FLTK)
+          set(FLAGS "${FLAGS} -mwindows")
+        else()
+          set(FLAGS "${FLAGS} -mconsole")
+        endif()
+        set_target_properties(${TEST} PROPERTIES LINK_FLAGS "${FLAGS}")
+      endif()
+      add_test(${TEST}_cpp ${TEST} -nopopup)
+    endforeach()
+  endif()
+  # enable this once we have worked out the path issues on the build machines
+  if(0 AND ENABLE_BUILD_DYNAMIC)
+    find_package(PythonInterp)
+    if(PYTHONINTERP_FOUND)
+      file(GLOB_RECURSE ALLFILES tutorial/python/*.py demos/api/*.py)
+      filter_tests("${ALLFILES}" TESTFILES)
+      foreach(TESTFILE ${TESTFILES})
+        get_filename_component(TEST ${TESTFILE} NAME_WE)
+        add_test(NAME ${TEST}_py COMMAND ${PYTHON_EXECUTABLE} ${TESTFILE} -nopopup)
+        set_property(TEST ${TEST}_py APPEND PROPERTY ENVIRONMENT
+                     "PYTHONPATH=${CMAKE_SOURCE_DIR}/api")
+        set_property(TEST ${TEST}_py APPEND PROPERTY ENVIRONMENT
+                     "LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}")
+        endforeach()
+    endif()
+  endif()
+endif()
+
+message(STATUS "")
+message(STATUS "Gmsh ${GMSH_VERSION} has been configured for ${GMSH_OS}")
+message(STATUS "")
+message(STATUS " * Build options:" ${GMSH_CONFIG_OPTIONS})
+message(STATUS " * Build type: " ${CMAKE_BUILD_TYPE})
+message(STATUS " * C compiler: " ${CMAKE_C_COMPILER})
+message(STATUS " * C++ compiler: " ${CMAKE_CXX_COMPILER})
+message(STATUS " * Install prefix: " ${CMAKE_INSTALL_PREFIX})
+message(STATUS "")
+
+mark_as_advanced(ANN_INC ANN_LIB CAIRO_LIB CAIRO_INC CGNS_INC GMM_INC
+                 GMP_INC GMP_LIB MMG_INC MMG_LIB HDF5_LIB
+                 MED_LIB OCC_INC SZ_LIB
+                 PETSC_LIBS SLEPC_INC SLEPC_INC2 SLEPC_LIB
+                 BISON FLEX MAKEINFO TEXI2PDF FLTK_CONFIG_SCRIPT
+                 GMSH_EXTERNAL_INCLUDE_DIRS GMSH_EXTERNAL_LIBRARIES)
Index: /issm/trunk-jpl/externalpackages/gmsh/install-4-linux-python-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/gmsh/install-4-linux-python-static.sh	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/gmsh/install-4-linux-python-static.sh	(revision 25745)
@@ -0,0 +1,68 @@
+#!/bin/bash
+set -eu
+
+
+# TODO:
+# - Add support for,
+#	- BLAS_LAPACK
+#	- MUMPS
+#	- NUMPY
+#	- PETSC4PY
+#	- PETSC
+# (see configs/4/linux/static/CMakeLists.txt)
+#
+
+## Constants
+#
+VER="4.5.6"
+
+PETSC_ROOT="${ISSM_DIR}/externalpackages/petsc/install"
+
+# Cleanup
+rm -rf install src
+mkdir install src
+
+# Download source
+$ISSM_DIR/scripts/DownloadExternalPackage.sh "https://issm.ess.uci.edu/files/externalpackages/gmsh-${VER}-source.tgz" "gmsh-${VER}-source.tgz"
+
+# Untar source
+tar -xvzf gmsh-${VER}-source.tgz
+
+# Move source to 'src' directory
+mv gmsh-${VER}-source/* src
+rm -rf gmsh-${VER}-source
+
+# Copy customized source and config files to 'src' directory
+cp configs/4/linux/static/CMakeLists.txt src
+
+# Configure
+#
+# NOTE:
+# - Option -DENABLE_FLTK=0 is used because we do not need GUI.
+# - Option -DENABLE_MPEG_ENCODE=0 is used because we do not need to record MPEG 
+#	movies.
+# - Option -DENABLE_OCC=0 is used because we do not need CAD kernel and are not 
+#	importing STEP/IGES files.
+# - Option -DENABLE_TOUCHBAR=0 is used because we do not have GUI, therefore we 
+#	do not need to support Apple Touch bar.
+#
+cd install
+cmake ../src \
+	-DCMAKE_BUILD_TYPE=Release \
+	-DCMAKE_INSTALL_PREFIX="${ISSM_DIR}/externalpackages/gmsh/install" \
+	-DENABLE_BUILD_LIB=1 \
+	-DENABLE_FLTK=0 \
+	-DENABLE_MPEG_ENCODE=0 \
+	-DENABLE_MPI=1 \
+	-DENABLE_OCC=0 \
+	-DENABLE_TOUCHBAR=0 \
+	-DMETIS_ROOT="${PETSC_ROOT}"
+
+# Compile and install
+if [ $# -eq 0 ]; then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
Index: /issm/trunk-jpl/externalpackages/gmsh/install-4-linux-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/gmsh/install-4-linux-static.sh	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/gmsh/install-4-linux-static.sh	(revision 25745)
@@ -0,0 +1,66 @@
+#!/bin/bash
+set -eu
+
+
+# TODO:
+# - Add support for,
+#	- BLAS_LAPACK
+#	- MUMPS
+#	- PETSC
+# (see configs/4/linux/static/CMakeLists.txt)
+#
+
+## Constants
+#
+VER="4.5.6"
+
+PETSC_ROOT="${ISSM_DIR}/externalpackages/petsc/install"
+
+# Cleanup
+rm -rf install src
+mkdir install src
+
+# Download source
+$ISSM_DIR/scripts/DownloadExternalPackage.sh "https://issm.ess.uci.edu/files/externalpackages/gmsh-${VER}-source.tgz" "gmsh-${VER}-source.tgz"
+
+# Untar source
+tar -xvzf gmsh-${VER}-source.tgz
+
+# Move source to 'src' directory
+mv gmsh-${VER}-source/* src
+rm -rf gmsh-${VER}-source
+
+# Copy customized source and config files to 'src' directory
+cp configs/4/mac/static/CMakeLists.txt src
+
+# Configure
+#
+# NOTE:
+# - Option -DENABLE_FLTK=0 is used because we do not need GUI.
+# - Option -DENABLE_MPEG_ENCODE=0 is used because we do not need to record MPEG 
+#	movies.
+# - Option -DENABLE_OCC=0 is used because we do not need CAD kernel and are not 
+#	importing STEP/IGES files.
+# - Option -DENABLE_TOUCHBAR=0 is used because we do not have GUI, therefore we 
+#	do not need to support Apple Touch bar.
+#
+cd install
+cmake ../src \
+	-DCMAKE_BUILD_TYPE=Release \
+	-DCMAKE_INSTALL_PREFIX="${ISSM_DIR}/externalpackages/gmsh/install" \
+	-DENABLE_BUILD_LIB=1 \
+	-DENABLE_FLTK=0 \
+	-DENABLE_MPEG_ENCODE=0 \
+	-DENABLE_MPI=1 \
+	-DENABLE_OCC=0 \
+	-DENABLE_TOUCHBAR=0 \
+	-DMETIS_ROOT="${PETSC_ROOT}"
+
+# Compile and install
+if [ $# -eq 0 ]; then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
Index: /issm/trunk-jpl/externalpackages/gmsh/install-4-mac-python-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/gmsh/install-4-mac-python-static.sh	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/gmsh/install-4-mac-python-static.sh	(revision 25745)
@@ -0,0 +1,68 @@
+#!/bin/bash
+set -eu
+
+
+# TODO:
+# - Add support for,
+#	- BLAS_LAPACK
+#	- MUMPS
+#	- NUMPY
+#	- PETSC4PY
+#	- PETSC
+# (see configs/4/mac/static/CMakeLists.txt)
+#
+
+## Constants
+#
+VER="4.5.6"
+
+PETSC_ROOT="${ISSM_DIR}/externalpackages/petsc/install"
+
+# Cleanup
+rm -rf install src
+mkdir install src
+
+# Download source
+$ISSM_DIR/scripts/DownloadExternalPackage.sh "https://issm.ess.uci.edu/files/externalpackages/gmsh-${VER}-source.tgz" "gmsh-${VER}-source.tgz"
+
+# Untar source
+tar -xvzf gmsh-${VER}-source.tgz
+
+# Move source to 'src' directory
+mv gmsh-${VER}-source/* src
+rm -rf gmsh-${VER}-source
+
+# Copy customized source and config files to 'src' directory
+cp configs/4/mac/static/CMakeLists.txt src
+
+# Configure
+#
+# NOTE:
+# - Option -DENABLE_FLTK=0 is used because we do not need GUI.
+# - Option -DENABLE_MPEG_ENCODE=0 is used because we do not need to record MPEG 
+#	movies.
+# - Option -DENABLE_OCC=0 is used because we do not need CAD kernel and are not 
+#	importing STEP/IGES files.
+# - Option -DENABLE_TOUCHBAR=0 is used because we do not have GUI, therefore we 
+#	do not need to support Apple Touch bar.
+#
+cd install
+cmake ../src \
+	-DCMAKE_BUILD_TYPE=Release \
+	-DCMAKE_INSTALL_PREFIX="${ISSM_DIR}/externalpackages/gmsh/install" \
+	-DENABLE_BUILD_LIB=1 \
+	-DENABLE_FLTK=0 \
+	-DENABLE_MPEG_ENCODE=0 \
+	-DENABLE_MPI=1 \
+	-DENABLE_OCC=0 \
+	-DENABLE_TOUCHBAR=0 \
+	-DMETIS_ROOT="${PETSC_ROOT}"
+
+# Compile and install
+if [ $# -eq 0 ]; then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
Index: /issm/trunk-jpl/externalpackages/gmsh/install-4-mac-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/gmsh/install-4-mac-static.sh	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/gmsh/install-4-mac-static.sh	(revision 25745)
@@ -0,0 +1,65 @@
+#!/bin/bash
+set -eu
+
+
+# TODO:
+# - Add support for,
+#	- BLAS_LAPACK
+#	- MUMPS
+#	- PETSC
+# (see configs/4/mac/static/CMakeLists.txt)
+#
+
+## Constants
+#
+VER="4.5.6"
+
+PETSC_ROOT="${ISSM_DIR}/externalpackages/petsc/install"
+
+# Cleanup
+rm -rf install src
+mkdir install src
+
+# Download source
+$ISSM_DIR/scripts/DownloadExternalPackage.sh "https://issm.ess.uci.edu/files/externalpackages/gmsh-${VER}-source.tgz" "gmsh-${VER}-source.tgz"
+
+# Untar source
+tar -xvzf gmsh-${VER}-source.tgz
+
+# Move source to 'src' directory
+mv gmsh-${VER}-source/* src
+rm -rf gmsh-${VER}-source
+
+# Copy customized source and config files to 'src' directory
+cp configs/${VER}/mac/static/CMakeLists.txt src
+
+# Configure
+#
+# NOTE:
+# - Option -DENABLE_FLTK=0 is used because we do not need GUI.
+# - Option -DENABLE_MPEG_ENCODE=0 is used because we do not need to record MPEG 
+#	movies.
+# - Option -DENABLE_OCC=0 is used because we do not need CAD kernel and are not 
+#	importing STEP/IGES files.
+# - Option -DENABLE_TOUCHBAR=0 is used because we do not have GUI, therefore we 
+#	do not need to support Apple Touch bar.
+#
+cd install
+cmake ../src \
+	-DCMAKE_INSTALL_PREFIX="${ISSM_DIR}/externalpackages/gmsh/install" \
+	-DENABLE_BUILD_LIB=1 \
+	-DENABLE_FLTK=0 \
+	-DENABLE_MPEG_ENCODE=0 \
+	-DENABLE_MPI=1 \
+	-DENABLE_OCC=0 \
+	-DENABLE_TOUCHBAR=0 \
+	-DMETIS_ROOT="${PETSC_ROOT}"
+
+# Compile and install
+if [ $# -eq 0 ]; then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
Index: sm/trunk-jpl/externalpackages/gmsh/install-4-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/gmsh/install-4-static.sh	(revision 25744)
+++ 	(revision )
@@ -1,37 +1,0 @@
-#!/bin/bash
-set -eu
-
-
-## Constants
-#
-VER="4.5.6"
-
-# Cleanup
-rm -rf install src
-mkdir install src
-
-# Download source
-$ISSM_DIR/scripts/DownloadExternalPackage.sh "https://issm.ess.uci.edu/files/externalpackages/gmsh-${VER}-source.tgz" "gmsh-${VER}-source.tgz"
-
-# Untar source
-tar -xvzf gmsh-${VER}-source.tgz
-
-# Move source to 'src' directory
-mv gmsh-${VER}-source/* src
-rm -rf gmsh-${VER}-source
-
-# Configure
-cd install
-cmake ../src \
-	-DCMAKE_INSTALL_PREFIX="${ISSM_DIR}/externalpackages/gmsh/install" \
-	-DENABLE_MPI=1 \
-	-DENABLE_BUILD_LIB=1
-
-# Compile and install
-if [ $# -eq 0 ]; then
-	make
-	make install
-else
-	make -j $1
-	make -j $1 install
-fi
Index: /issm/trunk-jpl/externalpackages/gmsh/install-4.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/gmsh/install-4.sh	(revision 25744)
+++ /issm/trunk-jpl/externalpackages/gmsh/install-4.sh	(revision 25745)
@@ -21,11 +21,28 @@
 rm -rf gmsh-${VER}-source
 
+# Copy customized source and config files to 'src' directory
+cp configs/${VER}/mac/CMakeLists.txt src
+
 # Configure
+#
+# NOTE:
+# - Option -DENABLE_FLTK=0 is used because we do not need GUI.
+# - Option -DENABLE_MPEG_ENCODE=0 is used because we do not need to record MPEG 
+#	movies.
+# - Option -DENABLE_OCC=0 is used because we do not need CAD kernel and are not 
+#	importing STEP/IGES files.
+# - Option -DENABLE_TOUCHBAR=0 is used because we do not have GUI, therefore we 
+#	do not need to support Apple Touch bar.
+#
 cd install
 cmake ../src \
 	-DCMAKE_INSTALL_PREFIX="${ISSM_DIR}/externalpackages/gmsh/install" \
+	-DENABLE_BUILD_DYNAMIC=1 \
+	-DENABLE_BUILD_SHARED=1 \
+	-DENABLE_FLTK=0 \
+	-DENABLE_MPEG_ENCODE=0 \
 	-DENABLE_MPI=1 \
-	-DENABLE_BUILD_DYNAMIC=1 \
-	-DENABLE_BUILD_SHARED=1
+	-DENABLE_OCC=0 \
+	-DENABLE_TOUCHBAR=0
 
 # Compile and install
Index: /issm/trunk-jpl/externalpackages/gmt/configs/6/cmake/ConfigUser.cmake
===================================================================
--- /issm/trunk-jpl/externalpackages/gmt/configs/6/cmake/ConfigUser.cmake	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/gmt/configs/6/cmake/ConfigUser.cmake	(revision 25745)
@@ -0,0 +1,308 @@
+#
+#
+# Copyright (c) 1991-2019 by the GMT Team (https://www.generic-mapping-tools.org/team.html)
+# See LICENSE.TXT file for copying and redistribution conditions.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by the
+# Free Software Foundation; version 3 or any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+# for more details.
+#
+# Contact info: www.generic-mapping-tools.org
+# ----------------------------------------------------------------------------
+
+# Use this file to override variables in 'ConfigDefault.cmake' on a per-user
+# basis.  First copy 'ConfigUserTemplate.cmake' to 'ConfigUser.cmake', then
+# edit 'ConfigUser.cmake'.  'ConfigUser.cmake' is not version controlled
+# (currently listed in .gitignore).
+#
+# Note: CMake considers an empty string, "FALSE", "OFF", "NO", or any string
+# ending in "-NOTFOUND" to be false (this happens to be case-insensitive, so
+# "False", "off", "no", and "something-NotFound" are all false).  Other values
+# are true.  Thus it does not matter whether you use TRUE and FALSE, ON and
+# OFF, or YES and NO for your booleans.
+
+##
+## Section 1: Installation paths
+##
+
+# ============================================================================
+# Basic setup begins here.  All settings are optional.  In most cases, setting
+# CMAKE_INSTALL_PREFIX should be all you need to do in order to build GMT with
+# reasonable defaults enabled.  Note: If you need to specify directory names
+# with spaces (e.g., on Windows) then you must put them in quotes.
+# ============================================================================
+
+# Installation path (usually defaults to /usr/local) [auto]:
+set (CMAKE_INSTALL_PREFIX "$ENV{ISSM_DIR}/externalpackages/gmt/install")
+
+# Set install name suffix used for directories and gmt executables
+# [undefined]:
+#set (GMT_INSTALL_NAME_SUFFIX "suffix")
+
+# Install into traditional directory structure. Disable to install a
+# distribution type directory structure (doc and share separated) [on]:
+#set (GMT_INSTALL_TRADITIONAL_FOLDERNAMES OFF)
+
+# Install convenience links for GMT modules. Disable to install only the main
+# gmt program and access modules as "gmt modulename options" [TRUE]:
+#set (GMT_INSTALL_MODULE_LINKS FALSE)
+
+# Make executables relocatable on supported platforms (relative RPATH) [FALSE]:
+set (GMT_INSTALL_RELOCATABLE TRUE)
+
+# Exclude optional GDAL, PCRE, PCRE2, FFTW3, LAPACK, BLAS, ZLIB dependencies even if you have them installed [FALSE]
+#set (GMT_EXCLUDE_GDAL TRUE)
+#set (GMT_EXCLUDE_PCRE TRUE)
+#set (GMT_EXCLUDE_PCRE2 TRUE)
+#set (GMT_EXCLUDE_FFTW3 TRUE)
+#set (GMT_EXCLUDE_LAPACK TRUE)
+#set (GMT_EXCLUDE_BLAS TRUE)
+#set (GMT_EXCLUDE_ZLIB TRUE)
+
+# ============================================================================
+# Advanced configuration begins here.  Usually it is not necessary to edit any
+# settings below.  You should know what you are doing if you do though.  Note:
+# installation paths are relative to ${CMAKE_INSTALL_PREFIX} unless absolute
+# path is given.
+# ============================================================================
+
+# Set binary installation path [bin]:
+#set (GMT_BINDIR "bin")
+
+# Set library installation path [lib or lib64]:
+#set (GMT_LIBDIR "lib")
+
+# Set include installation path [include/gmt${GMT_INSTALL_NAME_SUFFIX}]:
+#set (GMT_INCLUDEDIR "include/gmt")
+
+# Set share installation path [share or share/gmt${GMT_INSTALL_NAME_SUFFIX}]:
+#set (GMT_DATADIR "share/gmt")
+
+# Set doc installation path [share/doc or
+# share/doc/gmt${GMT_INSTALL_NAME_SUFFIX}]:
+#set (GMT_DOCDIR "share/doc/gmt")
+
+# Set manpage installation path [share/man or
+# share/doc/gmt${GMT_INSTALL_NAME_SUFFIX}/man]:
+#set (GMT_MANDIR "share/doc/gmt/man")
+
+# Install documentation files from this external location instead of creating
+# new HTML documents from scratch [${GMT_SOURCE_DIR}/doc_release]:
+#set (GMT_INSTALL_EXTERNAL_DOC OFF)
+
+# Install manual pages from this external location instead of creating the
+# manpages from scratch [${GMT_SOURCE_DIR}/man_release]:
+#set (GMT_INSTALL_EXTERNAL_MAN OFF)
+
+##
+## Section 2: Build dependencies (should only be needed if CMake cannot
+## automatically detect the rights version or path.)
+##
+
+# Set URL to GMT Data server [auto]:
+#set (GMT_DATA_SERVER "data_server_url")
+
+# Set path to GSHHG Shoreline Database [auto]:
+set (GSHHG_ROOT "$ENV{ISSM_DIR}/externalpackages/gshhg/install")
+
+# Copy GSHHG files to ${GMT_DATADIR}/coast [FALSE]:
+#set (COPY_GSHHG TRUE)
+
+# Set path to DCW Digital Chart of the World for GMT [auto]:
+#set (DCW_ROOT "dcw-gmt_path")
+
+# Copy DCW files to ${GMT_DATADIR}/dcw [FALSE]:
+#set (COPY_DCW TRUE)
+
+# Copy GDAL's 'data' directory to ${GMT_DATADIR}/GDAL_DATA [FALSE]:
+#set (GDAL_DATA_PATH C:/programs/compa_libs/gdal_GIT/compileds/VC14_64/data)
+
+# Copy PROJ4's 'share' directory to ${GMT_DATADIR}/GDAL_DATA [FALSE]:
+#set (PROJ_DATA_PATH C:/programs/compa_libs/proj5_GIT/compileds/VC14_64/share/proj)
+
+# FOR WINDOWS ONLY
+# Set path to location of Ghostscript binaries (optional install)
+#set (GHOST_DATA_PATH C:/programs/compa_libs/ghostscript/bin)
+
+# FOR WINDOWS ONLY
+# Set path to location where the gmtmex is located.
+#set (GMTMEX_PATH "C:/progs_cygw/GMTdev/gmtmex/${GMTver}")
+
+# Set location of NetCDF (can be root directory, path to header file or path
+# to nc-config) [auto]:
+set (NETCDF_ROOT "$ENV{ISSM_DIR}/externalpackages/netcdf/install")
+
+# Set location of GDAL (can be root directory, path to header file or path to
+# gdal-config) [auto]:
+set (GDAL_ROOT "$ENV{ISSM_DIR}/externalpackages/gdal/install")
+
+# Set location of PCRE (can be root directory, path to header file or path to
+# pcre-config) [auto]:
+#set (PCRE_ROOT "pcre_install_prefix")
+# Alternatively, set location of PCRE2 (can be root directory, path to header file or path to
+# pcre2-config) [auto]:
+#set (PCRE2_ROOT "pcre2_install_prefix")
+
+# Set location of single precision FFTW (can be root directory or path to
+# header file) [auto]:
+#set (FFTW3_ROOT "fftw_install_prefix")
+
+# Set location of ZLIB (can be root directory or path to header file) [auto]:
+set (ZLIB_ROOT "$ENV{ISSM_DIR}/externalpackages/petsc/install")
+
+# Set location of CURL (can be root directory or path to header file) [auto]:
+#set (CURL_ROOT "curl_install_prefix")
+
+# Set location of GLIB component gthread [auto].  This is an optional (and
+# experimental) option which you need to enable:
+#set (GMT_USE_THREADS TRUE)
+# If pkg-config is not installed (e.g. on Windows) you need to specify these:
+#set (GLIB_INCLUDE_DIR c:/path/to/glib-dev/include/glib-2.0)
+#set (GLIB_LIBRARIES c:/path/to/glib-dev/lib/glib-2.0.lib)
+
+# Set LAPACK location. Use this when want to link with LAPACK and it's not found automatically
+set (LAPACK_LIBRARY "-L$ENV{ISSM_DIR}/externalpackages/petsc/install/lib -lflapack")
+set (BLAS_LIBRARY "-L$ENV{ISSM_DIR}/externalpackages/petsc/install/lib -lfblas")
+
+##
+## Section 3: GMT features
+##
+
+# Enforce GPL or LGPL conformity. Use this to disable routines that cannot be
+# redistributed under the terms of the GPL or LGPL such as Shewchuk's
+# triangulation (valid values are GPL, LGPL and off) [off]:
+#set (LICENSE_RESTRICTED GPL)
+
+# Allow building of OpenMP if compiler supports it
+# set (GMT_ENABLE_OPENMP TRUE)
+
+# Configure default units (possible values are SI and US) [SI]:
+#set (UNITS "US")
+
+# Enable building of shared libraries [TRUE] (disable to use static libraries;
+# not recommended; on non-x86 architectures uncomment the next option as well):
+#set (BUILD_SHARED_LIBS FALSE)
+
+# Create position independent code on all targets [auto] (needed for static
+# build on non-x86):
+#set (CMAKE_POSITION_INDEPENDENT_CODE TRUE)
+
+# Build GMT shared lib with supplemental modules [TRUE]:
+#set (BUILD_SUPPLEMENTS FALSE)
+
+# Build/Install GMT Developer include files [TRUE]:
+# This installs the extra include files and configured files needed by 3rd-party
+# developers.  Until we build a separate gmt-devel we include them in the main
+# Distribution.
+#set (BUILD_DEVELOPER FALSE)
+
+##
+## Section 4: Advanced tweaking
+##
+
+#
+# Testing and development
+#
+
+# Enable running examples/tests with "ctest" or "make check" (out-of-source).
+# Need to set either DO_EXAMPLES, DO_TESTS or both and uncomment the following
+# line.
+#enable_testing()
+#set (DO_EXAMPLES TRUE)
+#set (DO_TESTS TRUE)
+#set (DO_ANIMATIONS TRUE)
+# Number of parallel test jobs with "make check":
+#set (N_TEST_JOBS 4)
+
+# Enable this option to run GMT programs from within ${GMT_BINARY_DIR} without
+# installing or setting GMT_SHAREDIR and GMT_USERDIR first. This is required
+# for testing [OFF]:
+#set (SUPPORT_EXEC_IN_BINARY_DIR ON)
+
+# List extra sub-dirs of 'src' with a CMakeList.txt to build non-module codes
+# that link against the full gmt libs (not just the API; for building codes
+# that only need the GMT API, see the gmt-custom project).
+#set (EXTRA_BUILD_DIRS apidemo)
+# Uncomment the following line to enable running low-level C tests of the API
+#set (DO_API_TESTS ON)
+
+# Directory in which to install the release sources per default
+# [${GMT_BINARY_DIR}/gmt-${GMT_PACKAGE_VERSION}]:
+#set (GMT_RELEASE_PREFIX "release-src-prefix")
+
+# If set to false, image conversion from PS images to PNG and PDF does
+# not depend on the gmt binary target. Note: "make gmt" is then required
+# before docs_depends [TRUE].
+#set (GMT_DOCS_DEPEND_ON_GMT FALSE)
+
+#
+# Debugging
+#
+
+# Set build type can be: empty, Debug, Release, RelWithDebInfo or MinSizeRel
+# [Release]:
+#set (CMAKE_BUILD_TYPE Debug)
+
+# Extra debugging for developers:
+#if ( CMAKE_GENERATOR STREQUAL "Xcode" )
+##	So Xcode can find the supplemental plug-ins during debug sessions
+#	add_definitions(-DXCODER)
+#   add_definitions(-DDEBUG_MODERN)			# To set PPID == 0 during Xcode test
+#	message("Add Xcode definition for GMT")
+#endif()
+#add_definitions(-DDEBUG)
+#add_definitions(-DMEMDEBUG) # Turn on memory tracking see gmt_support.c for extra info
+#set (CMAKE_C_FLAGS "-Wall -Wdeclaration-after-statement") # recommended even for release build
+#set (CMAKE_C_FLAGS "-Wextra ${CMAKE_C_FLAGS}")            # extra warnings
+#set (CMAKE_C_FLAGS_DEBUG -ggdb3)                          # gdb debugging symbols
+#set (CMAKE_LINK_DEPENDS_DEBUG_MODE TRUE)                  # debug link dependencies
+if (HAVE_OPENMP)
+	set (CMAKE_C_FLAGS_RELEASE "-ggdb3 -O2 -Wuninitialized -flax-vector-conversions")  # check uninitialized variables
+else (HAVE_OPENMP)
+	set (CMAKE_C_FLAGS_RELEASE "-ggdb3 -O2 -Wuninitialized")  # check uninitialized variables
+endif (HAVE_OPENMP)
+
+#
+# System specific tweaks
+#
+
+# This is for GCC on Solaris to avoid "relocations remain against allocatable
+# but non-writable sections" problems:
+#set (USER_GMTLIB_LINK_FLAGS -mimpure-text)
+
+# This may be needed to enable strdup and extended math functions with GCC and
+# Suncc on Solaris:
+#set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__EXTENSIONS__")
+
+# Do not warn when building with Windows SDK or Visual Studio Express:
+#set (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
+
+# Manually select runtime library when compiling with Windows SDK or Visual
+# Studio Express:
+#set (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS c:/Windows/System32/msvcr100.dll)
+
+# If your NetCDF library is static (not recommended, applies to Windows only)
+#set (NETCDF_STATIC TRUE)
+
+# If want to rename the DLLs to something else than the default (e.g. to
+# append the bitness - Windows only)
+# WARNING: if using this option it is mandatory that the suffix starts with an underscore.
+#if (WIN32)
+# set (BITAGE 32)
+# # Detect if we are building a 32 or 64 bits version
+# if (CMAKE_SIZEOF_VOID_P EQUAL 8)
+#   set (BITAGE 64)
+# endif ()
+# set (GMT_DLL_RENAME gmt_w${BITAGE})
+# set (PSL_DLL_RENAME psl_w${BITAGE})
+#endif(WIN32)
+
+# On Windows Visual C 2012 needs _ALLOW_KEYWORD_MACROS to build
+#if(MSVC11)
+#  add_definitions(/D_ALLOW_KEYWORD_MACROS)
+#endif(MSVC11)
Index: /issm/trunk-jpl/externalpackages/gmt/configs/6/static/cmake/ConfigUser.static.cmake
===================================================================
--- /issm/trunk-jpl/externalpackages/gmt/configs/6/static/cmake/ConfigUser.static.cmake	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/gmt/configs/6/static/cmake/ConfigUser.static.cmake	(revision 25745)
@@ -0,0 +1,308 @@
+#
+#
+# Copyright (c) 1991-2019 by the GMT Team (https://www.generic-mapping-tools.org/team.html)
+# See LICENSE.TXT file for copying and redistribution conditions.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by the
+# Free Software Foundation; version 3 or any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+# for more details.
+#
+# Contact info: www.generic-mapping-tools.org
+# ----------------------------------------------------------------------------
+
+# Use this file to override variables in 'ConfigDefault.cmake' on a per-user
+# basis.  First copy 'ConfigUserTemplate.cmake' to 'ConfigUser.cmake', then
+# edit 'ConfigUser.cmake'.  'ConfigUser.cmake' is not version controlled
+# (currently listed in .gitignore).
+#
+# Note: CMake considers an empty string, "FALSE", "OFF", "NO", or any string
+# ending in "-NOTFOUND" to be false (this happens to be case-insensitive, so
+# "False", "off", "no", and "something-NotFound" are all false).  Other values
+# are true.  Thus it does not matter whether you use TRUE and FALSE, ON and
+# OFF, or YES and NO for your booleans.
+
+##
+## Section 1: Installation paths
+##
+
+# ============================================================================
+# Basic setup begins here.  All settings are optional.  In most cases, setting
+# CMAKE_INSTALL_PREFIX should be all you need to do in order to build GMT with
+# reasonable defaults enabled.  Note: If you need to specify directory names
+# with spaces (e.g., on Windows) then you must put them in quotes.
+# ============================================================================
+
+# Installation path (usually defaults to /usr/local) [auto]:
+set (CMAKE_INSTALL_PREFIX "$ENV{ISSM_DIR}/externalpackages/gmt/install")
+
+# Set install name suffix used for directories and gmt executables
+# [undefined]:
+#set (GMT_INSTALL_NAME_SUFFIX "suffix")
+
+# Install into traditional directory structure. Disable to install a
+# distribution type directory structure (doc and share separated) [on]:
+#set (GMT_INSTALL_TRADITIONAL_FOLDERNAMES OFF)
+
+# Install convenience links for GMT modules. Disable to install only the main
+# gmt program and access modules as "gmt modulename options" [TRUE]:
+#set (GMT_INSTALL_MODULE_LINKS FALSE)
+
+# Make executables relocatable on supported platforms (relative RPATH) [FALSE]:
+set (GMT_INSTALL_RELOCATABLE TRUE)
+
+# Exclude optional GDAL, PCRE, PCRE2, FFTW3, LAPACK, BLAS, ZLIB dependencies even if you have them installed [FALSE]
+#set (GMT_EXCLUDE_GDAL TRUE)
+#set (GMT_EXCLUDE_PCRE TRUE)
+#set (GMT_EXCLUDE_PCRE2 TRUE)
+#set (GMT_EXCLUDE_FFTW3 TRUE)
+#set (GMT_EXCLUDE_LAPACK TRUE)
+#set (GMT_EXCLUDE_BLAS TRUE)
+#set (GMT_EXCLUDE_ZLIB TRUE)
+
+# ============================================================================
+# Advanced configuration begins here.  Usually it is not necessary to edit any
+# settings below.  You should know what you are doing if you do though.  Note:
+# installation paths are relative to ${CMAKE_INSTALL_PREFIX} unless absolute
+# path is given.
+# ============================================================================
+
+# Set binary installation path [bin]:
+#set (GMT_BINDIR "bin")
+
+# Set library installation path [lib or lib64]:
+#set (GMT_LIBDIR "lib")
+
+# Set include installation path [include/gmt${GMT_INSTALL_NAME_SUFFIX}]:
+#set (GMT_INCLUDEDIR "include/gmt")
+
+# Set share installation path [share or share/gmt${GMT_INSTALL_NAME_SUFFIX}]:
+#set (GMT_DATADIR "share/gmt")
+
+# Set doc installation path [share/doc or
+# share/doc/gmt${GMT_INSTALL_NAME_SUFFIX}]:
+#set (GMT_DOCDIR "share/doc/gmt")
+
+# Set manpage installation path [share/man or
+# share/doc/gmt${GMT_INSTALL_NAME_SUFFIX}/man]:
+#set (GMT_MANDIR "share/doc/gmt/man")
+
+# Install documentation files from this external location instead of creating
+# new HTML documents from scratch [${GMT_SOURCE_DIR}/doc_release]:
+#set (GMT_INSTALL_EXTERNAL_DOC OFF)
+
+# Install manual pages from this external location instead of creating the
+# manpages from scratch [${GMT_SOURCE_DIR}/man_release]:
+#set (GMT_INSTALL_EXTERNAL_MAN OFF)
+
+##
+## Section 2: Build dependencies (should only be needed if CMake cannot
+## automatically detect the rights version or path.)
+##
+
+# Set URL to GMT Data server [auto]:
+#set (GMT_DATA_SERVER "data_server_url")
+
+# Set path to GSHHG Shoreline Database [auto]:
+set (GSHHG_ROOT "$ENV{ISSM_DIR}/externalpackages/gshhg/install")
+
+# Copy GSHHG files to ${GMT_DATADIR}/coast [FALSE]:
+#set (COPY_GSHHG TRUE)
+
+# Set path to DCW Digital Chart of the World for GMT [auto]:
+#set (DCW_ROOT "dcw-gmt_path")
+
+# Copy DCW files to ${GMT_DATADIR}/dcw [FALSE]:
+#set (COPY_DCW TRUE)
+
+# Copy GDAL's 'data' directory to ${GMT_DATADIR}/GDAL_DATA [FALSE]:
+#set (GDAL_DATA_PATH C:/programs/compa_libs/gdal_GIT/compileds/VC14_64/data)
+
+# Copy PROJ4's 'share' directory to ${GMT_DATADIR}/GDAL_DATA [FALSE]:
+#set (PROJ_DATA_PATH C:/programs/compa_libs/proj5_GIT/compileds/VC14_64/share/proj)
+
+# FOR WINDOWS ONLY
+# Set path to location of Ghostscript binaries (optional install)
+#set (GHOST_DATA_PATH C:/programs/compa_libs/ghostscript/bin)
+
+# FOR WINDOWS ONLY
+# Set path to location where the gmtmex is located.
+#set (GMTMEX_PATH "C:/progs_cygw/GMTdev/gmtmex/${GMTver}")
+
+# Set location of NetCDF (can be root directory, path to header file or path
+# to nc-config) [auto]:
+set (NETCDF_ROOT "$ENV{ISSM_DIR}/externalpackages/netcdf/install")
+
+# Set location of GDAL (can be root directory, path to header file or path to
+# gdal-config) [auto]:
+set (GDAL_ROOT "$ENV{ISSM_DIR}/externalpackages/gdal/install")
+
+# Set location of PCRE (can be root directory, path to header file or path to
+# pcre-config) [auto]:
+#set (PCRE_ROOT "pcre_install_prefix")
+# Alternatively, set location of PCRE2 (can be root directory, path to header file or path to
+# pcre2-config) [auto]:
+#set (PCRE2_ROOT "pcre2_install_prefix")
+
+# Set location of single precision FFTW (can be root directory or path to
+# header file) [auto]:
+#set (FFTW3_ROOT "fftw_install_prefix")
+
+# Set location of ZLIB (can be root directory or path to header file) [auto]:
+set (ZLIB_ROOT "$ENV{ISSM_DIR}/externalpackages/petsc/install")
+
+# Set location of CURL (can be root directory or path to header file) [auto]:
+set (CURL_ROOT "$ENV{ISSM_DIR}/externalpackages/curl/install")
+
+# Set location of GLIB component gthread [auto].  This is an optional (and
+# experimental) option which you need to enable:
+#set (GMT_USE_THREADS TRUE)
+# If pkg-config is not installed (e.g. on Windows) you need to specify these:
+#set (GLIB_INCLUDE_DIR c:/path/to/glib-dev/include/glib-2.0)
+#set (GLIB_LIBRARIES c:/path/to/glib-dev/lib/glib-2.0.lib)
+
+# Set LAPACK location. Use this when want to link with LAPACK and it's not found automatically
+#set (LAPACK_LIBRARY "-L$ENV{ISSM_DIR}/externalpackages/petsc/install/lib -lflapack")
+#set (BLAS_LIBRARY "-L$ENV{ISSM_DIR}/externalpackages/petsc/install/lib -lfblas")
+
+##
+## Section 3: GMT features
+##
+
+# Enforce GPL or LGPL conformity. Use this to disable routines that cannot be
+# redistributed under the terms of the GPL or LGPL such as Shewchuk's
+# triangulation (valid values are GPL, LGPL and off) [off]:
+#set (LICENSE_RESTRICTED GPL)
+
+# Allow building of OpenMP if compiler supports it
+# set (GMT_ENABLE_OPENMP TRUE)
+
+# Configure default units (possible values are SI and US) [SI]:
+#set (UNITS "US")
+
+# Enable building of shared libraries [TRUE] (disable to use static libraries;
+# not recommended; on non-x86 architectures uncomment the next option as well):
+set (BUILD_SHARED_LIBS FALSE)
+
+# Create position independent code on all targets [auto] (needed for static
+# build on non-x86):
+set (CMAKE_POSITION_INDEPENDENT_CODE TRUE)
+
+# Build GMT shared lib with supplemental modules [TRUE]:
+set (BUILD_SUPPLEMENTS FALSE)
+
+# Build/Install GMT Developer include files [TRUE]:
+# This installs the extra include files and configured files needed by 3rd-party
+# developers.  Until we build a separate gmt-devel we include them in the main
+# Distribution.
+#set (BUILD_DEVELOPER FALSE)
+
+##
+## Section 4: Advanced tweaking
+##
+
+#
+# Testing and development
+#
+
+# Enable running examples/tests with "ctest" or "make check" (out-of-source).
+# Need to set either DO_EXAMPLES, DO_TESTS or both and uncomment the following
+# line.
+#enable_testing()
+#set (DO_EXAMPLES TRUE)
+#set (DO_TESTS TRUE)
+#set (DO_ANIMATIONS TRUE)
+# Number of parallel test jobs with "make check":
+#set (N_TEST_JOBS 4)
+
+# Enable this option to run GMT programs from within ${GMT_BINARY_DIR} without
+# installing or setting GMT_SHAREDIR and GMT_USERDIR first. This is required
+# for testing [OFF]:
+#set (SUPPORT_EXEC_IN_BINARY_DIR ON)
+
+# List extra sub-dirs of 'src' with a CMakeList.txt to build non-module codes
+# that link against the full gmt libs (not just the API; for building codes
+# that only need the GMT API, see the gmt-custom project).
+#set (EXTRA_BUILD_DIRS apidemo)
+# Uncomment the following line to enable running low-level C tests of the API
+#set (DO_API_TESTS ON)
+
+# Directory in which to install the release sources per default
+# [${GMT_BINARY_DIR}/gmt-${GMT_PACKAGE_VERSION}]:
+#set (GMT_RELEASE_PREFIX "release-src-prefix")
+
+# If set to false, image conversion from PS images to PNG and PDF does
+# not depend on the gmt binary target. Note: "make gmt" is then required
+# before docs_depends [TRUE].
+#set (GMT_DOCS_DEPEND_ON_GMT FALSE)
+
+#
+# Debugging
+#
+
+# Set build type can be: empty, Debug, Release, RelWithDebInfo or MinSizeRel
+# [Release]:
+#set (CMAKE_BUILD_TYPE Debug)
+
+# Extra debugging for developers:
+#if ( CMAKE_GENERATOR STREQUAL "Xcode" )
+##	So Xcode can find the supplemental plug-ins during debug sessions
+#	add_definitions(-DXCODER)
+#   add_definitions(-DDEBUG_MODERN)			# To set PPID == 0 during Xcode test
+#	message("Add Xcode definition for GMT")
+#endif()
+#add_definitions(-DDEBUG)
+#add_definitions(-DMEMDEBUG) # Turn on memory tracking see gmt_support.c for extra info
+#set (CMAKE_C_FLAGS "-Wall -Wdeclaration-after-statement") # recommended even for release build
+#set (CMAKE_C_FLAGS "-Wextra ${CMAKE_C_FLAGS}")            # extra warnings
+#set (CMAKE_C_FLAGS_DEBUG -ggdb3)                          # gdb debugging symbols
+#set (CMAKE_LINK_DEPENDS_DEBUG_MODE TRUE)                  # debug link dependencies
+if (HAVE_OPENMP)
+	set (CMAKE_C_FLAGS_RELEASE "-ggdb3 -O2 -Wuninitialized -flax-vector-conversions")  # check uninitialized variables
+else (HAVE_OPENMP)
+	set (CMAKE_C_FLAGS_RELEASE "-ggdb3 -O2 -Wuninitialized")  # check uninitialized variables
+endif (HAVE_OPENMP)
+
+#
+# System specific tweaks
+#
+
+# This is for GCC on Solaris to avoid "relocations remain against allocatable
+# but non-writable sections" problems:
+#set (USER_GMTLIB_LINK_FLAGS -mimpure-text)
+
+# This may be needed to enable strdup and extended math functions with GCC and
+# Suncc on Solaris:
+#set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__EXTENSIONS__")
+
+# Do not warn when building with Windows SDK or Visual Studio Express:
+#set (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
+
+# Manually select runtime library when compiling with Windows SDK or Visual
+# Studio Express:
+#set (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS c:/Windows/System32/msvcr100.dll)
+
+# If your NetCDF library is static (not recommended, applies to Windows only)
+set (NETCDF_STATIC TRUE)
+
+# If want to rename the DLLs to something else than the default (e.g. to
+# append the bitness - Windows only)
+# WARNING: if using this option it is mandatory that the suffix starts with an underscore.
+#if (WIN32)
+# set (BITAGE 32)
+# # Detect if we are building a 32 or 64 bits version
+# if (CMAKE_SIZEOF_VOID_P EQUAL 8)
+#   set (BITAGE 64)
+# endif ()
+# set (GMT_DLL_RENAME gmt_w${BITAGE})
+# set (PSL_DLL_RENAME psl_w${BITAGE})
+#endif(WIN32)
+
+# On Windows Visual C 2012 needs _ALLOW_KEYWORD_MACROS to build
+#if(MSVC11)
+#  add_definitions(/D_ALLOW_KEYWORD_MACROS)
+#endif(MSVC11)
Index: /issm/trunk-jpl/externalpackages/gmt/configs/6/static/cmake/modules/FindGDAL.cmake
===================================================================
--- /issm/trunk-jpl/externalpackages/gmt/configs/6/static/cmake/modules/FindGDAL.cmake	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/gmt/configs/6/static/cmake/modules/FindGDAL.cmake	(revision 25745)
@@ -0,0 +1,187 @@
+#
+#
+# Locate gdal
+#
+# This module accepts the following environment variables:
+#
+#    GDAL_DIR or GDAL_ROOT - Specify the location of GDAL
+#
+# This module defines the following CMake variables:
+#
+#    GDAL_FOUND - True if libgdal is found
+#    GDAL_LIBRARY - A variable pointing to the GDAL library
+#    GDAL_INCLUDE_DIR - Where to find the headers
+
+#=============================================================================
+# Copyright 2007-2009 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See COPYING-CMAKE-SCRIPTS for more information.
+#=============================================================================
+# Note: this file is not an exact copy of the original file from Kitware.
+#       It has been modified for the needs of GMT.
+
+#
+# $GDAL_DIR is an environment variable that would
+# correspond to the ./configure --prefix=$GDAL_DIR
+# used in building gdal.
+#
+# Created by Eric Wing. I'm not a gdal user, but OpenSceneGraph uses it
+# for osgTerrain so I whipped this module together for completeness.
+# I actually don't know the conventions or where files are typically
+# placed in distros.
+# Any real gdal users are encouraged to correct this (but please don't
+# break the OS X framework stuff when doing so which is what usually seems
+# to happen).
+
+# This makes the presumption that you are include gdal.h like
+#
+#include "gdal.h"
+
+if (DEFINED GDAL_ROOT AND NOT GDAL_ROOT)
+	set (GDAL_LIBRARY "" CACHE INTERNAL "")
+	set (GDAL_INCLUDE_DIR "" CACHE INTERNAL "")
+	return()
+endif (DEFINED GDAL_ROOT AND NOT GDAL_ROOT)
+
+if (UNIX AND NOT GDAL_FOUND)
+	# Use gdal-config to obtain the library version (this should hopefully
+	# allow us to -lgdal1.x.y where x.y are correct version)
+	# For some reason, libgdal development packages do not contain
+	# libgdal.so...
+	find_program (GDAL_CONFIG gdal-config
+		HINTS
+		${GDAL_DIR}
+		${GDAL_ROOT}
+		$ENV{GDAL_DIR}
+		$ENV{GDAL_ROOT}
+		PATH_SUFFIXES bin
+		PATHS
+		/sw # Fink
+		/opt/local # DarwinPorts
+		/opt/csw # Blastwave
+		/opt
+		/usr/local
+	)
+
+	if (GDAL_CONFIG)
+		execute_process (COMMAND ${GDAL_CONFIG} --cflags
+			ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
+			OUTPUT_VARIABLE GDAL_CONFIG_CFLAGS)
+		if (GDAL_CONFIG_CFLAGS)
+			string (REGEX MATCHALL "-I[^ ]+" _gdal_dashI ${GDAL_CONFIG_CFLAGS})
+			string (REGEX REPLACE "-I" "" _gdal_includepath "${_gdal_dashI}")
+			string (REGEX REPLACE "-I[^ ]+" "" _gdal_cflags_other ${GDAL_CONFIG_CFLAGS})
+		endif (GDAL_CONFIG_CFLAGS)
+		execute_process (COMMAND ${GDAL_CONFIG} --libs
+			ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
+			OUTPUT_VARIABLE GDAL_CONFIG_LIBS)
+		if (GDAL_CONFIG_LIBS)
+			string (REGEX MATCHALL "-l[^ ]+" _gdal_dashl ${GDAL_CONFIG_LIBS})
+			string (REGEX REPLACE "-l" "" _gdal_lib "${_gdal_dashl}")
+			string (REGEX MATCHALL "-L[^ ]+" _gdal_dashL ${GDAL_CONFIG_LIBS})
+			string (REGEX REPLACE "-L" "" _gdal_libpath "${_gdal_dashL}")
+		endif (GDAL_CONFIG_LIBS)
+		execute_process (COMMAND ${GDAL_CONFIG} --dep-libs
+			ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
+			OUTPUT_VARIABLE GDAL_CONFIG_DEP_LIBS)
+		if (GDAL_CONFIG_DEP_LIBS)
+			string (REGEX MATCHALL "-l[^ ]+" _gdal_dashl ${GDAL_CONFIG_DEP_LIBS})
+			string (REGEX REPLACE "-l" "" _gdal_dep_lib "${_gdal_dashl}")
+			string (REGEX MATCHALL "-L[^ ]+" _gdal_dashL ${GDAL_CONFIG_DEP_LIBS})
+			string (REGEX REPLACE "-L" "" _gdal_dep_libpath "${_gdal_dashL}")
+		endif (GDAL_CONFIG_DEP_LIBS)
+	endif (GDAL_CONFIG)
+	if (_gdal_dep_lib)
+		list (REMOVE_DUPLICATES _gdal_dep_lib)
+		list (REMOVE_ITEM _gdal_dep_lib gdal)
+	endif (_gdal_dep_lib)
+endif (UNIX AND NOT GDAL_FOUND)
+
+find_path (GDAL_INCLUDE_DIR gdal.h
+	HINTS
+	${_gdal_includepath}
+	${GDAL_DIR}
+	${GDAL_ROOT}
+	$ENV{GDAL_DIR}
+	$ENV{GDAL_ROOT}
+	PATH_SUFFIXES
+	include/gdal
+	include/GDAL
+	include
+	PATHS
+	~/Library/Frameworks/gdal.framework/Headers
+	/Library/Frameworks/gdal.framework/Headers
+	/sw # Fink
+	/opt/local # DarwinPorts
+	/opt/csw # Blastwave
+	/opt
+	/usr/local
+)
+
+find_library (GDAL_LIBRARY
+	NAMES ${_gdal_lib} gdal gdal_i gdal1.5.0 gdal1.4.0 gdal1.3.2 GDAL
+	HINTS
+	${GDAL_DIR}
+	${GDAL_ROOT}
+	$ENV{GDAL_DIR}
+	$ENV{GDAL_ROOT}
+	${_gdal_libpath}
+	PATH_SUFFIXES lib
+	PATHS
+	~/Library/Frameworks/gdal.framework
+	/Library/Frameworks/gdal.framework
+	/sw # Fink
+	/opt/local # DarwinPorts
+	/opt/csw # Blastwave
+	/opt
+	/usr/local
+)
+
+# find all libs that gdal-config --dep-libs reports
+foreach (_extralib ${_gdal_dep_lib})
+	find_library (_found_lib_${_extralib}
+		NAMES ${_extralib}
+		HINTS
+		${HDF5_ROOT}
+		$ENV{HDF5_ROOT}
+		${ZLIB_ROOT}
+		$ENV{ZLIB_ROOT}
+		${CURL_ROOT}
+		$ENV{CURL_ROOT}
+		PATH_SUFFIXES lib
+		PATHS 
+		${_gdal_dep_libpath}
+	)
+	list (APPEND GDAL_LIBRARY ${_found_lib_${_extralib}})
+endforeach (_extralib)
+
+# append manually-supplied libs
+# find all manually-supplied libs
+if (GDAL_EXTRA_LIBS)
+	# Ensure -l is precedeced by whitespace to not match
+	# '-l' in '-L/usr/lib/x86_64-linux-gnu/hdf5/serial'
+	string (REGEX MATCHALL "(^| )-l[^ ]+" _gdal_extra_lib_dashl ${GDAL_EXTRA_LIBS})
+	string (REGEX REPLACE "(^| )-l" "" _gdal_extra_lib "${_gdal_extra_lib_dashl}")
+	string (REGEX MATCHALL "(^| )-L[^ ]+" _gdal_extra_lib_dashL ${GDAL_EXTRA_LIBS})
+	string (REGEX REPLACE "(^| )-L" "" _gdal_extra_libpath "${_gdal_extra_lib_dashL}")
+	foreach (_extralib ${_gdal_extra_lib})
+		find_library (_found_lib_${_extralib}
+			NAMES ${_extralib}
+			PATH_SUFFIXES lib
+			PATHS 
+			${_gdal_extra_libpath}
+		)
+		list (APPEND GDAL_LIBRARY ${_found_lib_${_extralib}})
+	endforeach (_extralib)
+endif (GDAL_EXTRA_LIBS)
+
+include (FindPackageHandleStandardArgs)
+find_package_handle_standard_args (GDAL DEFAULT_MSG GDAL_LIBRARY GDAL_INCLUDE_DIR)
+
+set (GDAL_LIBRARIES ${GDAL_LIBRARY})
+set (GDAL_INCLUDE_DIRS ${GDAL_INCLUDE_DIR})
Index: /issm/trunk-jpl/externalpackages/gmt/configs/6/static/cmake/modules/FindGSHHG.cmake
===================================================================
--- /issm/trunk-jpl/externalpackages/gmt/configs/6/static/cmake/modules/FindGSHHG.cmake	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/gmt/configs/6/static/cmake/modules/FindGSHHG.cmake	(revision 25745)
@@ -0,0 +1,95 @@
+#
+#
+# Locate GSHHG shorelines
+#
+# This module accepts the following environment variables:
+#
+#  GSHHG_ROOT, GSHHGDIR - Specify the location of GSHHG
+#
+# This module defines the following CMake variables:
+#
+#    GSHHG_FOUND        - True if GSHHG is found
+#    GSHHG_PATH         - A variable pointing to the GSHHG path
+#    GSHHG_VERSION      - String of the GSHHG version found
+#    GSHHG_MIN_REQUIRED_VERSION_{MAJOR, MINOR, PATCH}
+#                       - Major, minor, and patch version required
+
+# get GSHHG path
+find_path (GSHHG_PATH
+	NAMES binned_GSHHS_c.nc
+	HINTS ${GSHHG_ROOT} $ENV{GSHHG_ROOT} $ENV{GSHHGDIR}
+	PATH_SUFFIXES
+	gmt-gshhg
+	gshhg
+	gshhg-gmt
+	gshhg-gmt-nc4
+	share/gmt/gshhg
+	share/gmt-gshhg
+	share/gshhg
+	share/gshhg-gmt
+	share/gshhg-gmt-nc4
+	PATHS
+	${CMAKE_SOURCE_DIR}
+	/sw # Fink
+	/opt/local # DarwinPorts
+	/opt/csw # Blastwave
+	/opt
+	/usr/local
+	DOC "Global Self-consistent Hierarchical High-resolution Geography"
+)
+
+# get GSHHG file
+if (GSHHG_PATH)
+	find_file (_GSHHG_FILE
+		NAMES binned_GSHHS_c.nc
+		HINTS ${GSHHG_PATH})
+endif (GSHHG_PATH)
+
+# The minimum required GSHHG version
+set (GSHHG_MIN_REQUIRED_VERSION_MAJOR 2 CACHE INTERNAL "GSHHG required version major")
+set (GSHHG_MIN_REQUIRED_VERSION_MINOR 2 CACHE INTERNAL "GSHHG required version minor")
+set (GSHHG_MIN_REQUIRED_VERSION_PATCH 0 CACHE INTERNAL "GSHHG required version patch")
+set (GSHHG_MIN_REQUIRED_VERSION
+	"${GSHHG_MIN_REQUIRED_VERSION_MAJOR}.${GSHHG_MIN_REQUIRED_VERSION_MINOR}.${GSHHG_MIN_REQUIRED_VERSION_PATCH}")
+
+# Temporary hack to bypass failure of compilation of code to find GSHHG
+set (GSHHG_FOUND TRUE)
+set (GSHHG_VERSION "2.3.4" CACHE INTERNAL "GSHHG version")
+
+# check GSHHG version
+if (_GSHHG_FILE AND NOT GSHHG_FOUND)
+	try_run (_EXIT_GSHHG_VERSION _COMPILED_GSHHG_VERSION
+		${CMAKE_BINARY_DIR}/CMakeTmp
+		${CMAKE_CURRENT_SOURCE_DIR}/gshhg_version.c
+		CMAKE_FLAGS
+		-DINCLUDE_DIRECTORIES=${NETCDF_INCLUDE_DIR}
+		-DLINK_LIBRARIES=${NETCDF_LIBRARIES}
+		COMPILE_DEFINITIONS -DSTANDALONE
+		COMPILE_OUTPUT_VARIABLE _GSHHG_VERSION_COMPILE_OUT
+		RUN_OUTPUT_VARIABLE _GSHHG_VERSION_STRING
+		ARGS \"${_GSHHG_FILE}\" ${GSHHG_MIN_REQUIRED_VERSION})
+
+	if (NOT _COMPILED_GSHHG_VERSION OR _EXIT_GSHHG_VERSION STREQUAL FAILED_TO_RUN)
+		message(FATAL_ERROR "Cannot determine GSHHG version:\n
+		${_GSHHG_VERSION_COMPILE_OUT}\n
+		${_GSHHG_VERSION_STRING}")
+	endif ()
+
+	# check version string
+	if (_COMPILED_GSHHG_VERSION)
+		# strip whitespace
+		string (STRIP ${_GSHHG_VERSION_STRING} GSHHG_VERSION)
+		if (_EXIT_GSHHG_VERSION EQUAL 0)
+			# found GSHHG of required version or higher
+			set (GSHHG_VERSION ${GSHHG_VERSION} CACHE INTERNAL "GSHHG version")
+		elseif (_EXIT_GSHHG_VERSION EQUAL -1)
+			# found GSHHG but version is too old
+			message (WARNING "GSHHG found but it is too old (${GSHHG_VERSION}). "
+				"Need at least ${GSHHG_MIN_REQUIRED_VERSION}.")
+		endif (_EXIT_GSHHG_VERSION EQUAL 0)
+	endif (_COMPILED_GSHHG_VERSION)
+endif (_GSHHG_FILE AND NOT GSHHG_FOUND)
+
+include (FindPackageHandleStandardArgs)
+find_package_handle_standard_args (GSHHG DEFAULT_MSG
+	GSHHG_PATH GSHHG_VERSION)
Index: /issm/trunk-jpl/externalpackages/gmt/configs/6/static/cmake/modules/FindNETCDF.cmake
===================================================================
--- /issm/trunk-jpl/externalpackages/gmt/configs/6/static/cmake/modules/FindNETCDF.cmake	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/gmt/configs/6/static/cmake/modules/FindNETCDF.cmake	(revision 25745)
@@ -0,0 +1,181 @@
+#
+#
+# Locate netcdf
+#
+# This module accepts the following environment variables:
+#
+#    NETCDF_DIR or NETCDF_ROOT - Specify the location of NetCDF
+#
+# This module defines the following CMake variables:
+#
+#    NETCDF_FOUND - True if libnetcdf is found
+#    NETCDF_LIBRARY - A variable pointing to the NetCDF library
+#    NETCDF_INCLUDE_DIR - Where to find the headers
+#    NETCDF_INCLUDE_DIRS - Where to find the headers
+#    NETCDF_DEFINITIONS - Extra compiler flags
+
+#=============================================================================
+# Inspired by FindGDAL
+#
+# Distributed under the OSI-approved bsd license (the "License")
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See COPYING-CMAKE-SCRIPTS for more information.
+#=============================================================================
+
+# This makes the presumption that you are include netcdf.h like
+#
+#include "netcdf.h"
+
+if (UNIX AND NOT NETCDF_FOUND)
+	# Use nc-config to obtain the libraries
+	find_program (NETCDF_CONFIG nc-config
+		HINTS
+		${NETCDF_DIR}
+		${NETCDF_ROOT}
+		$ENV{NETCDF_DIR}
+		$ENV{NETCDF_ROOT}
+		PATH_SUFFIXES bin
+		PATHS
+		/sw # Fink
+		/opt/local # DarwinPorts
+		/opt/csw # Blastwave
+		/opt
+		/usr/local
+	)
+
+	if (NETCDF_CONFIG)
+		execute_process (COMMAND ${NETCDF_CONFIG} --cflags
+			ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
+			OUTPUT_VARIABLE NETCDF_CONFIG_CFLAGS)
+		if (NETCDF_CONFIG_CFLAGS)
+			string (REGEX MATCHALL "(^| )-I[^ ]+" _netcdf_dashI ${NETCDF_CONFIG_CFLAGS})
+			string (REGEX REPLACE "(^| )-I" "" _netcdf_includepath "${_netcdf_dashI}")
+			string (REGEX REPLACE "(^| )-I[^ ]+" "" _netcdf_cflags_other ${NETCDF_CONFIG_CFLAGS})
+		endif (NETCDF_CONFIG_CFLAGS)
+		execute_process (COMMAND ${NETCDF_CONFIG} --libs
+			ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
+			OUTPUT_VARIABLE NETCDF_CONFIG_LIBS)
+		if (NETCDF_CONFIG_LIBS)
+			# Ensure -l is precedeced by whitespace to not match
+			# '-l' in '-L/usr/lib/x86_64-linux-gnu/hdf5/serial'
+			string (REGEX MATCHALL "(^| )-l[^ ]+" _netcdf_dashl ${NETCDF_CONFIG_LIBS})
+			string (REGEX REPLACE "(^| )-l" "" _netcdf_lib "${_netcdf_dashl}")
+			string (REGEX MATCHALL "(^| )-L[^ ]+" _netcdf_dashL ${NETCDF_CONFIG_LIBS})
+			string (REGEX REPLACE "(^| )-L" "" _netcdf_libpath "${_netcdf_dashL}")
+		endif (NETCDF_CONFIG_LIBS)
+	endif (NETCDF_CONFIG)
+	if (_netcdf_lib)
+		list (REMOVE_DUPLICATES _netcdf_lib)
+		list (REMOVE_ITEM _netcdf_lib netcdf)
+	endif (_netcdf_lib)
+endif (UNIX AND NOT NETCDF_FOUND)
+
+find_path (NETCDF_INCLUDE_DIR netcdf.h
+	HINTS
+	${_netcdf_includepath}
+	${NETCDF_DIR}
+	${NETCDF_ROOT}
+	$ENV{NETCDF_DIR}
+	$ENV{NETCDF_ROOT}
+	PATH_SUFFIXES
+	include/netcdf
+	include/netcdf-4
+	include/netcdf-3
+	include
+	PATHS
+	/sw # Fink
+	/opt/local # DarwinPorts
+	/opt/csw # Blastwave
+	/opt
+	/usr/local
+)
+
+find_library (NETCDF_LIBRARY
+	NAMES netcdf
+	HINTS
+	${_netcdf_libpath}
+	${NETCDF_DIR}
+	${NETCDF_ROOT}
+	$ENV{NETCDF_DIR}
+	$ENV{NETCDF_ROOT}
+	PATH_SUFFIXES lib
+	PATHS
+	/sw
+	/opt/local
+	/opt/csw
+	/opt
+	/usr/local
+)
+
+# find all libs that nc-config reports
+foreach (_extralib ${_netcdf_lib})
+	find_library (_found_lib_${_extralib}
+		NAMES ${_extralib}
+		HINTS
+		${HDF5_ROOT}
+		$ENV{HDF5_ROOT}
+		${ZLIB_ROOT}
+		$ENV{ZLIB_ROOT}
+		${CURL_ROOT}
+		$ENV{CURL_ROOT}
+		PATH_SUFFIXES lib
+		PATHS 
+		${_netcdf_libpath}
+	)
+	list (APPEND NETCDF_LIBRARY ${_found_lib_${_extralib}})
+endforeach (_extralib)
+
+# find all manually-supplied libs
+if (NETCDF_EXTRA_LIBS)
+	# Ensure -l is precedeced by whitespace to not match
+	# '-l' in '-L/usr/lib/x86_64-linux-gnu/hdf5/serial'
+	string (REGEX MATCHALL "(^| )-l[^ ]+" _netcdf_extra_lib_dashl ${NETCDF_EXTRA_LIBS})
+	string (REGEX REPLACE "(^| )-l" "" _netcdf_extra_shared_lib "${_netcdf_extra_lib_dashl}")
+	string (REGEX MATCHALL "(^| )-L[^ ]+" _netcdf_extra_lib_dashL ${NETCDF_EXTRA_LIBS})
+	string (REGEX REPLACE "(^| )-L" "" _netcdf_extra_libpath "${_netcdf_extra_lib_dashL}")
+	foreach (_extralib ${_netcdf_extra_shared_lib})
+		find_library (_found_lib_${_extralib}
+			NAMES ${_extralib}
+			PATH_SUFFIXES lib
+			PATHS 
+			${_netcdf_extra_libpath}
+		)
+		list (APPEND NETCDF_LIBRARY ${_found_lib_${_extralib}})
+	endforeach (_extralib)
+	# Retrieve static library names
+	string(REGEX MATCHALL "[a-zA-Z0-9]+\\.a" _netcdf_extra_static_lib "${NETCDF_EXTRA_LIBS}")
+	foreach (_extralib ${_netcdf_extra_static_lib})
+		find_library (_found_lib_${_extralib}
+			NAMES ${_extralib}
+			PATH_SUFFIXES lib
+			PATHS 
+			${_netcdf_extra_libpath}
+		)
+		list (APPEND NETCDF_LIBRARY ${_found_lib_${_extralib}})
+	endforeach (_extralib)
+endif (NETCDF_EXTRA_LIBS)
+
+if (NETCDF_LIBRARY AND NETCDF_INCLUDE_DIR AND NOT HAVE_NETCDF4)
+	# Ensure that NetCDF with version 4 extensions is installed
+	include (CMakePushCheckState)
+	include (CheckSymbolExists)
+	cmake_push_check_state() # save state of CMAKE_REQUIRED_*
+	set (CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${NETCDF_INCLUDE_DIR})
+	set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${NETCDF_LIBRARY})
+	set (HAVE_NETCDF4 HAVE_NETCDF4) # to force check_symbol_exists again
+	check_symbol_exists (nc_def_var_deflate netcdf.h HAVE_NETCDF4)
+	cmake_pop_check_state() # restore state of CMAKE_REQUIRED_*
+	if (NOT HAVE_NETCDF4)
+		message (SEND_ERROR "Library found but netCDF-4/HDF5 format unsupported. Do not configure netCDF-4 with --disable-netcdf-4.")
+	endif (NOT HAVE_NETCDF4)
+endif (NETCDF_LIBRARY AND NETCDF_INCLUDE_DIR AND NOT HAVE_NETCDF4)
+
+include (FindPackageHandleStandardArgs)
+find_package_handle_standard_args (NETCDF
+	DEFAULT_MSG NETCDF_LIBRARY NETCDF_INCLUDE_DIR HAVE_NETCDF4)
+
+set (NETCDF_LIBRARIES ${NETCDF_LIBRARY})
+set (NETCDF_INCLUDE_DIRS ${NETCDF_INCLUDE_DIR})
+string (REPLACE "-DNDEBUG" "" NETCDF_DEFINITIONS "${_netcdf_cflags_other}")
Index: /issm/trunk-jpl/externalpackages/gmt/install-6-linux-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/gmt/install-6-linux-static.sh	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/gmt/install-6-linux-static.sh	(revision 25745)
@@ -0,0 +1,78 @@
+#!/bin/bash
+set -eu
+
+
+## Constants
+#
+VER="6.0.0"
+
+PETSC_ROOT="${ISSM_DIR}/externalpackages/petsc/install"
+
+BLASLAPACK_ROOT="${PETSC_ROOT}"
+HDF5_ROOT="${PETSC_ROOT}"
+
+# Find libgfortran and libgcc so we do not have to hardcode them
+#
+# Should retrieve a copy of gfortran that is compiled from source before returning one that is installed via package manager
+#
+# TODO:
+# - Test if -static-libgfortran flag will avoid all of this.
+# - Otherwise, refactor this to work with other gfortran installations.
+#
+LIBGFORTRAN=$(mdfind -onlyin /usr -name libgfortran | grep -n libgfortran.a | grep -v i386 | sed "s/[0-9]*://g" | head -1)
+LIBGFORTRAN_ROOT=${LIBGFORTRAN%/*}
+LIBGCC=$(mdfind -onlyin ${LIBGFORTRAN_ROOT} -name libgcc | grep -n libgcc.a | grep -v i386 | sed "s/[0-9]*://g" | head -1)
+
+GDAL_EXTRA_LIBS="-lstdc++" # Determined by running `$GDAL_ROOT/bin/gdal-config --dep-libs` then removing duplicate libs
+NETCDF_EXTRA_LIBS="-lsqlite3 -lpthread -ldl -liconv" # `$NETCDF_ROOT/bin/nc-config --libs` does not report certain dependencies of certain static libraries (see also customized configuration file ./configs/6.0/static/cmake/modules/FindNETCDF.cmake)
+
+# Environment
+#
+export CC=mpicc
+
+# Download source
+$ISSM_DIR/scripts/DownloadExternalPackage.sh "https://issm.ess.uci.edu/files/externalpackages/gmt-${VER}.tar.gz" "gmt-${VER}.tar.gz"
+
+# Unpack source
+tar -zxvf gmt-${VER}.tar.gz
+
+# Cleanup
+rm -rf install src
+mkdir install src
+
+# Move source to 'src' directory
+mv gmt-${VER}/* src
+rm -rf gmt-${VER}
+
+# Copy custom configuration files
+cp ./configs/6/static/cmake/ConfigUser.static.cmake ./src/cmake/ConfigUser.cmake
+cp ./configs/6/static/cmake/modules/FindGSHHG.cmake ./src/cmake/modules
+
+# Configure
+cd src
+mkdir build
+cd build
+
+# NOTE:
+# - The CMake modules used to find and probe the BLAS and LAPACK libraries do
+#	not seem to handle the situation where BLAS_LIBRARY and LAPACK_LIBRARY are
+#	set but we are working with static libraries
+#	(see customized ConfigUser.static.cmake). Using BLAS_LIBRARIES and
+#	LAPACK_LIBRARIES is a workaround.
+#
+cmake \
+	-DBLAS_LIBRARIES="${BLASLAPACK_ROOT}/lib/libfblas.a;${LIBGFORTRAN_ROOT}/libgfortran.a;${LIBGFORTRAN_ROOT}/libquadmath.a;${LIBGCC}" \
+	-DGDAL_EXTRA_LIBS="${GDAL_EXTRA_LIBS}" \
+	-DHDF5_ROOT="${HDF5_ROOT}" \
+	-DLAPACK_LIBRARIES="${BLASLAPACK_ROOT}/lib/libflapack.a;${LIBGFORTRAN_ROOT}/libgfortran.a;${LIBGFORTRAN_ROOT}/libquadmath.a;${LIBGCC}" \
+	-DNETCDF_EXTRA_LIBS="${NETCDF_EXTRA_LIBS}" \
+	..
+
+# Compile and install
+if [ $# -eq 0 ]; then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
Index: /issm/trunk-jpl/externalpackages/gmt/install-6-linux.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/gmt/install-6-linux.sh	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/gmt/install-6-linux.sh	(revision 25745)
@@ -0,0 +1,56 @@
+#!/bin/bash
+set -eu
+
+
+## Constants
+#
+VER="6.0.0"
+
+CURL_ROOT="${ISSM_DIR}/externalpackages/curl/install"
+
+# Environment
+#
+export CC=mpicc
+
+# Download source
+$ISSM_DIR/scripts/DownloadExternalPackage.sh "https://issm.ess.uci.edu/files/externalpackages/gmt-${VER}.tar.gz" "gmt-${VER}.tar.gz"
+
+# Unpack source
+tar -zxvf gmt-${VER}.tar.gz
+
+# Cleanup
+rm -rf install src
+mkdir install src
+
+# Move source to 'src' directory
+mv gmt-${VER}/* src
+rm -rf gmt-${VER}
+
+# Copy custom configuration files
+cp ./configs/6/cmake/ConfigUser.cmake ./src/cmake
+
+# Configure
+cd src
+mkdir build
+cd build
+
+# NOTE:
+# - There is a CMake variable named CURL_ROOT in src/cmake/ConfigUser.cmake
+#	that, ostensibly, allows for supplying the path to curl when it is in a
+#	non-standard location. That said, newer versions of CMake will ignore said
+#	variable and instead try to find curl itself. Passing in the two options
+#	below overrides this behavior.
+#
+cmake \
+	-DCURL_LIBRARY="${CURL_ROOT}/lib" \
+	-DCURL_INCLUDE_DIR="${CURL_ROOT}/include" \
+	..
+
+# Compile and install
+if [ $# -eq 0 ]; then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
Index: /issm/trunk-jpl/externalpackages/gmt/install-6-mac-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/gmt/install-6-mac-static.sh	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/gmt/install-6-mac-static.sh	(revision 25745)
@@ -0,0 +1,73 @@
+#!/bin/bash
+set -eu
+
+
+## Constants
+#
+VER="6.0.0"
+
+PETSC_ROOT="${ISSM_DIR}/externalpackages/petsc/install"
+
+BLASLAPACK_ROOT="${PETSC_ROOT}"
+HDF5_ROOT="${PETSC_ROOT}"
+
+# Find libgfortran and libgcc so we do not have to hardcode them
+#
+# Should retrieve a copy of gfortran that is compiled from source before returning one that is installed via package manager
+#
+# TODO:
+# - Test if -static-libgfortran flag will avoid all of this.
+# - Otherwise, refactor this to work with other gfortran installations.
+#
+LIBGFORTRAN=$(mdfind -onlyin /usr -name libgfortran | grep -n libgfortran.a | grep -v i386 | sed "s/[0-9]*://g" | head -1)
+LIBGFORTRAN_ROOT=${LIBGFORTRAN%/*}
+LIBGCC=$(mdfind -onlyin ${LIBGFORTRAN_ROOT} -name libgcc | grep -n libgcc.a | grep -v i386 | sed "s/[0-9]*://g" | head -1)
+
+GDAL_EXTRA_LIBS="-lc++" # `$GDAL_ROOT/bin/gdal-config --dep-libs` does not report need to link to libc++ (see also customized configuration file ./configs/6.0/static/cmake/modules/FindGDAL.cmake)
+NETCDF_EXTRA_LIBS="-lsqlite3 -lpthread -ldl -liconv" # `$NETCDF_ROOT/bin/nc-config --libs` does not report certain dependencies of certain static libraries (see also customized configuration file ./configs/6.0/static/cmake/modules/FindNETCDF.cmake)
+
+# Environment
+#
+export CC=mpicc
+
+# Download source
+$ISSM_DIR/scripts/DownloadExternalPackage.sh "https://issm.ess.uci.edu/files/externalpackages/gmt-${VER}.tar.gz" "gmt-${VER}.tar.gz"
+
+# Unpack source
+tar -zxvf gmt-${VER}.tar.gz
+
+# Cleanup
+rm -rf install src
+mkdir install src
+
+# Move source to 'src' directory
+mv gmt-${VER}/* src
+rm -rf gmt-${VER}
+
+# Copy custom configuration files
+cp ./configs/6/static/cmake/ConfigUser.static.cmake ./src/cmake/ConfigUser.cmake
+cp ./configs/6/static/cmake/modules/FindGDAL.cmake ./src/cmake/modules
+cp ./configs/6/static/cmake/modules/FindGSHHG.cmake ./src/cmake/modules
+cp ./configs/6/static/cmake/modules/FindNETCDF.cmake ./src/cmake/modules
+
+# Configure
+cd src
+mkdir build
+cd build
+
+cmake \
+	-DBLAS_LIBRARIES="${BLASLAPACK_ROOT}/lib/libfblas.a;${LIBGFORTRAN_ROOT}/libgfortran.a;${LIBGFORTRAN_ROOT}/libquadmath.a;${LIBGCC}" \
+	-DGDAL_EXTRA_LIBS="${GDAL_EXTRA_LIBS}" \
+	-DHDF5_ROOT="${HDF5_ROOT}" \
+	-DLAPACK_LIBRARIES="${BLASLAPACK_ROOT}/lib/libflapack.a;${LIBGFORTRAN_ROOT}/libgfortran.a;${LIBGFORTRAN_ROOT}/libquadmath.a;${LIBGCC}" \
+	-DNETCDF_EXTRA_LIBS="${NETCDF_EXTRA_LIBS}" \
+	..
+
+# Compile and install
+if [ $# -eq 0 ]; then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
Index: /issm/trunk-jpl/externalpackages/gmt/install-6-mac.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/gmt/install-6-mac.sh	(revision 25745)
+++ /issm/trunk-jpl/externalpackages/gmt/install-6-mac.sh	(revision 25745)
@@ -0,0 +1,56 @@
+#!/bin/bash
+set -eu
+
+
+## Constants
+#
+VER="6.0.0"
+
+CURL_ROOT="${ISSM_DIR}/externalpackages/curl/install"
+
+# Environment
+#
+export CC=mpicc
+
+# Download source
+$ISSM_DIR/scripts/DownloadExternalPackage.sh "https://issm.ess.uci.edu/files/externalpackages/gmt-${VER}.tar.gz" "gmt-${VER}.tar.gz"
+
+# Unpack source
+tar -zxvf gmt-${VER}.tar.gz
+
+# Cleanup
+rm -rf install src
+mkdir install src
+
+# Move source to 'src' directory
+mv gmt-${VER}/* src
+rm -rf gmt-${VER}
+
+# Copy custom configuration files
+cp ./configs/6/cmake/ConfigUser.cmake ./src/cmake
+
+# Configure
+cd src
+mkdir build
+cd build
+
+# NOTE:
+# - There is a CMake variable named CURL_ROOT in src/cmake/ConfigUser.cmake
+#	that, ostensibly, allows for supplying the path to curl when it is in a
+#	non-standard location. That said, newer versions of CMake will ignore said
+#	variable and instead try to find curl itself. Passing in the two options
+#	below overrides this behavior.
+#
+cmake \
+	-DCURL_LIBRARY="${CURL_ROOT}/lib" \
+	-DCURL_INCLUDE_DIR="${CURL_ROOT}/include" \
+	..
+
+# Compile and install
+if [ $# -eq 0 ]; then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
+fi
Index: sm/trunk-jpl/externalpackages/gmt/install-6.0-linux-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/gmt/install-6.0-linux-static.sh	(revision 25744)
+++ 	(revision )
@@ -1,82 +1,0 @@
-#!/bin/bash
-set -eu
-
-
-# TODO:
-# - Apply changes made to ./install-6.0-mac-static.sh and customized 
-#	configuration files to this file.
-#
-
-## Constants
-#
-VER="6.0.0"
-
-PETSC_ROOT="${ISSM_DIR}/externalpackages/petsc/install"
-
-BLASLAPACK_ROOT="${PETSC_ROOT}"
-CURL_ROOT="${ISSM_DIR}/externalpackages/curl/install"
-GDAL_ROOT="${ISSM_DIR}/externalpackages/gdal/install"
-HDF5_ROOT="${PETSC_ROOT}"
-NETCDF_ROOT="${ISSM_DIR}/externalpackages/netcdf/install"
-PROJ_ROOT="${ISSM_DIR}/externalpackages/proj/install"
-ZLIB_ROOT="${PETSC_ROOT}"
-
-GDAL_LIBRARY="${GDAL_ROOT}/lib/libgdal.a;${NETCDF_ROOT}/lib/libnetcdf.a;${HDF5_ROOT}/lib/libhdf5_hl.a;${HDF5_ROOT}/lib/libhdf5.a;${PROJ_ROOT}/lib/libproj.a;${ZLIB_ROOT}/lib/libz.a;/usr/lib/x86_64-linux-gnu/libpthread.so;/usr/lib/x86_64-linux-gnu/libm.so;/usr/lib/x86_64-linux-gnu/librt.so;/usr/lib/x86_64-linux-gnu/libdl.so;${CURL_ROOT}/lib/libcurl.a;/usr/lib/x86_64-linux-gnu/libssl.a;/usr/lib/x86_64-linux-gnu/libcrypto.a;/usr/lib/x86_64-linux-gnu/libsqlite3.a;/usr/lib/x86_64-linux-gnu/libexpat.a;/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25;" # Determined by running `$GDAL_ROOT/bin/gdal-config --dep-libs` then removing duplicate libs
-NETCDF_LIBRARY="${NETCDF_ROOT}/lib/libnetcdf.a;/usr/lib/x86_64-linux-gnu/libm.so;${CURL_ROOT}/lib/libcurl.a;${HDF5_ROOT}/lib/libhdf5_hl.a;${HDF5_ROOT}/lib/libhdf5.a;${ZLIB_ROOT}/lib/libz.a;/usr/lib/x86_64-linux-gnu/libssl.a;/usr/lib/x86_64-linux-gnu/libcrypto.a;/usr/lib/x86_64-linux-gnu/libdl.so" # Determined by running `$NETCDF_ROOT/bin/nc-config --libs`
-
-# Environment
-#
-export CC=mpicc
-
-# Download source
-$ISSM_DIR/scripts/DownloadExternalPackage.sh "https://issm.ess.uci.edu/files/externalpackages/gmt-${VER}.tar.gz" "gmt-${VER}.tar.gz"
-
-# Unpack source
-tar -zxvf gmt-${VER}.tar.gz
-
-# Cleanup
-rm -rf install src
-mkdir install src
-
-# Move source to 'src' directory
-mv gmt-${VER}/* src
-rm -rf gmt-${VER}
-
-# Copy custom configuration files
-cp ./configs/6.0/static/cmake/ConfigUser.static.cmake ./src/cmake/ConfigUser.cmake
-cp ./configs/6.0/static/cmake/modules/FindGSHHG.cmake ./src/cmake/modules
-
-# Configure
-cd src
-mkdir build
-cd build
-
-# NOTE:
-# - There is a CMake variable named CURL_ROOT in src/cmake/ConfigUser.cmake
-#	that, ostensibly, allows for supplying the path to curl when it is in a
-#	non-standard location. That said, newer versions of CMake will ignore said
-#	variable and instead try to find curl itself. Passing in the two options
-#	below overrides this behavior.
-# - The CMake modules used to find and probe the BLAS and LAPACK libraries do
-#	not seem to handle the situation where BLAS_LIBRARY and LAPACK_LIBRARY are
-#	set but we are working with static libraries
-#	(see customized ConfigUser.static.cmake). Using BLAS_LIBRARIES and
-#	LAPACK_LIBRARIES is a workaround.
-#
-cmake \
-	-DBLAS_LIBRARIES="${BLASLAPACK_ROOT}/lib/libfblas.a;-L/usr/lib/x86_64-linux-gnu;-lgfortran" \
-	-DCURL_LIBRARY="${CURL_ROOT}/lib" \
-	-DCURL_INCLUDE_DIR="${CURL_ROOT}/include" \
-	-DLAPACK_LIBRARIES="${BLASLAPACK_ROOT}/lib/libflapack.a;-L/usr/lib/x86_64-linux-gnu;-lgfortran" \
-	-DGDAL_LIBRARY="${GDAL_LIBRARY}" \
-	-DNETCDF_LIBRARY="${NETCDF_LIBRARY}" \
-	..
-
-# Compile and install
-if [ $# -eq 0 ]; then
-	make
-	make install
-else
-	make -j $1
-	make -j $1 install
-fi
Index: sm/trunk-jpl/externalpackages/gmt/install-6.0-linux.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/gmt/install-6.0-linux.sh	(revision 25744)
+++ 	(revision )
@@ -1,56 +1,0 @@
-#!/bin/bash
-set -eu
-
-
-## Constants
-#
-VER="6.0.0"
-
-CURL_ROOT="${ISSM_DIR}/externalpackages/curl/install"
-
-# Environment
-#
-export CC=mpicc
-
-# Download source
-$ISSM_DIR/scripts/DownloadExternalPackage.sh "https://issm.ess.uci.edu/files/externalpackages/gmt-${VER}.tar.gz" "gmt-${VER}.tar.gz"
-
-# Unpack source
-tar -zxvf gmt-${VER}.tar.gz
-
-# Cleanup
-rm -rf install src
-mkdir install src
-
-# Move source to 'src' directory
-mv gmt-${VER}/* src
-rm -rf gmt-${VER}
-
-# Copy custom configuration files
-cp ./configs/6.0/cmake/ConfigUser.cmake ./src/cmake
-
-# Configure
-cd src
-mkdir build
-cd build
-
-# NOTE:
-# - There is a CMake variable named CURL_ROOT in src/cmake/ConfigUser.cmake
-#	that, ostensibly, allows for supplying the path to curl when it is in a
-#	non-standard location. That said, newer versions of CMake will ignore said
-#	variable and instead try to find curl itself. Passing in the two options
-#	below overrides this behavior.
-#
-cmake \
-	-DCURL_LIBRARY="${CURL_ROOT}/lib" \
-	-DCURL_INCLUDE_DIR="${CURL_ROOT}/include" \
-	..
-
-# Compile and install
-if [ $# -eq 0 ]; then
-	make
-	make install
-else
-	make -j $1
-	make -j $1 install
-fi
Index: sm/trunk-jpl/externalpackages/gmt/install-6.0-mac-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/gmt/install-6.0-mac-static.sh	(revision 25744)
+++ 	(revision )
@@ -1,78 +1,0 @@
-#!/bin/bash
-set -eu
-
-
-# TODO:
-# - Apply changes to this file and customized configuration files to 
-#	./install-6.0-linux-static.sh
-#
-
-## Constants
-#
-VER="6.0.0"
-
-PETSC_ROOT="${ISSM_DIR}/externalpackages/petsc/install"
-
-BLASLAPACK_ROOT="${PETSC_ROOT}"
-HDF5_ROOT="${PETSC_ROOT}"
-
-# Find libgfortran and libgcc so we do not have to hardcode them
-#
-# Should retrieve a copy of gfortran that is compiled from source before returning one that is installed via package manager
-#
-# TODO:
-# - Test if -static-libgfortran flag will avoid all of this.
-# - Otherwise, refactor this to work with other gfortran installations.
-#
-LIBGFORTRAN=$(mdfind -onlyin /usr -name libgfortran | grep -n libgfortran.a | grep -v i386 | sed "s/[0-9]*://g" | head -1)
-LIBGFORTRAN_ROOT=${LIBGFORTRAN%/*}
-LIBGCC=$(mdfind -onlyin ${LIBGFORTRAN_ROOT} -name libgcc | grep -n libgcc.a | grep -v i386 | sed "s/[0-9]*://g" | head -1)
-
-GDAL_EXTRA_LIBS="-lc++" # `$GDAL_ROOT/bin/gdal-config --dep-libs` does not report need to link to libc++ (see also customized configuration file ./configs/6.0/static/cmake/modules/FindGDAL.cmake)
-NETCDF_EXTRA_LIBS="-lsqlite3 -lpthread -ldl -lidn2 -lldap -liconv" # `$NETCDF_ROOT/bin/nc-config --libs` does not report certain dependencies of certain static libraries (see also customized configuration file ./configs/6.0/static/cmake/modules/FindNETCDF.cmake)
-
-# Environment
-#
-export CC=mpicc
-
-# Download source
-$ISSM_DIR/scripts/DownloadExternalPackage.sh "https://issm.ess.uci.edu/files/externalpackages/gmt-${VER}.tar.gz" "gmt-${VER}.tar.gz"
-
-# Unpack source
-tar -zxvf gmt-${VER}.tar.gz
-
-# Cleanup
-rm -rf install src
-mkdir install src
-
-# Move source to 'src' directory
-mv gmt-${VER}/* src
-rm -rf gmt-${VER}
-
-# Copy custom configuration files
-cp ./configs/6.0/static/cmake/ConfigUser.static.cmake ./src/cmake/ConfigUser.cmake
-cp ./configs/6.0/static/cmake/modules/FindGDAL.cmake ./src/cmake/modules
-cp ./configs/6.0/static/cmake/modules/FindGSHHG.cmake ./src/cmake/modules
-cp ./configs/6.0/static/cmake/modules/FindNETCDF.cmake ./src/cmake/modules
-
-# Configure
-cd src
-mkdir build
-cd build
-
-cmake \
-	-DBLAS_LIBRARIES="${BLASLAPACK_ROOT}/lib/libfblas.a;${LIBGFORTRAN_ROOT}/libgfortran.a;${LIBGFORTRAN_ROOT}/libquadmath.a;${LIBGCC}" \
-	-DGDAL_EXTRA_LIBS="${GDAL_EXTRA_LIBS}" \
-	-DHDF5_ROOT="${HDF5_ROOT}" \
-	-DLAPACK_LIBRARIES="${BLASLAPACK_ROOT}/lib/libflapack.a;${LIBGFORTRAN_ROOT}/libgfortran.a;${LIBGFORTRAN_ROOT}/libquadmath.a;${LIBGCC}" \
-	-DNETCDF_EXTRA_LIBS="${NETCDF_EXTRA_LIBS}" \
-	..
-
-# Compile and install
-if [ $# -eq 0 ]; then
-	make
-	make install
-else
-	make -j $1
-	make -j $1 install
-fi
Index: sm/trunk-jpl/externalpackages/gmt/install-6.0-mac.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/gmt/install-6.0-mac.sh	(revision 25744)
+++ 	(revision )
@@ -1,56 +1,0 @@
-#!/bin/bash
-set -eu
-
-
-## Constants
-#
-VER="6.0.0"
-
-CURL_ROOT="${ISSM_DIR}/externalpackages/curl/install"
-
-# Environment
-#
-export CC=mpicc
-
-# Download source
-$ISSM_DIR/scripts/DownloadExternalPackage.sh "https://issm.ess.uci.edu/files/externalpackages/gmt-${VER}.tar.gz" "gmt-${VER}.tar.gz"
-
-# Unpack source
-tar -zxvf gmt-${VER}.tar.gz
-
-# Cleanup
-rm -rf install src
-mkdir install src
-
-# Move source to 'src' directory
-mv gmt-${VER}/* src
-rm -rf gmt-${VER}
-
-# Copy custom configuration files
-cp ./configs/6.0/cmake/ConfigUser.cmake ./src/cmake
-
-# Configure
-cd src
-mkdir build
-cd build
-
-# NOTE:
-# - There is a CMake variable named CURL_ROOT in src/cmake/ConfigUser.cmake
-#	that, ostensibly, allows for supplying the path to curl when it is in a
-#	non-standard location. That said, newer versions of CMake will ignore said
-#	variable and instead try to find curl itself. Passing in the two options
-#	below overrides this behavior.
-#
-cmake \
-	-DCURL_LIBRARY="${CURL_ROOT}/lib" \
-	-DCURL_INCLUDE_DIR="${CURL_ROOT}/include" \
-	..
-
-# Compile and install
-if [ $# -eq 0 ]; then
-	make
-	make install
-else
-	make -j $1
-	make -j $1 install
-fi
Index: /issm/trunk-jpl/externalpackages/netcdf/install-4.7-mac-parallel-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/netcdf/install-4.7-mac-parallel-static.sh	(revision 25744)
+++ /issm/trunk-jpl/externalpackages/netcdf/install-4.7-mac-parallel-static.sh	(revision 25745)
@@ -22,5 +22,4 @@
 VER="4.7.2"
 
-CURL_ROOT="${ISSM_DIR}/externalpackages/curl/install"
 HDF5_ROOT="${ISSM_DIR}/externalpackages/petsc/install"
 ZLIB_ROOT="${ISSM_DIR}/externalpackages/petsc/install"
@@ -29,7 +28,6 @@
 #
 export CC=mpicc
-export CPPFLAGS="-I${CURL_ROOT}/include -I${HDF5_ROOT}/include -I${ZLIB_ROOT}/include"
+export CPPFLAGS="-I${ZLIB_ROOT}/include"
 
-export CURLLIB="${CURL_ROOT}/lib/libcurl.a"
 export HDF5LIB="${HDF5_ROOT}/lib/libhdf5_hl.a ${HDF5_ROOT}/lib/libhdf5.a"
 export ZLIB="${ZLIB_ROOT}/lib/libz.a"
@@ -58,4 +56,5 @@
 	--disable-doxygen \
 	--enable-netcdf4 \
+	--disable-dap \
 	--disable-testsets \
 	--disable-examples \
Index: /issm/trunk-jpl/externalpackages/netcdf/install-4.7-parallel-static-with_tests.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/netcdf/install-4.7-parallel-static-with_tests.sh	(revision 25744)
+++ /issm/trunk-jpl/externalpackages/netcdf/install-4.7-parallel-static-with_tests.sh	(revision 25745)
@@ -22,5 +22,4 @@
 VER="4.7.2"
 
-CURL_ROOT="${ISSM_DIR}/externalpackages/curl/install"
 HDF5_ROOT="${ISSM_DIR}/externalpackages/petsc/install"
 ZLIB_ROOT="${ISSM_DIR}/externalpackages/petsc/install"
@@ -29,6 +28,8 @@
 #
 export CC=mpicc
-export CPPFLAGS="-I${CURL_ROOT}/include -I${HDF5_ROOT}/include -I${ZLIB_ROOT}/include"
-export LIBS="${CURL_ROOT}/lib/libcurl.a ${HDF5_ROOT}/lib/libhdf5_hl.a ${HDF5_ROOT}/lib/libhdf5.a ${ZLIB_ROOT}/lib/libz.a /usr/lib/x86_64-linux-gnu/libssl.a /usr/lib/x86_64-linux-gnu/libcrypto.a -L/usr/lib/x86_64-linux-gnu -ldl"
+export CPPFLAGS="-I${ZLIB_ROOT}/include"
+
+export HDF5LIB="${HDF5_ROOT}/lib/libhdf5_hl.a ${HDF5_ROOT}/lib/libhdf5.a"
+export ZLIB="${ZLIB_ROOT}/lib/libz.a"
 
 # Download source
@@ -55,4 +56,5 @@
 	--disable-doxygen \
 	--enable-netcdf4 \
+	--disable-dap \
 	--disable-examples \
 	--disable-filter-testing \
Index: /issm/trunk-jpl/externalpackages/netcdf/install-4.7-parallel-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/netcdf/install-4.7-parallel-static.sh	(revision 25744)
+++ /issm/trunk-jpl/externalpackages/netcdf/install-4.7-parallel-static.sh	(revision 25745)
@@ -22,5 +22,4 @@
 VER="4.7.2"
 
-CURL_ROOT="${ISSM_DIR}/externalpackages/curl/install"
 HDF5_ROOT="${ISSM_DIR}/externalpackages/petsc/install"
 ZLIB_ROOT="${ISSM_DIR}/externalpackages/petsc/install"
@@ -29,6 +28,8 @@
 #
 export CC=mpicc
-export CPPFLAGS="-I${CURL_ROOT}/include -I${HDF5_ROOT}/include -I${ZLIB_ROOT}/include"
-export LIBS="${CURL_ROOT}/lib/libcurl.a ${HDF5_ROOT}/lib/libhdf5_hl.a ${HDF5_ROOT}/lib/libhdf5.a ${ZLIB_ROOT}/lib/libz.a /usr/lib/x86_64-linux-gnu/libssl.a /usr/lib/x86_64-linux-gnu/libcrypto.a -L/usr/lib/x86_64-linux-gnu -ldl"
+export CPPFLAGS="-I${ZLIB_ROOT}/include"
+
+export HDF5LIB="${HDF5_ROOT}/lib/libhdf5_hl.a ${HDF5_ROOT}/lib/libhdf5.a"
+export ZLIB="${ZLIB_ROOT}/lib/libz.a"
 
 # Download source
@@ -55,4 +56,5 @@
 	--disable-doxygen \
 	--enable-netcdf4 \
+	--disable-dap \
 	--disable-testsets \
 	--disable-examples \
Index: sm/trunk-jpl/externalpackages/petsc/install-3.12-mac-solid_earth-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/petsc/install-3.12-mac-solid_earth-static.sh	(revision 25744)
+++ 	(revision )
@@ -1,65 +1,0 @@
-#!/bin/bash
-set -eu
-
-
-## Constants
-#
-VER="3.12.3"
-
-# Download source
-$ISSM_DIR/scripts/DownloadExternalPackage.sh "https://issm.ess.uci.edu/files/externalpackages/petsc-lite-${VER}.tar.gz" "petsc-${VER}.tar.gz"
-
-# Unpack source
-tar -zxvf petsc-${VER}.tar.gz
-
-# Cleanup
-rm -rf install src
-mkdir install src
-
-# Move source to 'src' directory
-mv petsc-${VER}/* src/
-rm -rf petsc-${VER}
-
-# Configure
-#
-# NOTE: 
-# - Cannot use --with-fpic option when compiling static libs,
-#
-#		Cannot determine compiler PIC flags if shared libraries is turned off
-#		Either run using --with-shared-libraries or --with-pic=0 and supply the
-#		compiler PIC flag via CFLAGS, CXXXFLAGS, and FCFLAGS
-#
-# - Added -fallow-argument-mismatch to FFLAGS in order to clear,
-#
-#		error: The Fortran compiler gfortran will not compile files that call 
-#		the same routine with arguments of different types.
-#
-#	This has only been added to macOS static builds, but may be needed 
-#	elsewhere.
-# - Added -static-libgfortran to all macOS static builds, but this will not 
-#	work out of the box on Linux.
-#
-cd src
-./config/configure.py \
-	--prefix="${ISSM_DIR}/externalpackages/petsc/install" \
-	--PETSC_DIR="${ISSM_DIR}/externalpackages/petsc/src" \
-	--with-shared-libraries=0 \
-	--CFLAGS="-fPIC" \
-	--CXXFLAGS="-fPIC" \
-	--FFLAGS="-fPIC -fallow-argument-mismatch -static-libgfortran" \
-	--with-debugging=0 \
-	--with-valgrind=0 \
-	--with-x=0 \
-	--with-ssl=0 \
-	--download-fblaslapack=1 \
-	--download-mpich=1 \
-	--download-metis=1 \
-	--download-parmetis=1 \
-	--download-scalapack=1 \
-	--download-mumps=1 \
-	--download-zlib=1 \
-	--download-hdf5=1
-
-# Compile and install
-make
-make install
Index: /issm/trunk-jpl/externalpackages/petsc/install-3.12-mac-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/petsc/install-3.12-mac-static.sh	(revision 25744)
+++ /issm/trunk-jpl/externalpackages/petsc/install-3.12-mac-static.sh	(revision 25745)
@@ -29,5 +29,6 @@
 #		Either run using --with-shared-libraries or --with-pic=0 and supply the
 #		compiler PIC flag via CFLAGS, CXXXFLAGS, and FCFLAGS
-#
+# - Added -Wno-error=implicit-function-declaration to CFLAGS for Clang >= 12. 
+#	May need to remove it for earlier versions not using the C99 standard.
 # - Added -fallow-argument-mismatch to FFLAGS in order to clear,
 #
@@ -45,5 +46,5 @@
 	--PETSC_DIR="${ISSM_DIR}/externalpackages/petsc/src" \
 	--with-shared-libraries=0 \
-	--CFLAGS="-fPIC" \
+	--CFLAGS="-fPIC -Wno-error=implicit-function-declaration" \
 	--CXXFLAGS="-fPIC" \
 	--FFLAGS="-fPIC -fallow-argument-mismatch -static-libgfortran" \
@@ -57,5 +58,7 @@
 	--download-parmetis=1 \
 	--download-scalapack=1 \
-	--download-mumps=1
+	--download-mumps=1 \
+	--download-zlib=1 \
+	--download-hdf5=1
 
 # Compile and install
Index: /issm/trunk-jpl/externalpackages/proj/install-6.2-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/proj/install-6.2-static.sh	(revision 25744)
+++ /issm/trunk-jpl/externalpackages/proj/install-6.2-static.sh	(revision 25745)
@@ -7,5 +7,5 @@
 VER="6.2.1"
 
-## Environnment
+## Environment
 #
 export CC=mpicc
Index: /issm/trunk-jpl/jenkins/debian_linux-valgrind
===================================================================
--- /issm/trunk-jpl/jenkins/debian_linux-valgrind	(revision 25745)
+++ /issm/trunk-jpl/jenkins/debian_linux-valgrind	(revision 25745)
@@ -0,0 +1,85 @@
+# NOTE: This configuration can be used to debug, with Valgrind, builds that 
+#		require Boost.
+
+#--------------------#
+# ISSM Configuration #
+#--------------------#
+
+MATLAB_PATH="/usr/local/MATLAB/R2019b"
+
+ISSM_CONFIG='\
+	--prefix=${ISSM_DIR} \
+	--disable-static \
+	--enable-development \
+	--enable-debugging \
+	--with-numthreads=4 \
+	--with-matlab-dir=${MATLAB_PATH} \
+	--with-python-dir=/usr \
+	--with-python-numpy-dir=/usr/local/lib/python2.7/dist-packages/numpy \
+	--with-fortran-lib="-L/usr/lib/x86_64-linux-gnu -lgfortran" \
+	--with-mpi-include=${ISSM_DIR}/externalpackages/petsc/install/include \
+	--with-mpi-libflags="-L${ISSM_DIR}/externalpackages/petsc/install/lib -lmpi -lmpicxx -lmpifort" \
+	--with-blas-lapack-dir=${ISSM_DIR}/externalpackages/petsc/install \
+	--with-metis-dir=${ISSM_DIR}/externalpackages/petsc/install \
+	--with-scalapack-dir=${ISSM_DIR}/externalpackages/petsc/install \
+	--with-mumps-dir=${ISSM_DIR}/externalpackages/petsc/install \
+	--with-hdf5-dir=${ISSM_DIR}/externalpackages/petsc/install \
+	--with-petsc-dir=${ISSM_DIR}/externalpackages/petsc/install \
+	--with-gsl-dir=${ISSM_DIR}/externalpackages/gsl/install \
+	--with-boost-dir=${ISSM_DIR}/externalpackages/boost/install \
+	--with-dakota-dir=${ISSM_DIR}/externalpackages/dakota/install \
+	--with-triangle-dir=${ISSM_DIR}/externalpackages/triangle/install \
+	--with-chaco-dir=${ISSM_DIR}/externalpackages/chaco/install \
+	--with-m1qn3-dir=${ISSM_DIR}/externalpackages/m1qn3/install \
+	--with-semic-dir=${ISSM_DIR}/externalpackages/semic/install \
+'
+
+#-------------------#
+# External Packages #
+#-------------------#
+
+EXTERNALPACKAGES="
+	autotools	install-debian-linux.sh
+	cmake		install.sh
+	petsc		install-3.14-linux.sh
+	gsl			install.sh
+	boost		install-1.7-linux-valgrind.sh
+	dakota		install-6.2-linux.sh
+	curl		install-7.67.sh
+	netcdf		install-4.7-parallel.sh
+	proj		install-6.2.sh
+	gdal		install-3-python-netcdf.sh
+	gshhg		install.sh
+	gmt			install-6.0-linux.sh
+	gmsh		install-4.sh
+	triangle	install-linux.sh
+	chaco		install.sh
+	m1qn3		install.sh
+	semic		install.sh
+	valgrind	install-linux.sh
+	shell2junit	install.sh
+"
+
+#---------#
+# Testing #
+#---------#
+
+# Test suites
+MATLAB_TEST=0
+PYTHON_TEST=0
+JAVASCRIPT_TEST=0
+EXAMPLES_TEST=0
+
+# Number of CPUs used in ISSM compilation
+#
+# NOTE: One is usually safer as some packages are very sensitive to parallel
+# 		compilation
+#
+NUMCPUS_INSTALL=8
+
+# Number of CPUs used in the nightly runs
+NUMCPUS_RUN=1
+
+# Nightly run options
+MATLAB_NROPTIONS=""
+PYTHON_NROPTIONS=""
Index: /issm/trunk-jpl/jenkins/pine_island-mac-binaries-matlab
===================================================================
--- /issm/trunk-jpl/jenkins/pine_island-mac-binaries-matlab	(revision 25744)
+++ /issm/trunk-jpl/jenkins/pine_island-mac-binaries-matlab	(revision 25745)
@@ -3,5 +3,6 @@
 #--------------------#
 
-MATLAB_PATH="/Applications/MATLAB_R2018a.app"
+# MATLAB path
+MATLAB_PATH="/Applications/MATLAB_R2019b.app"
 
 # NOTE:
@@ -10,4 +11,5 @@
 #
 
+# ISSM CONFIGURATION
 ISSM_CONFIG='\
 	--prefix=${ISSM_DIR} \
@@ -34,10 +36,4 @@
 	--with-semic-dir=${ISSM_DIR}/externalpackages/semic/install \
 '
-
-# Test suites
-MATLAB_TEST=0
-PYTHON_TEST=0
-JAVASCRIPT_TEST=0
-EXAMPLES_TEST=0
 
 #-------------------#
@@ -69,4 +65,10 @@
 #---------#
 
+# Test suites
+MATLAB_TEST=0
+PYTHON_TEST=0
+JAVASCRIPT_TEST=0
+EXAMPLES_TEST=0
+
 # Number of CPUs used in ISSM compilation
 #
@@ -74,5 +76,5 @@
 # 		compilation
 #
-NUMCPUS_INSTALL=4
+NUMCPUS_INSTALL=8
 
 # Number of CPUs used in the nightly runs
Index: /issm/trunk-jpl/jenkins/pine_island-mac-binaries-python
===================================================================
--- /issm/trunk-jpl/jenkins/pine_island-mac-binaries-python	(revision 25745)
+++ /issm/trunk-jpl/jenkins/pine_island-mac-binaries-python	(revision 25745)
@@ -0,0 +1,87 @@
+#--------------------#
+# ISSM Configuration #
+#--------------------#
+
+# NOTE:
+# - We can disable dependency tracking in the Autotools because the binaries
+#	should always be a one-time build.
+#
+
+# ISSM CONFIGURATION
+ISSM_CONFIG='\
+	--prefix=${ISSM_DIR} \
+	--enable-standalone-executables \
+	--enable-standalone-modules \
+	--enable-standalone-libraries \
+	--disable-dependency-tracking \
+	--with-python-dir=/System/Library/Frameworks/Python.framework/Versions/2.7 \
+	--with-python-numpy-dir=/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy \
+	--with-fortran-lib="/usr/local/Cellar/gcc/10.2.0/lib/gcc/10/libgfortran.a /usr/local/Cellar/gcc/10.2.0/lib/gcc/10/libquadmath.a /usr/local/Cellar/gcc/10.2.0/lib/gcc/10/gcc/x86_64-apple-darwin19/10.2.0/libgcc.a" \
+	--with-mpi-include=${ISSM_DIR}/externalpackages/petsc/install/include \
+	--with-mpi-libflags="-L${ISSM_DIR}/externalpackages/petsc/install/lib -lmpi -lmpicxx -lmpifort" \
+	--with-blas-lapack-dir=${ISSM_DIR}/externalpackages/petsc/install \
+	--with-metis-dir=${ISSM_DIR}/externalpackages/petsc/install \
+	--with-scalapack-dir=${ISSM_DIR}/externalpackages/petsc/install \
+	--with-mumps-dir=${ISSM_DIR}/externalpackages/petsc/install \
+	--with-hdf5-dir=${ISSM_DIR}/externalpackages/petsc/install \
+	--with-petsc-dir=${ISSM_DIR}/externalpackages/petsc/install \
+	--with-gsl-dir=${ISSM_DIR}/externalpackages/gsl/install \
+	--with-boost-dir=${ISSM_DIR}/externalpackages/boost/install \
+	--with-dakota-dir=${ISSM_DIR}/externalpackages/dakota/install \
+	--with-triangle-dir=${ISSM_DIR}/externalpackages/triangle/install \
+	--with-chaco-dir=${ISSM_DIR}/externalpackages/chaco/install \
+	--with-m1qn3-dir=${ISSM_DIR}/externalpackages/m1qn3/install \
+	--with-semic-dir=${ISSM_DIR}/externalpackages/semic/install \
+'
+
+#-------------------#
+# External Packages #
+#-------------------#
+
+EXTERNALPACKAGES="
+	autotools	install.sh
+	cmake		install.sh
+	petsc		install-3.12-mac-static.sh
+	gsl			install-static.sh
+	boost		install-1.7-mac-static.sh
+	dakota		install-6.2-mac-static.sh
+	curl		install-7.67-static.sh
+	netcdf		install-4.7-mac-parallel-static.sh
+	proj		install-6.2-static.sh
+	gdal		install-3-python-netcdf-static.sh
+	gshhg		install.sh
+	gmt			install-6-mac-static.sh
+	gmsh		install-4-mac-python-static.sh
+	triangle	install-mac-static.sh
+	chaco		install.sh
+	m1qn3		install.sh
+	semic		install.sh
+	shell2junit	install.sh
+"
+
+#---------#
+# Testing #
+#---------#
+
+# Test suites
+MATLAB_TEST=0
+PYTHON_TEST=0
+JAVASCRIPT_TEST=0
+EXAMPLES_TEST=0
+
+# Number of CPUs used in ISSM compilation
+#
+# NOTE: One is usually safer as some packages are very sensitive to parallel
+# 		compilation
+#
+NUMCPUS_INSTALL=8
+
+# Number of CPUs used in the nightly runs
+NUMCPUS_RUN=1
+
+# Nightly run options
+#
+# See documentation in test/NightlyRun/runme.* for more information.
+#
+PYTHON_NROPTIONS=""
+MATLAB_NROPTIONS=""
Index: sm/trunk-jpl/jenkins/ross-debian_linux-valgrind
===================================================================
--- /issm/trunk-jpl/jenkins/ross-debian_linux-valgrind	(revision 25744)
+++ 	(revision )
@@ -1,85 +1,0 @@
-# NOTE: This configuration can be used to debug, with Valgrind, builds that 
-#		require Boost.
-
-#--------------------#
-# ISSM Configuration #
-#--------------------#
-
-MATLAB_PATH="/usr/local/MATLAB/R2019b"
-
-ISSM_CONFIG='\
-	--prefix=${ISSM_DIR} \
-	--disable-static \
-	--enable-development \
-	--enable-debugging \
-	--with-numthreads=4 \
-	--with-matlab-dir=${MATLAB_PATH} \
-	--with-python-dir=/usr \
-	--with-python-numpy-dir=/usr/local/lib/python2.7/dist-packages/numpy \
-	--with-fortran-lib="-L/usr/lib/x86_64-linux-gnu -lgfortran" \
-	--with-mpi-include=${ISSM_DIR}/externalpackages/petsc/install/include \
-	--with-mpi-libflags="-L${ISSM_DIR}/externalpackages/petsc/install/lib -lmpi -lmpicxx -lmpifort" \
-	--with-blas-lapack-dir=${ISSM_DIR}/externalpackages/petsc/install \
-	--with-metis-dir=${ISSM_DIR}/externalpackages/petsc/install \
-	--with-scalapack-dir=${ISSM_DIR}/externalpackages/petsc/install \
-	--with-mumps-dir=${ISSM_DIR}/externalpackages/petsc/install \
-	--with-hdf5-dir=${ISSM_DIR}/externalpackages/petsc/install \
-	--with-petsc-dir=${ISSM_DIR}/externalpackages/petsc/install \
-	--with-gsl-dir=${ISSM_DIR}/externalpackages/gsl/install \
-	--with-boost-dir=${ISSM_DIR}/externalpackages/boost/install \
-	--with-dakota-dir=${ISSM_DIR}/externalpackages/dakota/install \
-	--with-triangle-dir=${ISSM_DIR}/externalpackages/triangle/install \
-	--with-chaco-dir=${ISSM_DIR}/externalpackages/chaco/install \
-	--with-m1qn3-dir=${ISSM_DIR}/externalpackages/m1qn3/install \
-	--with-semic-dir=${ISSM_DIR}/externalpackages/semic/install \
-'
-
-#-------------------#
-# External Packages #
-#-------------------#
-
-EXTERNALPACKAGES="
-	autotools	install-debian-linux.sh
-	cmake		install.sh
-	petsc		install-3.14-linux.sh
-	gsl			install.sh
-	boost		install-1.7-linux-valgrind.sh
-	dakota		install-6.2-linux.sh
-	curl		install-7.67.sh
-	netcdf		install-4.7-parallel.sh
-	proj		install-6.2.sh
-	gdal		install-3-python-netcdf.sh
-	gshhg		install.sh
-	gmt			install-6.0-linux.sh
-	gmsh		install-4.sh
-	triangle	install-linux.sh
-	chaco		install.sh
-	m1qn3		install.sh
-	semic		install.sh
-	valgrind	install-linux.sh
-	shell2junit	install.sh
-"
-
-#---------#
-# Testing #
-#---------#
-
-# Test suites
-MATLAB_TEST=0
-PYTHON_TEST=0
-JAVASCRIPT_TEST=0
-EXAMPLES_TEST=0
-
-# Number of CPUs used in ISSM compilation
-#
-# NOTE: One is usually safer as some packages are very sensitive to parallel
-# 		compilation.
-#
-NUMCPUS_INSTALL=8
-
-# Number of CPUs used in the nightly runs
-NUMCPUS_RUN=1
-
-# Nightly run options
-MATLAB_NROPTIONS=""
-PYTHON_NROPTIONS=""
