bump to -rc12
[gnucap-felix.git] / configure.ac
blob3a8859820da70457ca1ff5ae0a02d931ec63879b
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 #                            COPYRIGHT
6 #  Copyright (C) 2005, 2006 Dan McMahill
8 #  This program is free software; you can redistribute it and/or modify
9 #  it under the terms of the GNU General Public License as published by
10 #  the Free Software Foundation; either version 3 of the License, or
11 #  (at your option) any later version.
13 #  This program is distributed in the hope that it will be useful,
14 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 #  GNU General Public License for more details.
18 #  You should have received a copy of the GNU General Public License
19 #  along with this program; if not, write to the Free Software
20 #  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #  02110-1301, USA.
23 AC_PREREQ(2.67)
24 AC_INIT([gnucap-uf],[0.0.2-rc12],[felix@salfelder.org])
25 AC_CANONICAL_BUILD
26 AC_CANONICAL_HOST
27 AC_CANONICAL_TARGET
28 AM_INIT_AUTOMAKE([-Wno-portability silent-rules])
31 AC_PROG_CXX
32 AC_PROG_MAKE_SET
34 AC_CONFIG_SRCDIR([src/main.cc])
35 AC_CONFIG_MACRO_DIR([m4])
36 AC_CONFIG_HEADERS([src/config.h])
37 AC_LANG(C++)
39 # this will break Makefile dependencies (d'0h)
40 # AM_MAINTAINER_MODE
42 AC_PREFIX_DEFAULT("/usr/local")
44 # libdir_const="${prefix}/lib"
46 #sysconfdir='/bar/etc'
48 #AC_SUBST([PREFIX])
49 #AC_SUBST([LIBDIR])
51 dnl ----------------- doc ------------------
52 AC_MSG_CHECKING([doc])
53 AC_ARG_ENABLE([doc],
54 [  --enable-doc            Enable building of modules. [[default: disabled]]],
56 if test "X$enable_doc" = "Xno" ; then
57         AC_MSG_RESULT([no])
58 else
59         AC_MSG_RESULT([yes])
60         enable_doc=yes
64         AC_MSG_RESULT([no])
65         enable_doc=no
67 AC_OUTPUT([doc/Makefile])
68 AM_CONDITIONAL([DOC], [test x$enable_doc != xno] )
69 dnl ----------------- man ------------------
70 AC_MSG_CHECKING([man])
71 AC_ARG_ENABLE([man],
72 [  --enable-man            Enable building of modules. [[default: disabled]]],
74 if test "X$enable_man" = "Xno" ; then
75         AC_MSG_RESULT([no])
76 else
77         AC_MSG_RESULT([yes])
78         enable_man=yes
82         AC_MSG_RESULT([no])
83         enable_man=no
86 dnl ------------- modules -------------------
87 dnl MODULES=
88 AC_MSG_CHECKING([if shared modules should be compiled and installed])
89 AC_ARG_ENABLE([modules],
90 [  --enable-modules            Enable building of modules. [[default: disabled]]],
92 if test "X$enable_modules" = "Xno" ; then
93         AC_MSG_RESULT([no])
94 else
95         AC_MSG_RESULT([yes])
96         enable_modules=yes
100         AC_MSG_RESULT([yes])
101         enable_modules=yes
103 AC_OUTPUT([modules/Makefile])
104 AM_CONDITIONAL([MODULES], [test x$enable_modules != xno] )
106 dnl ------------------- debugging -------------------
107 AC_MSG_CHECKING([if debug code should be compiled in])
108 AC_ARG_ENABLE([debug],
109 [  --enable-debug            Enable building of debug code. [[default: disabled]]],
111 if test "X$enable_debug" = "Xno" ; then
112         AC_MSG_RESULT([no])
113 else
114         AC_MSG_RESULT([yes])
115         enable_debug=yes
119         AC_MSG_RESULT([no])
120         enable_debug=no
123 # Checks for programs.
124 AC_PROG_CXX
125 AC_PROG_AWK
126 AC_PROG_CC
127 AC_PROG_CPP
128 AC_PROG_INSTALL
129 AC_PROG_LN_S
130 AC_PROG_MAKE_SET
131 AC_PROG_MKDIR_P
132 AC_CHECK_PROG(GIT,git,yes)
133 AC_MSG_CHECKING([for git repo])
134 AS_IF([test x"$GIT" = "xyes" && test -d $srcdir/.git],
135       [have_git_repo=yes],
136       [have_git_repo=no])
137 AC_MSG_RESULT([$have_git_repo])
139 WHICH_MAKE=`which make`
140 AC_SUBST([WHICH_MAKE])
142 AH_TEMPLATE(HAVE_GIT_REPO, "whether this is built from git")
143 AH_TEMPLATE(GIT_BRANCH, "the current branch")
144 AH_TEMPLATE(GIT_TAG, "the description")
145 AH_TEMPLATE(GIT_COMMIT, "the commit id")
146 AH_TEMPLATE(GIT_COMMIT_SHORT, "the commit id short")
148 AM_CONDITIONAL([HAVE_GIT_REPO], [test yes = $have_git_repo])
149 AS_IF([test yes = $have_git_repo],
150       [AC_MSG_NOTICE([building from git])
151        git_commit=`git rev-parse HEAD`
152        git_commit_short=`git rev-parse --short HEAD`
153        git_tag=`git describe`
154        git_branch=`git rev-parse --abbrev-ref HEAD`
155        AC_DEFINE([HAVE_GIT_REPO],[1])
156       ],[
157        AC_DEFINE([HAVE_GIT_REPO],[0])
158       ])
161 # hmmm...
162 # AC_SUBST(GIT_COMMIT, $git_commit)
163 AC_SUBST(GIT_COMMIT_SHORT, $git_commit_short)
164 # AC_SUBST(GIT_BRANCH, $git_branch)
165 # AC_SUBST(GIT_TAG, $git_tag)
167 AM_CONDITIONAL([VPATH_BUILD], [test ! x$srcdir = "x."])
169 ac_script='s/\$\$/$/g;s/\\\\/\\/'
170 reverse=`$as_echo "$program_transform_name" | sed "$ac_script"`
171 GNUCAP_CPPFLAGS=-I$includedir/`echo gnucap | sed -e "$reverse"`
172 AC_SUBST([GNUCAP_CPPFLAGS])
174 # required by attach command
175 AH_TEMPLATE([GNUCAP_CPPFLAGS])
176 AC_DEFINE_UNQUOTED([GNUCAP_CPPFLAGS],["$GNUCAP_CPPFLAGS"])
178 # If we are cross compiling, then we need to search for a
179 # gnucap-modelgen program to use for our build.  This can
180 # either be an installed modelgen or it can be specified
181 # like:
182 #   env MODELGEN=/build/i686--linux/modelgen/gnucap-modelgen /srcs/gnucap/configure
183 #           --host=alpha--netbsd --build=i686--linux
185 if test "$cross_compiling" = yes; then
186         AC_PATH_PROG(MODELGEN, gnucap-modelgen)
187 else
188         MODELGEN=../modelgen/gnucap-modelgen
189         AC_SUBST([MODELGEN])
192 # for building the documentation
193 #AC_PATH_PROG(DVIPDFM, dvipdfm, notfound)
194 #AM_CONDITIONAL(MISSING_DVIPDFM, test x$DVIPDFM = xnotfound)
195 #AC_PATH_PROG(HACHA, hacha, notfound)
196 #AC_PATH_PROG(HEVEA, hevea, notfound)
197 #AM_CONDITIONAL(MISSING_HEVEA, test x$HEVEA = xnotfound -o x$HACHA = xnotfound)
198 #AC_PATH_PROG(LATEX, latex, notfound)
199 #AC_PATH_PROG(MAKEINDEX, makeindex, notfound)
200 #AM_CONDITIONAL(MISSING_LATEX, test x$LATEX = xnotfound -o x$MAKEINDEX = xnotfound)
202 # Checks for libraries.
204 AC_LANG([C++])
205 LT_INIT()
206 AC_CHECK_LIB([m], [cos])
208 # probably unneeded.
209 AC_CHECK_LIB([gslcblas], [cblas_dgemv])
210 AC_CHECK_LIB([gsl], [gsl_blas_dgemm])
211 AC_CHECK_LIB([gsl], [gsl_fit_linear])
212 AC_CHECK_FUNCS([sqrt])
215 dnl ----------------------------------------------------
216 have_fftw=no
217 AC_CHECK_HEADERS([rfftw.h], [AC_DEFINE([HAVE_FFTW_H], [1],
218                            [Define to 1 if you have fftw])
219                             have_fftw=yes
220                             ] )
222 # fixme: complain if HAVE_FFTW
223 AC_CHECK_LIB([fftw], [fftw_create_plan], LIBS="$LIBS -lfftw")
224 AC_CHECK_LIB([rfftw], [rfftw_create_plan], LIBS="-lrfftw $LIBS")
226 dnl ----------------------------------------------------
227 # some more checks. some should depend on switches. but the switches arent
228 # there yet
229 HAVE_CLAPACK_H=0
230 AC_CHECK_HEADER([atlas/clapack.h],
231                 [AC_DEFINE([HAVE_CLAPACK_H], [1],
232                            [Define to 1 if you have atlas/clapack.h])
233                  HAVE_CLAPACK_H=1],
234                 [AC_MSG_NOTICE([please install package libatlas-dev])])
235 AM_CONDITIONAL([USE_ATLAS], [test $HAVE_CLAPACK_H -eq 1])
237 LAPACK_LIBS=
238 AC_CHECK_LIB([lapack], [dgelss_],
239              [LAPACK_LIBS="-llapack"
240               AC_DEFINE([HAVE_LIBLAPACK], [1], [Define to 1 if there is liblapack])])
241 AC_SUBST([LAPACK_LIBS])
243 AC_CHECK_HEADER([boost/algorithm/string.hpp],
244                 [AC_DEFINE([HAVE_STRING_HPP], [1],
245                            [Define to 1 if there is boost/algorithm/string.hpp])],
246                 [AC_MSG_NOTICE([please install the boost package])])
248 # fixme: refine a bit?
249 have_boost=no
250 AC_CHECK_HEADERS([boost/assign.hpp],
251                  [have_boost=yes
252                  AC_DEFINE([HAVE_BOOST], [1], [have boost])
253                  ],
254                  [AC_MSG_NOTICE(You need the Boost libraries.)
255                  ])
257 AC_CHECK_HEADER([boost/algorithm/string/split.hpp],
258                 [AC_DEFINE([HAVE_SPLIT_HPP], [1],
259                            [Define to 1 if there is boost/algorithm/string/split.hpp])],
260                 [AC_MSG_NOTICE([please install the boost package])])
262 AC_CHECK_HEADER([readline/readline.h],
263                 [AC_DEFINE([HAVE_READLINE_H], [1],
264                            [Define to 1 if you have readline/readline.h])],
265                 [AC_MSG_ERROR([please install the libreadline-dev package])])
267 AC_CHECK_HEADER([readline/history.h],
268                 [AC_DEFINE([HAVE_HISTORY_H], [1],
269                            [Define to 1 if you have readline/history.h])],
270                 [AC_MSG_ERROR([please install the libreadline-dev package])])
273 AC_ARG_WITH([gsl],
274 [AS_HELP_STRING([--with-gsl],
275   [support gsl @<:@default=yes@:>@])],
277 [with_gsl=yes])
279 HAVE_GSL_H=0
280 if test "x$with_gsl" != xno ; then
281         AC_CHECK_HEADER([gsl/gsl_fit.h],
282         [AC_DEFINE([HAVE_GSL_FIT_H], [1],
283                 [Define to 1 if you have gsl/gsl_fit.h])
284                 HAVE_GSL_H=1
285         ],
286         [AC_MSG_NOTICE([consider installing the libgsl0-dev package])])
288 AM_CONDITIONAL([USE_GSL], [test $HAVE_GSL_H -eq 1])
290 AC_ARG_WITH([readline],
291 [AS_HELP_STRING([--with-readline],
292   [support command line editing @<:@default=yes@:>@])],
294 [with_readline=yes])
296 if test "x$with_readline" != xno ; then
297         AC_CHECK_LIB([termcap], [main]) 
298         AC_CHECK_LIB([readline], [main])
301 AC_CHECK_LIB([dl], [dlopen])
303 # LT_INIT([static shared])
305 # shared.
306 #AC_DISABLE_STATIC
307 #AC_PROG_LIBTOOL
309 # Checks for header files.
310 #AC_CHECK_HEADERS([fcntl.h unistd.h])
312 AC_CHECK_HEADERS([boost/assign.hpp], [],
313                  [AC_MSG_ERROR(You need the Boost libraries.)])
315 # Checks for typedefs, structures, and compiler characteristics.
317 # Checks for library functions.
319 if test "$enable_debug" = "yes" ; then
320         CPPFLAGS="$CPPFLAGS -DTRACE_UNTESTED"
321 else
322         CPPFLAGS="$CPPFLAGS -DNDEBUG"
325 CXXFLAGS+=" -Wall \
326    -W -Wno-sign-compare \
327    -Wpointer-arith -Wcast-qual \
328    -Wwrite-strings -Wconversion \
329    -Woverloaded-virtual -O2 -Wlong-long \
330    -Wsign-compare -Wcast-align"
332 # if we have gcc and we've asked for debugging then add lots of -W
333 if test "x$GCC" = "xyes" -a "$enable_debug" = "yes"; then
334         for flag in -DTRACE_UNTESTED -Wall -W -Wno-sign-compare \
335                 -Wpointer-arith -Wcast-qual \
336                 -Wwrite-strings -Wconversion \
337                 -Woverloaded-virtual -O2 -Wlong-long \
338                 -Wsign-compare -Wcast-align ; do
339                 case " ${CFLAGS} " in
340                         *\ ${flag}\ *)
341                                 # flag is already present
342                                 ;;
343                         *)
344                                 CFLAGS="$CFLAGS ${flag}"
345                                 ;;
346                 esac
347                 case " ${CXXFLAGS} " in
348                         *\ ${flag}\ *)
349                                 # flag is already present
350                                 ;;
351                         *)
352                                 CXXFLAGS="$CXXFLAGS ${flag}"
353                                 ;;
354                 esac
355         done
357 # remove additional added  -OX
358     FOUNDOX="no"
359     NEWCXXFLAGS=""
360         for flag in ${CXXFLAGS} ; do
361         case " -O0 -O1 -O2 -O3 " in
362                         *\ ${flag}\ *)
363               if test "${FOUNDOX}" = "no"; then
364                   NEWCXXFLAGS="${NEWCXXFLAGS} ${flag}"
365               fi
366               FOUNDOX="yes"
367               ;;
368             *)
369               NEWCXXFLAGS="${NEWCXXFLAGS} ${flag}"
370               ;;
371         esac
372     done
373     CXXFLAGS=${NEWCXXFLAGS}
374 #    echo "CXXFLAGS: ${CXXFLAGS}"
375     FOUNDOX="no"
376     NEWCFLAGS=""
377         for flag in ${CFLAGS} ; do
378         case " -O0 -O1 -O2 -O3 " in
379                         *\ ${flag}\ *)
380               if test "${FOUNDOX}" = "no"; then
381                   NEWCFLAGS="${NEWCFLAGS} ${flag}"
382               fi
383               FOUNDOX="yes"
384               ;;
385             *)
386               NEWCFLAGS="${NEWCFLAGS} ${flag}"
387               ;;
388         esac
389     done
390     CFLAGS=${NEWCFLAGS}
391 #    echo "CFLAGS: ${CFLAGS}"
395 # exports symbols to plugins
396 LDFLAGS="$LDFLAGS -rdynamic"
398 # stupid hack (needed?)
399 if test "x${prefix}" = "xNONE"; then
400                 AC_DEFINE_UNQUOTED( PREFIX, "${ac_default_prefix}", "Prefix")
401                 AC_DEFINE_UNQUOTED( LIBDIR, "${ac_default_prefix}/lib", "Libdir")
402                 AC_DEFINE_UNQUOTED( SODIR, "${ac_default_prefix}/lib", "Sodir")
403 else
404                 AC_DEFINE_UNQUOTED( PREFIX, "${prefix}", "Prefix")
405                 AC_DEFINE_UNQUOTED( LIBDIR, "${prefix}/lib", "Libdir")
406                 AC_DEFINE_UNQUOTED( SODIR, "${prefix}/lib", "Sodir")
409 # todo
410 #if test "X$enable_man" = "Xyes"; then
411         #AC_OUTPUT([
412                 #man/Makefile
413                 #man/Addmodel/Makefile
414                 #man/Behavior/Makefile
415                 #man/Circuit/Makefile
416                 #man/Commands/Makefile
417                 #man/Tech/Makefile
418         #])
421 # workaround, as we don't want to know the names literally
422 AC_CONFIG_SUBDIRS()
423 for i in `shopt -s nullglob; echo extern/*`; do
424         AS_IF([test -d $i -a -x $i/configure], [subdirs="$subdirs $i"])
425 done
427 #AC_OUTPUT([
428 #       Makefile
429 #       doc/Makefile
430 #       examples/Makefile
431 #       man/Makefile
432 #       man/Addmodel/Makefile
433 #       man/Behavior/Makefile
434 #       man/Circuit/Makefile
435 #       man/Commands/Makefile
436 #       man/Tech/Makefile
437 #       modelgen/Makefile
438 #       src/Makefile
439 #       ])
441 AC_CONFIG_FILES([main/gnucap-conf], [chmod +x main/gnucap-conf])
442 AC_CONFIG_FILES([main/gnucap.mk], [chmod +x main/gnucap.mk])
443 AC_CONFIG_FILES([src/gnucap], [chmod +x src/gnucap])
445 AC_OUTPUT([
446         Makefile
447         lib/Makefile
448         main/Makefile
449         modelgen/Makefile
450         plugins/Makefile
451         include/Makefile
452         src/Makefile
453         apps/Makefile
454         tests/Makefile
455         examples/Makefile])
457 plugindir=$libdir/$package
459 AC_MSG_RESULT([
460 ** Configuration summary for $PACKAGE $VERSION:
462    prefix:     $prefix
463    suffix:     $program_suffix
464    exec_prefix:$exec_prefix
465    plugindir:  $plugindir
466    libdir:     $libdir
467    CPPFLAGS:   $CPPFLAGS
468    CFLAGS:     $CFLAGS
469    CXXFLAGS:   $CXXFLAGS
470    LDFLAGS:    $LDFLAGS
471    LIBS:       $LIBS
472    debug:      $enable_debug
473    modules:    $enable_modules
474    shared_lib: $enable_lib
475    doc:        $enable_doc
476    fftw:       $have_fftw
477    boost:      $have_boost
478    externals:   $subdirs
479    git repo:   $have_git_repo