1dnl
2dnl configure.in:
3dnl
4dnl  Source file for GrADS auto-configuration script.
5dnl
6dnl  Run ./bootstrap to generate a configure script from this file
7dnl  using autoconf.
8dnl
9dnl  See acinclude.m4 for definitions of the GA_xxx macros
10
11# The version number
12# below is the "master" version that will appear in all code, etc.
13AC_INIT(GrADS, [1.9b4])
14
15# Require autoconf 2.52 (comes with Mac OS X 10.2) or newer
16AC_PREREQ(2.52)
17
18# Supporting scripts are in etc/
19AC_CONFIG_AUX_DIR(etc)
20
21# Require automake 1.6 (comes with Mac OS X 10.2) or newer,
22# don't #define PACKAGE and VERSION,
23# disable dependency checking
24AM_INIT_AUTOMAKE([1.6 no-define no-dependencies])
25
26AM_CONFIG_HEADER([src/config.h])
27
28# The following macro prevents annoying interactions between CVS and
29# automake, which result in make attempting to invoke autotools
30# even when the configure script is up to date
31AM_MAINTAINER_MODE
32
33
34# I personally think it is nicer to have binaries go to ./bin by default,
35# rather than /usr/bin.
36AC_PREFIX_DEFAULT(`pwd`)
37
38
39# ----------------------------------------------------
40#  Additional arguments for the configure script
41# ----------------------------------------------------
42
43AC_ARG_WITH(readline, AC_HELP_STRING([--with-readline],
44                    [command line editing via readline]))
45AC_ARG_WITH(printim,  AC_HELP_STRING([--with-printim],
46                    [printim command - image output using GD]))
47AC_ARG_WITH(lats,     AC_HELP_STRING([--with-lats],
48                    [LATS interface for generating GRIB and netCDF files]))
49AC_ARG_WITH(gui,      AC_HELP_STRING([--with-gui],
50                    [Athena X11 widget-based GUI]))
51AC_ARG_WITH(nc,      AC_HELP_STRING([--with-nc],
52                     [gradsnc executable, with netCDF support]))
53AC_ARG_WITH(dods,     AC_HELP_STRING([--with-dods],
54                     [gradsdods executable, with netCDF and DODS support]))
55AC_ARG_WITH(hdf,      AC_HELP_STRING([--with-hdf],
56                     [gradshdf executable, with netCDF and NCSA HDF4]))
57AC_ARG_WITH(xlibemu,  AC_HELP_STRING([--with-xlibemu],
58		     [Use X11 Emulation library (Win32 only)]))
59
60AC_ARG_WITH(wi,       AC_HELP_STRING([--with-wi],
61                    [wi command - image output using ImageMagick \
62                     (Note: this feature is deprecated in favor of the \
63		      printim command,  and is disabled by default.]))
64
65AC_ARG_ENABLE(old-supplibs, AC_HELP_STRING([--enable-old-supplibs],
66    [Use pre-1.9 non-canonical names for supplib directories]),
67    [old_supplibs="yes"])
68
69AC_ARG_ENABLE(dyn-supplibs, AC_HELP_STRING([--enable-dyn-supplibs],
70    [Use dynamic (shared object) system libraries, if present, for optional features. This will produce smaller, but possibly less portable, binaries. By default, only static libraries from a GrADS supplibs distribution will be used for optional feature support to maximize binary portability.]),
71    [ GA_ENABLE_DYNAMIC() ])
72
73AC_ARG_VAR(SUPPLIBS,
74           [Custom path (must be absolute) to a GrADS supplib distribution])
75
76
77# ----------------------------------------------------
78# Checks for programs
79# ----------------------------------------------------
80
81echo
82echo "Checking for programs"
83echo "------------------"
84if test -z "$CFLAGS" ; then
85  CFLAGS="-g -O"
86fi
87AC_PROG_AWK
88AC_PROG_CC
89AC_PROG_CXX
90AC_PROG_INSTALL
91AC_PROG_LN_S
92echo
93
94echo "Setting host specific options"
95echo "-------------------------"
96
97# ----------------------------------------------------
98# Get host platform
99# ----------------------------------------------------
100
101AC_CANONICAL_HOST()
102
103# echo Host machine:   "$host"
104# echo Host vendor: "$host_vendor"
105# echo Host OS:     "$host_os"
106# echo Host CPU:    "$host_cpu"
107
108# ----------------------------------------------------
109# Set supplibs directory name
110# ----------------------------------------------------
111
112GA_SET_SUPPLIBS([. ..])
113
114# ----------------------------------------------------
115# Set host specific options
116# ----------------------------------------------------
117
118case "$host" in
119
120  alpha-*-osf*)
121    # Option needed for IEEE floating points
122    CFLAGS="$(CFLAGS) -ieee"
123  ;;
124
125  cray-*-*)
126    # Used for define below
127    is_cray="yes"
128  ;;
129
130  i*86-pc-linux-*)
131  ;;
132
133  sparc-sun-solaris*)
134    # Some system calls are in unusual places
135    host_ldadd="-lsocket -lnsl -lw"
136    guilibadd="-lSM -lICE"
137  ;;
138
139dnl ARLINDO please edit the win stuff appropriately
140  i*86-*-win*)
141
142    if test "$with_xlibemu" != "no" ; then
143      echo "Check for X emulation libraries..."
144      AC_CHECK_LIB(grx20, main, [use_xlibemu=yes])
145      if test "$use_xlibemu" = "yes" ; then
146       	xlibemu_libs="-lgrx20 -mwindows"
147	AC_SUBST(xlibemu_libs)
148      fi
149    fi
150  ;;
151
152  *-hpux11*)
153     # Used for define below
154     is_hpux11="yes"
155  ;;
156
157  *-darwin*)
158     # Used for DODS 3.2 linking kludge
159     is_darwin="yes"
160  ;;
161esac
162
163if test is_cray!="yes" ; then
164   AC_DEFINE(GRADS_CRAY, 0, [Machine is NOT a Cray])
165else
166    AC_DEFINE(GRADS_CRAY, 1, [Machine is a Cray])
167fi
168
169if test is_hpux11!="yes" ; then
170AC_DEFINE(GRADS_HP64, 0, [Machine is NOT a 64-bit HP])
171else
172AC_DEFINE(GRADS_HP64, 1, [Machine is 64-bit HP])
173fi
174
175# ----------------------------------------------------
176# Check for basic libraries.
177# ----------------------------------------------------
178
179echo
180echo "Checking system libraries, headers, and compiler features"
181echo "-----------------------------------------"
182
183AC_CHECK_LIB(m,cos,, AC_MSG_ERROR([Fatal: Math library not found]))
184
185dnl get X11 library path
186AC_PATH_XTRA
187
188dnl for basic X-windows support
189dnl joew: Don't think this is needed after AC_PATH_XTRA
190# AC_CHECK_LIB(X11, XOpenDisplay,, AC_MSG_ERROR([Fatal: X11 library not found]))
191
192echo
193
194# ----------------------------------------------------
195# Check for basic header files.
196# ----------------------------------------------------
197
198AC_HEADER_STDC
199AC_CHECK_HEADERS(malloc.h sys/file.h unistd.h)
200echo
201
202dnl Checks for typedefs, structures, and compiler characteristics.
203AC_C_CONST
204
205dnl joew - In autoconf 2.52, AC_C_BIGENDIAN seems to ignore its
206dnl parameters, so I test the internal variable that it sets.  Note
207dnl that AC_BIG_ENDIAN defines its own macro, WORDS_BIGENDIAN, so
208dnl really it would make most sense to replace the instances of
209dnl BYTEORDER in the GrADS source; but that might cause confusion
210dnl among longtime users.
211AC_C_BIGENDIAN
212if test $ac_cv_c_bigendian = "yes" ; then
213   AC_DEFINE(BYTEORDER,1,[BIG_ENDIAN machine])
214else
215   AC_DEFINE(BYTEORDER,0,[little_endian machine])
216fi
217
218dnl The following tests all check for functions and typedefs that are
219dnl required for GrADS, but 1) I don't think we support any platforms
220dnl where they fail, and 2) if they do, there is no backup plan
221dnl anyway. So I figure we might as well speed the script up a bit by
222dnl commenting them out, unless/until there is some actual handling
223dnl for failure.
224
225dnl AC_TYPE_SIZE_T AC_STRUCT_TM
226
227dnl Checks for library functions.
228dnl AC_TYPE_SIGNAL
229dnl AC_FUNC_STRFTIME
230dnl AC_FUNC_VPRINTF
231dnl AC_CHECK_FUNCS(strdup strstr strtod strtol)
232
233dnl In this case we do have an alternative - valprs()
234AC_CHECK_FUNCS(strtod)
235
236dnl Check for and set up large file support via fseeko()
237AC_TYPE_OFF_T
238AC_SYS_LARGEFILE
239AC_FUNC_FSEEKO
240
241# ----------------------------------------------------
242# Check for optional feature support
243# ----------------------------------------------------
244
245echo
246echo Checking for optional feature support
247echo ------------------------------------
248
249AC_MSG_CHECKING([whether to use dynamic linking])
250if test "$ga_dyn_supplibs" = "yes" ; then
251   AC_MSG_RESULT([yes (Warning: binaries may not be suitable for distribution)])
252else
253   AC_MSG_RESULT([no])
254fi
255
256echo
257
258use_readline=no
259if test "$with_readline" != "no" ; then
260  echo "Check GrADS command line editing support..."
261  GA_CHECK_READLINE([use_readline=yes])
262fi
263if test $use_readline = "yes" ; then
264  echo "+ Command line editing enabled"
265  GA_SET_LIB_VAR(readline_libs, readline)
266  AC_SUBST(readline_libs)
267  AC_DEFINE(READLINE, 1, [Enable command line editing])
268  AC_DEFINE(MM_READLINE,,[Enhanced readline with history])
269else
270  echo "- Command line editing disabled"
271  AC_DEFINE(READLINE, 0, [Enable command line editing])
272fi
273echo
274
275
276use_gui=no
277if test "$with_gui" != "no" ; then
278   echo "Check GrADS GUI support..."
279   GA_CHECK_GUI([use_gui=yes])
280fi
281if test $use_gui = "yes" ; then
282  AC_DEFINE(USEGUI, 1, [Enable GUI widgets])
283  echo "+ GUI enabled"
284  GA_SET_LIB_VAR(gui_libs, [sx freq])
285  gui_libs="$gui_libs -lXaw -lXmu -lXt $guilibadd"
286  AC_SUBST(gui_libs)
287else
288  AC_DEFINE(USEGUI, 0, [Enable GUI widgets])
289  echo  "- GUI disabled"
290fi
291echo
292
293
294use_printim=no
295if test "$with_printim" != "no" ; then
296  echo "Check GrADS printim support..."
297  GA_CHECK_GD([use_printim=yes], [])
298fi
299
300if test $use_printim = "yes" ; then
301  AC_DEFINE(GXPNG, 1, [Enable printim using GD library \
302                       (http://www.boutell.com/gd) for PNG/GIF images])
303  GA_SET_LIB_VAR(printim_libs, [gd png z])
304  AC_SUBST(printim_libs)
305  extra_utils="$extra_utils gxtran"
306  echo "+ printim enabled"
307else
308  AC_DEFINE(GXPNG, 0, [Enable printim using GD library \
309                       (http://www.boutell.com/gd) for PNG/GIF images])
310  echo "- printim disabled (Warning: gxtran will not be built)"
311fi
312echo
313
314
315use_wi=no
316AC_MSG_CHECKING([if wi command has been enabled])
317# ImageMagick is disabled by default
318if test "$with_wi" = "yes" ; then
319   AC_MSG_RESULT(yes)
320   echo "Checking for wi command's support libraries & headers..."
321   GA_CHECK_IMG([use_wi=yes], [])
322else
323   AC_MSG_RESULT(no)
324fi
325
326if test $use_wi = "yes" ; then
327   AC_DEFINE(USEIMG, 1, [Enable wi using ImageMagick library])
328   echo "+ wi enabled (Warning: this feature is deprecated and may not"\
329        " build properly)"
330   LIBS="-lMagick -ljpeg $LIBS -lXext"
331   GA_SET_LIB_VAR(wi_libs, [Magick jpeg])
332   AC_SUBST(wi_libs)
333   wi_libadd="-lXext"
334   AC_SUBST(wi_libadd)
335else
336   AC_DEFINE(USEIMG, 0, [Enable wi using ImageMagick library])
337   echo "- wi disabled"
338fi
339echo
340
341if test "$with_lats" != "no" ; then
342  AC_DEFINE(USELATS, 1, [Enable LATS ])
343  echo "+ LATS enabled"
344  use_lats=yes
345else
346  AC_DEFINE(USELATS, 0, [Enable LATS ])
347  echo "- LATS disabled"
348  use_lats=no
349fi
350
351echo
352echo Checking which GrADS binaries can be built
353echo ------------------------------------
354
355use_nc=no
356if test "$with_nc" != "no" ; then
357     GA_CHECK_NC([use_nc=yes])
358fi
359if test $use_nc = "yes" ; then
360  GA_SET_LIB_VAR(nc_libs, [netcdf udunits])
361  AC_SUBST(nc_libs)
362  extra_bins="$extra_bins gradsnc"
363  echo "+ gradsnc (plain netCDF) build enabled"
364else
365  echo "- gradsnc (plain netCDF) build disabled"
366fi
367echo
368
369
370use_hdf=no
371if test "$with_hdf" != "no" ; then
372  GA_CHECK_HDF([use_hdf=yes])
373fi
374if test $use_hdf = "yes" ; then
375    GA_SET_LIB_VAR(hdf_libs, [mfhdf df jpeg udunits z])
376    AC_SUBST(hdf_libs)
377    extra_bins="$extra_bins gradshdf"
378    echo "+ gradshdf (HDF-SDS/netCDF) build enabled"
379else
380  echo "- gradshdf (HDF-SDS/netCDF) build disabled"
381fi
382echo
383
384
385use_dods=no
386if test "$with_dods" != "no" ; then
387  GA_CHECK_DODS([use_dods=yes])
388fi
389
390if test $use_dods = "yes" ; then
391
392    extra_bins="$extra_bins gradsdods"
393    GA_SET_LIB_VAR(dods_libs, [udunits www rx z])
394
395
396    GA_CHECK_LIB(gadods, main, [use_gadods=yes], [use_gadods=no])
397    if test $use_gadods = "yes" ; then
398       dods_rep_libs="-lgadods -lnc-dods -ldap++"
399       gadods_def="-DUSEGADODS=1"
400       echo "+ gradsdods (OPeNDAP/netCDF) build enabled - gridded and station interfaces"
401    else
402       dods_rep_libs="-lnc-dods -ldap++"
403       gadods_def="-DUSEGADODS=0"
404       echo "+ gradsdods (OPeNDAP/netCDF) build enabled - gridded interface only"
405    fi
406
407    dods_libs="$dods_rep_libs $dods_rep_libs $dods_libs"
408    AC_SUBST(dods_libs)
409    AC_SUBST(gadods_def)
410else
411    echo "- gradsdods (OPeNDAP/netCDF) build disabled"
412fi
413
414echo
415
416#  ----------------------------------------------------
417# Send test results to makefile and config.h
418# ----------------------------------------------------
419
420# Some non-configuration-dependent GrADS macros
421AC_DEFINE(GRADS_VERSION, "AC_PACKAGE_VERSION", [GrADS version])
422AC_DEFINE(GRADS_DESC,, [Obsolete feature description string])
423AC_DEFINE(PRINT_EPS,,[Integrate gxeps command into print])
424dnl AC_DEFINE(PRINTIM_JPEG)
425dnl AC_DEFINE(MM_NEW_PROMPT)
426
427# These are used to add the necessary source files to Makefile targets
428AM_CONDITIONAL(READLINE, [ test "$use_readline"  = "yes" ] )
429AM_CONDITIONAL(USEGUI,   [ test "$use_gui"  = "yes" ] )
430AM_CONDITIONAL(GXPNG,    [ test "$use_printim"  = "yes" ] )
431AM_CONDITIONAL(USEIMG,   [ test "$use_wi"  = "yes" ] )
432AM_CONDITIONAL(USELATS,  [ test "$use_lats" = "yes" ] )
433AM_CONDITIONAL(USEGADODS,[ test "$use_gadods" = "yes" ] )
434AM_CONDITIONAL(XLIBEMU,  [ test "$use_xlibemu" = "yes" ] )
435
436# These control which binaries are built
437AM_CONDITIONAL(USEDODS,  [ test "$use_dods" = "yes" ] )
438AM_CONDITIONAL(USENC,    [ test "$use_nc" = "yes" ] )
439AM_CONDITIONAL(USEHDF,   [ test "$use_hdf" = "yes" ] )
440AC_SUBST(extra_bins)
441AC_SUBST(extra_utils)
442
443# Host specific linker flags
444AC_SUBST(host_ldadd)
445
446# Hack to deal with Darwin C++ quirk: template instantiations can't
447# be done inside archives, and must be separate objects.
448# So inst.o is extracted from libdap++.a and linked separately.
449AM_CONDITIONAL(DODS_DARWIN,   [ test "$is_darwin" = "yes" \
450			      	&& test "$use_dods" = "yes"])
451
452
453dnl ----------------------------------------------------
454dnl Print summary and write output files
455dnl ----------------------------------------------------
456
457build_date=`date +%D`
458build_host=`uname -sr`
459build_info="Built `date` for ${host}"
460
461   echo \
462"  +=========================================================================+"
463   echo "   GrADS "AC_PACKAGE_VERSION ":" $build_info
464   echo \
465"  +=========================================================================+"
466   echo
467   echo "  +----------------------------------+"
468   echo "  |                                  |"
469   echo "  | Configuration Summary            |"
470   echo "  |                                  |"
471if test "$use_readline" = "yes" ; then
472   echo "  |  + readline enabled              |"
473else
474   echo "  |  - readline disabled             |"
475fi
476if test "$use_printim" = "yes" ; then
477   echo "  |  + printim enabled               |"
478else
479   echo "  |  - printim disabled              |"
480fi
481if test "$use_gui" = "yes" ; then
482   echo "  |  + GUI enabled                   |"
483else
484   echo "  |  - GUI disabled                  |"
485fi
486if test "$use_lats" = "yes" ; then
487   echo "  |  + LATS enabled                  |"
488else
489   echo "  |  - LATS disabled                 |"
490fi
491if test "$use_wi" = "yes" ; then
492   echo "  |  + wi enabled (deprecated)       |"
493else
494   echo "  |  - wi disabled (default)         |"
495fi
496   echo "  |                                  |"
497   echo "  | Build Summary                    |"
498   echo "  |                                  |"
499   echo "  |  + gradsc    (classic) enabled   |"
500if test "$use_nc" = "yes" ; then
501   echo "  |  + gradsnc   (netCDF)  enabled   |"
502else
503   echo "  |  - gradsnc   (netCDF)  disabled  |"
504fi
505if test "$use_hdf" = "yes" ; then
506   echo "  |  + gradshdf  (HDF-SDS) enabled   |"
507else
508   echo "  |  - gradshdf  (HDF-SDS) disabled  |"
509fi
510if test "$use_dods" = "yes" ; then
511   echo "  |  + gradsdods (OPeNDAP) enabled   |"
512  if test "$use_gadods" = "yes" ; then
513   echo "  |    (both grid & stn interfaces)  |"
514  else
515   echo "  |    (grid interface only)         |"
516  fi
517else
518   echo "  |  - gradsdods (OPeNDAP) disabled  |"
519fi
520   echo "  |                                  |"
521if test "$ga_dyn_supplibs" = "yes" ; then
522   echo "  |  + Dynamic linking enabled       |"
523else
524   echo "  |  - Dynamic linking disabled      |"
525fi
526   echo "  |                                  |"
527   echo "  +----------------------------------+"
528
529echo "configure: creating src/VERSION"
530echo AC_PACKAGE_VERSION > src/VERSION
531
532echo "configure: creating src/buildinfo.h"
533mkdir -p src
534echo "static char *buildinfo = \"${build_info}\";" > src/buildinfo.h
535
536AC_CONFIG_FILES([Makefile src/Makefile])
537AC_OUTPUT
538
539echo
540echo "Run 'make && make install' to build GrADS."
541echo "Executables will be installed" \
542     "to bin/ in current dir, unless prefix was specified."
543echo
544