2 # $Id: configure.in,v 1.121 2006/10/30 12:28:54 ballen4705 Exp $
4 dnl Process this file with autoconf to produce a configure script.
6 AC_INIT(smartmontools, 5.37, smartmontools-support@lists.sourceforge.net)
7 AC_CONFIG_SRCDIR(smartctl.cpp)
9 smartmontools_configure_date=`date -u +"%Y/%m/%d %T %Z"`
10 smartmontools_cvs_tag=`echo '$Id: configure.in,v 1.121 2006/10/30 12:28:54 ballen4705 Exp $'`
11 smartmontools_release_date=2006/04/12
12 smartmontools_release_time="17:39:01 UTC"
14 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_CONFIGURE_ARGS, "$ac_configure_args", [smartmontools Configure Arguments])
15 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_CONFIGURE_DATE, "$smartmontools_configure_date", [smartmontools Configure Date])
16 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_RELEASE_DATE, "$smartmontools_release_date", [smartmontools Release Date])
17 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_RELEASE_TIME, "$smartmontools_release_time", [smartmontools Release Time])
18 AC_DEFINE_UNQUOTED(CONFIG_H_CVSID, "$smartmontools_cvs_tag", [smartmontools CVS Tag])
19 AC_DEFINE_UNQUOTED(PACKAGE_HOMEPAGE, "http://smartmontools.sourceforge.net/", [smartmontools Home Page])
21 AM_CONFIG_HEADER(config.h)
28 dnl Checks for programs.
34 dnl Set flags which may affect AC_CHECK_*.
37 CPPFLAGS="$CPPFLAGS -mno-cygwin"
38 LDFLAGS="$LDFLAGS -mno-cygwin"
39 CPPFLAGS="$CPPFLAGS -idirafter ${srcdir}/posix -idirafter ${srcdir}/os_win32"
42 dnl Checks for libraries.needed for gethostbyname (Solaris needs
43 dnl libnsl, might in the future also need libsocket)
44 # AC_SEARCH_LIBS (FUNCTION, SEARCH-LIBS, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES])
45 AC_SEARCH_LIBS(gethostbyname, nsl, , AC_SEARCH_LIBS(gethostbyname, nsl, , , -lsocket), , )
47 dnl Checks for header files.
48 AC_CHECK_HEADERS([locale.h])
49 AC_CHECK_HEADERS([getopt.h])
50 AC_CHECK_HEADERS([dev/ata/atavar.h])
51 AC_CHECK_HEADERS([netdb.h])
52 dnl we need [u]int64_t and friends.
53 AC_CHECK_HEADERS([inttypes.h]) dnl C99, UNIX98, solaris 2.6+
54 AC_CHECK_HEADERS([stdint.h]) dnl C99
55 AC_CHECK_HEADERS([sys/inttypes.h]) dnl pre-UNIX98
56 AC_CHECK_HEADERS([sys/int_types.h]) dnl pre-UNIX98, solaris 2.6+
57 dnl Check for FreeBSD twe include files...currently missing on 5.2, but should be there
58 AC_CHECK_HEADERS([sys/tweio.h])
59 AC_CHECK_HEADERS([sys/twereg.h])
60 dnl Check for FreeBSD twa include files...
61 AC_CHECK_HEADERS([sys/tw_osl_ioctl.h])
62 dnl This header file needed at least for SuSE LINUX
63 AC_CHECK_HEADERS([linux/compiler.h])
65 dnl Checks for typedefs, structures, and compiler characteristics.
66 AC_CHECK_TYPES([int64_t, uint64_t])
68 dnl Checks for library functions.
69 AC_CHECK_FUNCS([getopt])
70 AC_CHECK_FUNCS([getopt_long])
71 AC_CHECK_FUNCS([getdomainname])
72 AC_CHECK_FUNCS([gethostname])
73 AC_CHECK_FUNCS([gethostbyname])
74 AC_CHECK_FUNCS([sigset])
75 AC_CHECK_FUNCS([strtoull])
76 AC_CHECK_FUNCS([uname])
78 # Check whether snprintf appends null char and returns expected length on overflow
79 AH_TEMPLATE(HAVE_WORKING_SNPRINTF, [Define to 1 if the `snprintf' function is sane])
80 AC_MSG_CHECKING([for working snprintf])
81 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[ char buf[]="ABCDEFGHI";
82 int i=snprintf(buf,8,"12345678"); return !(!buf[7] && i==8); ]])],
83 [libc_have_working_snprintf=yes],
84 [libc_have_working_snprintf=no],
85 [libc_have_working_snprintf=no])
86 AC_SUBST(libc_have_working_snprintf)
87 if test "$libc_have_working_snprintf" = "yes"; then
88 AC_DEFINE(HAVE_WORKING_SNPRINTF)
90 AC_MSG_RESULT([$libc_have_working_snprintf])
92 # check for __attribute__((packed))
93 AH_TEMPLATE(HAVE_ATTR_PACKED, [Define to 1 if C++ compiler supports __attribute__((packed))])
94 AC_MSG_CHECKING([whether C++ compiler supports __attribute__((packed))])
95 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[struct a { int b; } __attribute__((packed));]])],
96 [gcc_have_attr_packed=yes], [gcc_have_attr_packed=no])
97 AC_SUBST(gcc_have_attr_packed)
98 if test "$gcc_have_attr_packed" = "yes"; then
99 AC_DEFINE(HAVE_ATTR_PACKED)
101 AC_MSG_RESULT([$gcc_have_attr_packed])
107 AC_SUBST([exampledir], ['${docdir}/examplescripts'])
109 AC_ARG_WITH(initscriptdir,[AC_HELP_STRING([--with-initscriptdir=dir],[Location of init scripts (default is ${sysconfdir}/rc.d/init.d)])],[initddir="$withval"],[initddir='${sysconfdir}/rc.d/init.d'])
112 AC_ARG_WITH(docdir,[AC_HELP_STRING([--with-docdir=dir],[Location of documentation (default is ${prefix}/share/doc/smartmontools-5.X)])],[docdir="$withval"],[docdir='${prefix}/share/doc/${PACKAGE}-${VERSION}'])
115 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=''])
116 AC_SUBST(smartd_suffix)
117 AM_CONDITIONAL(SMARTD_SUFFIX, test $smartd_suffix)
119 if test "$prefix" = "NONE"; then
120 dnl no prefix and no mandir, so use ${prefix}/share/man as default
121 if test "$mandir" = '${prefix}/man'; then
122 AC_SUBST([mandir], ['${prefix}/share/man'])
126 AC_SUBST(releaseversion,['${PACKAGE}-${VERSION}'])
127 AC_SUBST(smartmontools_release_date)
128 AC_SUBST(smartmontools_release_time)
130 dnl if OS not recognized, then use the os_generic modules
133 AC_SUBST([os_deps], ['os_linux.o'])
134 AC_SUBST([os_libs], ['']) ;;
136 AC_SUBST([os_deps], ['os_linux.o'])
137 AC_SUBST([os_libs], ['']) ;;
139 AC_SUBST([os_deps], ['os_freebsd.o'])
140 AC_SUBST([os_libs], ['-lcam']);;
142 AC_DEFINE_UNQUOTED(DEFAULT_MAILER, "mailx", [use mailx as default mailer])
143 AC_DEFINE_UNQUOTED(NEED_SOLARIS_ATA_CODE, "os_solaris_ata.s", [need assembly code os_solaris_ata.s])
144 AC_SUBST([os_deps], ['os_solaris.o os_solaris_ata.o'])
145 AC_SUBST([os_libs], ['']) ;;
147 AC_DEFINE_UNQUOTED(DEFAULT_MAILER, "mailx", [use mailx as default mailer])
148 AC_SUBST([os_deps], ['os_solaris.o'])
149 AC_SUBST([os_libs], ['']) ;;
151 AC_SUBST([os_deps], ['os_netbsd.o'])
152 AC_SUBST([os_libs], ['-lutil']) ;;
154 AC_SUBST([os_deps], ['os_openbsd.o'])
155 AC_SUBST([os_libs], ['-lutil']) ;;
157 AC_SUBST([os_deps], ['os_win32.o'])
158 AC_SUBST([os_libs], ['']) ;;
160 AC_SUBST([os_deps], ['os_win32.o'])
161 AC_SUBST([os_libs], ['']) ;;
163 AC_SUBST([os_deps], ['os_darwin.o'])
164 AC_SUBST([os_libs], ['-framework CoreFoundation -framework IOKit']) ;;
166 AC_SUBST([os_deps], ['os_generic.o'])
167 AC_SUBST([os_libs], ['']) ;;
170 # Define symbols for optional functions in OS specific module
173 AC_DEFINE(HAVE_ATA_IDENTIFY_IS_CACHED, 1, [Define to 1 if you have the `ata_identify_is_cached' function in os_*.c.]) ;;
177 AC_DEFINE(HAVE_GET_OS_VERSION_STR, 1, [Define to 1 if you have the `get_os_version_str' function in os_*.c.]) ;;
180 dnl Define platform-specific symbol.
181 AM_CONDITIONAL(OS_DARWIN, [echo $host_os | grep '^darwin' > /dev/null])
182 AM_CONDITIONAL(OS_SOLARIS, [echo $host_os | grep '^solaris' > /dev/null])
183 AM_CONDITIONAL(OS_WIN32_MINGW, [echo $host_os | grep '^mingw' > /dev/null])
185 dnl Add -Wall and -W if using gcc and its not already specified.
186 if test "x$GCC" = "xyes"; then
187 if test -z "`echo "$CXXFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
188 CXXFLAGS="$CXXFLAGS -Wall"
190 # In the next line, do NOT delete the 2 spaces inside double quotes.
191 if test -z "`echo "$CXXFLAGS " | grep "\-W " 2> /dev/null`" ; then
192 CXXFLAGS="$CXXFLAGS -W"
196 # MinGW uses MSVCRT.DLL which uses printf format "%I64d" and not "%lld" for int64_t
197 CXXFLAGS="$CXXFLAGS -Wno-format";;
200 dnl We are NOT using gcc, so enable host-specific compiler flags
203 dnl set CXXFLAGS for Solaris C++ compiler
204 if test -z "`echo "$CXXFLAGS" | grep "\-xmemalign" 2> /dev/null`" ; then
205 dnl we have to tell the compilers about packed ATA structures
206 CXXFLAGS="-xmemalign=1i $CXXFLAGS"
208 if test -z "`echo "$CXXFLAGS" | grep "\-xO" 2> /dev/null`" ; then
209 dnl turn on optimization if user has not explicitly set its value
210 CXXFLAGS="-xO2 $CXXFLAGS"
212 if test -z "`echo "$CXXFLAGS" | grep "\-erroff" 2> /dev/null`" ; then
213 dnl suppress warnings on use of string literal (const char[]) as
214 dnl char*. TODO: Sun Studio 10 (Sun C++ 5.7) or above only?
215 CXXFLAGS="-erroff=%none,wbadinitl,wbadasgl,badargtypel2w $CXXFLAGS"
220 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_BUILD_HOST, "${host}", [smartmontools Build Host])
224 AC_OUTPUT(Makefile examplescripts/Makefile)