1 dnl **** Process this file with autoconf to produce a configure script.
6 AC_CONFIG_AUX_DIR(ac-tools)
8 AC_CONFIG_HEADER(include/config.h:ac-tools/config.h.in)
10 AC_PREFIX_DEFAULT("/usr/local")
12 builtin(include, ac-tools/aclocal.m4)
18 AC_SUBST(MKINSTALLDIRS)
38 AC_SUBST(GRACE_EDITOR)
53 dnl **** Those are for T1lib
55 AC_SUBST(T1_AA_TYPE16)
56 AC_SUBST(T1_AA_TYPE32)
57 AC_SUBST(T1_AA_TYPE64)
59 dnl **** Grace version numbers
65 VERSTRING=${MAJOR_REV}.${MINOR_REV}.${PATCHLEVEL}
66 if test "x${program_suffix}" = "xNONE"
68 PROG_SUFFIX="-$VERSTRING"
70 PROG_SUFFIX=${program_suffix}
73 dnl **** define home dir of Grace
74 if test "x${prefix}" = "xNONE"
76 GRACE_HOME=${ac_default_prefix}/grace-$VERSTRING
78 GRACE_HOME=${prefix}/grace
80 AC_ARG_ENABLE(grace-home,
81 [ --enable-grace-home=DIR define Grace home dir [[PREFIX/grace-x.y.z]]],
82 [GRACE_HOME="${enableval}"])
85 dnl **** option to define config file overriding autodetect
87 [ --enable-config=FILE define configuration FILE to override
88 autodetection (not recommended!)],
89 [CONF_FILE="${enableval}"])
91 dnl **** define C compiler
94 [ --with-cc=PROG use PROG as C compiler [${CC-gcc}]],
97 dnl **** define Fortran compiler
100 [ --with-f77=PROG use PROG as Fortran compiler [${FC-f77}]],
103 dnl Chance to add include path
104 AC_ARG_WITH(extra-incpath,
105 [ --with-extra-incpath=PATH define extra include path (dir1:dir2:...) [[none]]],
106 [CPPFLAGS="${CPPFLAGS} -I`echo ${withval}|sed 's/:/\ -I/g'`"])
109 AC_ARG_WITH(extra-ldpath,
110 [ --with-extra-ldpath=PATH define extra ld path (dir1:dir2:...) [[none]]],
111 [LDFLAGS="-L`echo ${withval}|sed 's/:/\ -L/g'` ${LDFLAGS}";
113 sparc-sun-solaris*) LDFLAGS="-R:${withval} ${LDFLAGS}";;
117 dnl **** use bundled T1lib
118 AC_ARG_WITH(bundled_t1lib,
119 [ --with-bundled-t1lib use bundled T1lib [[no]]],
120 [case "${withval}" in
121 yes) bundled_t1lib=true ;;
122 no) bundled_t1lib=false;;
123 *) AC_MSG_ERROR(bad value ${withval} for --with-bundled-t1lib) ;;
124 esac],[bundled_t1lib=false])
126 dnl **** use bundled Expat
127 AC_ARG_WITH(bundled_expat,
128 [ --with-bundled-expat use bundled Expat [[no]]],
129 [case "${withval}" in
130 yes) bundled_expat=true ;;
131 no) bundled_expat=false;;
132 *) AC_MSG_ERROR(bad value ${withval} for --with-bundled-expat) ;;
133 esac],[bundled_expat=false])
135 dnl **** use bundled Xbae
136 AC_ARG_WITH(bundled_xbae,
137 [ --with-bundled-xbae use bundled Xbae [[yes]]],
138 [case "${withval}" in
139 yes) bundled_xbae=true ;;
140 no) bundled_xbae=false;;
141 *) AC_MSG_ERROR(bad value ${withval} for --with-bundled-xbae) ;;
142 esac],[bundled_xbae=true])
145 AC_ARG_ENABLE(netcdf,
146 [ --enable-netcdf enable support for netCDF [[yes]]],
147 [case "${enableval}" in
150 *) AC_MSG_ERROR(bad value ${enableval} for --enable-netcdf) ;;
155 [ --with-fftw use FFTW library for Fourier transforms [[yes]]],
156 [case "${withval}" in
159 *) AC_MSG_ERROR(bad value ${withval} for --with-fftw) ;;
162 dnl **** whether to build JPEG driver
163 AC_ARG_ENABLE(jpegdrv,
164 [ --enable-jpegdrv build JPEG driver [[yes]]],
165 [case "${enableval}" in
168 *) AC_MSG_ERROR(bad value ${enableval} for --enable-jpegdrv) ;;
169 esac],[jpegdrv=true])
171 dnl **** whether to build PNG driver
172 AC_ARG_ENABLE(pngdrv,
173 [ --enable-pngdrv build PNG driver [[yes]]],
174 [case "${enableval}" in
177 *) AC_MSG_ERROR(bad value ${enableval} for --enable-pngdrv) ;;
180 dnl **** whether to build PDF driver
181 AC_ARG_ENABLE(pdfdrv,
182 [ --enable-pdfdrv build PDF driver [[yes]]],
183 [case "${enableval}" in
186 *) AC_MSG_ERROR(bad value ${enableval} for --enable-pdfdrv) ;;
190 AC_ARG_ENABLE(editres,
191 [ --enable-editres enable editres support [[yes]]],
192 [case "${enableval}" in
195 *) AC_MSG_ERROR(bad value ${enableval} for --enable-editres) ;;
196 esac],[editres=true])
199 AC_ARG_ENABLE(xmhtml,
200 [ --enable-xmhtml use XmHTML widget for on-line help [[yes]]],
201 [case "${enableval}" in
204 *) AC_MSG_ERROR(bad value ${enableval} for --enable-xmhtml) ;;
207 dnl **** define editor
208 GRACE_EDITOR="'xterm -e vi'"
210 [ --with-editor=COMMAND define editor [[\"xterm -e vi\"]]],
211 [GRACE_EDITOR="'${withval}'"])
213 dnl **** define help viewer
214 AC_ARG_WITH(helpviewer,
215 [ --with-helpviewer=COMMAND define (alternative) help viewer command],
216 [HELPVIEWER="-DGRACE_HELPVIEWER=${withval}"])
218 dnl **** define print command
219 AC_ARG_WITH(printcmd,
220 [ --with-printcmd=PROG use PROG for printing],
221 [if test "x${withval}" != "x"; then
222 PRINT_CMD="'${withval}'"
229 dnl **** default papersize
230 AC_ARG_ENABLE(papersize,
231 [ --enable-papersize=PAPER select paper size for docs (a4 or letter) [[a4]]],
232 [case "${enableval}" in
234 letter) PAPERSIZE=letter;;
235 *) AC_MSG_ERROR(bad value ${enableval} for --enable-papersize) ;;
236 esac],[PAPERSIZE=a4])
238 dnl **** check if user wants to compile with debugging support
240 [ --enable-debug turn on support for debugging [[no]]],
241 [case "${enableval}" in
244 *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
247 dnl **** maintainer mode
248 AC_ARG_ENABLE(maintainer,
249 [ --enable-maintainer enable maintainer's mode [[no]]],
250 [case "${enableval}" in
251 yes) maintainer=true; debug=true ;;
252 no) maintainer=false ;;
253 *) AC_MSG_ERROR(bad value ${enableval} for --enable-maintainer) ;;
254 esac],[maintainer=false])
256 if test $maintainer = true
258 AC_DEFINE(WITH_DEBUG)
262 dnl **** Possibility to override defaults
263 if test "x$CONF_FILE" != "x"
265 if test -r $CONF_FILE
267 AC_MSG_RESULT(--> using \`$CONF_FILE' as config file)
270 AC_MSG_ERROR(--> Can't open file \`$CONF_FILE' for reading!)
274 dnl **** Define CFLAGS etc empty to prevent configure from setting them
277 LDFLAGS=${LDFLAGS-""}
278 OPTIMIZE=${OPTIMIZE-""}
282 dnl **** Check for host type
285 dnl Checks for C compiler
292 if test "x${CFLAGS}" = "x"
294 if test "x${GCC}" = "xyes"
296 dnl **** default settings for gcc
299 CFLAGS="-fno-common -Wall -pedantic -Wpointer-arith -Wnested-externs"
301 dnl **** check for strength-reduce bug
302 ACX_GCC_STRENGTH_REDUCE(CFLAGS="$CFLAGS -fno-strength-reduce")
304 dnl **** some arch-specific optimizations/settings for gcc
306 i486-*) CPU_FLAGS="-m486";;
307 i586-*) ACX_CHECK_CC_FLAGS(-mcpu=pentium,cpu_pentium,
308 [CPU_FLAGS=-mcpu=pentium],
309 [ACX_CHECK_CC_FLAGS(-mpentium,pentium,
310 [CPU_FLAGS=-mpentium], [CPU_FLAGS=-m486])])
312 i686-*) ACX_CHECK_CC_FLAGS(-mcpu=pentiumpro,cpu_pentiumpro,
313 [CPU_FLAGS=-mcpu=pentiumpro],
314 [ACX_CHECK_CC_FLAGS(-mpentiumpro,pentiumpro,
315 [CPU_FLAGS=-mpentiumpro], [CPU_FLAGS=-m486])])
319 CFLAGS="$CPU_FLAGS $CFLAGS"
328 CFLAGS="-Aa -D_HPUX_SOURCE"
332 mips-sgi-irix6.[[4-9]]*)
334 OPTIMIZE="-O2 -OPT:Olimit=0"
335 DEBUG="-g3 -O2 -OPT:Olimit=0"
338 CFLAGS="-fullwarn -woff 835"
339 OPTIMIZE="-O2 -Olimit 3500"
342 CFLAGS="-D_ALL_SOURCE"
356 true) CFLAGS="$DEBUG $CFLAGS";;
357 *) CFLAGS="$OPTIMIZE $CFLAGS";;
362 if test ! -x $FC; then
366 *) AC_CHECK_PROG(fc, $FC, $FC, no)
371 if test "${FC}" = "no"
373 AC_MSG_RESULT(--> Fortran tests won't be compiled)
377 dnl **** Check for some compiler/system characteristics
379 AC_CHECK_SIZEOF(char,0)
380 AC_CHECK_SIZEOF(short,0)
381 AC_CHECK_SIZEOF(int,0)
382 AC_CHECK_SIZEOF(long,0)
383 AC_CHECK_SIZEOF(long long,0)
384 AC_CHECK_SIZEOF(float,0)
385 AC_CHECK_SIZEOF(double,0)
386 AC_CHECK_SIZEOF(long double,0)
387 AC_CHECK_SIZEOF(void *,0)
389 dnl **** Check for endianess
392 dnl **** Checks for FPU arithmetics
395 dnl **** .exe/.obj file extensions
403 dnl **** Checks for programs.
404 AC_CHECK_PROG(AR, ar, ar, NONE)
405 if test "$AR" = "NONE"; then
406 AC_MSG_ERROR(--> Can't find \`ar'!)
418 *) INSTALL=`pwd`/ac-tools/"shtool install -c" ;
421 MKINSTALLDIRS=`pwd`/ac-tools/"shtool mkdir -p -f"
423 if test "x$PRINT_CMD" = "xNONE"; then
424 AC_CHECK_PROG(LP_CMD, lp, 'lp -c', "NONE")
425 if test "${ac_cv_prog_LP_CMD}" = "NONE"; then
426 AC_CHECK_PROG(LPR_CMD, lpr, 'lpr', "NONE")
427 if test "${ac_cv_prog_LPR_CMD}" = "NONE"; then
430 PRINT_CMD="${ac_cv_prog_LPR_CMD}"
433 PRINT_CMD="${ac_cv_prog_LP_CMD}"
437 AC_MSG_RESULT(--> Using \"$PRINT_CMD\" to print)
439 dnl **** Checks for header files.
442 AC_CHECK_HEADERS(unistd.h fcntl.h)
443 AC_CHECK_HEADERS(sys/param.h sys/time.h sys/select.h)
445 dnl **** math.h and related
446 AC_CHECK_HEADERS(math.h float.h ieeefp.h)
448 dnl **** Checks for typedefs, structures, and compiler characteristics.
454 dnl **** Checks for library functions.
457 AC_CHECK_FUNCS(getcwd gethostname)
458 AC_CHECK_FUNCS(strstr)
459 AC_CHECK_FUNCS(memcpy memmove bcopy)
460 AC_CHECK_FUNCS(unlink fcntl)
461 AC_CHECK_FUNCS(popen)
462 AC_CHECK_FUNCS(gettimeofday)
463 AC_CHECK_FUNCS(fnmatch)
464 AC_CHECK_FUNCS(vsnprintf)
465 AC_CHECK_FUNCS(on_exit)
466 AC_CHECK_FUNCS(strerror)
467 if test "$ac_cv_func_strerror" = no; then
468 AC_CACHE_CHECK([for sys_errlist declaration in stdio.h], ac_cv_sys_errlist_decl,
469 AC_EGREP_HEADER(sys_errlist, stdio.h, ac_cv_sys_errlist_decl="yes",
470 ac_cv_sys_errlist_decl="no"))
471 if test "$ac_cv_sys_errlist_decl" = yes; then
472 AC_DEFINE(HAVE_SYS_ERRLIST_DECL)
476 ICE_CHECK_DECL(drand48, stdlib.h)
478 dnl **** Check for locale
479 AC_CHECK_FUNCS(setlocale)
481 dnl **** Check for buggy realloc()
482 ACX_CHECK_REALLOC(AC_DEFINE(REALLOC_IS_BUGGY))
484 dnl **** Checks for libm
487 dnl **** Those functions are usually found in libm but...
488 ICE_CHECK_DECL(hypot, math.h)
489 ICE_CHECK_DECL(rint, math.h)
490 ICE_CHECK_DECL(cbrt, math.h)
491 ICE_CHECK_DECL(log2, math.h)
492 ICE_CHECK_DECL(asinh, math.h)
493 ICE_CHECK_DECL(acosh, math.h)
494 ICE_CHECK_DECL(atanh, math.h)
495 ICE_CHECK_DECL(lgamma, math.h)
497 dnl **** The machten4 (unix for mac) system does have signgam in libm
498 dnl **** but it is not declared in <math.h>
499 if test "$ac_cv_func_lgamma" = yes; then
500 AC_CACHE_CHECK([for signgam declaration in math.h], ac_cv_signgam_decl,
501 AC_EGREP_HEADER(signgam, math.h, ac_cv_signgam_decl="yes",
502 ac_cv_signgam_decl="no"))
503 if test "$ac_cv_signgam_decl" = yes; then
504 AC_DEFINE(HAVE_SIGNGAM_DECL)
508 ICE_CHECK_DECL(erf, math.h)
509 ICE_CHECK_DECL(erfc, math.h)
510 ICE_CHECK_DECL(j0, math.h)
511 ICE_CHECK_DECL(j1, math.h)
512 ICE_CHECK_DECL(jn, math.h)
513 ICE_CHECK_DECL(y0, math.h)
514 ICE_CHECK_DECL(y1, math.h)
515 ICE_CHECK_DECL(yn, math.h)
516 ICE_CHECK_DECL(finite, math.h)
517 dnl **** C9X-compatible isfinite() may be a good replacement for finite()
518 if test "$ac_cv_lib_m_finite" != yes; then
519 ICE_CHECK_DECL(isfinite, math.h)
521 ICE_CHECK_DECL(isnan, math.h)
523 dnl **** Check for T1lib installed
524 if test $bundled_t1lib = false
526 ACX_CHECK_T1LIB(5.0.2, AC_DEFINE(HAVE_LIBT1), bundled_t1lib=true)
529 if test $bundled_t1lib = true
531 dnl **** Use the bundled T1lib
533 AC_MSG_RESULT(--> Bundled version of T1lib will be used)
535 T1_LIB='$(TOP)/T1lib/libt1.a'
536 T1_INC='-I$(TOP)/T1lib/t1lib'
539 dnl **** Check ANSI types
542 AC_MSG_RESULT(--> Good. Seems you have compatible version of T1lib installed)
545 dnl **** Check for Expat installed
546 if test $bundled_expat = false
548 ACX_CHECK_EXPAT(1.95.7, AC_DEFINE(HAVE_EXPAT), bundled_expat=true)
551 if test $bundled_expat = true
553 dnl **** Use the bundled Expat
555 AC_MSG_RESULT(--> Bundled version of Expat will be used)
557 EXPAT_LIB='$(TOP)/expat/libexpat.a'
558 EXPAT_INC='-I$(TOP)/expat'
561 AC_MSG_RESULT(--> Good. Seems you have compatible version of Expat installed)
564 dnl **** Check for XDR
565 mdw_CHECK_MANYLIBS(xdrstdio_create, nsl rpc xdr rpclib, XDR_LIB=$mdw_cv_lib_xdrstdio_create, XDR_LIB="NONE")
567 if test "${XDR_LIB}" = "NONE"; then
569 AC_MSG_RESULT(--> No XDR library found; grconvert will not be built)
571 grconvert_dir="grconvert"
574 dnl **** Check for dlopen() interface
575 dnl (Linux, SunOS-[4,5], OSF, IRIX, AIX-4, UnixWare, ...)
576 mdw_CHECK_MANYLIBS(dlopen, dl, [DL_LIB=$mdw_cv_lib_dlopen; AC_DEFINE(HAVE_DLOPEN)], DL_LIB="NONE")
578 if test "${DL_LIB}" != "NONE"; then
579 dnl **** Old implementations of dlopen() don't have RTLD_NOW
580 AC_CACHE_CHECK([whether RTLD_NOW is defined in dlfcn.h], ac_rtld_now_in_dlfcn_h,
586 ], ac_rtld_now_in_dlfcn_h="yes"; AC_DEFINE(HAVE_RTLD_NOW),
587 ac_rtld_now_in_dlfcn_h="no")
590 dnl **** Check for shl_load() interface (HP/UX)
591 mdw_CHECK_MANYLIBS(shl_load, dld, [DL_LIB=$mdw_cv_lib_shl_load; AC_DEFINE(HAVE_SHL_LOAD)], DL_LIB="NONE")
594 if test "${DL_LIB}" = "NONE"; then
595 AC_MSG_RESULT(--> Support for dll modules will not be compiled)
599 if test $netcdf = true
601 ACX_CHECK_NETCDF(3.0, AC_DEFINE(HAVE_NETCDF),
602 AC_MSG_RESULT(--> support for netCDF is disabled))
607 ACX_CHECK_FFTW(2.1.3, AC_DEFINE(HAVE_FFTW),
608 AC_MSG_RESULT(--> using legacy unoptimized FFT code))
611 dnl **** check for libz - needed for PDF and PNG drivers and XmHTML
612 if test $pngdrv = true || test $pdfdrv = true || test $xmhtml = true
614 ACX_CHECK_ZLIB(1.0.3)
617 dnl **** check for libxmi - needed for all raster drivers
618 ACX_CHECK_XMI(1.2, , jpegdrv=false;pngdrv=false;
619 AC_MSG_RESULT(--> all raster drivers are disabled))
621 dnl **** check for IJG's libjpeg - also, for PDF driver and XmHTML
622 if test $jpegdrv = true || test $pdfdrv = true || test $xmhtml = true
624 ACX_CHECK_JPEG(61, AC_DEFINE(HAVE_LIBJPEG),
625 AC_MSG_RESULT(--> JPEG backend is disabled))
628 dnl **** check for libpng - needed for PDF and PNG drivers and XmHTML
629 if test $pngdrv = true || test $pdfdrv = true || test $xmhtml = true
631 ACX_CHECK_PNG(0.9.6, AC_DEFINE(HAVE_LIBPNG),
632 AC_MSG_RESULT(--> PNG backend is disabled))
635 dnl **** check for PDFlib
636 if test $pdfdrv = true
638 ACX_CHECK_PDFLIB(6.0.0, AC_DEFINE(HAVE_LIBPDF), pdfdrv=false)
640 if test $pdfdrv != true; then
641 AC_MSG_RESULT(--> PDF driver is disabled)
644 dnl **** TODO: undefine unneeded libraries
648 dnl **** Choose a GUI *****
650 dnl **** default is gui-less
654 if test "$no_x" = yes; then
657 dnl **** Check for Motif
658 GUI_LIBS="-lXt -lXext -lX11 $X_PRE_LIBS $X_EXTRA_LIBS"
663 CFLAGS="$X_CFLAGS $CFLAGS"
664 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
665 LDFLAGS="$X_LIBS $LDFLAGS"
669 true) AC_CHECK_LIB(Xmu,_XEditResCheckMessages,GUI_LIBS="-lXmu $GUI_LIBS"; AC_DEFINE(WITH_EDITRES));;
673 if test "$ac_cv_lib_Xmu__XEditResCheckMessages" != yes; then
674 AC_MSG_RESULT(--> support for EditRes protocol is disabled)
677 dnl **** some Motif-2.1 variants need the -lXp library
678 AC_CHECK_LIB(Xp,main,GUI_LIBS="-lXp $GUI_LIBS")
682 dnl **** check for Xpm lib
683 ACX_CHECK_XPM(30411, GUI_LIBS="$XPM_LIB $GUI_LIBS"; AC_DEFINE(HAVE_XPM),AC_MSG_ERROR(Xpm lib has not been found))
685 ACX_CHECK_MOTIF(1002)
686 if test "$acx_cv_motif" = "no"; then
687 dnl **** only Motif GUI is supported by now:
691 AC_MSG_ERROR(M*tif has not been found)
693 GUI_LIBS="$MOTIF_LIB $GUI_LIBS"
695 GUI_FLAGS="$X_CFLAGS"
698 dnl **** Special Motif checks
699 xsave_CPPFLAGS="$CPPFLAGS"
701 CPPFLAGS="$CPPFLAGS $GUI_FLAGS"
702 LIBS="$X_LIBS $GUI_LIBS $LIBS"
704 dnl **** Check for Xbae widget
705 if test $bundled_xbae = false
707 AC_CHECK_LIB(Xbae, XbaeCreateMatrix, XBAE_LIB="-lXbae";AC_DEFINE(HAVE_LIBXBAE))
709 if test -z "$XBAE_LIB"
711 dnl **** Use the bundled Xbae library
712 AC_MSG_RESULT(--> Bundled version of Xbae library will be used)
713 XBAE_LIB='$(TOP)/Xbae/Xbae/libXbae.a'
714 XBAE_INC='-I$(TOP)/Xbae'
717 AC_MSG_RESULT(--> Good. Seems you have compatible version of Xbae installed)
720 dnl **** Check for XmHTML widget
721 if test $xmhtml = true
723 ACX_CHECK_XMHTML(1105, AC_DEFINE(WITH_XMHTML), xmhtml=false)
726 GUI_LIBS="$XMHTML_LIB $XBAE_LIB $GUI_LIBS"
728 CPPFLAGS="$xsave_CPPFLAGS"
734 dnl **** Final list of subdirs
735 SUBDIRS="cephes ${t1lib_dir} ${expat_dir} ${xbae_dir} lib/base lib/canvas lib/core src ${grconvert_dir} fonts templates doc examples auxiliary"
737 dnl **** Create Make.conf
738 AC_OUTPUT(Make.conf:ac-tools/Make.conf.in)