Skip to content
This repository
tree: 6c5d37c647
Fetching contributors…

Cannot retrieve contributors at this time

file 306 lines (261 sloc) 11.583 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
AC_INIT([puff],[2.2.1],[rorik@gi.alaska.edu],[puff-uaf])

# print GNU copyright in configure script
AC_COPYRIGHT

# put autotools-generated files here
AC_CONFIG_AUX_DIR(auto)

# get build system parameters, need config.guess and config.sub to use these
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET

AC_DEFINE_UNQUOTED(BUILD_OS,$build,Autoconf-generated architecture)

AM_INIT_AUTOMAKE

# put all the preprocessor symbols in config.h
AM_CONFIG_HEADER(config.h)

# make the default install directory this one
AC_PREFIX_DEFAULT(`pwd`)
# make the default install directory one above this one
#AC_PREFIX_DEFAULT(`(cd ..; pwd)`)

AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
#AC_PROG_RANLIB
AC_PROG_LIBTOOL

# disable maintainer-only options in generated Makefiles unless the flag
# --enable-maintainer-mode is given at configure time
AM_MAINTAINER_MODE

#AC_HEADER_STDC

PUFF_FIND_NETCDF
AC_C_BIGENDIAN
AC_LANG(C++)
AC_CHECK_HEADERS(algorithm cmath cstdlib ctime fstream list iomanip iostream sstream strstream string vector)
AC_CHECK_HEADERS(cmapf.h dirent.h getopt.h sys/types.h sys/stat.h)

dnl hold off looking for these since the generated script seems to not
dnl conform to what the c++ compiler wants, although some functions are there
dnl AC_LANG_PUSH(C)
AC_CHECK_FUNCS(atoi cbrt exp10 sscanf printf)
dnl AC_LANG_POP(C)
AC_CHECK_FUNCS(toupper setenv putenv)

dnl mini_httpd needs these on Solaris
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(dmapf, stlmbr)
AC_CHECK_LIB(dmapf, stlmbr,,puff_need_libdmapf="yes")
AM_CONDITIONAL(PUFF_NEED_LIBDMAPF, test "$puff_need_libdmapf" == "yes")

AC_CHECK_LIB(crypt, crypt)

#############################################
dnl ashxp checks

AC_CHECK_HEADERS(cmapf.h jpeglib.h unistd.h libgen.h)
AC_CHECK_LIB(m, sin)
dnl find libjpeg, else build our own
AC_CHECK_LIB(jpeg, jpeg_std_error,,[
AC_MSG_WARN([cannot find 'libjpeg'; will build version 6b from source])
echo "*** configuring jpeg-6b ***"
puff_this_dir=`pwd`
cd src/ashxp/jpeg-6b && ./configure CC=$CC && cd $puff_this_dir
echo "*** done configuring jpeg-6b ***"
ashxp_need_libjpeg="yes"
])
AC_CHECK_FUNCS([basename ceil ceilf floor floorf logf mkstemp tmpnam])
dnl find correct location to put default background file
if test "$prefix" != "NONE"; then
AC_DEFINE_UNQUOTED([ASHXP_BG_FILE_LOCATION],"$prefix/etc/images/",location of default background file)
AC_DEFINE_UNQUOTED([ASHXP_FONTFILE],"$prefix/etc/fonts/FreeMonoBold.ttf",location of default default font)
else
AC_DEFINE_UNQUOTED([ASHXP_BG_FILE_LOCATION],"$ac_default_prefix/etc/images/",location of default background file)
AC_DEFINE_UNQUOTED([ASHXP_FONTFILE],"$ac_default_prefix/etc/fonts/FreeMonoBold.ttf",location of default font)
fi
dnl build our own jpeg library if one was not found
AM_CONDITIONAL(ASHXP_BUILD_LIBJPEG, test "$ashxp_need_libjpeg" = "yes")
#if test "$ashxp_need_libjpeg" = "yes"; then
# AC_CONFIG_SUBDIRS([jpeg-6b])
# LDFLAGS="$LDFLAGS -Ljpeg-6b"
# LIBS="$LIBS -ljpeg"
#fi

