# # $Id: configure.in 3057 2010-02-03 20:56:41Z chrfranke $ # dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.50) AC_INIT(smartmontools, 5.40, smartmontools-support@lists.sourceforge.net) AC_CONFIG_SRCDIR(smartctl.cpp) smartmontools_configure_date=`date -u +'%Y-%m-%d %T %Z'` smartmontools_cvs_tag=`echo '$Id: configure.in 3057 2010-02-03 20:56:41Z chrfranke $'` smartmontools_release_date=2009-12-09 smartmontools_release_time="21:00:32 UTC" AC_DEFINE_UNQUOTED(SMARTMONTOOLS_CONFIGURE_ARGS, "$ac_configure_args", [smartmontools Configure Arguments]) AC_DEFINE_UNQUOTED(SMARTMONTOOLS_CONFIGURE_DATE, "$smartmontools_configure_date", [smartmontools Configure Date]) AC_DEFINE_UNQUOTED(SMARTMONTOOLS_RELEASE_DATE, "$smartmontools_release_date", [smartmontools Release Date]) AC_DEFINE_UNQUOTED(SMARTMONTOOLS_RELEASE_TIME, "$smartmontools_release_time", [smartmontools Release Time]) AC_DEFINE_UNQUOTED(CONFIG_H_CVSID, "$smartmontools_cvs_tag", [smartmontools CVS Tag]) AC_DEFINE_UNQUOTED(PACKAGE_HOMEPAGE, "http://smartmontools.sourceforge.net/", [smartmontools Home Page]) AM_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE AM_MAINTAINER_MODE AC_LANG_CPLUSPLUS dnl Checks for programs. AC_PROG_CXX AM_PROG_AS AC_PROG_INSTALL AC_CANONICAL_HOST dnl Set flags which may affect AC_CHECK_*. case "${host}" in *-*-mingw*) # If building on Cygwin and not cross-compiling add '-mno-cygwin' # to select MinGW gcc. This does no longer work for gcc 4.x. if test "${build}" = "${host}" && test -x /usr/bin/uname && \ /usr/bin/uname | grep -i '^CYGWIN' >/dev/null; then AC_MSG_CHECKING([whether C and C++ compiler support -mno-cygwin]) gcc_support_m_no_cygwin=no if $CC -v -mno-cygwin >/dev/null 2>&1 && \ $CXX -v -mno-cygwin >/dev/null 2>&1; then gcc_support_m_no_cygwin=yes fi AC_MSG_RESULT([$gcc_support_m_no_cygwin]) if test "$gcc_support_m_no_cygwin" != "yes"; then AC_MSG_ERROR([$CC and $CXX do not support -mno-cygwin, see INSTALL file for details.]) fi CPPFLAGS="$CPPFLAGS -mno-cygwin" LDFLAGS="$LDFLAGS -mno-cygwin" fi CPPFLAGS="$CPPFLAGS -idirafter ${srcdir}/posix -idirafter ${srcdir}/os_win32" ;; *-*-freebsd*) CPPFLAGS="$CPPFLAGS -I/usr/src/sys" ;; esac # Check for SVN. AC_MSG_CHECKING([whether this is a build from SVN]) is_svn_build=no if test -f "$srcdir/.svn/entries"; then is_svn_build=unknown if (cd "$srcdir" && svn --version && svnversion && svn info) >/dev/null 2>&1; then is_svn_build=yes fi fi AM_CONDITIONAL(IS_SVN_BUILD, [test "$is_svn_build" = "yes"]) AC_MSG_RESULT([$is_svn_build]) dnl Checks for libraries needed for name services (Solaris needs dnl libnsl, might in the future also need libsocket) # AC_SEARCH_LIBS (FUNCTION, SEARCH-LIBS, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES]) AC_SEARCH_LIBS(socket, socket) AC_SEARCH_LIBS(gethostbyname, nsl) AC_SEARCH_LIBS(getaddrinfo, nsl) AC_SEARCH_LIBS(getdomainname, nsl) dnl Checks for header files. AC_CHECK_HEADERS([locale.h]) AC_CHECK_HEADERS([dev/ata/atavar.h]) AC_CHECK_HEADERS([netdb.h]) dnl we need [u]int64_t and friends. AC_CHECK_HEADERS([inttypes.h]) dnl C99, UNIX98, solaris 2.6+ AC_CHECK_HEADERS([stdint.h]) dnl C99 AC_CHECK_HEADERS([sys/inttypes.h]) dnl pre-UNIX98 AC_CHECK_HEADERS([sys/int_types.h]) dnl pre-UNIX98, solaris 2.6+ dnl Check for FreeBSD twe include files...currently missing on 5.2, but should be there AC_CHECK_HEADERS([sys/tweio.h]) AC_CHECK_HEADERS([sys/twereg.h]) dnl Check for FreeBSD twa include files... AC_CHECK_HEADERS([sys/tw_osl_ioctl.h]) dnl Check for FreeBSD ciss include files... AC_CHECK_HEADERS([dev/ciss/cissio.h]) dnl This header file is needed for cciss_ioctl.h at least on SuSE LINUX AC_CHECK_HEADERS([linux/compiler.h]) dnl Check for Linux CCISS include file AC_CHECK_HEADERS([linux/cciss_ioctl.h], [], [], [AC_INCLUDES_DEFAULT #ifdef HAVE_LINUX_COMPILER_H # include #endif ]) dnl Checks for typedefs, structures, and compiler characteristics. AC_CHECK_TYPES([int64_t, uint64_t]) dnl Checks for library functions. AC_CHECK_FUNCS([getopt_long], , [ AC_MSG_NOTICE([smartmontools does no longer support platforms without getopt_long().]) AC_MSG_NOTICE([Please inform ${PACKAGE_BUGREPORT},]) AC_MSG_NOTICE([including details about your build environment.]) AC_MSG_ERROR([function getopt_long() not found]) ]) AC_CHECK_FUNCS([getdomainname]) AC_CHECK_FUNCS([gethostname]) AC_CHECK_FUNCS([getaddrinfo]) AC_CHECK_FUNCS([gethostbyname]) AC_CHECK_FUNCS([sigset]) AC_CHECK_FUNCS([strtoull]) AC_CHECK_FUNCS([uname]) # Check whether snprintf appends null char and returns expected length on overflow AH_TEMPLATE(HAVE_WORKING_SNPRINTF, [Define to 1 if the `snprintf' function is sane]) AC_MSG_CHECKING([for working snprintf]) AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ char buf[]="ABCDEFGHI"; int i=snprintf(buf,8,"12345678"); return !(!buf[7] && i==8); ]])], [libc_have_working_snprintf=yes], [libc_have_working_snprintf=no], [libc_have_working_snprintf=no]) AC_SUBST(libc_have_working_snprintf) if test "$libc_have_working_snprintf" = "yes"; then AC_DEFINE(HAVE_WORKING_SNPRINTF) fi AC_MSG_RESULT([$libc_have_working_snprintf]) # check for __attribute__((packed)) AH_TEMPLATE(HAVE_ATTR_PACKED, [Define to 1 if C++ compiler supports __attribute__((packed))]) AC_MSG_CHECKING([whether C++ compiler supports __attribute__((packed))]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[struct a { int b; } __attribute__((packed));]])], [gcc_have_attr_packed=yes], [gcc_have_attr_packed=no]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) #error "Sun's compiler cannot handle __attribute__((packed))!" #endif]])], [true], [gcc_have_attr_packed=no]) AC_SUBST(gcc_have_attr_packed) if test "$gcc_have_attr_packed" = "yes"; then AC_DEFINE(HAVE_ATTR_PACKED) fi AC_MSG_RESULT([$gcc_have_attr_packed]) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) AC_SUBST(ASFLAGS) AC_SUBST([exampledir], ['${docdir}/examplescripts']) AC_ARG_WITH(initscriptdir, [AC_HELP_STRING([--with-initscriptdir=DIR],[Location of init scripts [SYSCONFDIR/rc.d/init.d]])], [initddir="$withval"],[initddir='${sysconfdir}/rc.d/init.d']) AC_SUBST(initddir) AM_CONDITIONAL(INSTALL_INITSCRIPT, [test "$with_initscriptdir" != "no"]) docdir_is_default=no AC_ARG_WITH(docdir, [AC_HELP_STRING([--with-docdir=DIR],[Location of documentation [DATADIR/doc/smartmontools]])], [docdir="$withval"], [ if test -z "$docdir"; then # autoconf 2.5x without '--docdir' support docdir='${datadir}/doc/${PACKAGE}' docdir_is_default=yes elif test "$docdir" = '${datarootdir}/doc/${PACKAGE_TARNAME}'; then # autoconf 2.6x '--docdir' default docdir_is_default=yes fi ]) AC_SUBST(docdir) AC_ARG_ENABLE(drivedb, [AC_HELP_STRING([--enable-drivedb],[Enables drive database file])]) AC_ARG_WITH(drivedbdir, [AC_HELP_STRING([--with-drivedbdir=DIR],[Location of drive database file (implies --enable-drivedb) [DATADIR/smartmontools]])], [drivedbdir="$withval"; enable_drivedb="yes"], [drivedbdir=; test "$enable_drivedb" = "yes" && drivedbdir='${datadir}/${PACKAGE}']) AC_SUBST(drivedbdir) AM_CONDITIONAL(ENABLE_DRIVEDB, [test "$enable_drivedb" = "yes"]) AC_ARG_ENABLE(savestates, [AC_HELP_STRING([--enable-savestates],[Enables default smartd state files])]) AC_ARG_WITH(savestates, [AC_HELP_STRING([--with-savestates=PREFIX],[Prefix for default smartd state files (implies --enable-savestates) [LOCALSTATEDIR/lib/smartmontools/smartd.]])], [savestates="$withval"; enable_savestates="yes"], [savestates=; test "$enable_savestates" = "yes" && savestates='${localstatedir}/lib/${PACKAGE}/smartd.']) savestatesdir="${savestates%/*}" AC_SUBST(savestates) AC_SUBST(savestatesdir) AM_CONDITIONAL(ENABLE_SAVESTATES, [test "$enable_savestates" = "yes"]) AC_ARG_ENABLE(attributelog, [AC_HELP_STRING([--enable-attributelog],[Enables default smartd attribute log files])]) AC_ARG_WITH(attributelog, [AC_HELP_STRING([--with-attributelog=PREFIX],[Prefix for default smartd attribute log files (implies --enable-attributelog) [LOCALSTATEDIR/lib/smartmontools/attrlog.]])], [attributelog="$withval"; enable_attributelog="yes"], [attributelog=; test "$enable_attributelog" = "yes" && attributelog='${localstatedir}/lib/${PACKAGE}/attrlog.']) attributelogdir="${attributelog%/*}" AC_SUBST(attributelog) AC_SUBST(attributelogdir) AM_CONDITIONAL(ENABLE_ATTRIBUTELOG, [test "$enable_attributelog" = "yes"]) AC_ARG_ENABLE(sample,[AC_HELP_STRING([--enable-sample],[Enables appending .sample to the installed smartd rc script and configuration file])],[smartd_suffix='.sample'],[smartd_suffix='']) AC_SUBST(smartd_suffix) AM_CONDITIONAL(SMARTD_SUFFIX, test $smartd_suffix) AC_ARG_WITH(os-deps, [AC_HELP_STRING([--with-os-deps='os_module.o ...'],[Specify OS dependent module(s) [guessed]])], [ for x in $with_os_deps; do case $x in *.o) ;; *) AC_MSG_ERROR([non-object file specified by --with-os-deps]) ;; esac done ],[]) AC_ARG_WITH(selinux,[AC_HELP_STRING([--with-selinux],[Enables SELinux support])], [ AC_CHECK_HEADERS([selinux/selinux.h], [], [echo "*** Error: Missing SELinux header files";exit 1]) AC_CHECK_LIB(selinux, matchpathcon, [with_selinux=yes], [echo "*** Error: Missing or incorrect SELinux library files"; exit 1],) ],[]) AC_SUBST(with_selinux) if test "$with_selinux" = "yes"; then AC_DEFINE(WITH_SELINUX, [1], [Define to 1 if SELinux support is enabled]) fi AC_ARG_WITH(libcap-ng, [AC_HELP_STRING([--with-libcap-ng=[auto|yes|no]], [Add Libcap-ng support to smartd [auto]])], [with_libcap_ng="$withval"], [with_libcap_ng=auto]) use_libcap_ng=no if test "$with_libcap_ng" != "no"; then AC_CHECK_LIB(cap-ng, capng_clear, [AC_DEFINE(HAVE_LIBCAP_NG, 1, [Define to 1 if you have the `cap-ng' library (-lcap-ng).]) CAPNG_LDADD="-lcap-ng"; use_libcap_ng=yes]) if test "$use_libcap_ng" = "yes"; then AC_CHECK_HEADER(cap-ng.h, [], [AC_MSG_ERROR([libcap-ng libraries found but headers are missing])]) elif test "$with_libcap_ng" = "yes"; then AC_MSG_ERROR([libcap-ng support was requested but the library was not found]) fi fi AC_MSG_CHECKING([whether to use libcap-ng]) AC_SUBST(CAPNG_LDADD) AM_CONDITIONAL(ENABLE_CAPABILITIES, [test "$use_libcap_ng" = "yes"]) AC_MSG_RESULT([$use_libcap_ng]) if test "$prefix" = "NONE"; then dnl no prefix and no mandir, so use ${prefix}/share/man as default if test "$mandir" = '${prefix}/man'; then AC_SUBST([mandir], ['${prefix}/share/man']) fi fi AC_SUBST(releaseversion,['${PACKAGE}-${VERSION}']) AC_SUBST(smartmontools_release_date) AC_SUBST(smartmontools_release_time) AC_MSG_CHECKING([for OS dependent modules and libraries]) dnl if OS not recognized, then use the os_generic modules case "${host}" in *-*-linux*) AC_SUBST([os_deps], ['os_linux.o cciss.o']) if test "$with_selinux" = "yes"; then AC_SUBST([os_libs], ['-lselinux']) else AC_SUBST([os_libs], ['']) fi;; *-*-freebsd*|*-*-dragonfly*|*-*-kfreebsd*-gnu*) AC_SUBST([os_deps], ['os_freebsd.o cciss.o']) AC_SUBST([os_libs], ['-lcam']) AC_CHECK_LIB(usb, libusb20_dev_get_device_desc) ;; sparc-*-solaris*) AC_DEFINE_UNQUOTED(DEFAULT_MAILER, "mailx", [use mailx as default mailer]) AC_DEFINE_UNQUOTED(NEED_SOLARIS_ATA_CODE, "os_solaris_ata.s", [need assembly code os_solaris_ata.s]) AC_SUBST([os_deps], ['os_solaris.o os_solaris_ata.o']) AC_SUBST([os_libs], ['']) ;; *-pc-solaris*) AC_DEFINE_UNQUOTED(DEFAULT_MAILER, "mailx", [use mailx as default mailer]) AC_SUBST([os_deps], ['os_solaris.o']) AC_SUBST([os_libs], ['']) ;; *-*-netbsd*) AC_SUBST([os_deps], ['os_netbsd.o']) AC_SUBST([os_libs], ['-lutil']) ;; *-*-openbsd*) AC_SUBST([os_deps], ['os_openbsd.o']) AC_SUBST([os_libs], ['-lutil']) ;; *-*-cygwin*) AC_SUBST([os_deps], ['os_win32.o']) AC_SUBST([os_libs], ['']) ;; *-*-mingw*) AC_SUBST([os_deps], ['os_win32.o']) AC_SUBST([os_libs], ['']) ;; *-*-darwin*) AC_SUBST([os_deps], ['os_darwin.o']) AC_SUBST([os_libs], ['-framework CoreFoundation -framework IOKit']) ;; *-*-nto-qnx*) AC_SUBST([os_deps], ['os_qnxnto.o']) AC_SUBST([os_libs], ['']) ;; *) AC_SUBST([os_deps], ['os_generic.o']) AC_SUBST([os_libs], ['']) ;; esac # Replace if '--with-os-deps' was specified test -z "$with_os_deps" || os_deps="$with_os_deps" AC_MSG_RESULT([$os_deps $os_libs]) # Define symbols for optional functions in OS specific module case "${os_deps}" in os_win32*) AC_DEFINE(HAVE_ATA_IDENTIFY_IS_CACHED, 1, [Define to 1 if you have the `ata_identify_is_cached' function in os_*.c.]) ;; esac case "${os_deps}" in os_win32*) AC_DEFINE(HAVE_GET_OS_VERSION_STR, 1, [Define to 1 if you have the `get_os_version_str' function in os_*.c.]) ;; esac # Check if we need adapter to old interface (dev_legacy.cpp) os_src=`echo "${os_deps}"|sed -n 's,^\([[^ .]]*\)\.o.*$,\1.cpp,p'` AC_MSG_CHECKING([whether ${os_src} uses new interface]) if grep "smart_interface" "${srcdir}/${os_src}" >/dev/null 2>&1; then os_new_interface=yes else os_new_interface=no os_deps="${os_deps} dev_legacy.o" AC_DEFINE(OLD_INTERFACE, 1, [Define to 1 if os_*.cpp still uses the old interface]) fi AC_MSG_RESULT([$os_new_interface]) dnl Define platform-specific symbol. AM_CONDITIONAL(OS_DARWIN, [echo $host_os | grep '^darwin' > /dev/null]) AM_CONDITIONAL(OS_SOLARIS, [echo $host_os | grep '^solaris' > /dev/null]) AM_CONDITIONAL(OS_WIN32_MINGW, [echo $host_os | grep '^mingw' > /dev/null]) AM_CONDITIONAL(OS_FREEBSD, [echo $host_os | grep '^freebsd' > /dev/null]) dnl Add -Wall and -W if using g++ and its not already specified. if test "$GXX" = "yes"; then if test -z "`echo "$CXXFLAGS" | grep "\-Wall" 2> /dev/null`" ; then CXXFLAGS="$CXXFLAGS -Wall" fi # In the next line, do NOT delete the 2 spaces inside double quotes. if test -z "`echo "$CXXFLAGS " | grep "\-W " 2> /dev/null`" ; then CXXFLAGS="$CXXFLAGS -W" fi case "${host}" in *-*-mingw*) # MinGW uses MSVCRT.DLL which uses printf format "%I64d" and not "%lld" for int64_t CXXFLAGS="$CXXFLAGS -Wno-format";; esac # Disable strict aliasing rules by default (see ticket #23). if test -z "`echo "$CXXFLAGS" | grep "\-f[[no-]]*strict-aliasing" 2> /dev/null`" ; then AC_MSG_CHECKING([whether g++ supports -fno-strict-aliasing]) ac_save_CXXFLAGS="$CXXFLAGS" CXXFLAGS="-fno-strict-aliasing" AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [gcc_have_fno_strict_aliasing=yes], [gcc_have_fno_strict_aliasing=no]) CXXFLAGS="$ac_save_CXXFLAGS" if test "$gcc_have_fno_strict_aliasing" = "yes"; then CXXFLAGS="$CXXFLAGS -fno-strict-aliasing" fi AC_MSG_RESULT([$gcc_have_fno_strict_aliasing]) fi else dnl We are NOT using gcc, so enable host-specific compiler flags case "${host}" in sparc*-*-solaris*) dnl set CXXFLAGS for Solaris/SPARC C++ compiler if test -z "`echo "$CXXFLAGS" | grep "\-xmemalign" 2> /dev/null`" ; then dnl we have to tell the compilers about packed ATA structures CXXFLAGS="-xmemalign=1i $CXXFLAGS" fi esac case "${host}" in *-*-solaris*) if test -z "`echo "$CXXFLAGS" | grep "\-xO" 2> /dev/null`" ; then dnl turn on optimization if user has not explicitly set its value CXXFLAGS="-xO2 $CXXFLAGS" fi if test -z "`echo "$CXXFLAGS" | grep "\-erroff" 2> /dev/null`" ; then dnl suppress trivial warnings CXXFLAGS="-erroff=%none,wbadinitl,wbadasgl,badargtypel2w,badargtype2w $CXXFLAGS" fi esac fi AC_DEFINE_UNQUOTED(SMARTMONTOOLS_BUILD_HOST, "${host}", [smartmontools Build Host]) AC_SUBST(CXXFLAGS) AC_OUTPUT(Makefile examplescripts/Makefile) AC_PROG_MAKE_SET # Print note that the docdir default value has changed # TODO: Remove this after next release if test "$docdir_is_default" = "yes"; then old_def_docdir='${prefix}/share/doc/${PACKAGE}-${VERSION}' old_def_docdir_eval="`eval eval eval echo $old_def_docdir`" docdir_eval="`eval eval eval echo $docdir`" AC_MSG_NOTICE([********** PLEASE NOTE **********]) AC_MSG_NOTICE(['docdir' default has changed]) AC_MSG_NOTICE([from: $old_def_docdir_eval]) AC_MSG_NOTICE([to: $docdir_eval]) AC_MSG_NOTICE([*********************************]) fi