fix: building shared lib on Mac/Darwin
[gss-tcad.git] / configure.in
blob9660de731c504621332faef755ad067166077563
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 AC_PREREQ(2.59)
5 AC_INIT(GSS, 0.46, gdiso@ustc.edu)
6 AC_CONFIG_SRCDIR([src/main.cc])
8 # Create a configuration header
9 AC_CONFIG_HEADERS([config.h])
11 GSS_DIR=`(pwd)`
13 AC_CANONICAL_HOST
15 #--------------------------------------------------------------------------
16 # Checks for programs.
17 #--------------------------------------------------------------------------
18 AC_PROG_CC(icc gcc cc)
19 AC_PROG_CXX(icpc g++ CC)
20 AC_PROG_LEX
21 if test "$LEX" != flex ;  then
22  AC_MSG_ERROR(ERROR: Can't find flex!)
24 AC_PROG_YACC
25 if test "$YACC" != "bison -y" ;  then
26  AC_MSG_ERROR(ERROR: Can't find bison!)
28 AC_PROG_MAKE_SET
31 CFLAGS=" -O1 "
32 CXXFLAGS=" -O1 "
33 #LDFLAGS=
34 #CPPFLAGS=""
35 #LIBS=""
38 #--------------------------------------------------------------------------
39 # check if debug requested
40 #--------------------------------------------------------------------------
41 AC_MSG_CHECKING([if debugging is enabled])
42 AC_ARG_ENABLE(debug,
43   [  --enable-debug[=OPTS]     build for debugging [default=no]],,
44   enableval=no)
45 if test "$enableval" = "no"; then
46   debug=no
47 else
48   if test "$enableval" = "" || test "$enableval" = "yes"; then
49     opt=-g
50   else
51     opt=$enableval
52   fi
53   CFLAGS="$opt"
54   CXXFLAGS="$opt"
55   debug=yes
57 AC_MSG_RESULT($debug)
60 #--------------------------------------------------------------------------
61 # get executable extensions
62 #--------------------------------------------------------------------------
63 AC_EXEEXT
66 #---------------------------------------------------------------------------
67 # get CGNS header path and library
68 #---------------------------------------------------------------------------
69 for d in         \
70     "/usr"       \
71     "/usr/local" \
72     "$HOME"    \
73     "$HOME/local" ; do
74     if test -f "$d/include/cgnslib.h" && test -f "$d/lib/libcgns.a"; then
75       CGNSDIR=`(cd $d; pwd)`
76       break
77     fi
78 done
80 AC_MSG_CHECKING([if CGNS directory was specified])
81 AC_ARG_WITH(cgns,
82   [  --with-cgns=CGNSdir     directory containing CGNS distribution.
83                           $CGNSdir/include for header
84                           $CGNSdir/lib for library],
85   CGNSDIR=$withval)
86 if test ! -z "$CGNSDIR" || test ! "$CGNSDIR" = "no"; then
87   AC_MSG_RESULT($CGNSDIR)
88   if test ! -f "$CGNSDIR/include/cgnslib.h"; then
89     AC_MSG_ERROR($CGNSDIR directory does not contain cgnslib.h)
90   fi
93 #---------------------------------------------------------------------------
94 # get TIFF header path and library
95 #---------------------------------------------------------------------------
96 AC_CHECK_HEADERS([tiffio.h],[AC_DEFINE([HAVE_TIFF],,[Use tiff to save screen])])
97 AC_CHECK_LIB([tiff], [TIFFOpen],[LIBS="$LIBS -ltiff"])
100 #---------------------------------------------------------------------------
101 # check if gsl library installed
102 #---------------------------------------------------------------------------
103 AC_ARG_ENABLE(gsl,
104   [  --enable-gsl[=OPTS]       use gsl Fermi function [default=no]],,
105   enableval=no)
106 if  test "$enableval" = "yes"; then
107   AC_CHECK_HEADERS([gsl/gsl_sf_fermi_dirac.h],AC_DEFINE([HAVE_GSL],[],[Use GSL to compute Fermi Integral]))
108   AC_CHECK_LIB([gsl -lgslcblas], [gsl_sf_fermi_dirac_half],[LIBS="$LIBS -lgsl -lgslcblas"])
112 #---------------------------------------------------------------------------
113 # check if PETSC installed
114 #---------------------------------------------------------------------------
115 if test -z "$PETSC_DIR" ; then
116     AC_MSG_ERROR(ERROR: Can't find PETSC dir! Please install PETSC first.)
121 #---------------------------------------------------------------------------
122 # Checks for system libraries.
123 #---------------------------------------------------------------------------
124 AC_CHECK_LIB([dl], [dlopen])
125 AC_CHECK_LIB([m], [sin],[LIBS="$LIBS -lm"])
127 # Checks for header files.
128 AC_HEADER_STDC
129 AC_CHECK_HEADERS([fcntl.h float.h limits.h stddef.h stdlib.h string.h stdio.h assert.h sys/time.h ])
131 # Checks for typedefs, structures, and compiler characteristics.
132 AC_HEADER_STDBOOL
133 AC_C_CONST
134 AC_C_INLINE
135 AC_TYPE_SIZE_T
136 AC_HEADER_TIME
138 # Checks for library functions.
139 AC_FUNC_MALLOC
140 AC_FUNC_REALLOC
141 AC_FUNC_STRTOD
142 AC_CHECK_FUNCS([memset pow sqrt])
145 #---------------------------------------------------------------------------
146 # Checks for system define
147 #---------------------------------------------------------------------------
148 case $host_os in
149   *cygwin* )
150         AC_DEFINE([CYGWIN],,[Define to use CYGWIN env]);;
151   *linux* )
152         AC_DEFINE([LINUX],,[Define to use LINUX env]);;
153   *darwin* )
154         AC_DEFINE([DARWIN],,[Define to use DARWIN env]);;
155 esac
158 AC_ARG_WITH(Win32,
159             [  --with-Win32            use Win32 native graphic function for plot],
160             AC_DEFINE([HAVE_WIN32],,[Define to use Win32 native graphic function])
161             Win32API=1,
162             Win32API=0)
163 #echo $Win32API
164 if  test  "$Win32API" = 0 ; then 
165   AC_PATH_X
166   AC_PATH_XTRA
167   if ! test "$x_includes" = ""; then
168      X11INCS=-I$x_includes
169      AC_DEFINE([HAVE_X11],,[Define to use X11 graphic function])
170   else
171      AC_CHECK_HEADERS([X11/Xlib.h],AC_DEFINE([HAVE_X11],,[Define to use X11 graphic function]))
172   fi
173   if ! test "$x_libraries" = ""; then
174      X11LIBS="-L$x_libraries -lX11"
175   else
176      AC_CHECK_LIB([X11], [XFlush],[X11LIBS="-lX11"])
177   fi
180 AC_MSG_CHECKING([options for building dynamic library])
181 case $host_os in
182   *darwin* )
183     LDFSHARED=" -dynamiclib ";;
184   *)
185     LDFSHARED=" -shared";;
186 esac
188 AC_PROG_MAKE_SET
189 AC_SUBST(GSS_DIR)
190 AC_SUBST(CGNSDIR)
191 AC_SUBST(X11INCS)
192 AC_SUBST(X11LIBS)
193 AC_SUBST(HAVE_X11)
194 AC_SUBST(INSTLIST)
195 AC_SUBST(BIN_INSTALL_DIR)
196 AC_SUBST(LIB_INSTALL_DIR)
197 AC_SUBST(LDFSHARED)
199 AC_CONFIG_FILES([make.defs])
200 AC_OUTPUT