#############################################
# check for libnetcdf_c++ Isn't there a macro that will do this?

AC_CHECK_HEADERS(netcdf.h netcdfcpp.h)
dnl do this initial check so the library gets added to the link list
AC_CHECK_LIB(netcdf, ncopen)
dnl redo this check (it was cached) so we can exit if it is not found
AC_CHECK_LIB(netcdf, ncopen,,puff_have_libnetcdf=no)

dnl Store the old libraries to restore later. We want to test for netcdf_c++
dnl but not add it to the link list because c-compiled programs (mini_httpd)
dnl will choke. The src/Makefile will add it where it is necessary.
AC_MSG_CHECKING(for NcFile in libnetcdf_c++)
puff_old_libs=$LIBS
LIBS="-lnetcdf_c++ $LIBS"
AC_TRY_COMPILE([#include <netcdfcpp.h>],
  [NcFile nc("file");],[puff_have_libnetcdf_cxx="yes"],[puff_have_libnetcdf_cxx="no"])
if test $puff_have_libnetcdf_cxx == "yes"; then
  echo "yes"
  AC_DEFINE(HAVE_LIBNETCDF_CXX,1,define to 1 if you have libnetcdf_c++)
  # supress deprecated warnings from libnetcdf_c++ when using g++
# AX_CXXFLAGS_GCC_OPTION(-Wno-deprecated)
else
  echo "no"
  echo "****************************"
  echo "You need Unidata's netcdf and netcdf_c++ libraries in order to build"
  echo " this version of Puff. You can download it directly from Unidata at"
  echo "http://www.unidata.ucar.edu/packages/netcdf"
  echo "or from the Puff download page at"
  echo "http://puff.images.alaska.edu/download"
  echo "See the Puff documentation for help if you have difficulty."
  echo "****************************"
  AC_MSG_ERROR()
fi
dnl restore old libraries so c compiling does not choke on -lnetcdf_c++
LIBS=$puff_old_libs
#############################################

# check for unidata's UDUNITS library and data files
if test "x$NETCDF_INC" = "x"; then
  puff_udunits_dat="/usr/local/etc/udunits.dat"
else
  puff_udunits_dat="$NETCDF_INC/../etc/udunits.dat"
fi
dnl on MacOS X, we need libudport which has threaded functions
AC_CHECK_FUNC(tdelete,,AC_CHECK_LIB([udport],[tdelete]))
dnl do this initial check so the library gets added to the link list
#AC_CHECK_LIB([udunits], [utInit],,,$puff_libudport)
dnl now add libudport if need be
#LIBS="$LIBS $puff_libudport"
dnl redo this check (it will be cached) so we can exit if it is not found
AC_CHECK_LIB([udunits], [utInit],,puff_have_libudunits=no)
dnl this must be DEFINE_UNQUOTED and then a quoted string so the quotes get
dnl substituted into the source file correctly
AC_CHECK_FILE([$puff_udunits_dat],[AC_DEFINE_UNQUOTED([UDUNITS_DAT],["$puff_udunits_dat"],[location of udunits data file])])
AC_CHECK_HEADERS([udunits.h])
if test "x$puff_have_libudunits" = xno; then
  echo "****************************"
  echo "You need Unidata's UDUnits library in order to build this version of"
  echo "Puff. You can download it directly from Unidata at "
  echo "http://www.unidata.ucar.edu/packages/udunits"
  echo "or from the Puff download page at"
  echo "http://puff.images.alaska.edu/download"
  echo "See the Puff documentation for help if you have difficulty."
  echo "****************************"
  AC_MSG_ERROR()
fi

#############################################
dnl wget is used to fetch netCDF data files for the puff tests
AC_PATH_PROG(WGET,wget,,)
AC_ARG_VAR(WGET,path to wget)

AC_PATH_PROG(PERL,perl,,)
AC_ARG_VAR(PERL,path to perl)

#AC_PATH_PROG(NCGEN,ncgen,,)
#AC_ARG_VAR(NCGEN,path to ncgen)

#AC_PATH_PROG(WGRIB,wgrib,,)
#AC_ARG_VAR(WGRIB,path to wgrib)

dnl programs for ashgmt
if test "x$GMTHOME" != "x"; then
PATH="$PATH:$GMTHOME/bin"
fi

dnl The following all are required for ashgmt
AC_PATH_PROG(CONVERT,convert,,)
AC_ARG_VAR(CONVERT,path to convert)

AC_PATH_PROG(GMTSET,gmtset,,)
#AC_ARG_VAR(GMTSET,path to gmtset)

AC_PATH_PROG(PSCOAST,pscoast,,)
#AC_ARG_VAR(PSCOAST,path to pscoast)

AC_PATH_PROG(PSBASEMAP,psbasemap,,)
#AC_ARG_VAR(PSBASEMAP,path to psbasemap)

AC_PATH_PROG(PSXY,psxy,,)
#AC_ARG_VAR(PSXY,path to psxy)

AC_PATH_PROG(PSTEXT,pstext,,)
#AC_ARG_VAR(PSTEXT,path to pstext)

AC_PATH_PROG(PSCONTOUR,pscontour,,)
#AC_ARG_VAR(PSCONTOUR,path to pscontour)

AC_PATH_PROG(MAKECPT,makecpt,,)

AC_PATH_PROG(GIFSICLE, gifsicle,,)
AC_ARG_VAR(GIFSICLE, path to gifsicle)

AC_PATH_PROG(NCKS, ncks,,)
AC_PATH_PROG(NCAP, ncap,,)
AC_PATH_PROG(NCATTED, ncatted,,)

AC_PATH_PROG(GHOSTSCRIPT, gs,,)

dnl cgi's and other web stuff may reside in different places
#AC_ARG_VAR(CGIHOME, [location of CGI's])

dnl set ashdump.pl to the location we build here
if test "$prefix" != "NONE"; then
AC_SUBST(ASHDUMP,"${prefix}/bin/ashdump.pl")
AC_SUBST(PATH_TO_WEBPUFF,"${prefix}/web")
AC_SUBST(INSTALL_DIR,"${prefix}")
else
AC_SUBST(ASHDUMP,"${ac_default_prefix}/bin/ashdump.pl")
AC_SUBST(PATH_TO_WEBPUFF,"${ac_default_prefix}/web")
AC_SUBST(INSTALL_DIR,"${ac_default_prefix}")
fi

dnl build our own jpeg library if one was not found
AM_CONDITIONAL(ASHXP_BUILD_LIBJPEG, test "$ashxp_need_libjpeg" = "yes")

dnl check for getopt_long, and compile my version if it is not there
AC_CHECK_FUNCS([getopt getopt_long])
AC_CHECK_FUNC(getopt_long, , [puff_need_getopt_long="yes"] )
AM_CONDITIONAL(PUFF_NEED_GETOPT_LONG, test "$puff_need_getopt_long" = "yes")
#############################################
# if --with-freetype, check and add compiler flags
AC_ARG_WITH(freetype,AC_HELP_STRING([--with-freetype],[use freetype fonts (default is no)]))
if (test "x$withval" = "xyes"); then
  AC_LANG_PUSH(C)
  AC_CHECK_LIB(freetype, FT_Init_FreeType,,AC_ERROR([libfreetype not found]))
  ft_cflags=`freetype-config --cflags`
  CFLAGS="$CFLAGS $ft_cflags"
  ft_libs=`freetype-config --libs`
  LIBS="$LIBS $ft_libs"
  AC_LANG_POP(C)
fi
#############################################
# if --enable-warnings, add these compiler flags
AC_ARG_ENABLE(warnings,AC_HELP_STRING([--enable-warnings],[add compiler warnings (default is no)]),enable_warnings=$enableval, enable_warnings=no)

if test "$enable_warnings" = "yes"; then
  case $CXX in
    g++) CXXFLAGS="$CXXFLAGS -Wall";; dnl GNU compiler
    CC) CXXFLAGS="CXXFLAGS +w";; dnl SunWorkShop compiler
  esac
