1dnl Configure migrate version 3.1 and newer
2dnl Process this file with autoconf to produce a configure script.
3dnl @MIGRATEVERSION@
4dnl @prefix@
5dnl @ARCH@
6dnl @MACOSVERSION@
7dnl @SYSTEM@
8dnl @SYSTEMVERSION@
9dnl @EXCEPTION@
10dnl @STDCPLUS@
11dnl @CC@
12dnl @CXX@
13dnl @INSTALL@
14dnl @TAR@
15dnl @MPICC@
16dnl @GMAKE@
17dnl @CPUTYPE@
18dnl @OSTYPE@
19dnl @MT_FILES@
20dnl @HARDWARECFLAGS@
21dnl @PAPERFORMAT@
22dnl @THREADCFLAGS@
23dnl @LIBS@
24dnl @THREADLIB@
25dnl @RANDOMLIBS@
26dnl Check for a file in the source
27AC_INIT(main.c)
28dnl Checks for system and operating system.
29AC_CANONICAL_SYSTEM
30AC_SUBST(CPUTYPE)
31CPUTYPE="$host_cpu"
32AC_SUBST(OSTYPE)
33OSTYPE="$host_os"
34AC_SUBST(MIGRATESUBVERSION)
35
36`(svn info | grep Revision | awk '{printf "%s\n",\$2}' > MIGRATE_SUBVERSION) 2>1 > /dev/null`
37MIGRATESUBVERSION=`head -1 MIGRATE_SUBVERSION`;
38#
39#MIGRATESUBVERSION=`svn info | grep Revision | awk '{printf "%s",\$2}'`;
40#echo "If the svn call fails no action needs to be taken, "
41#echo "it checks the migrate subversion number"
42#echo "on my system when I produce binaries"
43#echo "Migrate subversion = $MIGRATESUBVERSION"
44USERFLAGS=" "
45USERFLAGS+=$CFLAGS
46#echo "Userflags          = $USERFLAGS"
47dnl Checks for programs.
48AC_SUBST(CFLAGS)
49
50dnl to allow the PDF subsystem (haru) to compile using gmake
51AC_CHECK_PROG(GMAKE, gmake, gmake, make)
52
53dnl to allow the PDF subsystem (haru) to compile the correct makefile.SYSTEM
54OS=`uname -s`
55#echo $OS
56case $OS in
57     Linux) SYSTEM="gcc";
58     	    SYSTEMVERSION="";
59	    CPUINFO="egrep  'name|GHz|MHz' /proc/cpuinfo";;
60     Darwin) SYSTEM="osx";
61	    CPUINFO="sysctl machdep.cpu.brand_string";
62     	     SYSTEMVERSION=`sw_vers | grep ProductVersion | awk '{ printf "%s", $2 }' | tr -d "." |  awk '{if(substr($1,1,3)+0.0 > 105) { printf "-DGRANDCENTRAL"}}'`;;
63esac
64
65AC_SUBST(SYSTEM)
66AC_SUBST(CPUINFO)
67echo "=======================================================================";
68echo "Migrate subversion: $MIGRATESUBVERSION"
69echo "Hardware: $host_vendor"
70echo "System OS: $host_os  $OS  $SYSTEMVERSION"
71echo "System CPU: $host_cpu"
72echo "-----------------------------------------------------------------------"
73
74dnl to allow for compilers that fail to recognize -fexceptions
75AC_SUBST(EXCEPTION)
76dnl to allow for compilers that use -lstdc++ or not
77AC_SUBST(STDCPLUS)
78AC_PROG_CC(gcc icc pgcc cc)
79AC_PROG_CXX(g++ xlC cxx cc++ aCC c++ )
80case $CC in
81             gcc) EXCEPTION="-fexceptions";
82		  STDCPLUS="-lstdc++";
83	     	  case "$host_vendor" in
84	     	  apple) CFLAGS="-O3 -fvectorize  -funroll-loops -D$CPUTYPE" ;
85	     	  SYSTEM="osx";;
86	     	  *) CFLAGS="-O3  -funroll-loops -fomit-frame-pointer  -falign-loops=16  -D$CPUTYPE" ;
87	     	  SYSTEM="gcc";;
88	     	  esac ;;
89     	     pgcc) CFLAGS="-B -fast ";
90	     	  SYSTEM="gcc";;
91#            icc)  CFLAGS=" -O3 -tpp7 -xKW -pad -ip ";
92             icc)  CFLAGS+=" -fast ";
93	     	  SYSTEM="icc";;
94             cc)   case "$host_vendor" in
95                   ibm) CFLAGS="-O3 -Dinline='/*inline*/' -q cpluscmt -DIBM";
96	     	         SYSTEM="aixcc";;
97                   *)   CFLAGS="-O " ;
98	     	        SYSTEM="gcc";;
99             esac;;
100	     xlc) CFLAGS="-O3  -Dinline='/*inline*/' -q cpluscmt -DIBM";
101	     	  SYSTEM="aixcc";;
102	     xlc_r) CFLAGS="-O3  -Dinline='/*inline*/' -q cpluscmt -DIBM";
103	     	  SYSTEM="aixcc";;
104	     xlC) CFLAGS="-O3  -Dinline='/*inline*/' -q cpluscmt -DIBM";
105	     	  SYSTEM="aixcc";;
106	     xlC_r) CFLAGS="-O3  -Dinline='/*inline*/' -q cpluscmt -DIBM";
107	     	  SYSTEM="aixcc";;
108esac
109CFLAGS+=$USERFLAGS
110echo "C-compiler:  $CC"
111echo "C++-compiler:$CXX"
112echo "CFLAGS: $CFLAGS"
113echo "=======================================================================";
114
115AC_PROG_INSTALL
116dnl Checks for libraries.
117AC_SUBST(RANDOMCFLAGS)
118AC_SUBST(RANDOMLIBS)
119
120RANDOMLIBS=" "
121RANDOMCFLAG=" "
122AC_SUBST(TAR)
123TAR="tar"
124AC_SUBST(THREADCFLAGS)
125AC_SUBST(THREADLIB)
126THREADLIBS=" "
127case "`$ac_config_guess`" in
128	powerpc-apple-darwin*) LIBS=""; TAR="gnutar";;
129	*) ;;
130esac
131
132AC_CHECK_LIB(pthread, pthread_create, [
133        pthreadlib=yes
134        pthreadlib="-lpthread" ])
135if test -n "$pthreadlib"; then
136	THREADLIB="$pthreadlib"
137fi
138savelibs=$LIBS
139AC_SUBST(MPICC)
140AC_CHECK_LIB(mpi,MPI_Init)
141
142case "`$ac_config_guess`" in
143	powerpc-apple-darwin*) MPICC="mpicc";;
144	*aix*) MPICC="mpcc_r";;
145	*) MPICC=mpicc;;
146esac
147LIBS=$savelibs
148
149AC_CHECK_LIB(m, exp)
150
151
152dnl Checks for header files.
153AC_CONFIG_HEADER(conf.h)
154AC_HEADER_STDC
155AC_CHECK_HEADERS(limits.h strings.h)
156
157if test -n "$pthreadlib"; then
158	AC_CHECK_HEADERS(pthread.h,THREADCFLAGS="-D_REENTRANT -DPTHREADS")
159fi
160
161
162case "`$ac_config_guess`" in
163	powerpc-apple-darwin*) 	AC_CHECK_HEADERS(pthread.h,THREADCFLAGS="-D_REENTRANT -DPTHREADS");;
164	*) ;;
165esac
166
167dnl Checks for typedefs, structures, and compiler characteristics.
168AC_C_CONST
169AC_TYPE_SIZE_T
170AC_CHECK_TYPE(int, long)
171AC_STRUCT_TM
172AC_C_INLINE
173
174dnl Checks for library functions.
175AC_TYPE_SIGNAL
176AC_FUNC_STRFTIME
177AC_CHECK_FUNCS(strcspn)
178AC_CHECK_FUNCS(strsep)
179
180case "`$ac_config_guess`" in
181        *aix*) ;;
182        *) AC_CHECK_FUNCS(lgamma);;
183esac
184
185dnl checking for architecture settings
186AC_SUBST(ARCH)
187ARCH=""
188AC_ARG_ENABLE(allmac,
189  [AS_HELP_STRING([--enable-allmac], [enable Macintosh architectures: intel, intel64])],
190  have_allmac=$enableval, have_allmac=no)
191
192AC_ARG_ENABLE(macintel,
193  [AS_HELP_STRING([--enable-macintel], [enable Macintosh architectures: intel, intel64])],
194  have_macintel=$enableval, have_macintel=no)
195
196AC_SUBST(MACOSVERSION)
197MACOSVERSION=""
198
199if test "$have_allmac" = "yes"; then
200  AC_DEFINE(HAVE_ALLMAC, 1, [Define to enable multiple architectures])
201  ARCH=" -arch x86_64 "
202  MACOSVERSION=" -mmacosx-version-min=10.6"
203  CPUTYPE="Intel"
204  OSTYPE="MacOS10.6"
205fi
206
207if test "$have_macintel" = "yes"; then
208  AC_DEFINE(HAVE_MACINTEL, 1, [Define to enable multiple architectures])
209  ARCH=" -arch x86_64 "
210  MACOSVERSION=" -mmacosx-version-min=10.6"
211  CPUTYPE="Intel"
212  OSTYPE="MacOS10.6"
213fi
214
215
216dnl replacing system version
217AC_SUBST(SYSTEMVERSION)
218
219
220dnl the user can choose which zlib to use
221AC_ARG_WITH(
222	[zlib],
223	AS_HELP_STRING([--with-zlib=shipped|system|no],[Specify the zlib to use, shipped or system. Default is to autodetect system and fallback to shipped.]),
224	[[zlib=$withval]],
225	[[zlib=detect]]
226)
227
228dnl Check the value for the --with-zlib switch
229AC_MSG_CHECKING([which zlib implementation to use])
230case "$zlib" in
231     "detect")
232	AC_MSG_RESULT([autodetect])
233	AC_CHECK_LIB(z, main,
234		[zlib="system"],
235		[zlib="shipped"]
236	)
237	;;
238     "shipped")
239	AC_MSG_RESULT(shipped)
240	(cd zlib;configure -static)
241	;;
242     "system")
243	AC_MSG_RESULT(system)
244	AC_CHECK_LIB(z, main, [zlib="system"],
245        		AC_MSG_ERROR([migrate did not find zlib on your system])
246	)
247	;;
248      "no")
249	AC_MSG_RESULT(none)
250	#AC_MSG_ERROR([migrate setting changed so that no compression is available])
251        ;;
252      *)
253	AC_MSG_RESULT()
254	AC_MSG_ERROR([Unknown zlib option "$zlib". Use either "system" or "shipped".])
255	;;
256esac
257if [[ "$zlib" = "shipped" ]]; then
258   ZLIB="-lz"
259   ZLIBDIR="-Lzlib"
260   ZLIBINCL="-Izlib"
261   ZLIBHARUINCL="-I../zlib"
262   ZLIBTARGET="zlib"
263   NOZLIB=""
264   HAVE_ZNZ=" -DHAVE_ZLIB -DZNZ"
265#   AC_CONFIG_FILES(zlib/Makefile)
266elif [[ "$zlib" = "system" ]]; then
267     ZLIB="-lz"
268     ZLIBDIR=""
269     ZLIBINCL=""
270     ZLIBHARUINCL=""
271     ZLIBTARGET="zlibsystem"
272     NOZLIB=""
273     HAVE_ZNZ=" -DHAVE_ZLIB -DZNZ"
274     AC_CHECK_FUNCS(gzbuffer)
275elif [[ "$zlib" = "no" ]]; then
276     ZLIB=""
277     ZLIBDIR=""
278     ZLIBINCL=""
279     ZLIBHARUINCL=""
280     ZLIBTARGET=""
281     NOZLIB="-DNOZLIB"
282     HAVE_ZNZ=""
283fi
284
285dnl make ZLIB and ZLIBDIR visible to Makefiles
286AC_SUBST([ZLIBTARGET])
287AC_SUBST([ZLIB])
288AC_SUBST([ZLIBDIR])
289AC_SUBST([ZLIBINCL])
290AC_SUBST([ZLIBHARUINCL])
291AC_SUBST([NOZLIB])
292AC_SUBST([HAVE_ZNZ])
293
294dnl checking for SSE2 or ALTIVEC
295AC_SUBST(HARDWARECFLAGS)
296HARDWARECFLAGS=""
297AC_ARG_ENABLE(sse2,
298  [AS_HELP_STRING([--enable-sse2], [enable SSE2 optimizations for random number generator])],
299  have_sse2=$enableval, have_sse2=no)
300
301AC_ARG_ENABLE(altivec,
302  [AS_HELP_STRING([--enable-altivec], [enable Altivec optimizations for random number generator])],
303  have_altivec=$enableval, have_altivec=no)
304
305if test "$have_allmac" = "no"; then
306if test "$have_sse2" = "yes"; then
307  AC_DEFINE(HAVE_SSE2, 1, [Define to enable SSE2 optimizations])
308  HARDWARECFLAGS="-msse2 -DSSE2"
309fi
310
311if test "$have_altivec" = "yes"; then
312  AC_DEFINE(HAVE_ALTIVEC, 1, [Define to enable Altivec optimizations.])
313  HARDWARECFLAGS=" -faltivec -maltivec"
314fi
315fi
316
317dnl substitute which files to compile for mersenne twister
318AC_SUBST(MT_FILES)
319MT_FILES="SFMT.c"
320# SFMT.h SFMT-params19937.h"
321if test "$have_sse2" = "yes"; then
322MT_FILES="SFMT.c"
323# SFMT.h SFMT-sse2.h SFMT-sse2.c"
324fi
325if test "$have_altivec" = "yes"; then
326MT_FILES="SFMT.c"
327# SFMT.h SFMT-alti.h SFMT-alti.c"
328fi
329#echo "Copying source from Mersenne-Twister directory into main source directory"
330sh copy_mt_to_src
331
332AC_SUBST(PAPERFORMAT)
333PAPERFORMAT="-DLETTERPAPER"
334AC_ARG_ENABLE(A4,
335  [AS_HELP_STRING([--enable-A4], [use A4 paper format for PDF outputfile -- Default is Letter paper format])],
336  have_A4=$enableval, have_A4=no)
337
338if test "$have_A4" = "yes"; then
339  PAPERFORMAT="-DA4PAPER"
340fi
341
342
343
344
345AC_OUTPUT(Makefile)
346echo " "
347echo " MIGRATE-N is now setup"
348echo " to compile the program you need to type one of the"
349echo " commands below (ordered by preference):"
350echo " "
351echo " SINGLE CPU machines "
352echo "     make           # with PDF output support"
353echo "                    # this might fail on first attempt,"
354echo "                    # if the make fails, please let me know"
355echo "                    # often linking fails because the C++ pdf library"
356echo "                    # and the core migrate parts (C) mismatch"
357echo "                    # check the Makefile line for STDLIB= -lstdc++"
358echo " "
359echo " SMP machines  [more than 1 CPU in machine] "
360echo "     make thread    # uses the thread library if present"
361echo "     make           # on macs running macos 10.6+ using GrandCentral"
362echo " "
363echo " PARALLEL Computers, Clusters with MPI software "
364echo "     make mpis        # each cpu-core can be treated as a node"
365echo "     make mpis-thread # experimental, may increase load per node!"
366echo "------------------------------------------------------------------------"
367echo "SPEED and other TESTING "
368echo "    the migrate website contains a testsuite.tar.gz that has"
369echo "    many tests for single, parallel and thread compilations"
370echo "    the tests are driven by a python script rt (see the README"
371echo "    in the testsuite) and a submit script that allows to streamline"
372echo "    submissions to a batch queue system, currently supported systems"
373echo "    are SUN/ORACLE GRIDENGINE, TORQUE/MOAB, and NONE"
374echo "------------------------------------------------------------------------"
375echo "In case there are problems with the compile send a message to the "
376echo "migrate-support@google.com usergroup, include a log of"
377echo "   ./configure"
378echo "   make"
379echo "=======================================================================";
380
381
382
383
384
385
386
387
388
389
390