diff --git a/Makefile.am b/Makefile.am index cf4a975939abdf878fb36f9b53f421a2e00bf90b..dc85818b637ff59f067966322543c05e4f73eb5a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ if GRAPE - SUBDIRS = gnu-compat BLAS ALBERTA_UTIL SOLVER PLOT_ANSI ALBERTA GRAPE + SUBDIRS = gnu-compat ALBERTA_UTIL SOLVER PLOT_ANSI ALBERTA GRAPE else - SUBDIRS = gnu-compat BLAS ALBERTA_UTIL SOLVER PLOT_ANSI ALBERTA + SUBDIRS = gnu-compat ALBERTA_UTIL SOLVER PLOT_ANSI ALBERTA endif ACLOCAL_AMFLAGS = -I ./m4 @@ -13,8 +13,8 @@ if MAINTAINER_MODE cvs-clean: @echo Fixing package for cvs commit... find . -name \*~ -exec rm -rf {} \; - find ./ALBERTA ./BLAS ./ALBERTA_UTIL ./PLOT_ANSI ./SOLVER -name Makefile.in -exec rm -rf {} \; - find ./DEMO ./ALBERTA ./BLAS ./ALBERTA_UTIL ./PLOT_ANSI ./SOLVER -name Makefile -exec rm -rf {} \; + find ./ALBERTA ./ALBERTA_UTIL ./PLOT_ANSI ./SOLVER -name Makefile.in -exec rm -rf {} \; + find ./DEMO ./ALBERTA ./ALBERTA_UTIL ./PLOT_ANSI ./SOLVER -name Makefile -exec rm -rf {} \; find ./DEMO \( -name \*~ -o -name \*.o -o -name \*.lo \) -exec /bin/rm -f {} \; find ./DEMO \( -name ellipt -o -name heat -o -name nonlin \) -exec /bin/rm -f {} \; find ./DEMO -name Makefile -exec /bin/rm -f {} \; @@ -28,7 +28,7 @@ cvs-clean: cp -f NEWS admin/ cp -f README admin/ cp -f INSTALL admin/ - chgrp -R alberta * + chgrp -R albert * dist-hook: @echo Deleting CVS directories in $(distdir) diff --git a/configure.ac b/configure.ac index a9e3fe94636a145ab0698554e082a33ed56593e1..dbaa0389509f84849d1bda2d83162def205bdfd1 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,7 @@ AC_INIT([alberta], [1.2-pre3], [dani@mathematik.uni-freiburg.de]) AC_CONFIG_SRCDIR([ALBERTA/src/Common/alberta.h]) AM_MAINTAINER_MODE -AC_CONFIG_FILES([Makefile BLAS/Makefile ALBERTA_UTIL/Makefile +AC_CONFIG_FILES([Makefile ALBERTA_UTIL/Makefile gnu-compat/Makefile GRAPE/Makefile GRAPE/mesh/Makefile GRAPE/mesh/2d/Makefile @@ -91,7 +91,7 @@ AC_PATH_XTRA AC_HEADER_STDC AC_CHECK_HEADERS([malloc.h unistd.h X11/Xlib.h X11/Xutil.h],, [AC_MSG_ERROR([Exiting...])]) -AC_CHECK_HEADERS([GL/gl.h GL/glx.h rpc/xdr.h],,[AC_MSG_ERROR([Exiting...])]) +AC_CHECK_HEADERS([rpc/xdr.h],,[AC_MSG_ERROR([Exiting...])]) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST @@ -124,70 +124,93 @@ case "$build" in plot_for_sun=false;; esac -case "$build_os" in -*linux*) AC_MSG_RESULT([Building on Linux system...]) - AC_CHECK_LIB(g2c, main) - AC_CHECK_LIB(blas, main,, - [AC_MSG_WARN([Problems with libblas, also tried lg2c...]) - make_own_blas_lib=libblas.la], - [-lg2c]) - AC_CHECK_LIB(X11, main,, - [AC_MSG_ERROR([Exiting...])], - [${X_LIBS}]) - AC_CHECK_LIB(Xext, main,, - [AC_MSG_ERROR([Exiting...])], - [${X_LIBS}]) - AC_CHECK_LIB(GL, main,, - [AC_CHECK_LIB(MesaGL,main)], - [${X_LIBS}]) -;; -*) - AC_CHECK_LIB(blas, main,, - [AC_MSG_WARN([Problems with libblas, creating our own...]) - make_own_blas_lib=libblas.la]) - AC_CHECK_LIB(X11, main,, - [AC_MSG_ERROR(Exiting...)], - [${X_LIBS}]) - AC_CHECK_LIB(Xext, main,, - [AC_MSG_ERROR(Exiting...)], - [${X_LIBS}]) - AC_CHECK_LIB(gl, main) - AC_CHECK_LIB(GL, main) -;; -esac +dnl +dnl check for BLAS library. The BLAS may come under different names. We default +dnl to -lblas, but other possibilities are sunperf, atlas, cpml (Alpha AXP) +dnl etc etc etc etc etc etc etc etc etc etc ........................... +dnl +dnl Let the user decide what it wants. +dnl +AC_ARG_WITH(BLASname, +AC_HELP_STRING([--with-BLASname=NAME], [use NAME as the name of the BLAS library (without leading "lib" prefix and trailing suffix). Default: "blas"]), +[case "$withval" in + yes) AC_MSG_ERROR("option \"--with-BLASname\" requires an argument") + ;; + no) AC_MSG_ERROR("option \"--with-BLASname\" requires an argument") + ;; + *) LIBBLAS=$withval + ;; +esac], +LIBBLAS=blas) +AC_SUBST(LIBBLAS) +ALBERTA_CHECK_PACKAGE(blas, $LIBBLAS, , ${FLIBS},,,,required) -gltools_include= -LIBGLTOOLS_PRESENT= -AC_MSG_CHECKING([for libgltools.a]) -AC_ARG_WITH(gltools, -AC_HELP_STRING([--with-gltools=PATH], - [specify the absolute path of the gltools library]), -[if test -f $withval/gltools-2-4/libgltools.a; then - AC_MSG_RESULT([Found libgltools.a in specified directory $withval/gltools-2-4.]) - gltools_include="-I$withval/gltools-2-4" - AC_DEFINE(HAVE_LIBGLTOOLS,1, - [Define to 1 if you have the `gltools-2-4' library (-lgltools)]) - - LIBGLTOOLS_PRESENT=1 - LIBS="-L$withval/gltools-2-4 -lgltools $LIBS" -else - AC_MSG_RESULT([*** No libgltools.a found in $withval/gltools-2-4.]) -fi], -[if test -f ./gltools-2-4/libgltools.a; then - AC_MSG_RESULT([Found libgltools.a in default directory ./gltools-2-4]) - gltools_include="-I`pwd`/gltools-2-4" - AC_DEFINE(HAVE_LIBGLTOOLS,1, - [Define to 1 if you have the `gltools-2-4' library (-lgltools)]) - LIBGLTOOLS_PRESENT=1 - LIBS="-L`pwd`/gltools-2-4 -lgltools $LIBS" -else - AC_MSG_RESULT([*** No libgltools.a found in ./gltools-2-4]) -fi]) +dnl +dnl check for X11 +dnl +AC_PATH_X +AC_PATH_XTRA +X_ALL_LIBS="${X_PRE_LIBS} ${X_LIBS} -lX11 ${X_EXTRA_LIBS}" +AC_SUBST(X_ALL_LIBS) + +dnl +dnl check for OpenGL (maybe Mesa) +dnl +AC_ARG_WITH(GLname, +AC_HELP_STRING([--with-GLname=NAME], [use NAME as the name of the OpenGL (tm) library (without leading "lib" prefix and trailing suffix). Default: "GL"]), +[case "$withval" in + yes) AC_MSG_ERROR("option \"--with-GLname\" requires an argument") + ;; + no) AC_MSG_ERROR("option \"--with-GLname\" requires an argument") + ;; + *) LIBGL=$withval + ;; +esac], +LIBGL=GL) +AC_SUBST(LIBGL) +ALBERTA_CHECK_PACKAGE(opengl, $LIBGL, ,${X_ALL_LIBS}, GL/gl.h,,,required) + +dnl case "$build_os" in +dnl *linux*) AC_MSG_RESULT([Building on Linux system...]) +dnl AC_CHECK_LIB(g2c, main) +dnl AC_CHECK_LIB(blas, main,, +dnl [AC_MSG_WARN([Problems with libblas, also tried lg2c...]) +dnl make_own_blas_lib=libblas.la], +dnl [-lg2c]) +dnl AC_CHECK_LIB(X11, main,, +dnl [AC_MSG_ERROR([Exiting...])], +dnl [${X_LIBS}]) +dnl AC_CHECK_LIB(Xext, main,, +dnl [AC_MSG_ERROR([Exiting...])], +dnl [${X_LIBS}]) +dnl AC_CHECK_LIB(GL, main,, +dnl [AC_CHECK_LIB(MesaGL,main)], +dnl [${X_LIBS}]) +dnl ;; +dnl *) +dnl AC_CHECK_LIB(blas, main,, +dnl [AC_MSG_WARN([Problems with libblas, creating our own...]) +dnl make_own_blas_lib=libblas.la]) +dnl AC_CHECK_LIB(X11, main,, +dnl [AC_MSG_ERROR(Exiting...)], +dnl [${X_LIBS}]) +dnl AC_CHECK_LIB(Xext, main,, +dnl [AC_MSG_ERROR(Exiting...)], +dnl [${X_LIBS}]) +dnl AC_CHECK_LIB(gl, main) +dnl AC_CHECK_LIB(GL, main) +dnl ;; +dnl esac + +dnl +dnl check for optional pacakge gltools +dnl +ALBERTA_CHECK_PACKAGE(gltools, gltools, , ${X_ALL_LIBS}, glmesh.h,,,optional) dnl dnl some defines to enable building of alberta_movi dnl -ALBERTA_CHECK_PACKAGE(GRAPE, gr, , ${X_LIBS} -lX11, grape.h,, optional) +ALBERTA_CHECK_PACKAGE(grape, gr, , -l${LIBGL} ${X_ALL_LIBS}, grape.h,,, optional) AM_CONDITIONAL(GRAPE, test -n "${GRAPE_LIB}") ALBERTA_LIB_PATH=$prefix/lib ALBERTA_INCLUDE_PATH='$(top_srcdir)/ALBERTA/src/Common/ -I$(top_srcdir)/ALBERTA_UTIL' @@ -213,11 +236,9 @@ AC_SUBST(EL_INDEX) AM_CONDITIONAL(PLOT_FOR_SUN, test x$plot_for_sun = xtrue) AM_CONDITIONAL(PLOT_FOR_IBM, test x$plot_for_ibm = xtrue) AM_CONDITIONAL(PLOT_FOR_TIT, test x$plot_for_tit = xtrue) -AM_CONDITIONAL(USE_GLTOOLS, test x$LIBGLTOOLS_PRESENT = x1) +AM_CONDITIONAL(USE_GLTOOLS, test -n "${GLTOOLS_LIB}") AM_CONDITIONAL(USE_EL_INDEX, test x$EL_INDEX = x1) -AC_SUBST(gltools_include) -AC_SUBST(make_own_blas_lib) -AC_SUBST(LIBGLTOOLS_PRESENT) +dnl AC_SUBST(make_own_blas_lib) AC_OUTPUT diff --git a/m4/check-package.m4 b/m4/check-package.m4 index 449cc55fd8bc878974922a35643a24a964138d03..6e9be5f373f25ca376e8492f57b0ea721639cf28 100644 --- a/m4/check-package.m4 +++ b/m4/check-package.m4 @@ -1,6 +1,6 @@ +dnl ALBERTA_CHECK_PACKAGE() dnl dnl Check for a library + header files -dnl dnl dnl Arguments: dnl @@ -10,49 +10,115 @@ dnl $3: library path (-L$3) dnl $4: additional libraries needed (e.g. -lm -lGL) dnl $5: header name dnl $6: include path (-I$6) -dnl $7 \in \{optional, required\}, bail out if required, warning otherwise +dnl $7: package prefix, headers and library below $7/ +dnl $8 \in \{optional, required\}, bail out if required, warning otherwise +dnl +dnl Default is to check for libraries below $prefix/lib/ and for header-files +dnl below $prefix/include/ +dnl +dnl $5 may be empty (e.g. to check for a Fortran library). In this case +dnl $6 is ignored +dnl +dnl $7 may be empty, actually the idea to install libraries and +dnl headers in the same diretory is a little bit awkward. +dnl +dnl This Macro defines the following variables: +dnl +dnl Makefile-substitution +dnl +dnl $1_INCLUDE_PATH +dnl $1_LIB_PATH +dnl $1_INCLUDE +dnl $1_LIB linker flags excluding $4 +dnl $1_ALL_LIB linker flags including $4 +dnl +dnl config.h preprocessor macros +dnl +dnl HAVE_LIB$2 +dnl HAVE_$5_H +dnl + +dnl +dnl Helper-macros +dnl + +dnl +dnl ALBERTA_CHECK_PKG_OPT(PKGNAME) dnl AC_DEFUN([ALBERTA_CHECK_PKG_OPT], -[AC_ARG_WITH($1, +[m4_define([UPNAME], [m4_bpatsubst(m4_toupper([$1]),-,_)]) +AC_ARG_WITH($1, AC_HELP_STRING([--without-$1], [disable use of package $1 (default: autodetect)]), [case "$withval" in yes) ;; no) - m4_bpatsubst([$1],-,_)_DISABLE=yes + UPNAME[_DISABLE]=yes + AC_MSG_RESULT([Disabling "$1"]) ;; *) - AC_MSG_ERROR(["$withval" should have been either "yes" or "no"]) + AC_MSG_ERROR(["$withval" should have been either "yes" or "no"]) ;; esac], - [m4_bpatsubst([$1],-,_)_DISABLE=no]) + [UPNAME[_DISABLE]=no]) ]) +dnl +dnl ALBERTA_CHECK_PKG_HDR_OPT(PKGNAME, INCLUDEPATH) +dnl AC_DEFUN([ALBERTA_CHECK_PKG_HDR_OPT], -[AC_ARG_WITH($1-headers, -AC_HELP_STRING([--with-$1-headers=DIR], - [use $1 include files below directory DIR (default: $2)]), +[m4_define([UPNAME], [m4_bpatsubst(m4_toupper([$1]),-,_)]) +AC_ARG_WITH($1-headers, +m4_if($2,[], +[AC_HELP_STRING([--with-$1-headers=DIR], + [use $1 include files below directory DIR (default: PREFIX/include/)])], +[AC_HELP_STRING([--with-$1-headers=DIR], + [use $1 include files below directory DIR (default: $2)])]), [case "$withval" in yes) AC_MSG_ERROR("option \"--with-$1-headers\" requires an argument") ;; no) AC_MSG_ERROR("option \"--with-$1-headers\" requires an argument") ;; - *) m4_bpatsubst([$1],-,_)_INCLUDE_PATH=$withval + *) UPNAME[_INCLUDE_PATH]=$withval ;; esac], -[m4_bpatsubst([$1],-,_)_INCLUDE_PATH=$DEFAULT_INCDIR]) +test -z "${UPNAME[_INCLUDE_PATH]}" && UPNAME[_INCLUDE_PATH]=$DEFAULT_INCDIR) ]) +dnl +dnl headers and libraries below the same directory :( +dnl +AC_DEFUN([ALBERTA_CHECK_PKG_DIR_OPT], +[m4_define([UPNAME], [m4_bpatsubst(m4_toupper([$1]),-,_)]) +AC_ARG_WITH($1-dir, +AC_HELP_STRING([--with-$1-dir=DIR], + [use $1 library (and headers) below directory DIR (no default)]), +[case "$withval" in + yes) AC_MSG_ERROR("option \"--with-$1-dir\" requires an argument") + ;; + no) AC_MSG_ERROR("option \"--with-$1-dir\" requires an argument") + ;; + *) UPNAME[_LIB_PATH]=$withval + UPNAME[_INCLUDE_PATH]=$withval + ;; +esac]) +]) +dnl +dnl the macro itself +dnl AC_DEFUN(ALBERTA_CHECK_PACKAGE, [AC_REQUIRE([AC_SET_PREFIX]) -# -# foobar -# -m4_if($7, optional,[ALBERTA_CHECK_PKG_OPT([$1])]) -dnl if test "$7" = "optional"; then -dnl ALBERTA_CHECK_PKG_OPT([$1]) -dnl fi - -if test "${m4_bpatsubst([$1],-,_)_DISABLE}" = yes; then +dnl +dnl upcase $1 +dnl +m4_define([UPNAME], [m4_bpatsubst(m4_toupper([$1]),-,_)]) +dnl +dnl need to use m4_if, the $i arguments are not shell variables +dnl +m4_if($8, optional,[ALBERTA_CHECK_PKG_OPT([$1])]) +dnl +dnl bail out if package disabled completely +dnl +if test "${UPNAME[_DISABLE]}" = yes; then : else @@ -61,18 +127,28 @@ if test -z "$3"; then else DEFAULT_LIBDIR=$3 fi +dnl +dnl headers and libraries below the same directory :( +dnl +m4_if($5,[],[],[ALBERTA_CHECK_PKG_DIR_OPT([$1])]) +dnl +dnl location of library +dnl AC_ARG_WITH($1-lib, -AC_HELP_STRING([--with-$1-lib=DIR], - [use $1 library below directory DIR (default: $3)]), +m4_if($3,[], +[AC_HELP_STRING([--with-$1-lib=DIR], + [use $1 library below directory DIR (default: EPREFIX/lib/)])], +[AC_HELP_STRING([--with-$1-lib=DIR], + [use $1 library below directory DIR (default: $3)])]), [case "$withval" in yes) AC_MSG_ERROR("option \"--with-$1-lib\" requires an argument") ;; no) AC_MSG_ERROR("option \"--with-$1-lib\" requires an argument") ;; - *) m4_bpatsubst([$1],-,_)_LIB_PATH=$withval + *) UPNAME[_LIB_PATH]=$withval ;; esac], -m4_bpatsubst([$1],-,_)_LIB_PATH=$DEFAULT_LIBDIR) +test -z "${UPNAME[_LIB_PATH]}" && UPNAME[_LIB_PATH]=$DEFAULT_LIBDIR) dnl dnl now for the header file dnl @@ -81,45 +157,57 @@ if test -z "$6"; then else DEFAULT_INCDIR=$6 fi -m4_if($5,[],[],[ALBERTA_CHECK_PKG_HDR_OPT([$1], [$6])]) +m4_if($5,[],[],[ALBERTA_CHECK_PKG_HDR_OPT([$1], [PREFIX/include/])]) dnl dnl now check if the library and header files exist dnl -if test "$7" = "optional" ; then +if test "$8" = "optional" ; then AC_CHECK_LIB($2, main, - [m4_bpatsubst([$1],-,_)_LIB="-L${m4_bpatsubst([$1],-,_)_LIB_PATH} -l$2"], - [m4_bpatsubst([$1],-,_)_LIB="" - m4_bpatsubst([$1],-,_)_LIB_PATH="" - m4_bpatsubst([$1],-,_)_INCLUDE_PATH=""], - -L${m4_bpatsubst([$1],-,_)_LIB_PATH} $4) + [UPNAME[_LIB]="-L${UPNAME[_LIB_PATH]} -l$2" + UPNAME[_ALL_LIB]="-L${UPNAME[_LIB_PATH]} -l$2 $4"], + [UPNAME[_LIB]="" + UPNAME[_ALL_LIB]="" + UPNAME[_LIB_PATH]="" + UPNAME[_INCLUDE]="" + UPNAME[_INCLUDE_PATH]=""], + -L${UPNAME[_LIB_PATH]} $4) else AC_CHECK_LIB($2, main, - [m4_bpatsubst([$1],-,_)_LIB="-L${m4_bpatsubst([$1],-,_)_LIB_PATH} -l$2 $4"], + [UPNAME[_LIB]="-L${UPNAME[_LIB_PATH]} -l$2" + UPNAME[_ALL_LIB]="-L${UPNAME[_LIB_PATH]} -l$2 $4"], [AC_MSG_ERROR([Library "lib$2" was not found])], - -L$m4_bpatsubst([$1],-,_)_LIB_PATH $4) + -L$UPNAME[_LIB_PATH] $4) fi -if test "x${m4_bpatsubst([$1],-,_)_LIB}" = "x" ; then +if test "x${UPNAME[_LIB]}" = "x" ; then : else if test -n "$5"; then dnl dnl check for the header file dnl - [ac_]m4_bpatsubst([$1],-,_)_save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="-I${m4_bpatsubst([$1],-,_)_INCLUDE_PATH} $CPPFLAGS" - if test "$7" = "optional" ; then - AC_CHECK_HEADERS($5,, [m4_bpatsubst([$1],-,_)_LIB="" - m4_bpatsubst([$1],-,_)_LIB_PATH="" - m4_bpatsubst([$1],-,_)_INCLUDE_PATH=""]) + [ac_]UPNAME[_save_CPPFLAGS]="$CPPFLAGS" + CPPFLAGS="-I${UPNAME[_INCLUDE_PATH]} $CPPFLAGS" + if test "$8" = "optional" ; then + AC_CHECK_HEADERS($5,, [UPNAME[_LIB]="" + UPNAME[_ALL_LIB]="" + UPNAME[_INCLUDE]="" + UPNAME[_LIB_PATH]="" + UPNAME[_INCLUDE_PATH]=""]) else AC_CHECK_HEADERS($5,, AC_MSG_ERROR([Header file "$5" was not found])) fi - CPPCLAGS="${[ac_]m4_bpatsubst([$1],-,_)_save_CPPFLAGS}" +dnl +dnl no need to use -I... if header is located in standard include path +dnl + if ! test -f "${UPNAME[_INCLUDE_PATH]}/$5"; then + UPNAME[_INCLUDE]="" + fi + CPPCLAGS="${[ac_]UPNAME[_save_CPPFLAGS]}" fi dnl dnl define makefile substitutions and config.h macros dnl - if test "x${m4_bpatsubst([$1],-,_)_LIB}" = "x" ; then + if test "x${UPNAME[_LIB]}" = "x" ; then : else AC_DEFINE(m4_bpatsubst(m4_toupper([HAVE_LIB$2]),-,_), @@ -129,7 +217,9 @@ fi fi dnl disable fi -AC_SUBST(m4_bpatsubst([$1],-,_)_INCLUDE_PATH) -AC_SUBST(m4_bpatsubst([$1],-,_)_LIB_PATH) -AC_SUBST(m4_bpatsubst([$1],-,_)_LIB) +AC_SUBST(UPNAME[_INCLUDE_PATH]) +AC_SUBST(UPNAME[_LIB_PATH]) +AC_SUBST(UPNAME[_INCLUDE]) +AC_SUBST(UPNAME[_LIB]) +AC_SUBST(UPNAME[_ALL_LIB]) ])