fi
#############################################
# if --with-statistics, define PUFF_STATISTICS
AC_ARG_WITH(statistics,AC_HELP_STRING([--with-statistics],[add statistical information(default is no)]),with_statistics=$withval, with_statistics=no)

if test "$with_statistics" = "yes"; then
  AC_DEFINE(PUFF_STATISTICS,1,make additional statistical information)
fi
#############################################
# give the option not to build documentation
AC_ARG_WITH(documentation,AC_HELP_STRING([--with-documentation],[make/install docs(default is yes)]),with_documentation=$withval,with_documentation=no)

AM_CONDITIONAL(BUILD_INSTALL_DOCS, test "$with_documentation" == "yes")
#############################################
dnl deal with bugs, my bugs in all likelyhood.
case $build in
  powerpc-apple-darwin6.8) AC_DEFINE(BUG_GMTIME,1,[swap localtime for gmtime]);;
esac

#############################################
dnl disable shared libraries
dnl There is limited use to using a shared library, and just increases compilation
dnl time and causes problems on many systems.
dnl In fact, it may be better if we got rid of using a library all together. It is
dnl only here as a learning tool, actually.
AC_DEFINE(ENABLE_SHARED,0,Enable shared libraries)
echo "disabling shared libraries..."

#############################################
AC_CONFIG_FILES([src/perl/ashdump.pl],[chmod +x src/perl/ashdump.pl])
AC_CONFIG_FILES([src/perl/grib2pf],[chmod +x src/perl/grib2pf])
AC_CONFIG_FILES([src/perl/ashgmt],[chmod +x src/perl/ashgmt])
AC_CONFIG_FILES([src/perl/rereference.pl],[chmod +x src/perl/rereference.pl])
AC_CONFIG_FILES([test/test00.sh],[chmod +x test/test00.sh])
AC_CONFIG_FILES([test/test00b.sh],[chmod +x test/test00b.sh])
AC_CONFIG_FILES([Makefile src/Makefile src/libsrc/Makefile test/Makefile])
AC_CONFIG_FILES([src/perl/Makefile web/Makefile])
if test "$with_documentation" == "yes"; then
AC_CONFIG_FILES([doc/Makefile])
fi
AC_CONFIG_FILES([web/mini_httpd/Makefile])
AC_CONFIG_FILES([src/libsrc/dmapf-c/Makefile])
AC_CONFIG_FILES([src/ashxp/Makefile])
AC_CONFIG_FILES([src/ashxp/jpeg-6b/Makefile])
dnl the perl scripts for the web interface
AC_CONFIG_FILES([web/ashxpOptions.pl],[chmod +x web/ashxpOptions.pl])
AC_CONFIG_FILES([web/runParams.pl],[chmod +x web/runParams.pl])
AC_CONFIG_FILES([web/main.pl],[chmod +x web/main.pl])
AC_CONFIG_FILES([web/login.pl],[chmod +x web/login.pl])
AC_CONFIG_FILES([web/logout.pl],[chmod +x web/logout.pl])
AC_CONFIG_FILES([web/webpuff],[chmod +x web/webpuff])
AC_CONFIG_FILES([web/Webpuff.pm])
dnl manual pages
AC_CONFIG_FILES([man/Makefile])
AC_OUTPUT
Something went wrong with that request. Please try again.