dnl ----------------------------------------------------------------- dnl $Id: configure.in,v 1.10.4.1 2002/01/17 17:42:50 pwessel Exp $ dnl dnl Run GNU autoconf to produce a configure script from this input. dnl For GMT 3.4 configure script dnl dnl ----------------------------------------------------------------- dnl AC_REVISION(configure for GMT 3.4.1) AC_INIT(src/gmt.h) owncflags=${CFLAGS:-NONE} AC_CONFIG_AUX_DIR(`pwd`) AC_CANONICAL_SYSTEM AC_LANG_C AC_PROG_CC AC_PROG_CPP AC_PREFIX_DEFAULT(`pwd`) AC_CONFIG_HEADER(src/gmt_notposix.h:src/gmt_notposix.h.in) AC_CYGWIN dnl dnl ----------------------------------------------------------------- dnl GMT-specific make macros dnl ----------------------------------------------------------------- dnl AC_SUBST(SHELL) AC_SUBST(EXE) AC_SUBST(WIN32) AC_SUBST(COMPRESS) AC_SUBST(TRIANGLE_D) AC_SUBST(TRIANGLE_O) AC_SUBST(ALPHA_SINCOS_O) AC_SUBST(GMTLIB) AC_SUBST(CC_OPT) AC_SUBST(LD_OPT) AC_SUBST(LDFLAGS) AC_SUBST(VERSION) AC_SUBST(SL) AC_SUBST(rootdir) AC_SUBST(wwwdir) AC_SUBST(wrapbindir) AC_SUBST(wrapmandir) AC_SUBST(mansection) dnl dnl ----------------------------------------------------------------- dnl Special configure options for GMT installation dnl ----------------------------------------------------------------- dnl AC_ARG_ENABLE(debug, [ --enable-debug Compile in debug-information instead of optimizing code]) AC_ARG_ENABLE(shared, [ --enable-shared Build shared (dynamic) GMT libraries instead of static]) AC_ARG_ENABLE(triangle, [ --enable-triangle Use J. Shewchuck fast triangulation routine]) AC_ARG_ENABLE(US, [ --enable-US Choose US (inch) rather than SI (cm) units as default]) AC_ARG_ENABLE(wrapbin, [ --enable-wrapbin=dir Directory in which to install GMT wrapper script [/usr/bin]]) AC_ARG_ENABLE(wrapman, [ --enable-wrapman=dir Directory in which to install GMT wrapper man page [/usr/bin]]) AC_ARG_ENABLE(www, [ --enable-www=dir Directory in which to install GMT www pages [PREFIX/www]]) AC_ARG_ENABLE(mansect, [ --enable-mansect=sect GMT man page section [l]]) AC_ARG_ENABLE(eps, [ --enable-eps Set Encapsulated PostScript as default output format [Freeform PS]]) AC_ARG_ENABLE(flock, [ --disable-flock Disable file locking on .gmtcommands file]) dnl dnl ----------------------------------------------------------------- dnl Check for ar, csh/bash, ld, awk, and ranlib dnl ----------------------------------------------------------------- dnl AC_CHECK_PROG(AR, ar, ar, :) AC_CHECK_PROG(CSH, csh, csh, bash, ) AC_CHECK_PROG(LD, ld, ld, :) AC_CHECK_PROG(AS, as, as, :) AC_PROG_INSTALL AC_PROG_AWK AC_PROG_RANLIB dnl dnl ----------------------------------------------------------------- dnl Get current OS and chip type dnl ----------------------------------------------------------------- dnl os=`uname -s` chip=`uname -m` Sun_rev=`uname -r | grep '^5.'` dnl dnl ----------------------------------------------------------------- dnl Misc. parameters dnl ----------------------------------------------------------------- dnl EXE= WIN32= COMPRESS="@:" rootdir=`pwd` VERSION=`grep GMT_VERSION src/gmt.h | awk '{print $NF}' | sed -e 's/\"//g'` dnl dnl ----------------------------------------------------------------- dnl Special checking and action required for Cygwin dnl ----------------------------------------------------------------- dnl if test "$CYGWIN" = "yes" ; then EXE=".exe" WIN32="-D_WIN32" if test ! -d /tmp ; then AC_MSG_WARN(Cygwin: /tmp not found - created) mkdir /tmp fi if test ! -f /bin/sh.exe ; then AC_MSG_WARN(Cygwin: /bin/sh not found - created) this_sh=`type -p sh` cp -f $this_sh /bin fi fi dnl dnl ----------------------------------------------------------------- dnl Special checking and action required for OS/2 with EMX support dnl ----------------------------------------------------------------- dnl if test "$os" = "OS/2" ; then EXE=".exe" WIN32="-D__EMX__" COMPRESS="lxlite /ML1" fi dnl dnl ----------------------------------------------------------------- dnl Allow user to set --enable-binwrap to set wrapper bin dir dnl ----------------------------------------------------------------- dnl wrapbindir='/usr/bin' AC_MSG_CHECKING(for wrapper bin directory) if test "$enable_wrapbin" = "yes" ; then wrapbindir='/usr/bin' elif test ! "$enable_wrapbin" = "" ; then wrapbindir=$enable_wrapbin fi AC_MSG_RESULT($wrapbindir) dnl dnl ----------------------------------------------------------------- dnl Allow user to set --enable-manwrap to set wrapper man dir dnl ----------------------------------------------------------------- dnl wrapmandir='/usr/man' AC_MSG_CHECKING(for wrapper man directory) if test "$enable_wrapman" = "yes" ; then wrapmandir='/usr/man' elif test ! "$enable_wrapman" = "" ; then wrapmandir=$enable_wrapman fi AC_MSG_RESULT($wrapbindir) dnl dnl ----------------------------------------------------------------- dnl Allow user to set --enable-www to set install www dir dnl ----------------------------------------------------------------- dnl wwwdir='${prefix}/www' AC_MSG_CHECKING(for www directory) if test "$enable_www" = "yes" ; then wwwdir='${prefix}/www' elif test ! "$enable_www" = "" ; then wwwdir=$enable_www fi AC_MSG_RESULT($wwwdir) dnl dnl ----------------------------------------------------------------- dnl Allow user to set --enable-mansect to set man page section dnl ----------------------------------------------------------------- dnl AC_MSG_CHECKING(for man page section) if test "$enable_mansect" = "yes" ; then mansection=l elif test ! "$enable_mansect" = "" ; then mansection=$enable_mansect else mansection=l fi AC_MSG_RESULT($mansection) dnl dnl ----------------------------------------------------------------- dnl Allow user to set --enable)eps to set EPS as default format dnl ----------------------------------------------------------------- dnl if test "$enable_eps" = "yes" ; then eps=EPS else eps=PS fi dnl dnl ----------------------------------------------------------------- dnl Allow user to set --disable-flock for turning off file locking dnl ----------------------------------------------------------------- dnl AC_MSG_CHECKING(for file locking) AC_MSG_RESULT($enable_flock) dnl dnl ----------------------------------------------------------------- dnl Allow user to set --enable-debug to pass -g flag dnl ----------------------------------------------------------------- dnl AC_MSG_CHECKING(if we should compile with debugging switch -g) if test "$enable_debug" = "yes" ; then AC_MSG_RESULT(yes) OPTG="-g " OPTGO="-g " OPTS= else OPTG= OPTGO="-O " if test "$os" = "Darwin" ; then OPTS="-Wl,-x " elif test "$os" = "Rhapsody" ; then OPTS="-Wl,-x " else OPTS="-s " fi AC_MSG_RESULT(no) fi dnl dnl ----------------------------------------------------------------- dnl Allow user to set --enable-triangle to use J. Shewchuck's triangulation dnl ----------------------------------------------------------------- dnl AC_MSG_CHECKING(if the triangulation by Shewchuck should be used) if test "$enable_triangle" = "yes" ; then AC_MSG_RESULT(yes) TRIANGLE_D=-DTRIANGLE_D TRIANGLE_O=triangle.o else AC_MSG_RESULT(no) fi dnl dnl ----------------------------------------------------------------- dnl Allow user to set --enable-shared to build shared libraries dnl ----------------------------------------------------------------- dnl shared_unknown=no if test "$enable_shared" = "yes" ; then AC_MSG_CHECKING(if we can build shared libraries) if test "$os" = "Linux" ; then AC_MSG_RESULT(yes) GMTLIB='$(SHARED_LIB)' elif test "$os" = "FreeBSD" ; then AC_MSG_RESULT(yes) GMTLIB='$(SHARED_LIB)' elif test "$os" = "NetBSD" ; then AC_MSG_RESULT(yes) GMTLIB='$(SHARED_LIB)' elif test "$os" = "SunOS" ; then AC_MSG_RESULT(yes) GMTLIB='$(SHARED_LIB)' elif test "$os" = "HP-UX" ; then AC_MSG_RESULT(yes) GMTLIB='$(SHARED_LIB)' elif test "$os" = "IRIX64" ; then AC_MSG_RESULT(yes) GMTLIB='$(SHARED_LIB)' elif test "$os" = "OSF1" ; then AC_MSG_RESULT(yes) GMTLIB='$(SHARED_LIB)' elif test "$os" = "Rhapsody" ; then AC_MSG_RESULT(yes) GMTLIB='$(SHARED_LIB)' elif test "$os" = "Darwin" ; then AC_MSG_RESULT(yes) GMTLIB='$(SHARED_LIB)' else # Not yet implemented AC_MSG_RESULT(not supported for GMT under $os) enable_shared=no shared_unknown=yes GMTLIB='$(STATIC_LIB)' fi else GMTLIB='$(STATIC_LIB)' fi dnl dnl ----------------------------------------------------------------- dnl Determine LD_OPT and LDFLAGS for this platform dnl ----------------------------------------------------------------- dnl LDFLAGS=$OPTS LD_OPT= SL="so" if test "$enable_shared" = "yes" ; then AC_MSG_CHECKING(how to make a shared object) if test "$os" = "SunOS" ; then if test "$Sun_rev" = "" ; then # SunOS LD_OPT="-Bdynamic" LDFLAGS=$OPTS'-Wl,-L$(libdir)' else # Solaris LD_OPT="-G" LDFLAGS=$OPTS'-Wl,-R,$(libdir)' fi elif test "$os" = "Linux" ; then LD_OPT="-shared" LDFLAGS=$OPTS'-Wl,-rpath,$(libdir)' elif test "$os" = "FreeBSD" ; then LD_OPT="-shared" LDFLAGS=$OPTS'-Wl,-rpath,$(libdir)' elif test "$os" = "NetBSD" ; then LD_OPT="-shared" LDFLAGS=$OPTS'-Wl,-rpath,$(libdir)' elif test "$os" = "OSF1" ; then LD_OPT='-shared -expect_unresolved "*"' LDFLAGS=$OPTS'-Wl,-rpath,$(libdir)' elif test "$os" = "IRIX64" ; then LD_OPT="-shared" SL="sl" LDFLAGS=$OPTS'-Wl,-rpath,$(libdir)' elif test "$os" = "Rhapsody" ; then # MacOS X Server LD_OPT="-shared" LDFLAGS='-Wl,-x' elif test "$os" = "Darwin" ; then # MacOS X LD_OPT="-shared" LDFLAGS='-Wl,-x' elif test "$os" = "HP-UX" ; then LD_OPT="-b" LDFLAGS=$OPTS'-Wl,+b,$(libdir)' fi AC_MSG_RESULT(ld $LD_OPT) AC_MSG_CHECKING(the file extension for a shared object) AC_MSG_RESULT($SL) fi dnl dnl ----------------------------------------------------------------- dnl Determine CC_OPT for this platform dnl ----------------------------------------------------------------- dnl AC_MSG_CHECKING(compiler options for GMT) if test "$owncflags" = "NONE"; then if test "$GCC" = "yes"; then # GNU cc options if test "$chip" = "alpha" ; then # Alpha PC CC_OPT=$OPTG'-mieee' elif test "$os" = "Rhapsody" ; then # MacOS X Server CC_OPT=$OPTGO'-ansi -pedantic -traditional-cpp' LDFLAGS= elif test "$os" = "Darwin" ; then # MacOS X CC_OPT=$OPTGO'-ansi -pedantic -traditional-cpp' LDFLAGS= else CC_OPT=$OPTGO'-ansi -pedantic' fi elif test "$os" = "SunOS" ; then # Sun Workshop CC options CC_OPT=$OPTGO'-Xc' elif test "$os" = "IRIX64" ; then # SGI Irix cc options CC_OPT=$OPTGO elif test "$os" = "HP-UX" ; then # HP cc options CC_OPT=$OPTG'-Aa +Ofltacc +O1 +Olibcalls' if test "$enable_shared" = "yes" ; then CC_OPT=$CC_OPT' +z' fi elif test "$os" = "AIX" ; then # IBM AIX cc options CC_OPT=$OPTG'-O2' elif test "$os" = "AUX" ; then # Apple A/UX cc options CC_OPT=$OPTG'-Daux' elif test "$os" = "OSF1" ; then # Dec Alpha OSF cc options CC_OPT=$OPTG'-Olimit 1500 -ieee_with_inexact' elif test "$os" = "ULTRIX" ; then # Dec Ultrix cc options CC_OPT=$OPTG'-O -Olimit 1500' elif test "$os" = "Windows_NT" ; then # Interix w/ MS cc options CC_OPT=$OPTGO LDFLAGS= else # Generic setting for unknown systems CC_OPT=$OPTGO fi if test "$enable_flock" = "no" ; then CC_OPT=$CC_OPT' -DNO_LOCK' fi AC_MSG_RESULT([$CC_OPT (preset for your platform)]) else CC_OPT=$CFLAGS if test "$enable_flock" = "no" ; then CC_OPT=$CC_OPT' -DNO_LOCK' fi AC_MSG_RESULT([$CC_OPT (taken from CFLAGS in your environment)]) fi AC_MSG_CHECKING(linker options for GMT) AC_MSG_RESULT($LDFLAGS) dnl dnl ----------------------------------------------------------------- dnl Create share/gmt.conf and set site defaults dnl ----------------------------------------------------------------- dnl AC_MSG_CHECKING(for default GMT units) if test ! -f share/gmt.conf.orig ; then cp share/gmt.conf share/gmt.conf.orig fi if test ! -f share/.gmtdefaults_SI.orig ; then cp share/.gmtdefaults_SI share/.gmtdefaults_SI.orig fi if test ! -f share/.gmtdefaults_US.orig ; then cp share/.gmtdefaults_US share/.gmtdefaults_US.orig fi \rm -f share/gmt.conf if test "$enable_US" = "yes" ; then AC_MSG_RESULT(US (inch)) paper=Letter origdef=share/.gmtdefaults_US.orig thisdef=share/.gmtdefaults_US echo "US <- Set to SI or US" > share/gmt.conf else AC_MSG_RESULT(SI (cm)) paper=A4 origdef=share/.gmtdefaults_SI.orig thisdef=share/.gmtdefaults_SI echo "SI <- Set to SI or US" > share/gmt.conf fi egrep -v '^SI|^US' share/gmt.conf.orig >> share/gmt.conf AC_MSG_CHECKING(for default PostScript format) \rm -f $thisdef if test "$enable_eps" = "yes" ; then AC_MSG_RESULT((EPS)) if test "$enable_US" = "yes" ; then $AWK '{if ($1 == "PAPER_MEDIA") {printf "PAPER_MEDIA\t\t= Letter+\n"} else {print $0}}' $origdef > $thisdef else $AWK '{if ($1 == "PAPER_MEDIA") {printf "PAPER_MEDIA\t\t= A4+\n"} else {print $0}}' $origdef > $thisdef fi else AC_MSG_RESULT((PS)) if test "$enable_US" = "yes" ; then $AWK '{if ($1 == "PAPER_MEDIA") {printf "PAPER_MEDIA\t\t= Letter\n"} else {print $0}}' $origdef > $thisdef else $AWK '{if ($1 == "PAPER_MEDIA") {printf "PAPER_MEDIA\t\t= A4\n"} else {print $0}}' $origdef > $thisdef fi fi dnl dnl ----------------------------------------------------------------- dnl Check for libraries. Most installs will need to have dnl -lm but under Rhapsody/Darwin it is not needed. Thus, we look dnl for sin in -lm which should set -lm on most platforms. dnl We also look for sincos in -m and -lsunmath for Solaris. dnl ----------------------------------------------------------------- dnl AC_SEARCH_LIBS(sin, m) AC_SEARCH_LIBS(sincos, [m sunmath], [SINCOS=1], [SINCOS=0]) dnl dnl OSF specific check for broken sincos from Lloyd Parkes (lloyd@geo.vuw.ac.nz) dnl if test "$SINCOS" = "1" ; then AC_MSG_CHECKING(for a broken sincos function) AC_TRY_RUN([int main () { double s = 0.1, c = 0.2; double s1, c1; s1 = s; c1 = c; sincos (0.5, &s, &c); return (s == s1 || c == c1); /* FALSE if sincos works ok */ } ], [ AC_MSG_RESULT(no) AC_DEFINE(HAVE_SINCOS) ], [ case $target in alpha*-osf*) AC_DEFINE(HAVE_ALPHASINCOS) ALPHA_SINCOS_O=alpha-sincos.o AC_MSG_RESULT([yes.]) AC_MSG_RESULT([An assembly language wrapper will be used to fix sincos.] ) ;; *) AC_MSG_RESULT([yes.]) AC_MSG_RESULT([I don't know how to fix sincos on this machine.]) esac ], [ AC_MSG_RESULT([no sincos found.]) ]) fi dnl dnl ----------------------------------------------------------------- dnl Check for the availability of many ANSI-C functions dnl ----------------------------------------------------------------- dnl AC_CHECK_FUNC(copysign, AC_DEFINE(HAVE_COPYSIGN), ) AC_CHECK_FUNC(log1p, AC_DEFINE(HAVE_LOG1P), ) AC_CHECK_FUNC(hypot, AC_DEFINE(HAVE_HYPOT), ) AC_CHECK_FUNC(acosh, AC_DEFINE(HAVE_ACOSH), ) AC_CHECK_FUNC(asinh, AC_DEFINE(HAVE_ASINH), ) AC_CHECK_FUNC(atanh, AC_DEFINE(HAVE_ATANH), ) AC_CHECK_FUNC(rint, AC_DEFINE(HAVE_RINT), ) AC_CHECK_FUNC(irint, AC_DEFINE(HAVE_IRINT), ) AC_CHECK_FUNC(isnanf, AC_DEFINE(HAVE_ISNANF), ) AC_CHECK_FUNC(isnand, AC_DEFINE(HAVE_ISNAND), ) AC_CHECK_FUNC(isnan, AC_DEFINE(HAVE_ISNAN), ) AC_CHECK_FUNC(j0, AC_DEFINE(HAVE_J0), ) AC_CHECK_FUNC(j1, AC_DEFINE(HAVE_J1), ) AC_CHECK_FUNC(jn, AC_DEFINE(HAVE_JN), ) AC_CHECK_FUNC(y0, AC_DEFINE(HAVE_Y0), ) AC_CHECK_FUNC(y1, AC_DEFINE(HAVE_Y1), ) AC_CHECK_FUNC(yn, AC_DEFINE(HAVE_YN), ) AC_CHECK_FUNC(erf, AC_DEFINE(HAVE_ERF), ) AC_CHECK_FUNC(erfc, AC_DEFINE(HAVE_ERFC), ) dnl dnl ----------------------------------------------------------------- dnl Override HYPOT under Interix and Cygwin as our function is dnl much faster than what configure seems to find. dnl ----------------------------------------------------------------- dnl if test "$os" = "Windows_NT" ; then # Interix AC_DEFINE(HAVE_HYPOT, 0) elif test "$CYGWIN" = "yes" ; then # Cygwin environment AC_DEFINE(HAVE_HYPOT, 0) else # Let configure it out AC_CHECK_FUNC(hypot, AC_DEFINE(HAVE_HYPOT), ) fi dnl ----------------------------------------------------------------- dnl Find out about byte order dnl ----------------------------------------------------------------- dnl AC_C_BIGENDIAN dnl dnl ----------------------------------------------------------------- dnl Update the GMT macros dnl ----------------------------------------------------------------- dnl AC_CONFIG_SUBDIRS(src/mex) AC_CONFIG_SUBDIRS(src/xgrid) AC_OUTPUT(src/makegmt.macros src/GMT) dnl dnl ----------------------------------------------------------------- dnl Remove and, if trouble, write the .gmtconfigure file dnl ----------------------------------------------------------------- dnl if test -f .gmtconfigure ; then \rm -f .gmtconfigure fi if test "$shared_unknown" = "yes" ; then cat << EOF > .gmtconfigure ============================================================= Shared libraries for GMT under $os are not implemented. This can mean that your OS does not support shared libraries at all or that the GMT configure script simply does not know how to. Therefore, configure has ignored the --enable-shared option. However, if shared libraries ARE supported on this system you may try edit src/makegmt.macros and manually set the macros CC_OPT, LD_OPT, LDFLAGS, and GMTLIB accordingly. Please include the output of uname -a and mail the working makegmt.macros to gmt@soest.hawaii.edu. Thanx. ============================================================= EOF cat .gmtconfigure fi