configure.ac 11.8 KB
Newer Older
1
AC_INIT([stimfit],[0.16.0])
2
AC_CONFIG_SRCDIR(src/stimfit/gui/main.cpp)
3 4
AM_INIT_AUTOMAKE([1.11])
AM_SILENT_RULES([yes])
5
AC_CONFIG_MACRO_DIR([m4])
6 7 8 9

AC_PROG_CC
AC_PROG_INSTALL

10 11 12 13 14
_LT_SET_OPTION([LT_INIT],[dlopen])
AC_DIAGNOSE([obsolete],[AC_LIBTOOL_DLOPEN: Remove this warning and the call to _LT_SET_OPTION when you
put the `dlopen' option into LT_INIT's first parameter.])

LT_INIT
15 16 17 18 19 20
AC_PROG_CPP
AC_PROG_AWK
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_MKDIR_P
AC_PROG_CXX
21
AC_PROG_LIBTOOL
22

23
# BUILDDATE=`date`
24

25
# Build a standalone python module
26
AC_ARG_ENABLE([module], AS_HELP_STRING([--enable-module],[build a standalone python module; implies --enable-python]),[])
27 28
AM_CONDITIONAL(BUILD_MODULE, test "$enable_module" = "yes")

29
# pbuilder debian package build
30 31 32
AC_ARG_ENABLE([debian], AS_HELP_STRING([--enable-debian],[special build for pbuilder]),[])
AM_CONDITIONAL(BUILD_DEBIAN, test "$enable_debian" = "yes")

33 34 35 36
AC_MSG_CHECKING(for kernel)
case `uname` in 
    Darwin)
        AC_MSG_RESULT(darwin)
37 38
        CXXFLAGS="${CXXFLAGS} -fPIC"
        CFLAGS="${CFLAGS} -fPIC"
39 40
        STFKERNEL="darwin"
    ;;
41 42
    *)  
        # treat everything else (kfreebsd, hurd) as linux
43
        AC_MSG_RESULT(linux or similar)
44 45
        CXXFLAGS="-fPIC"
        CFLAGS="-fPIC"
46 47 48
        STFKERNEL="linux"
    ;;
esac
49
AM_CONDITIONAL([ISDARWIN], [test $STFKERNEL = "darwin"])
50

51
# Checks for python libraries.
52 53 54
AC_ARG_ENABLE([python], 
  AS_HELP_STRING(
    [--enable-python],
55
    [enable python console (default="yes")]),,
56 57
    [enable_python="yes"])

58
AM_CONDITIONAL(BUILD_PYTHON, test "$enable_python" = "yes")
59
if (test "$enable_python" = "yes") || (test "$enable_module" = "yes"); then
60
    AC_PYTHON_DEVEL()
61 62 63 64 65 66 67 68 69
    AC_PROG_SWIG(1.3.17)
    SWIG_ENABLE_CXX
    SWIG_PYTHON
    AC_SUBST(SWIG)
    CXXFLAGS="${CXXFLAGS}"
    CFLAGS="${CFLAGS}"
    LIBPYTHON_LDFLAGS=$PYTHON_LDFLAGS 
    LIBPYTHON_INCLUDES=$PYTHON_CPPFLAGS
    LIBNUMPY_INCLUDES=$PYTHON_NUMPY_INCLUDE
70
    LIBWXPYTHON_INCLUDES=$PYTHON_WXPYTHON_INCLUDE
71 72 73 74
else
    LIBPYTHON_LDFLAGS= 
    LIBPYTHON_INCLUDES= 
    LIBNUMPY_INCLUDES= 
75
    LIBWXPYTHON_INCLUDES= 
76 77 78 79
fi
AC_SUBST(LIBPYTHON_LDFLAGS)
AC_SUBST(LIBPYTHON_INCLUDES)
AC_SUBST(LIBNUMPY_INCLUDES)
80
AC_SUBST(LIBWXPYTHON_INCLUDES)
81

82
AC_MSG_CHECKING(for kernel)
83 84
case ${STFKERNEL} in 
    darwin)
Christoph Schmidt-Hieber's avatar
Christoph Schmidt-Hieber committed
85
        LIBSTF_LDFLAGS="-avoid-version"
86 87 88 89 90
        if test "$enable_module" = "yes" ; then
            CPPFLAGS="${CPPFLAGS} -DMODULE_ONLY"
        else
            CPPFLAGS="${CPPFLAGS}"
        fi
91
        STF_PYTHON_LIBNAME="libpystf.dylib"
92
        STFIO_PYTHON_LIBNAME="libpystfio.dylib"
93
        ARCH_FLAGS=""
94 95 96 97 98 99
        CFLAGS="${CFLAGS} ${ARCH_FLAGS}"
        CXXFLAGS="${CXXFLAGS} ${ARCH_FLAGS}"
        LDFLAGS="${LDFLAGS} ${ARCH_FLAGS}"
        OBJCFLAGS="${OBJCFLAGS} ${ARCH_FLAGS}"
        OBJCXXFLAGS="${OBJCXXFLAGS} ${ARCH_FLAGS}"
    ;;
100
    *)
101 102 103 104 105 106 107 108 109 110 111
        if test "$enable_module" = "yes" ; then
            LIBSTF_LDFLAGS="-avoid-version"
            CPPFLAGS="${CPPFLAGS} -DMODULE_ONLY"
        else
            if test "$enable_debian" = "yes" ; then
              LIBSTF_LDFLAGS="-Wl,-rpath,/usr/lib/stimfit -avoid-version"
            else
              LIBSTF_LDFLAGS="-Wl,-rpath,${prefix}/lib/stimfit -avoid-version"
            fi
            CPPFLAGS="${CPPFLAGS}"
        fi
112 113 114 115 116 117
        if test "$enable_debian" = "yes" ; then
            CPPFLAGS="${CPPFLAGS} `dpkg-buildflags --get CPPFLAGS`"
            CFLAGS="${CFLAGS} `dpkg-buildflags --get CFLAGS`"
            CXXFLAGS="${CXXFLAGS} `dpkg-buildflags --get CXXFLAGS`"
            LDFLAGS="${LDFLAGS} `dpkg-buildflags --get LDFLAGS`"
        fi
118
        STF_PYTHON_LIBNAME="libpystf.so"
119
        STFIO_PYTHON_LIBNAME="libpystfio.so"
120 121
    ;;
esac
Christoph Schmidt-Hieber's avatar
Christoph Schmidt-Hieber committed
122
AC_SUBST(LIBSTF_LDFLAGS)
123
AC_SUBST(STF_PYTHON_LIBNAME)
124
AC_SUBST(STFIO_PYTHON_LIBNAME)
125

126
# Checks for python libraries.
127 128 129 130
if test "$enable_python" = "yes" ; then
    CPPFLAGS="${CPPFLAGS} -DWITH_PYTHON"
fi

131
AC_ARG_ENABLE([ipython], AS_HELP_STRING([--enable-ipython],[enable ipython as the default shell (experimental); implies --enable-python]),[])
132 133 134 135 136 137 138 139 140 141
if test "$enable_ipython" = "yes" ; then
    CPPFLAGS="${CPPFLAGS} -DIPYTHON"
fi

# Build the exotic Stimfit flavour with Slope cursors
AC_ARG_WITH([pslope], AS_HELP_STRING([--with-pslope],[include slope measure cursors]),[])
if test "$with_pslope" = "yes" ; then
    CPPFLAGS="${CPPFLAGS} -DWITH_PSLOPE"
fi

142
AC_ARG_WITH([biosig], AS_HELP_STRING([--with-biosig],[build with libbiosig support]),[])
143
AM_CONDITIONAL(WITH_BIOSIG, test "$with_biosig" = "yes")
144

145
AC_ARG_WITH([biosig2], AS_HELP_STRING([--with-biosig2],[equivalent to --with-biosig]),[])
146 147
AM_CONDITIONAL(WITH_BIOSIG2, test "$with_biosig2" = "yes")

148 149 150
AC_ARG_WITH([biosiglite], AS_HELP_STRING([--with-biosiglite], [use builtin biosig library]), [])
AM_CONDITIONAL(WITH_BIOSIGLITE, test "$with_biosiglite" = "yes")

151 152
if test "$with_biosig2" = "yes" ; then
    CPPFLAGS="${CPPFLAGS} -DWITH_BIOSIG2"
153
    LIBBIOSIG_LDFLAGS="-lbiosig -lcholmod"
154
elif test "$with_biosig" = "yes" ; then
155
    CPPFLAGS="${CPPFLAGS} -DWITH_BIOSIG"
156
    LIBBIOSIG_LDFLAGS="-lbiosig -lcholmod"
157 158 159
elif test "$with_biosiglite" = "yes" ; then
    CPPFLAGS="${CPPFLAGS} -DWITH_BIOSIG2 -DWITH_BIOSIGLITE"
    LIBBIOSIG_LDFLAGS="-lcholmod"
160 161 162
fi
AC_SUBST(LIBBIOSIG_LDFLAGS)

163 164 165 166 167 168 169 170 171 172
AC_ARG_WITH([lapack-lib],
AS_HELP_STRING([--with-lapack-lib=LAPACKLIB],[Provide full path to custom lapack library]),
[
    if test "$withval" != "yes" -a "$withval" != ""; then
        LAPACKLIB=$withval
        LIBLAPACK_LDFLAGS="$LAPACKLIB"
        CPPFLAGS="${CPPFLAGS} -DHAVE_LAPACK" 
    fi
])

173 174 175 176 177
# Checks for libraries.
AC_CHECK_LIB([fftw3], [fftw_malloc], HAVE_FFTW3="yes")
if test "${HAVE_FFTW3}" != "yes" ; then
    AC_MSG_ERROR([Couldn't find fftw3.])
fi
178

179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
if test "$LAPACKLIB" = ""; then
    if test "$STFKERNEL" = "darwin" ; then
        # System LAPACK
        LIBLAPACK_LDFLAGS="/usr/lib/liblapack.dylib -framework Accelerate"
        CPPFLAGS="${CPPFLAGS} -DHAVE_LAPACK -DHAVE_LAPACK_SUFFIX" 
    else
        AC_CHECK_LIB([lapack], [dgemm_], HAVE_LAPACKX="yes")
        if test "${HAVE_LAPACKX}" != "yes" ; then
            AC_CHECK_LIB([lapack3], [dgemm_], HAVE_LAPACK3="yes")
            if test "${HAVE_LAPACK3}" != "yes" ; then
                AC_CHECK_LIB([lapack-3], [dgemm_], HAVE_LAPACK_3="yes")
                    if test "${HAVE_LAPACK_3}" != "yes" ; then
                        AC_CHECK_LIB([blas], [dgemm_], HAVE_ATLAS="yes")
                        if test "${HAVE_ATLAS}" != "yes" ; then
                            AC_MSG_ERROR([Couldn't find lapack.])
194
                        else
195
                            LIBLAPACK_LDFLAGS="-llapack -lblas"
196 197
                            CPPFLAGS="${CPPFLAGS} -DHAVE_LAPACK " 
                        fi
198 199 200 201
                    else
                        LIBLAPACK_LDFLAGS="-llapack-3"
                        CPPFLAGS="${CPPFLAGS} -DHAVE_LAPACK " 
                    fi
202
            else
203
                LIBLAPACK_LDFLAGS=-llapack3
204 205
                CPPFLAGS="${CPPFLAGS} -DHAVE_LAPACK " 
            fi
206 207 208
        else
            LIBLAPACK_LDFLAGS="-llapack -lblas"
            CPPFLAGS="${CPPFLAGS} -DHAVE_LAPACK " 
209
        fi
210
    fi
211 212
fi
AC_SUBST(LIBLAPACK_LDFLAGS)
213

214 215
# stuff not required for standalone module
if test "$enable_module" != "yes"; then
216

217
    # Optionally enables aui for doc/view architecture
218
    AC_ARG_ENABLE([aui], AS_HELP_STRING([--enable-aui],[enable AUI for the doc/view architecture (experimental)]),[])
219
    if test "$enable_aui" = "yes" ; then
220
        CPPFLAGS="${CPPFLAGS} -DWITH_AUIDOCVIEW"
221 222
    fi

223 224 225
    WXCONFIG=wx-config
    AC_ARG_WITH(wx-config,
    [[  --with-wx-config=FILE     Use the given path to wx-config when determining
226
                                wxWidgets configuration; defaults to "wx-config"]],
227
    [
228 229 230
        if test "$withval" != "yes" -a "$withval" != ""; then
            WXCONFIG=$withval
        fi
231
    ])
232

233
    wxversion=0
234

235 236
    AC_DEFUN([WXTEST],
    [
237 238 239 240 241 242 243 244
            AC_REQUIRE([AC_PROG_AWK])
            AC_MSG_CHECKING([wxWidgets version])
            if wxversion=`$WXCONFIG --version`; then
                    AC_MSG_RESULT([$wxversion])
            else
                    AC_MSG_RESULT([not found])
                    AC_MSG_ERROR([wxWidgets is required. Try --with-wx-config.])
            fi])
245

246 247
    # Call WXTEST func
    WXTEST
248

249 250
    # Verify minimus requires
    AC_MSG_CHECKING(for wxWidgets libraries)
251 252
    vers=`echo $wxversion | $AWK 'BEGIN { FS = "."; } { printf "% d", ($1 * 1000 + $2) * 1000 + $3;}'`
    if test -n "$vers" && test "$vers" -ge 2008000; then
253 254 255
            WX_CPPFLAGS="`$WXCONFIG --cppflags`"
            WX_CXXFLAGS="`$WXCONFIG --cxxflags`"
            if test "$STFKERNEL" = "darwin" ; then
256 257 258 259 260
                if test "${PY_AC_VERSION:0:1}" -ge 3; then
                    WX_LIBS="`$WXCONFIG --libs base`"
                else
                    WX_LIBS="`$WXCONFIG --libs propgrid,aui,adv,core,net,base`"
                fi
261 262 263 264
            else
                WX_LIBS="`$WXCONFIG --libs base,core,adv,aui,net`"
            fi
            AC_MSG_RESULT([$WX_LIBS])
265
    else
266
            AC_MSG_ERROR([wxWidgets 2.8.0 or newer is required])
267
    fi
268

269
    # CPPFLAGS="$CPPFLAGS $WX_CPPFLAGS"
270
    # CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS" dnl included in cppflags
271

272
    AC_SUBST(WX_LIBS)
273 274
    AC_SUBST(WX_CPPFLAGS)
    AC_SUBST(WX_CXXFLAGS)
275 276 277 278 279 280 281 282 283 284
dnl default value is to (silently) do nothing in the makefile
POSTLINK_COMMAND="@true"
MACSETFILE="@true"

AC_MSG_CHECKING(for wxWidgets platform)
WX_BASENAME="`$WXCONFIG --basename`"
case $WX_BASENAME in 
    *wx_osx*)
        AC_MSG_RESULT($WX_BASENAME)
        AC_CHECK_PROG(REZ, Rez, Rez, /Developer/Tools/Rez)
285
        POSTLINK_COMMAND="\$(REZ) -d __DARWIN__ -t APPL -o"
286 287 288 289 290 291
        AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
        MACSETFILE="\$(SETFILE)"
    ;;
    *wx_mac*)
        AC_MSG_RESULT($WX_BASENAME)
        AC_CHECK_PROG(REZ, Rez, Rez, /Developer/Tools/Rez)
292
        POSTLINK_COMMAND="\$(REZ) -d __DARWIN__ -t APPL -o"
293 294 295 296 297 298 299 300 301 302 303
        AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
        MACSETFILE="\$(SETFILE)"
    ;;
    *) 
        AC_MSG_RESULT(other)
    ;;
esac

AC_SUBST(POSTLINK_COMMAND)
AC_SUBST(MACSETFILE)

304 305 306
fi

# Checks for hdf5 libraries.
307 308 309 310 311 312 313 314 315 316
AC_ARG_WITH([hdf5-prefix],
AS_HELP_STRING([--with-hdf5-prefix=HDF5_PREFIX],[Provide full path to hdf5 prefix]),
[
    if test "$withval" != "yes" -a "$withval" != ""; then
        HDF5_PREFIX=${withval}
        LDFLAGS="${LDFLAGS} -L${HDF5_PREFIX}/lib"
        CPPFLAGS="${CPPFLAGS} -I${HDF5_PREFIX}/include" 
    fi
])

317
if test "${HDF5PREFIX}" = ""; then
318
    if test "$STFKERNEL" = "linux" ; then
319
        PKG_CHECK_MODULES([HDF5], [hdf5], [
320
            CPPFLAGS="${CPPFLAGS} ${HDF5_CFLAGS} -DH5_USE_16_API"
321
            LIBHDF5_LDFLAGS="${HDF5_LIBS} -lhdf5_hl"
322
	    LDFLAGS="${LDFLAGS} ${LIBHDF5_LDFLAGS}"
323 324 325 326
	], [
	    HDF5_CFLAGS=""
	    HDF5_LIBS=""
        ])
327 328 329
    fi
fi

330
AC_CHECK_HEADER([hdf5.h], [], [AC_MSG_ERROR([Couldn't find hdf5 header])])
331
AC_CHECK_LIB([hdf5],[H5Fopen],HAVE_HDF5="yes")
332 333 334
if test "${HAVE_HDF5}" != "yes" ; then
    AC_MSG_ERROR([Couldn't find hdf5 libraries.])
else
335
    if test "${HDF5_CFLAGS}" = ""; then
336 337 338
        CPPFLAGS="${CPPFLAGS} -DH5_USE_16_API"
        LIBHDF5_LDFLAGS="-lhdf5 -lhdf5_hl"
    fi
339
fi
Alois SCHLOEGL's avatar
Alois SCHLOEGL committed
340
AC_SUBST(LIBHDF5_LDFLAGS)
341 342

AC_ARG_ENABLE([debug],
343
        AS_HELP_STRING([--enable-debug],[build stimfit in debug mode]),[
344 345
])
    if test "$enable_debug" = "yes" ; then
346 347 348
        CPPFLAGS="${CPPFLAGS} -D_STFDEBUG "
        OPT_CXXFLAGS="-O0 -g3"
        CFLAGS="${CFLAGS} -O0 -g3"
349
    else
350 351
        OPT_CXXFLAGS="-O2 -g"
        CFLAGS="${CFLAGS} -O2 -g"
352 353
    fi
AC_SUBST(OPT_CXXFLAGS)
354 355

# gtest
356 357 358 359 360 361 362 363 364
GT_CPPFLAGS=""
GT_CXXFLAGS=""
GT_LIBS="-lpthread"
GT_LDFLAGS=""

AC_SUBST(GT_CPPFLAGS)
AC_SUBST(GT_CXXFLAGS)
AC_SUBST(GT_LIBS)
AC_SUBST(GT_LDFLAGS)
365
# end gtest
366

367 368
# CPPFLAGS="${CPPFLAGS} -DSTFDATE='\"${BUILDDATE}\"'"
CXXFLAGS="${CXXFLAGS} -Wall"
369

370 371
AC_CONFIG_HEADERS([stfconf.h])

372
AC_CONFIG_FILES([Makefile src/Makefile src/libstfio/Makefile src/libstfnum/Makefile src/libbiosiglite/Makefile src/pystfio/Makefile src/stimfit/Makefile src/stimfit/py/Makefile dist/macosx/stimfit.plist])
373 374

AC_OUTPUT