root/cgm/acsite.m4 @ 1040

Revision 1040, 26.5 KB (checked in by tautges, 2 years ago)

Version 10.2 of cgm.

Line 
1#######################################################################################
2# Implement checks for C and C++ compilers, with all corresponding options
3#
4# Sets the following variables:
5#  CPP      - The C preprocessor
6#  CC       - The C compiler
7#  CXX      - The C++ compiler
8#  CFLAGS   - C compiler flags
9#  CXXFLAGS - C++ compiler flags
10#  WITH_MPI - 'yes' if parallel support, 'no' otherwise
11#
12#######################################################################################
13AC_DEFUN([SNL_CHECK_COMPILERS], [
14
15  # Save these before calling AC_PROG_CC or AC_PROG_CXX
16  # because those macros will modify them, and we want
17  # the original user values, not the autoconf defaults.
18USER_CXXFLAGS="$CXXFLAGS"
19USER_CCFLAGS="$CFLAGS"
20
21  # Check for Parallel
22  # Need to check this early so we can look for the correct compiler
23AC_ARG_WITH( [mpi], AC_HELP_STRING([[--with-mpi(=DIR)]], [Enable parallel support]),
24             [WITH_MPI=$withval],[WITH_MPI=no] )
25case "x$WITH_MPI" in
26  xno)
27    CC_LIST="cc gcc cl egcs"
28    CXX_LIST="CC aCC cxx xlC_r xlC pgCC c++ g++ gpp cc++ cl FCC KCC RCC"
29    ;;
30  xyes)
31    CC_LIST="mpicc mpcc"
32    CXX_LIST="mpiCC mpCC mpicxx"
33    ;;
34  x*)
35    if test -z "$CC";then
36      for prog in mpicc mpcc; do
37        if test -x ${WITH_MPI}/bin/$prog; then
38          CC="${WITH_MPI}/bin/$prog"
39          CC_LIST="$prog"
40        fi
41      done
42    else
43      CC_LIST="$CC"
44    fi
45    if test -z "$CXX";then
46      for prog in mpicxx mpiCC mpCC; do
47        if test -x ${WITH_MPI}/bin/$prog; then
48          CXX="${WITH_MPI}/bin/$prog"
49          CXX_LIST="$prog"
50        fi
51      done
52    else
53      CXX_LIST="$CXX"
54    fi
55    WITH_MPI=yes
56    ;;
57esac
58AC_PROG_CC( [$CC_LIST] )
59AC_PROG_CPP
60AC_PROG_CXX( [$CXX_LIST] )
61AC_PROG_CXXCPP
62
63# Try to determine compiler-specific flags.  This must be done
64# before setting up libtool so that it can override libtool settings.
65SNL_CC_FLAGS
66SNL_CXX_FLAGS
67CFLAGS="$USER_CFLAGS $SNL_CC_SPECIAL"
68CXXFLAGS="$USER_CXXFLAGS $SNL_CXX_SPECIAL"
69
70# On IBM/AIX, the check for OBJEXT fails for the mpcc compiler.
71# (Comment out this hack, it should be fixed correctly now)
72#if test "x$OBJEXT" = "x"; then
73#  OBJEXT=o
74#fi
75
76  # Check for debug flags
77AC_ARG_ENABLE( debug, AC_HELP_STRING([--enable-debug],[Debug symbols (-g)]),
78               [enable_debug=$enableval], [enable_debug=] ) 
79AC_ARG_ENABLE( optimize, AC_HELP_STRING([--enable-optimize],[Compile optimized (-O2)]),
80               [enable_cxx_optimize=$enableval
81                enable_cc_optimize=$enableval],
82               [enable_cxx_optimize=
83                enable_cc_optimize=] )
84
85# Do enable_optimize by default, unless user has specified
86# custom CXXFLAGS or CFLAGS
87if test "x$enable_debug" = "x"; then
88  if test "x$enable_cxx_optimize" = "x"; then
89    if test "x$USER_CXXFLAGS" = "x"; then
90      enable_cxx_optimize=yes
91    fi
92  fi
93  if test "x$enable_cc_optimize" = "x"; then
94    if test "x$USER_CFLAGS" = "x"; then
95      enable_cc_optimize=yes
96    fi
97  fi
98fi
99
100# Choose compiler flags from CLI args
101if test "xyes" = "x$enable_debug"; then
102  CXXFLAGS="$CXXFLAGS -g"
103  CFLAGS="$CLFAGS -g"
104fi
105if test "xyes" = "x$enable_cxx_optimize"; then
106  CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG"
107fi
108if test "xyes" = "x$enable_cc_optimize"; then
109  CFLAGS="$CFLAGS -O2 -DNDEBUG"
110fi
111
112  # Check for 32/64 bit.
113  # This requires SNL_CXX_FLAGS and SNL_CC_FLAGS to have been called first
114AC_ARG_ENABLE( 32bit, AC_HELP_STRING([--enable-32bit],[Force 32-bit objects]),
115[
116  if test "xyes" != "x$enableval"; then
117    AC_MSG_ERROR([Unknown argument --enable-32bit=$enableval])
118  elif test "x" = "x$SNL_CXX_32BIT"; then
119    AC_MSG_ERROR([Don't know how to force 32-bit C++ on this platform.  Try setting CXXFLAGS manually])
120  elif test "x" = "x$SNL_CC_32BIT"; then
121    AC_MSG_ERROR([Don't know how to force 32-bit C on this platform.  Try setting CFLAGS manually])
122  fi
123  CXXFLAGS="$CXXFLAGS $SNL_CXX_32BIT"
124  CFLAGS="$CFLAGS $SNL_CC_32BIT"
125  enable_32bit=yes
126])
127# This requires SNL_CXX_FLAGS and SNL_CC_FLAGS to have been called first
128AC_ARG_ENABLE( 64bit, AC_HELP_STRING([--enable-64bit],[Force 64-bit objects]),
129[
130  if test "xyes" != "x$enableval"; then
131    AC_MSG_ERROR([Unknown argument --enable-64bit=$enableval])
132  elif test "x" = "x$SNL_CXX_64BIT"; then
133    AC_MSG_ERROR([Don't know how to force 64-bit C++ on this platform.  Try setting CXXFLAGS manually])
134  elif test "x" = "x$SNL_CC_64BIT"; then
135    AC_MSG_ERROR([Don't know how to force 64-bit C on this platform.  Try setting CFLAGS manually])
136  elif test "xyes" = "x$enable_32bit"; then
137    AC_MSG_ERROR([Cannot do both --enable-32bit and --enable-64bit])
138  fi
139  CXXFLAGS="$CXXFLAGS $SNL_CXX_64BIT"
140  CFLAGS="$CFLAGS $SNL_CC_64BIT"
141])
142
143]) # SNL_CHECK_COMPILERS
144
145
146
147#######################################################################################
148# Extract the value of a variable from a makefile fragment.
149# Arguments:
150#   - The path of the makefile fragment
151#   - The name of the makefile variable
152#   - Action on success (the shell variable "make_val" will contain the value
153#         of the variable)
154#   - Action on failure
155#######################################################################################
156AC_DEFUN([SNL_MAKE_INC_VAR], [
157make_val=
158snl_makefile="snl_check.mak"
159rm -f $snl_makefile
160
161if test ! -f $1 ; then
162  AC_MSG_WARN([File not found: $1])
163  $4
164else
165cat >$snl_makefile <<SNL_END_OF_MAKEFILE
166default:
167        @echo "\$($2)"
168
169include $1
170SNL_END_OF_MAKEFILE
171if make -f $snl_makefile > /dev/null 2>&1; then
172  make_val=`make -f $snl_makefile`
173  rm -f $snl_makefile
174  $3
175else
176  rm -f $snl_makefile
177  $4
178fi
179fi
180])
181
182
183#######################################################################################
184# Check for existance of new no-file-extension C++ headers.
185# Conditinionally sets the following preprocessor macros:
186#   CANT_USE_STD
187#    - The new no-extension versions of the c++ headers do not
188#      exist or do not define symbols to be in the "std" namespace.
189#      For example: if this is defined #include <map.h> rather than <map>.
190#   CANT_USE_STD_IO
191#    - The new no-extension versions of the c++ IO headers do not
192#      exist or do not define symbols to be in the "std" namespace.
193#      For example: if this is defined, #include <iostrea.h> rather than <iostream>
194#######################################################################################
195AC_DEFUN([SNL_CANT_USE_STD], [
196AC_LANG_SAVE
197AC_LANG_CPLUSPLUS
198
199AC_MSG_CHECKING([for C++-standard header files])
200AC_TRY_COMPILE([#include <vector>
201                #include <string>
202                #include <map>
203                #include <algorithm>
204               ],
205               [std::vector<std::string> v;
206                std::map<std::string,std::string> m;
207               ],
208               [AC_MSG_RESULT(yes)],
209               [AC_MSG_RESULT(no); CANT_USE_STD=-DCANT_USE_STD])
210
211AC_MSG_CHECKING([for C++-standard I/O header files])
212AC_TRY_COMPILE([#include <iosfwd>
213                #include <iostream>
214                #include <ostream>
215                #include <sstream>
216               ],
217               [std::cout << std::endl;],
218               [AC_MSG_RESULT(yes)],
219               [AC_MSG_RESULT(no); CANT_USE_STD_IO=-DCANT_USE_STD_IO])
220
221AC_LANG_RESTORE
222]) # SNL_CANT_USE_STD
223
224
225
226
227#######################################################################################
228# Check if template definitions (.cpp files) must be
229# included (in the .hpp files).
230# Sets TEMPLATE_DEFS_INCLUDED=1
231#######################################################################################
232AC_DEFUN([SNL_TEMPLATE_DEFS_INCLUDED], [
233AC_LANG_SAVE
234AC_LANG_CPLUSPLUS
235
236AC_MSG_CHECKING([if template definitions should be included])
237
238src=conftest.cc
239templ=conftemp.cc
240exe=conftest
241
242echo "template <typename T> class MyTempl { public: T get() const; };" >$templ
243echo "template <typename T> T MyTempl<T>::get() const { return 0; }"  >>$templ
244echo "template <typename T> class MyTempl { public: T get() const; };" >$src
245echo "int main( ) { MyTempl<int> c; return c.get(); }"                >>$src
246if $CXX $CXXFLAGS $LDFLAGS $src $templ -o $exe >/dev/null 2>/dev/null; then
247  TEMPLATE_DEFS_INCLUDED=
248  AC_MSG_RESULT(no)
249else
250  TEMPLATE_DEFS_INCLUDED=-DTEMPLATE_DEFS_INCLUDED
251  AC_MSG_RESULT(yes)
252fi
253
254rm -f $src $templ $exe
255AC_LANG_RESTORE
256]) # SNL_TEMPLATE_DEFS_INCLUDED
257
258
259
260
261#######################################################################################
262# Check for HDF5 library and related stuff
263# Sets HAVE_HDF5 to 'yes' or 'no'
264# If HAVE_HDF5 == yes, then updates INCLUDES and LIBS accordingly.
265#######################################################################################
266AC_DEFUN([SNL_CHECK_HDF5],[
267
268  # CLI option for linking zlib
269AC_ARG_WITH(zlib,
270  [AC_HELP_STRING([--with-zlib=DIR],[HDF5 requires zlib, and zlib can be found at...])],
271  [WITH_ZLIB=$withval],[WITH_ZLIB=])
272case "x$WITH_ZLIB" in
273  xyes|xno|x)
274    ;;
275  *)
276    if ! test -d  ${WITH_ZLIB}/lib; then
277      AC_MSG_ERROR([Not a directory: ${WITH_ZLIB}/lib])
278    fi
279    LIBS="$LIBS -L${WITH_ZLIB}/lib"
280    ;;
281esac
282HAVE_ZLIB=no
283if test "x$WITH_ZLIB" != "xno"; then
284  AC_CHECK_LIB([z],[deflate],[HAVE_ZLIB=yes],
285    [if test "x$WITH_ZLIB" != "x"; then AC_MSG_ERROR([Could not find zlib]); fi])
286fi
287
288  # CLI option for linking szip
289AC_ARG_WITH(szip,
290  [AC_HELP_STRING([--with-szip=DIR],[HDF5 requires szip, and szip an be found at...])],
291  [WITH_SZIP=$withval],[WITH_SZIP=])
292case "x$WITH_SZIP" in
293  xyes|xno|x)
294    ;;
295  *)
296    if ! test -d  ${WITH_SZIP}/lib; then
297      AC_MSG_ERROR([Not a directory: ${WITH_SZIP}/lib])
298    fi
299    LIBS="$LIBS -L${WITH_SZIP}/lib"
300    ;;
301esac
302HAVE_SZIP=no
303if test "x$WITH_SZIP" != "xno"; then
304  AC_CHECK_LIB([sz],[SZ_Decompress],[HAVE_SZIP=yes],
305    [if test "x$WITH_SZIP" != "x"; then AC_MSG_ERROR([Could not find libsz]); fi])
306fi
307
308  # CLI option for extra HDF5 link flags
309AC_ARG_WITH([--with-hdf5-ldflags],[AC_HELP_STRING([--with-hdf5-ldflags=...],
310 [Extra LDFLAGS required for HDF5 library (e.g. parallel IO lib)])],
311 [HDF5_LDFLAGS="$withval"],[HDF5_LDFLAGS=])
312case "x$HDF5_LDFLAGS" in
313  xno)
314    AC_MSG_ERROR("Invalid argument: --without-hdf5-ldflags")
315    ;;
316  xyes)
317    AC_MSG_ERROR("Nonsensical argument:  --with-hdf5-ldflags without any specified flags")
318    ;;
319esac
320
321
322  # CLI option for HDF5
323AC_MSG_CHECKING([if HDF5 support is enabled])
324AC_ARG_WITH(hdf5,
325[AC_HELP_STRING([--with-hdf5=DIR], [Specify HDF5 library to use for native file format])
326AC_HELP_STRING([--without-hdf5], [Disable support for native HDF5 file format])],
327[HDF5_ARG=$withval], [HDF5_ARG=yes])
328if test "xno" = "x$HDF5_ARG"; then
329  AC_MSG_RESULT([no])
330else
331  AC_MSG_RESULT([yes])
332fi
333
334 # if HDF5 support is not disabled, check to make sure we have HDF5
335if test "xno" != "x$HDF5_ARG"; then
336    # Check for IBM parallel IO library
337  if test "x$WITH_MPI" != "xno"; then
338    AC_CHECK_LIB([gpfs],[gpfs_stat],[LIBS="-lgpfs $LIBS"])
339  fi
340
341    # Add flag to defines
342  LIBS="$HDF5_LDFLAGS $LIBS"
343
344    # if a path is specified, update LIBS and INCLUDES accordingly
345  if test "xyes" != "x$HDF5_ARG"; then
346    if test -d "${HDF5_ARG}/lib"; then
347      LIBS="$LIBS -L${HDF5_ARG}/lib"
348    elif test -d "${HDF5_ARG}"; then
349      LIBS="$LIBS -L${HDF5_ARG}"
350    else
351      AC_MSG_ERROR("$HDF5_ARG is not a directory.")
352    fi
353    if test -d "${HDF5_ARG}/include"; then
354      INCLUDES="$INCLUDES -I${HDF5_ARG}/include"
355    else
356      INCLUDES="$INCLUDES -I${HDF5_ARG}"
357    fi
358  fi
359 
360    # check for libraries and headers
361  old_CPPFLAGS="$CPPFLAGS"
362  CPPFLAGS="$CPPFLAGS $INCLUDES"
363  AC_CHECK_HEADERS( [hdf5.h], [], [AC_MSG_ERROR("HDF5 header not found")] )
364  CPPFLAGS="$old_CPPFLAGSS"
365 
366  HAVE_LIB_HDF5=no
367  AC_CHECK_LIB( [hdf5], [H5Fopen], [HAVE_LIB_HDF5=yes] )
368  if test $HAVE_LIB_HDF5 = no; then
369    if test $HAVE_ZLIB = yes; then
370      unset ac_cv_lib_hdf5_H5Fopen
371      AC_CHECK_LIB( [hdf5], [H5Fopen], [HAVE_LIB_HDF5=yes; LIBS="-lz $LIBS"], [], [-lz] )
372    fi
373  fi
374  if test $HAVE_LIB_HDF5 = no; then
375    if test $HAVE_SZIP = yes; then
376      unset ac_cv_lib_hdf5_H5Fopen
377      AC_CHECK_LIB( [hdf5], [H5Fopen], [HAVE_LIB_HDF5=yes; LIBS="-lsz $LIBS"], [], [-lsz] )
378    fi
379  fi
380  if test $HAVE_LIB_HDF5 = no; then
381    if test $HAVE_SZIP = yes; then
382      if test $HAVE_ZLIB = yes; then
383        unset ac_cv_lib_hdf5_H5Fopen
384        AC_CHECK_LIB( [hdf5], [H5Fopen], [HAVE_LIB_HDF5=yes; LIBS="-lsz -lz $LIBS"], [], [-lz -lsz] )
385      fi
386    fi
387  fi
388  if test HAVE_LIB_HDF5 = no; then
389    AC_MSG_ERROR([Could not find HDF5 library (-lhdf5)])
390  fi
391  LIBS="-lhdf5 $LIBS"
392  HAVE_HDF5=yes
393else
394  HAVE_HDF5=no
395fi
396
397
398]) # SNL_CHECK_HDF5
399
400
401
402
403#######################################################################################
404# Check for NetCDF library ((C++)
405# Sets HAVE_NETCDF to 'yes' or 'no'
406# If HAVE_NETCDF == yes, then updates INCLUDES and LIBS accordingly.
407#######################################################################################
408AC_DEFUN([SNL_CHECK_NETCDF],[
409
410AC_MSG_CHECKING([if NetCDF support is enabled])
411AC_ARG_WITH(netcdf,
412[AC_HELP_STRING([--with-netcdf=DIR], [Specify NetCDF library to use for ExodusII file format])
413AC_HELP_STRING([--without-netcdf], [Disable support for ExodusII file format])],
414[NETCDF_ARG=$withval], [NETCDF_ARG=yes])
415if test "xno" = "x$NETCDF_ARG"; then
416  AC_MSG_RESULT([no])
417else
418  AC_MSG_RESULT([yes])
419fi
420
421 # if NetCDF support is not disabled
422if test "xno" != "x$NETCDF_ARG"; then
423    # Add flag to defines
424  DEFINES="$DEFINES -DNETCDF_FILE"
425
426    # Check for stream headers and set STRSTREAM_H_SPEC accordingly
427  AC_LANG_SAVE
428  AC_LANG_CPLUSPLUS
429  AC_CHECK_HEADER( [strstream.h], [NETCDF_DEF="<strstream.h>"], [
430    AC_CHECK_HEADER( [sstream.h], [NETCDF_DEF="<sstream.h>"], [
431      AC_CHECK_HEADER( [strstream], [NETCDF_DEF="<strstream>"], [
432        AC_CHECK_HEADER( [sstream], [NETCDF_DEF="<sstream>"] )
433  ] ) ] ) ] )
434  AC_LANG_RESTORE
435
436    # if a path is specified, update LIBS and INCLUDES accordingly
437  if test "xyes" != "x$NETCDF_ARG"; then
438    if test -d "${NETCDF_ARG}/lib"; then
439      LIBS="$LIBS -L${NETCDF_ARG}/lib"
440    elif test -d "${NETCDF_ARG}"; then
441      LIBS="$LIBS -L${NETCDF_ARG}"
442    else
443      AC_MSG_ERROR("$NETCDF_ARG is not a directory.")
444    fi
445    if test -d "${NETCDF_ARG}/include"; then
446      INCLUDES="$INCLUDES -I${NETCDF_ARG}/include"
447    elif test -d "${NETCDF_ARG}/inc"; then
448      INCLUDES="$INCLUDES -I${NETCDF_ARG}/inc"
449    else
450      INCLUDES="$INCLUDES -I${NETCDF_ARG}"
451    fi
452  fi
453 
454  old_CPPFLAGS="$CPPFLAGS"
455  CPPFLAGS="$CPPFLAGS $INCLUDES"
456  old_CXXFLAGS="$CXXFLAGS"
457  CXXFLAGS="$CXXFLAGS $INCLUDES"
458   # Check for C library
459  AC_CHECK_HEADERS( [netcdf.h], [], [AC_MSG_ERROR([[NetCDF header not found.]])] )
460  AC_MSG_CHECKING([for netcdf.hh])
461  AC_LANG_SAVE
462  AC_LANG_CPLUSPLUS
463  HAVE_NETCDF_HH=no
464  AC_TRY_COMPILE(
465[#include "netcdf.hh"], [], [HAVE_NETCDF_HH=yes; NETCDF_DEF=], [
466    AC_TRY_COMPILE(
467[#define STRSTREAM_H_SPEC $NETCDF_DEF
468 #include "netcdf.hh"], [], [HAVE_NETCDF_HH=yes], [NAVE_NETCDF_HH=no])])
469  AC_MSG_RESULT([$HAVE_NETCDF_HH])
470  if test $HAVE_NETCDF_HH != yes; then
471    AC_MSG_ERROR([NetCDF C++ header not found])
472  fi
473  if test "x$NETCDF_DEF" != "x"; then
474  CPPFLAGS="$CPPFLAGS -DSTRSTREAM_H_SPEC=$NETCDF_DEF"
475  CXXFLAGS="$CXXFLAGS -DSTRSTREAM_H_SPEC=$NETCDF_DEF"
476  fi
477  AC_MSG_CHECKING([[for netcdf_c++ library]])
478  LIBS="$LIBS -lnetcdf_c++ -lnetcdf"
479  AC_TRY_LINK(
480    [#include <netcdf.hh>], [NcFile ncf("foo",NcFile::ReadOnly);],
481    [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); AC_MSG_ERROR([NetCDF C++ API not found])] )
482  AC_LANG_RESTORE
483  CPPFLAGS="$old_CPPFLAGS"
484  CXXFLAGS="$old_CXXFLAGS"
485  if test "x$NETCDF_DEF" != "x"; then
486    DEFINES="$DEFINES '-DSTRSTREAM_H_SPEC=$NETCDF_DEF'"
487  fi
488 
489  HAVE_NETCDF=yes
490else
491  HAVE_NETCDF=no
492fi
493
494]) # SNL_HAVE_NETCDF
495
496
497
498
499#######################################################################################
500# Macro to set the following variables:
501# ACIS_VERSION
502# ACIS_LIB_DIR
503# ACIS_DEBUG_LIB_DIR
504# ACIS_PLATFORM
505# This macro expects ACIS_DIR to be set.
506# If ACIS_SYSTEM is set, ACIS_LIB_DIR will
507# be constructed using that value rather than
508# via a trial-and-error search.
509# If ACIS_VERSION is set, the corresponding test
510# will be skipped.
511#######################################################################################
512AC_DEFUN([SNL_ACIS_ENV], [
513
514AC_CHECK_FILE([$ACIS_DIR/include/acis.hxx], [], [AC_MSG_ERROR("Invalid ACIS path")])
515 
516if test "x" == "x$ACIS_SYSTEM"; then
517  dir_list="$ACIS_DIR/bin/*"
518else
519  dir_list="$ACIS_DIR/bin/$ACIS_SYSTEM"
520fi
521
522for dir in $dir_list; do
523    # first try non-debug libraries
524  case "$dir" in
525    *_debug)
526      ;;
527    *)
528      if ! test "$ACIS_VERSION" -gt "600"; then
529        SNL_ACIS_VERSION( [$dir] )
530        ACIS_LIB_DIR="$dir"
531      fi
532      ;;
533  esac
534    # next try debug libraries
535  case "$dir" in
536    *_debug)
537      if ! test "$ACIS_VERSION" -gt "600"; then
538        SNL_ACIS_VERSION( [$dir] )
539        ACIS_DEBUG_LIB_DIR="$dir"
540      fi
541      ;;
542  esac
543done
544
545if ! test "$ACIS_VERSION" -gt "600"; then
546  AC_MSG_ERROR([ACIS configuration failed.  Verify ACIS directory.  Try specifying ACIS system and version])
547fi
548
549# If either ACIS_LIB_DIR or ACIS_DEBUG_LIB_DIR is not defined,
550# make both the same
551if test "x" = "x$ACIS_LIB_DIR"; then
552  ACIS_LIB_DIR="$ACIS_DEBUG_LIB_DIR"
553elif test "x" = "x$ACIS_DEBUG_LIB_DIR"; then
554  ACIS_DEBUG_LIB_DIR="$ACIS_LIB_DIR"
555fi
556
557# Determine the ACIS platform name from the lib dir
558AC_MSG_CHECKING([ACIS platform name])
559case "$ACIS_LIB_DIR" in
560  $ACIS_DIR/bin/aix*) 
561    ACIS_PLATFORM=aix
562    ;;
563  $ACIS_DIR/bin/hp700*)
564    ACIS_PLATFORM=hp700
565    ;;
566  $ACIS_DIR/bin/linux*)
567    ACIS_PLATFORM=linux
568    ;;
569  $ACIS_DIR/bin/mac*)
570    ACIS_PLATFORM=mac
571    ;;
572  $ACIS_DIR/bin/osf1*)
573    ACIS_PLATFORM=osf1
574    ;;
575  $ACIS_DIR/bin/sgi*)
576    ACIS_PLATFORM=sgi
577    ;;
578  $ACIS_DIR/bin/solaris*)
579    ACIS_PLATFORM=solaris
580    ;;
581  *)
582    AC_MSG_ERROR([Cannot determine ACIS platform name.])
583    ;;
584esac
585AC_MSG_RESULT([$ACIS_PLATFORM])
586])
587
588
589
590#######################################################################################
591# Macro to check for ACIS translators.
592#######################################################################################
593AC_DEFUN([SNL_ACIS_TRANSLATOR], [
594AC_REQUIRE([SNL_ACIS_ENV])
595case "$ACIS_VERSION" in
596  11??)
597    ACIS_XLATE_LIBS='-lxacis2k -lxcore2k -lxutil'
598    ;;
599  1[23]??)
600    ACIS_XLATE_LIBS='-lSPAXAssemblyRep -lSPAXInterop -lSPAXBase -lxacis2k -lxcore2k -lxutil'
601    ;;
602  14??)
603    ACIS_XLATE_LIBS='-lSPAXAssemblyRep -lSPAXInterop -lSPAXAcisBase -lSPAXDefaultGeometryRep -lSPAXGeometryRepresentation -lSPAXPropertiesBRepImporter -lSPAXPropertiesBase -lSPAXBase -lxacis2k -lxcore2k'
604    ;;
605  *)
606    ACIS_XLATE_LIBS='-lSPAXEBOMBase -lSPAXEBOMNewAssemblyExporter -lSPAXEBOMNewAssemblyImporter -lSPAXXMLTk -lpthread -lSPAXPropertiesNewAssemblyImporter -lSPAXAssemblyRep -lSPAXInterop -lSPAXAcisBase -lSPAXDefaultGeometryRep -lSPAXGeometryRepresentation -lSPAXPropertiesBRepImporter -lSPAXPropertiesBase -lSPAXBase -lxacis2k -lxcore2k'
607    ;;
608esac
609old_LIBS="$LIBS"
610LIBS="$LIBS -L$ACIS_LIB_DIR $ACIS_XLATE_LIBS $ACIS_BASE_LIBS"
611AC_CHECK_LIB([xstep],[main],[ACIS_STEP_TRANSLATOR=-DACIS_STEP_TRANSLATOR])
612AC_CHECK_LIB([xiges],[main],[ACIS_IGES_TRANSLATOR=-DACIS_IGES_TRANSLATOR])
613LIBS="$old_LIBS"
614])
615
616
617#######################################################################################
618# *******************************************************************************
619# **************************** INTERNAL STUFF ***********************************
620# *******************************************************************************
621#######################################################################################
622
623#################################################################################
624# Check if the compiler defines a specific preprocessor macro
625# Arguments:
626#  - preprocessor define to check for
627#  - action upon success
628#  - action upon failure
629#################################################################################
630AC_DEFUN([SNL_TRY_COMPILER_DEFINE], [
631AC_COMPILE_IFELSE([
632AC_LANG_PROGRAM( [[#ifndef $1
633  choke me
634#endif]], []) ],
635[$2],[$3])
636])
637
638
639#######################################################################################
640# Check for compiler-specific flags.
641# Sets the following environmental variables:
642#   SNL_CXX_SPECIAL : Any compiler-specific flags which must be specified
643#   SNL_CXX_32BIT   : Flag to force compilation of 32-bit code
644#   SNL_CXX_64BIT   : Flag to force compilation of 64-bit code
645#######################################################################################
646AC_DEFUN([SNL_CXX_FLAGS], [
647AC_REQUIRE([AC_PROG_CXX])
648
649# Detect compiler
650AC_MSG_CHECKING([for known c++ compilers])
651# Autoconf does G++ for us
652if test x$GXX = xyes; then
653  cxx_compiler=GNU
654# Search for other compiler types
655# For efficiency, limit checks to relevant OSs
656else
657  cxx_compiler=unknown
658  AC_LANG_SAVE
659  AC_LANG_CPLUSPLUS
660  case "$target_os" in
661    aix*)
662      SNL_TRY_COMPILER_DEFINE([__IBMCPP__],[cxx_compiler=VisualAge])
663      ;;
664    solaris*|sunos*)
665      SNL_TRY_COMPILER_DEFINE([__SUNPRO_CC],[cxx_compiler=SunWorkshop])
666      ;;
667    irix*)
668      SNL_TRY_COMPILER_DEFINE([__sgi],[cxx_compiler=MIPSpro])
669      ;;
670    linux*)
671      SNL_TRY_COMPILER_DEFINE([__INTEL_COMPILER],[cxx_compiler=Intel])
672      SNL_TRY_COMPILER_DEFINE([__IBMCPP__],[cxx_compiler=VisualAge])
673      SNL_TRY_COMPILER_DEFINE([__DECCXX_VER],[cxx_compiler=Compaq])
674      ;;
675    hpux*)
676      SNL_TRY_COMPILER_DEFINE([__HP_aCC],[cxx_compiler=HP])
677      ;;
678    windows*)
679      SNL_TRY_COMPILER_DEFINE([__MSC_VER],[cxx_compiler=VisualStudio])
680      SNL_TRY_COMPILER_DEFINE([__INTEL_COMPILER],[cxx_compiler=Intel])
681      SNL_TRY_COMPILER_DEFINE([__DECCXX_VER],[cxx_compiler=Compaq])
682      SNL_TRY_COMPILER_DEFINE([__BORLANDC__],[cxx_compiler=Borland])
683      SNL_TRY_COMPILER_DEFINE([__CYGWIN__],[cxx_compiler=Cygwin])
684      SNL_TRY_COMPILER_DEFINE([__MINGW32__],[cxx_compiler=MinGW])
685      ;;
686  esac
687  AC_LANG_RESTORE
688fi
689AC_MSG_RESULT([$cxx_compiler])
690if test "x$cxx_compiler" = "xunknown"; then
691  AC_MSG_WARN([Unrecognized C++ compiler: $CXX])
692fi
693
694# Now decide special compiler flags using compiler/cpu combination
695AC_MSG_CHECKING([for known compiler/OS combinations])
696case "$cxx_compiler:$host_cpu" in
697  GNU:sparc*)
698    SNL_CXX_32BIT=-m32
699    SNL_CXX_64BIT=-m64
700    SNL_CXX_SPECIAL="-Wall -pipe"
701    ;;
702  GNU:powerpc*)
703    SNL_CXX_32BIT=-m32
704    SNL_CXX_64BIT=-m64
705    SNL_CXX_SPECIAL="-Wall -pipe"
706    ;;
707  GNU:i?86|GNU:x86_64)
708    SNL_CXX_32BIT=-m32
709    SNL_CXX_64BIT=-m64
710    SNL_CXX_SPECIAL="-Wall -pipe"
711    ;;
712  GNU:mips*)
713    SNL_CXX_32BIT="-mips32 -mabi=32"
714    SNL_CXX_64BIT="-mips64 -mabi=64"
715    SNL_CXX_SPECIAL="-Wall -pipe"
716    ;;
717  VisualAge:*)
718    SNL_CXX_32BIT=-q32
719    SNL_CXX_64BIT=-q64
720    # Do V5.0 namemangling for compatibility with ACIS, and enable RTTI
721    SNL_CXX_SPECIAL="-qrtti=all -qnamemangling=v5"
722    AR="ar -X 32_64"
723    NM="nm -B -X 32_64"
724    ;;
725  MIPSpro:mips)
726    SNL_CXX_32BIT=-n32
727    SNL_CXX_64BIT=-64
728    SNL_CXX_SPECIAL=-LANG:std
729    ;;
730  MIPSpro:*)
731    SNL_CXX_SPECIAL=-LANG:std
732    ;;
733  SunWorkshop:sparc*)
734    SNL_CXX_32BIT=-xarch=generic
735    SNL_CXX_64BIT=-xarch=generic64
736    ;;
737  *)
738    ;;
739esac
740AC_MSG_RESULT([$cxx_compiler:$host_cpu])
741]) # end SNL_CXX_FLAGS
742
743#######################################################################################
744# Check for compiler-specific flags.
745# Sets the following environmental variables:
746#   SNL_CC_SPECIAL : Any compiler-specific flags which must be specified
747#   SNL_CC_32BIT   : Flag to force compilation of 32-bit code
748#   SNL_CC_64BIT   : Flag to force compilation of 64-bit code
749#######################################################################################
750AC_DEFUN([SNL_CC_FLAGS], [
751AC_REQUIRE([AC_PROG_CC])
752
753# Detect compiler
754
755AC_MSG_CHECKING([for known C compilers])
756# Autoconf does gcc for us
757if test x$GCC = xyes; then
758  cc_compiler=GNU
759# Search for other compiler types
760# For efficiency, limit checks to relevant OSs
761else
762  cc_compiler=unknown
763  case "$target_os" in
764    aix*)
765      SNL_TRY_COMPILER_DEFINE([__IBMC__],[cc_compiler=VisualAge])
766      ;;
767    solaris*|sunos*)
768      SNL_TRY_COMPILER_DEFINE([__SUNPRO_C],[cc_compiler=SunWorkshop])
769      ;;
770    irix*)
771      SNL_TRY_COMPILER_DEFINE([__sgi],[cc_compiler=MIPSpro])
772      ;;
773    linux*)
774      SNL_TRY_COMPILER_DEFINE([__INTEL_COMPILER],[cc_compiler=Intel])
775      SNL_TRY_COMPILER_DEFINE([__IBMC__],[cc_compiler=VisualAge])
776      SNL_TRY_COMPILER_DEFINE([__DECC_VER],[cc_compiler=Compaq])
777      ;;
778    hpux*)
779      SNL_TRY_COMPILER_DEFINE([__HP_cc],[cc_compiler=HP])
780      ;;
781    windows*)
782      SNL_TRY_COMPILER_DEFINE([__MSC_VER],[cc_compiler=VisualStudio])
783      SNL_TRY_COMPILER_DEFINE([__INTEL_COMPILER],[cc_compiler=Intel])
784      SNL_TRY_COMPILER_DEFINE([__DECC_VER],[cc_compiler=Compaq])
785      SNL_TRY_COMPILER_DEFINE([__BORLANDC__],[cc_compiler=Borland])
786      SNL_TRY_COMPILER_DEFINE([__TURBOC__],[cc_compiler=TurboC])
787      SNL_TRY_COMPILER_DEFINE([__CYGWIN__],[cc_compiler=Cygwin])
788      SNL_TRY_COMPILER_DEFINE([__MINGW32__],[cc_compiler=MinGW])
789      ;;
790  esac
791fi
792AC_MSG_RESULT([$cc_compiler])
793if test "x$cc_compiler" = "xunknown"; then
794  AC_MSG_WARN([Unrecognized C compiler: $CXX])
795fi
796
797# Now decide special compiler flags using compiler/cpu combination
798AC_MSG_CHECKING([for known compiler/OS combinations])
799case "$cc_compiler:$host_cpu" in
800  GNU:sparc*)
801    SNL_CC_32BIT=-m32
802    SNL_CC_64BIT=-m64
803    SNL_CC_SPECIAL="-Wall -pipe"
804    ;;
805  GNU:powerpc*)
806    SNL_CC_32BIT=-m32
807    SNL_CC_64BIT=-m64
808    SNL_CC_SPECIAL="-Wall -pipe"
809    ;;
810  GNU:i?86|GNU:x86_64)
811    SNL_CC_32BIT=-m32
812    SNL_CC_64BIT=-m64
813    SNL_CC_SPECIAL="-Wall -pipe"
814    ;;
815  GNU:mips*)
816    SNL_CC_32BIT="-mips32 -mabi=32"
817    SNL_CC_64BIT="-mips64 -mabi=64"
818    SNL_CC_SPECIAL="-Wall -pipe"
819    ;;
820  VisualAge:*)
821    SNL_CC_32BIT=-q32
822    SNL_CC_64BIT=-q64
823    AR="ar -X 32_64"
824    NM="nm -B -X 32_64"
825    ;;
826  MIPSpro:mips)
827    SNL_CC_32BIT=-n32
828    SNL_CC_64BIT=-64
829    SNL_CC_SPECIAL=-LANG:std
830    ;;
831  MIPSpro:*)
832    SNL_CC_SPECIAL=-LANG:std
833    ;;
834  SunWorkshop:sparc*)
835    SNL_CC_32BIT=-xarch=generic
836    SNL_CC_64BIT=-xarch=generic64
837    ;;
838  *)
839    ;;
840esac
841AC_MSG_RESULT([$cc_compiler:$host_cpu])
842]) # end SNL_CC_FLAGS
843
844
845#######################################################################################
846# Macro to get ACIS_VERSION
847# Expected arguments: ACIS library path
848#######################################################################################
849AC_DEFUN([SNL_ACIS_VERSION], [
850AC_REQUIRE([AC_PROG_LIBTOOL])
851AC_LANG_SAVE
852AC_LANG_CPLUSPLUS
853AC_MSG_CHECKING([ACIS version of $1])
854src=conftest.cc
855exe=conftest
856
857cat <<END_SNL_ACIS_VERSION_SRC  >$src
858#include <stdio.h>
859int get_major_version();
860int get_minor_version();
861int get_point_version();
862int main(int,char**) { printf("%d\n",
863100*get_major_version() +
864 10*get_minor_version() +
865    get_point_version());
866return 0;}
867
868END_SNL_ACIS_VERSION_SRC
869
870FLAGS="$CXXFLAGS $LDFLAGS -L$1 -R$1"
871if ./libtool --mode=link $CXX $FLAGS $src -lSpaBase -o $exe >/dev/null 2>/dev/null; then
872  ACIS_VERSION=`./$exe || echo 0`
873  AC_MSG_RESULT($ACIS_VERSION)
874else
875  ACIS_VERSION=0
876  AC_MSG_RESULT(failed)
877fi
878
879#rm -f $src $exe
880AC_LANG_RESTORE
881]) # SNL_ACIS_VERSION
Note: See TracBrowser for help on using the browser.