]> git.proxmox.com Git - mirror_smartmontools-debian.git/blame - configure.in
Imported Upstream version 5.38+svn2879
[mirror_smartmontools-debian.git] / configure.in
CommitLineData
832b75ed 1#
2127e193 2# $Id: configure.in 2870 2009-08-02 20:38:30Z manfred99 $
832b75ed
GG
3#
4dnl Process this file with autoconf to produce a configure script.
5AC_PREREQ(2.50)
2127e193 6AC_INIT(smartmontools, 5.39, smartmontools-support@lists.sourceforge.net)
4d59bff9 7AC_CONFIG_SRCDIR(smartctl.cpp)
832b75ed
GG
8
9smartmontools_configure_date=`date -u +"%Y/%m/%d %T %Z"`
2127e193 10smartmontools_cvs_tag=`echo '$Id: configure.in 2870 2009-08-02 20:38:30Z manfred99 $'`
34ad0c5f
GG
11smartmontools_release_date=2008/03/10
12smartmontools_release_time="10:44:07 GMT"
832b75ed
GG
13
14AC_DEFINE_UNQUOTED(SMARTMONTOOLS_CONFIGURE_ARGS, "$ac_configure_args", [smartmontools Configure Arguments])
15AC_DEFINE_UNQUOTED(SMARTMONTOOLS_CONFIGURE_DATE, "$smartmontools_configure_date", [smartmontools Configure Date])
16AC_DEFINE_UNQUOTED(SMARTMONTOOLS_RELEASE_DATE, "$smartmontools_release_date", [smartmontools Release Date])
17AC_DEFINE_UNQUOTED(SMARTMONTOOLS_RELEASE_TIME, "$smartmontools_release_time", [smartmontools Release Time])
18AC_DEFINE_UNQUOTED(CONFIG_H_CVSID, "$smartmontools_cvs_tag", [smartmontools CVS Tag])
19AC_DEFINE_UNQUOTED(PACKAGE_HOMEPAGE, "http://smartmontools.sourceforge.net/", [smartmontools Home Page])
20
21AM_CONFIG_HEADER(config.h)
22
23AM_INIT_AUTOMAKE
24
25AM_MAINTAINER_MODE
26
4d59bff9 27AC_LANG_CPLUSPLUS
832b75ed 28dnl Checks for programs.
4d59bff9 29AC_PROG_CXX
832b75ed
GG
30AM_PROG_AS
31AC_PROG_INSTALL
32
33AC_CANONICAL_HOST
34dnl Set flags which may affect AC_CHECK_*.
35case "${host}" in
36 *-*-mingw*)
37 CPPFLAGS="$CPPFLAGS -mno-cygwin"
38 LDFLAGS="$LDFLAGS -mno-cygwin"
39 CPPFLAGS="$CPPFLAGS -idirafter ${srcdir}/posix -idirafter ${srcdir}/os_win32"
a37e7145
GG
40 ;;
41 *-*-freebsd*)
42 CPPFLAGS="$CPPFLAGS -I/usr/src/sys"
43 ;;
832b75ed
GG
44esac
45
2127e193
GI
46# Check for SVN.
47AC_MSG_CHECKING([whether this is a build from SVN])
48is_svn_build=no
49if test -f "$srcdir/.svn/entries"; then
50 is_svn_build=unknown
51 if (cd "$srcdir" && svn --version && svnversion && svn info) >/dev/null 2>&1; then
52 is_svn_build=yes
53 fi
54fi
55AM_CONDITIONAL(IS_SVN_BUILD, [test "$is_svn_build" = "yes"])
56AC_MSG_RESULT([$is_svn_build])
57
58dnl Checks for libraries needed for name services (Solaris needs
832b75ed
GG
59dnl libnsl, might in the future also need libsocket)
60# AC_SEARCH_LIBS (FUNCTION, SEARCH-LIBS, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES])
2127e193
GI
61AC_SEARCH_LIBS(socket, socket)
62AC_SEARCH_LIBS(gethostbyname, nsl)
63AC_SEARCH_LIBS(getaddrinfo, nsl)
64AC_SEARCH_LIBS(getdomainname, nsl)
832b75ed
GG
65
66dnl Checks for header files.
67AC_CHECK_HEADERS([locale.h])
832b75ed
GG
68AC_CHECK_HEADERS([dev/ata/atavar.h])
69AC_CHECK_HEADERS([netdb.h])
70dnl we need [u]int64_t and friends.
71AC_CHECK_HEADERS([inttypes.h]) dnl C99, UNIX98, solaris 2.6+
72AC_CHECK_HEADERS([stdint.h]) dnl C99
73AC_CHECK_HEADERS([sys/inttypes.h]) dnl pre-UNIX98
74AC_CHECK_HEADERS([sys/int_types.h]) dnl pre-UNIX98, solaris 2.6+
75dnl Check for FreeBSD twe include files...currently missing on 5.2, but should be there
76AC_CHECK_HEADERS([sys/tweio.h])
77AC_CHECK_HEADERS([sys/twereg.h])
78dnl Check for FreeBSD twa include files...
79AC_CHECK_HEADERS([sys/tw_osl_ioctl.h])
a37e7145
GG
80dnl Check for FreeBSD ciss include files...
81AC_CHECK_HEADERS([dev/ciss/cissio.h])
1953ff6d 82dnl This header file is needed for cciss_ioctl.h at least on SuSE LINUX
ba59cff1 83AC_CHECK_HEADERS([linux/compiler.h])
1953ff6d
GG
84dnl Check for Linux CCISS include file
85AC_CHECK_HEADERS([linux/cciss_ioctl.h], [], [], [AC_INCLUDES_DEFAULT
86#ifdef HAVE_LINUX_COMPILER_H
87# include <linux/compiler.h>
88#endif
89])
832b75ed
GG
90
91dnl Checks for typedefs, structures, and compiler characteristics.
92AC_CHECK_TYPES([int64_t, uint64_t])
93
94dnl Checks for library functions.
2127e193
GI
95AC_CHECK_FUNCS([getopt_long], , [
96 AC_MSG_NOTICE([smartmontools does no longer support platforms without getopt_long().])
97 AC_MSG_NOTICE([Please inform ${PACKAGE_BUGREPORT},])
98 AC_MSG_NOTICE([including details about your build environment.])
99 AC_MSG_ERROR([function getopt_long() not found])
100])
101
832b75ed
GG
102AC_CHECK_FUNCS([getdomainname])
103AC_CHECK_FUNCS([gethostname])
2127e193 104AC_CHECK_FUNCS([getaddrinfo])
832b75ed
GG
105AC_CHECK_FUNCS([gethostbyname])
106AC_CHECK_FUNCS([sigset])
107AC_CHECK_FUNCS([strtoull])
108AC_CHECK_FUNCS([uname])
109
110# Check whether snprintf appends null char and returns expected length on overflow
111AH_TEMPLATE(HAVE_WORKING_SNPRINTF, [Define to 1 if the `snprintf' function is sane])
112AC_MSG_CHECKING([for working snprintf])
113AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[ char buf[]="ABCDEFGHI";
114 int i=snprintf(buf,8,"12345678"); return !(!buf[7] && i==8); ]])],
4d59bff9
GG
115 [libc_have_working_snprintf=yes],
116 [libc_have_working_snprintf=no],
117 [libc_have_working_snprintf=no])
832b75ed
GG
118AC_SUBST(libc_have_working_snprintf)
119if test "$libc_have_working_snprintf" = "yes"; then
120 AC_DEFINE(HAVE_WORKING_SNPRINTF)
121fi
122AC_MSG_RESULT([$libc_have_working_snprintf])
123
124# check for __attribute__((packed))
4d59bff9
GG
125AH_TEMPLATE(HAVE_ATTR_PACKED, [Define to 1 if C++ compiler supports __attribute__((packed))])
126AC_MSG_CHECKING([whether C++ compiler supports __attribute__((packed))])
832b75ed
GG
127AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[struct a { int b; } __attribute__((packed));]])],
128 [gcc_have_attr_packed=yes], [gcc_have_attr_packed=no])
34ad0c5f
GG
129AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
130#error "Sun's compiler cannot handle __attribute__((packed))!"
131#endif]])],
132 [true], [gcc_have_attr_packed=no])
832b75ed
GG
133AC_SUBST(gcc_have_attr_packed)
134if test "$gcc_have_attr_packed" = "yes"; then
135 AC_DEFINE(HAVE_ATTR_PACKED)
136fi
137AC_MSG_RESULT([$gcc_have_attr_packed])
138
139AC_SUBST(CPPFLAGS)
140AC_SUBST(LDFLAGS)
141AC_SUBST(ASFLAGS)
142
143AC_SUBST([exampledir], ['${docdir}/examplescripts'])
144
145AC_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'])
146AC_SUBST(initddir)
2127e193 147AM_CONDITIONAL(INSTALL_INITSCRIPT, [test "$with_initscriptdir" != "no"])
832b75ed
GG
148
149AC_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}'])
150AC_SUBST(docdir)
151
2127e193
GI
152AC_ARG_ENABLE(drivedb, [AC_HELP_STRING([--enable-drivedb],[Enables drive database file])])
153
154AC_ARG_WITH(drivedbdir,
155 [AC_HELP_STRING([--with-drivedbdir=DIR],[Location of drive database file (implies --enable-drivedb) [DATADIR/smartmontools]])],
156 [drivedbdir="$withval"; enable_drivedb="yes"],
157 [drivedbdir=; test "$enable_drivedb" = "yes" && drivedbdir='${datadir}/${PACKAGE}'])
158AC_SUBST(drivedbdir)
159AM_CONDITIONAL(ENABLE_DRIVEDB, [test "$enable_drivedb" = "yes"])
160
161AC_ARG_ENABLE(savestates, [AC_HELP_STRING([--enable-savestates],[Enables default smartd state files])])
162
163AC_ARG_WITH(savestates,
164 [AC_HELP_STRING([--with-savestates=PREFIX],[Prefix for default smartd state files (implies --enable-savestates) [LOCALSTATEDIR/lib/smartmontools/smartd.]])],
165 [savestates="$withval"; enable_savestates="yes"],
166 [savestates=; test "$enable_savestates" = "yes" && savestates='${localstatedir}/lib/${PACKAGE}/smartd.'])
167savestatesdir="${savestates%/*}"
168AC_SUBST(savestates)
169AC_SUBST(savestatesdir)
170AM_CONDITIONAL(ENABLE_SAVESTATES, [test "$enable_savestates" = "yes"])
171
172AC_ARG_ENABLE(attributelog, [AC_HELP_STRING([--enable-attributelog],[Enables default smartd attribute log files])])
173
174AC_ARG_WITH(attributelog,
175 [AC_HELP_STRING([--with-attributelog=PREFIX],[Prefix for default smartd attribute log files (implies --enable-attributelog) [LOCALSTATEDIR/lib/smartmontools/attrlog.]])],
176 [attributelog="$withval"; enable_attributelog="yes"],
177 [attributelog=; test "$enable_attributelog" = "yes" && attributelog='${localstatedir}/lib/${PACKAGE}/attrlog.'])
178attributelogdir="${attributelog%/*}"
179AC_SUBST(attributelog)
180AC_SUBST(attributelogdir)
181AM_CONDITIONAL(ENABLE_ATTRIBUTELOG, [test "$enable_attributelog" = "yes"])
182
832b75ed
GG
183AC_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=''])
184AC_SUBST(smartd_suffix)
185AM_CONDITIONAL(SMARTD_SUFFIX, test $smartd_suffix)
186
2127e193
GI
187AC_ARG_WITH(os-deps,
188 [AC_HELP_STRING([--with-os-deps='os_module.o ...'],[Specify OS dependent module(s) [guessed]])],
189 [ for x in $with_os_deps; do
190 case $x in
191 *.o) ;;
192 *) AC_MSG_ERROR([non-object file specified by --with-os-deps]) ;;
193 esac
194 done
195 ],[])
196
197AC_ARG_WITH(selinux,[AC_HELP_STRING([--with-selinux],[Enables SELinux support])],
198 [
199 AC_CHECK_HEADERS([selinux/selinux.h], [], [echo "*** Error: Missing SELinux header files";exit 1])
200 AC_CHECK_LIB(selinux, matchpathcon, [with_selinux=yes], [echo "*** Error: Missing or incorrect SELinux library files"; exit 1],)
201 ],[])
202AC_SUBST(with_selinux)
203if test "$with_selinux" = "yes"; then
204 AC_DEFINE(WITH_SELINUX, [1], [Define to 1 if SELinux support is enabled])
205fi
206
832b75ed
GG
207if test "$prefix" = "NONE"; then
208 dnl no prefix and no mandir, so use ${prefix}/share/man as default
209 if test "$mandir" = '${prefix}/man'; then
210 AC_SUBST([mandir], ['${prefix}/share/man'])
211 fi
212fi
213
214AC_SUBST(releaseversion,['${PACKAGE}-${VERSION}'])
215AC_SUBST(smartmontools_release_date)
216AC_SUBST(smartmontools_release_time)
217
2127e193 218AC_MSG_CHECKING([for OS dependent modules and libraries])
832b75ed
GG
219dnl if OS not recognized, then use the os_generic modules
220case "${host}" in
832b75ed 221 *-*-linux*)
a37e7145 222 AC_SUBST([os_deps], ['os_linux.o cciss.o'])
2127e193
GI
223 if test "$with_selinux" = "yes"; then
224 AC_SUBST([os_libs], ['-lselinux'])
225 else
226 AC_SUBST([os_libs], [''])
227 fi;;
34ad0c5f 228 *-*-freebsd*|*-*-dragonfly*|*-*-kfreebsd*-gnu*)
a37e7145 229 AC_SUBST([os_deps], ['os_freebsd.o cciss.o'])
832b75ed
GG
230 AC_SUBST([os_libs], ['-lcam']);;
231 sparc-*-solaris*)
232 AC_DEFINE_UNQUOTED(DEFAULT_MAILER, "mailx", [use mailx as default mailer])
233 AC_DEFINE_UNQUOTED(NEED_SOLARIS_ATA_CODE, "os_solaris_ata.s", [need assembly code os_solaris_ata.s])
234 AC_SUBST([os_deps], ['os_solaris.o os_solaris_ata.o'])
235 AC_SUBST([os_libs], ['']) ;;
236 *-pc-solaris*)
237 AC_DEFINE_UNQUOTED(DEFAULT_MAILER, "mailx", [use mailx as default mailer])
238 AC_SUBST([os_deps], ['os_solaris.o'])
239 AC_SUBST([os_libs], ['']) ;;
240 *-*-netbsd*)
241 AC_SUBST([os_deps], ['os_netbsd.o'])
242 AC_SUBST([os_libs], ['-lutil']) ;;
243 *-*-openbsd*)
244 AC_SUBST([os_deps], ['os_openbsd.o'])
245 AC_SUBST([os_libs], ['-lutil']) ;;
246 *-*-cygwin*)
247 AC_SUBST([os_deps], ['os_win32.o'])
248 AC_SUBST([os_libs], ['']) ;;
249 *-*-mingw*)
250 AC_SUBST([os_deps], ['os_win32.o'])
251 AC_SUBST([os_libs], ['']) ;;
252 *-*-darwin*)
253 AC_SUBST([os_deps], ['os_darwin.o'])
254 AC_SUBST([os_libs], ['-framework CoreFoundation -framework IOKit']) ;;
a37e7145
GG
255 *-*-nto-qnx*)
256 AC_SUBST([os_deps], ['os_qnxnto.o'])
257 AC_SUBST([os_libs], ['']) ;;
258
832b75ed
GG
259 *)
260 AC_SUBST([os_deps], ['os_generic.o'])
261 AC_SUBST([os_libs], ['']) ;;
262esac
263
2127e193
GI
264# Replace if '--with-os-deps' was specified
265test -z "$with_os_deps" || os_deps="$with_os_deps"
266AC_MSG_RESULT([$os_deps $os_libs])
267
832b75ed
GG
268# Define symbols for optional functions in OS specific module
269case "${os_deps}" in
270 os_win32*)
271 AC_DEFINE(HAVE_ATA_IDENTIFY_IS_CACHED, 1, [Define to 1 if you have the `ata_identify_is_cached' function in os_*.c.]) ;;
272esac
273case "${os_deps}" in
274 os_win32*)
275 AC_DEFINE(HAVE_GET_OS_VERSION_STR, 1, [Define to 1 if you have the `get_os_version_str' function in os_*.c.]) ;;
276esac
277
2127e193
GI
278# Check if we need adapter to old interface (dev_legacy.cpp)
279os_src=`echo "${os_deps}"|sed -n 's,^\([[^ .]]*\)\.o.*$,\1.cpp,p'`
280AC_MSG_CHECKING([whether ${os_src} uses new interface])
281if grep "smart_interface" "${srcdir}/${os_src}" >/dev/null 2>&1; then
282 os_new_interface=yes
283else
284 os_new_interface=no
285 os_deps="${os_deps} dev_legacy.o"
286 AC_DEFINE(OLD_INTERFACE, 1, [Define to 1 if os_*.cpp still uses the old interface])
287fi
288AC_MSG_RESULT([$os_new_interface])
289
832b75ed
GG
290dnl Define platform-specific symbol.
291AM_CONDITIONAL(OS_DARWIN, [echo $host_os | grep '^darwin' > /dev/null])
292AM_CONDITIONAL(OS_SOLARIS, [echo $host_os | grep '^solaris' > /dev/null])
293AM_CONDITIONAL(OS_WIN32_MINGW, [echo $host_os | grep '^mingw' > /dev/null])
2127e193 294AM_CONDITIONAL(OS_FREEBSD, [echo $host_os | grep '^freebsd' > /dev/null])
832b75ed
GG
295
296dnl Add -Wall and -W if using gcc and its not already specified.
297if test "x$GCC" = "xyes"; then
4d59bff9
GG
298 if test -z "`echo "$CXXFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
299 CXXFLAGS="$CXXFLAGS -Wall"
832b75ed
GG
300 fi
301# In the next line, do NOT delete the 2 spaces inside double quotes.
4d59bff9
GG
302 if test -z "`echo "$CXXFLAGS " | grep "\-W " 2> /dev/null`" ; then
303 CXXFLAGS="$CXXFLAGS -W"
832b75ed
GG
304 fi
305 case "${host}" in
306 *-*-mingw*)
307 # MinGW uses MSVCRT.DLL which uses printf format "%I64d" and not "%lld" for int64_t
4d59bff9 308 CXXFLAGS="$CXXFLAGS -Wno-format";;
832b75ed
GG
309 esac
310else
311 dnl We are NOT using gcc, so enable host-specific compiler flags
312 case "${host}" in
34ad0c5f
GG
313 sparc*-*-solaris*)
314 dnl set CXXFLAGS for Solaris/SPARC C++ compiler
4d59bff9 315 if test -z "`echo "$CXXFLAGS" | grep "\-xmemalign" 2> /dev/null`" ; then
832b75ed 316 dnl we have to tell the compilers about packed ATA structures
4d59bff9 317 CXXFLAGS="-xmemalign=1i $CXXFLAGS"
832b75ed 318 fi
34ad0c5f
GG
319 esac
320 case "${host}" in
321 *-*-solaris*)
4d59bff9 322 if test -z "`echo "$CXXFLAGS" | grep "\-xO" 2> /dev/null`" ; then
832b75ed 323 dnl turn on optimization if user has not explicitly set its value
4d59bff9 324 CXXFLAGS="-xO2 $CXXFLAGS"
832b75ed 325 fi
4d59bff9 326 if test -z "`echo "$CXXFLAGS" | grep "\-erroff" 2> /dev/null`" ; then
2127e193
GI
327 dnl suppress trivial warnings
328 CXXFLAGS="-erroff=%none,wbadinitl,wbadasgl,badargtypel2w,badargtype2w $CXXFLAGS"
4d59bff9 329 fi
832b75ed
GG
330 esac
331fi
332
333AC_DEFINE_UNQUOTED(SMARTMONTOOLS_BUILD_HOST, "${host}", [smartmontools Build Host])
334
4d59bff9 335AC_SUBST(CXXFLAGS)
832b75ed
GG
336
337AC_OUTPUT(Makefile examplescripts/Makefile)
338AC_PROG_MAKE_SET