]> git.proxmox.com Git - mirror_smartmontools-debian.git/blob - configure.in
9db5131b1e252d387fc80cf014bd842f88780bff
[mirror_smartmontools-debian.git] / configure.in
1 #
2 # $Id: configure.in 3074 2010-03-05 23:00:30Z chrfranke $
3 #
4 dnl Process this file with autoconf to produce a configure script.
5 AC_PREREQ(2.50)
6 AC_INIT(smartmontools, 5.40, smartmontools-support@lists.sourceforge.net)
7 AC_CONFIG_SRCDIR(smartctl.cpp)
8
9 smartmontools_configure_date=`date -u +'%Y-%m-%d %T %Z'`
10 smartmontools_cvs_tag=`echo '$Id: configure.in 3074 2010-03-05 23:00:30Z chrfranke $'`
11 smartmontools_release_date=2009-12-09
12 smartmontools_release_time="21:00:32 UTC"
13
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])
20
21 AM_CONFIG_HEADER(config.h)
22
23 AM_INIT_AUTOMAKE
24
25 AM_MAINTAINER_MODE
26
27 AC_LANG_CPLUSPLUS
28 dnl Checks for programs.
29 AC_PROG_CXX
30 AM_PROG_AS
31 AC_PROG_INSTALL
32
33 AC_CANONICAL_HOST
34 dnl Set flags which may affect AC_CHECK_*.
35 case "${host}" in
36 *-*-mingw*)
37 # If building on Cygwin and not cross-compiling add '-mno-cygwin'
38 # to select MinGW gcc. This does no longer work for gcc 4.x.
39 if test "${build}" = "${host}" && test -x /usr/bin/uname && \
40 /usr/bin/uname | grep -i '^CYGWIN' >/dev/null; then
41 AC_MSG_CHECKING([whether $CC and $CXX support -mno-cygwin])
42 gcc_support_m_no_cygwin=no
43 if $CC -v -mno-cygwin >/dev/null 2>&1 && \
44 $CXX -v -mno-cygwin >/dev/null 2>&1; then
45 gcc_support_m_no_cygwin=yes
46 fi
47 AC_MSG_RESULT([$gcc_support_m_no_cygwin])
48 if test "$gcc_support_m_no_cygwin" != "yes"; then
49 AC_MSG_ERROR([$CC and $CXX do not support -mno-cygwin, see INSTALL file for details.])
50 fi
51 CPPFLAGS="$CPPFLAGS -mno-cygwin"
52 LDFLAGS="$LDFLAGS -mno-cygwin"
53 fi
54 CPPFLAGS="$CPPFLAGS -idirafter ${srcdir}/posix -idirafter ${srcdir}/os_win32"
55 ;;
56 *-*-freebsd*)
57 CPPFLAGS="$CPPFLAGS -I/usr/src/sys"
58 ;;
59 esac
60
61 # Check for SVN.
62 AC_MSG_CHECKING([whether this is a build from SVN])
63 is_svn_build=no
64 if test -f "$srcdir/.svn/entries"; then
65 is_svn_build=unknown
66 if (cd "$srcdir" && svn --version && svnversion && svn info) >/dev/null 2>&1; then
67 is_svn_build=yes
68 fi
69 fi
70 AM_CONDITIONAL(IS_SVN_BUILD, [test "$is_svn_build" = "yes"])
71 AC_MSG_RESULT([$is_svn_build])
72
73 dnl Checks for libraries needed for name services (Solaris needs
74 dnl libnsl, might in the future also need libsocket)
75 # AC_SEARCH_LIBS (FUNCTION, SEARCH-LIBS, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES])
76 AC_SEARCH_LIBS(socket, socket)
77 AC_SEARCH_LIBS(gethostbyname, nsl)
78 AC_SEARCH_LIBS(getaddrinfo, nsl)
79 AC_SEARCH_LIBS(getdomainname, nsl)
80
81 dnl Checks for header files.
82 AC_CHECK_HEADERS([locale.h])
83 AC_CHECK_HEADERS([dev/ata/atavar.h])
84 AC_CHECK_HEADERS([netdb.h])
85 dnl we need [u]int64_t and friends.
86 AC_CHECK_HEADERS([inttypes.h]) dnl C99, UNIX98, solaris 2.6+
87 AC_CHECK_HEADERS([stdint.h]) dnl C99
88 AC_CHECK_HEADERS([sys/inttypes.h]) dnl pre-UNIX98
89 AC_CHECK_HEADERS([sys/int_types.h]) dnl pre-UNIX98, solaris 2.6+
90 dnl Check for FreeBSD twe include files...currently missing on 5.2, but should be there
91 AC_CHECK_HEADERS([sys/tweio.h])
92 AC_CHECK_HEADERS([sys/twereg.h])
93 dnl Check for FreeBSD twa include files...
94 AC_CHECK_HEADERS([sys/tw_osl_ioctl.h])
95 dnl Check for FreeBSD ciss include files...
96 AC_CHECK_HEADERS([dev/ciss/cissio.h])
97 dnl This header file is needed for cciss_ioctl.h at least on SuSE LINUX
98 AC_CHECK_HEADERS([linux/compiler.h])
99 dnl Check for Linux CCISS include file
100 AC_CHECK_HEADERS([linux/cciss_ioctl.h], [], [], [AC_INCLUDES_DEFAULT
101 #ifdef HAVE_LINUX_COMPILER_H
102 # include <linux/compiler.h>
103 #endif
104 ])
105
106 dnl Checks for typedefs, structures, and compiler characteristics.
107 AC_CHECK_TYPES([int64_t, uint64_t])
108
109 dnl Checks for library functions.
110 AC_CHECK_FUNCS([getopt_long], , [
111 AC_MSG_NOTICE([smartmontools does no longer support platforms without getopt_long().])
112 AC_MSG_NOTICE([Please inform ${PACKAGE_BUGREPORT},])
113 AC_MSG_NOTICE([including details about your build environment.])
114 AC_MSG_ERROR([function getopt_long() not found])
115 ])
116
117 AC_CHECK_FUNCS([getdomainname])
118 AC_CHECK_FUNCS([gethostname])
119 AC_CHECK_FUNCS([getaddrinfo])
120 AC_CHECK_FUNCS([gethostbyname])
121 AC_CHECK_FUNCS([sigset])
122 AC_CHECK_FUNCS([strtoull])
123 AC_CHECK_FUNCS([uname])
124
125 # Check whether snprintf appends null char and returns expected length on overflow
126 AH_TEMPLATE(HAVE_WORKING_SNPRINTF, [Define to 1 if the `snprintf' function is sane])
127 AC_MSG_CHECKING([for working snprintf])
128 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[ char buf[]="ABCDEFGHI";
129 int i=snprintf(buf,8,"12345678"); return !(!buf[7] && i==8); ]])],
130 [libc_have_working_snprintf=yes],
131 [libc_have_working_snprintf=no],
132 [libc_have_working_snprintf=no])
133 AC_SUBST(libc_have_working_snprintf)
134 if test "$libc_have_working_snprintf" = "yes"; then
135 AC_DEFINE(HAVE_WORKING_SNPRINTF)
136 fi
137 AC_MSG_RESULT([$libc_have_working_snprintf])
138
139 # check for __attribute__((packed))
140 AH_TEMPLATE(HAVE_ATTR_PACKED, [Define to 1 if C++ compiler supports __attribute__((packed))])
141 AC_MSG_CHECKING([whether $CXX supports __attribute__((packed))])
142 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[struct a { int b; } __attribute__((packed));]])],
143 [gcc_have_attr_packed=yes], [gcc_have_attr_packed=no])
144 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
145 #error "Sun's compiler cannot handle __attribute__((packed))!"
146 #endif]])],
147 [true], [gcc_have_attr_packed=no])
148 AC_SUBST(gcc_have_attr_packed)
149 if test "$gcc_have_attr_packed" = "yes"; then
150 AC_DEFINE(HAVE_ATTR_PACKED)
151 fi
152 AC_MSG_RESULT([$gcc_have_attr_packed])
153
154 AC_SUBST(CPPFLAGS)
155 AC_SUBST(LDFLAGS)
156 AC_SUBST(ASFLAGS)
157
158 AC_SUBST([exampledir], ['${docdir}/examplescripts'])
159
160 AC_ARG_WITH(initscriptdir,
161 [AC_HELP_STRING([--with-initscriptdir=DIR],[Location of init scripts [SYSCONFDIR/rc.d/init.d]])],
162 [initddir="$withval"],[initddir='${sysconfdir}/rc.d/init.d'])
163 AC_SUBST(initddir)
164 AM_CONDITIONAL(INSTALL_INITSCRIPT, [test "$with_initscriptdir" != "no"])
165
166 docdir_is_default=no
167 AC_ARG_WITH(docdir,
168 [AC_HELP_STRING([--with-docdir=DIR],[Location of documentation [DATADIR/doc/smartmontools]])],
169 [docdir="$withval"],
170 [ if test -z "$docdir"; then
171 # autoconf 2.5x without '--docdir' support
172 docdir='${datadir}/doc/${PACKAGE}'
173 docdir_is_default=yes
174 elif test "$docdir" = '${datarootdir}/doc/${PACKAGE_TARNAME}'; then
175 # autoconf 2.6x '--docdir' default
176 docdir_is_default=yes
177 fi
178 ])
179 AC_SUBST(docdir)
180
181 AC_ARG_ENABLE(drivedb, [AC_HELP_STRING([--enable-drivedb],[Enables drive database file])])
182
183 AC_ARG_WITH(drivedbdir,
184 [AC_HELP_STRING([--with-drivedbdir=DIR],[Location of drive database file (implies --enable-drivedb) [DATADIR/smartmontools]])],
185 [drivedbdir="$withval"; enable_drivedb="yes"],
186 [drivedbdir=; test "$enable_drivedb" = "yes" && drivedbdir='${datadir}/${PACKAGE}'])
187 AC_SUBST(drivedbdir)
188 AM_CONDITIONAL(ENABLE_DRIVEDB, [test "$enable_drivedb" = "yes"])
189
190 AC_ARG_ENABLE(savestates, [AC_HELP_STRING([--enable-savestates],[Enables default smartd state files])])
191
192 AC_ARG_WITH(savestates,
193 [AC_HELP_STRING([--with-savestates=PREFIX],[Prefix for default smartd state files (implies --enable-savestates) [LOCALSTATEDIR/lib/smartmontools/smartd.]])],
194 [savestates="$withval"; enable_savestates="yes"],
195 [savestates=; test "$enable_savestates" = "yes" && savestates='${localstatedir}/lib/${PACKAGE}/smartd.'])
196 savestatesdir="${savestates%/*}"
197 AC_SUBST(savestates)
198 AC_SUBST(savestatesdir)
199 AM_CONDITIONAL(ENABLE_SAVESTATES, [test "$enable_savestates" = "yes"])
200
201 AC_ARG_ENABLE(attributelog, [AC_HELP_STRING([--enable-attributelog],[Enables default smartd attribute log files])])
202
203 AC_ARG_WITH(attributelog,
204 [AC_HELP_STRING([--with-attributelog=PREFIX],[Prefix for default smartd attribute log files (implies --enable-attributelog) [LOCALSTATEDIR/lib/smartmontools/attrlog.]])],
205 [attributelog="$withval"; enable_attributelog="yes"],
206 [attributelog=; test "$enable_attributelog" = "yes" && attributelog='${localstatedir}/lib/${PACKAGE}/attrlog.'])
207 attributelogdir="${attributelog%/*}"
208 AC_SUBST(attributelog)
209 AC_SUBST(attributelogdir)
210 AM_CONDITIONAL(ENABLE_ATTRIBUTELOG, [test "$enable_attributelog" = "yes"])
211
212 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=''])
213 AC_SUBST(smartd_suffix)
214 AM_CONDITIONAL(SMARTD_SUFFIX, test $smartd_suffix)
215
216 AC_ARG_WITH(os-deps,
217 [AC_HELP_STRING([--with-os-deps='os_module.o ...'],[Specify OS dependent module(s) [guessed]])],
218 [ for x in $with_os_deps; do
219 case $x in
220 *.o) ;;
221 *) AC_MSG_ERROR([non-object file specified by --with-os-deps]) ;;
222 esac
223 done
224 ],[])
225
226 AC_ARG_WITH(selinux,[AC_HELP_STRING([--with-selinux],[Enables SELinux support])],
227 [
228 AC_CHECK_HEADERS([selinux/selinux.h], [], [echo "*** Error: Missing SELinux header files";exit 1])
229 AC_CHECK_LIB(selinux, matchpathcon, [with_selinux=yes], [echo "*** Error: Missing or incorrect SELinux library files"; exit 1],)
230 ],[])
231 AC_SUBST(with_selinux)
232 if test "$with_selinux" = "yes"; then
233 AC_DEFINE(WITH_SELINUX, [1], [Define to 1 if SELinux support is enabled])
234 fi
235
236 AC_ARG_WITH(libcap-ng,
237 [AC_HELP_STRING([--with-libcap-ng=[auto|yes|no]], [Add Libcap-ng support to smartd [auto]])],
238 [with_libcap_ng="$withval"],
239 [with_libcap_ng=auto])
240
241 use_libcap_ng=no
242 if test "$with_libcap_ng" != "no"; then
243 AC_CHECK_LIB(cap-ng, capng_clear,
244 [AC_DEFINE(HAVE_LIBCAP_NG, 1, [Define to 1 if you have the `cap-ng' library (-lcap-ng).])
245 CAPNG_LDADD="-lcap-ng"; use_libcap_ng=yes])
246
247 if test "$use_libcap_ng" = "yes"; then
248 AC_CHECK_HEADER(cap-ng.h, [], [AC_MSG_ERROR([libcap-ng libraries found but headers are missing])])
249 elif test "$with_libcap_ng" = "yes"; then
250 AC_MSG_ERROR([libcap-ng support was requested but the library was not found])
251 fi
252 fi
253
254 AC_MSG_CHECKING([whether to use libcap-ng])
255 AC_SUBST(CAPNG_LDADD)
256 AM_CONDITIONAL(ENABLE_CAPABILITIES, [test "$use_libcap_ng" = "yes"])
257 AC_MSG_RESULT([$use_libcap_ng])
258
259 if test "$prefix" = "NONE"; then
260 dnl no prefix and no mandir, so use ${prefix}/share/man as default
261 if test "$mandir" = '${prefix}/man'; then
262 AC_SUBST([mandir], ['${prefix}/share/man'])
263 fi
264 fi
265
266 AC_SUBST(releaseversion,['${PACKAGE}-${VERSION}'])
267 AC_SUBST(smartmontools_release_date)
268 AC_SUBST(smartmontools_release_time)
269
270 AC_MSG_CHECKING([for OS dependent modules and libraries])
271 dnl if OS not recognized, then use the os_generic modules
272 os_win64=no
273 case "${host}" in
274 *-*-linux*)
275 AC_SUBST([os_deps], ['os_linux.o cciss.o'])
276 if test "$with_selinux" = "yes"; then
277 AC_SUBST([os_libs], ['-lselinux'])
278 else
279 AC_SUBST([os_libs], [''])
280 fi;;
281 *-*-freebsd*|*-*-dragonfly*|*-*-kfreebsd*-gnu*)
282 AC_SUBST([os_deps], ['os_freebsd.o cciss.o'])
283 AC_SUBST([os_libs], ['-lcam'])
284 AC_CHECK_LIB(usb, libusb20_dev_get_device_desc)
285 ;;
286 sparc-*-solaris*)
287 AC_DEFINE_UNQUOTED(DEFAULT_MAILER, "mailx", [use mailx as default mailer])
288 AC_DEFINE_UNQUOTED(NEED_SOLARIS_ATA_CODE, "os_solaris_ata.s", [need assembly code os_solaris_ata.s])
289 AC_SUBST([os_deps], ['os_solaris.o os_solaris_ata.o'])
290 AC_SUBST([os_libs], ['']) ;;
291 *-pc-solaris*)
292 AC_DEFINE_UNQUOTED(DEFAULT_MAILER, "mailx", [use mailx as default mailer])
293 AC_SUBST([os_deps], ['os_solaris.o'])
294 AC_SUBST([os_libs], ['']) ;;
295 *-*-netbsd*)
296 AC_SUBST([os_deps], ['os_netbsd.o'])
297 AC_SUBST([os_libs], ['-lutil']) ;;
298 *-*-openbsd*)
299 AC_SUBST([os_deps], ['os_openbsd.o'])
300 AC_SUBST([os_libs], ['-lutil']) ;;
301 *-*-cygwin*)
302 AC_SUBST([os_deps], ['os_win32.o'])
303 AC_SUBST([os_libs], ['']) ;;
304 *-*-mingw*)
305 AC_SUBST([os_deps], ['os_win32.o'])
306 AC_SUBST([os_libs], [''])
307 test "$host_cpu" = "x86_64" && os_win64=yes ;;
308 *-*-darwin*)
309 AC_SUBST([os_deps], ['os_darwin.o'])
310 AC_SUBST([os_libs], ['-framework CoreFoundation -framework IOKit']) ;;
311 *-*-nto-qnx*)
312 AC_SUBST([os_deps], ['os_qnxnto.o'])
313 AC_SUBST([os_libs], ['']) ;;
314
315 *)
316 AC_SUBST([os_deps], ['os_generic.o'])
317 AC_SUBST([os_libs], ['']) ;;
318 esac
319
320 # Replace if '--with-os-deps' was specified
321 test -z "$with_os_deps" || os_deps="$with_os_deps"
322 AC_MSG_RESULT([$os_deps $os_libs])
323
324 # Define symbols for optional functions in OS specific module
325 case "${os_deps}" in
326 os_win32*)
327 AC_DEFINE(HAVE_ATA_IDENTIFY_IS_CACHED, 1, [Define to 1 if you have the `ata_identify_is_cached' function in os_*.c.]) ;;
328 esac
329 case "${os_deps}" in
330 os_win32*)
331 AC_DEFINE(HAVE_GET_OS_VERSION_STR, 1, [Define to 1 if you have the `get_os_version_str' function in os_*.c.]) ;;
332 esac
333
334 # Check if we need adapter to old interface (dev_legacy.cpp)
335 os_src=`echo "${os_deps}"|sed -n 's,^\([[^ .]]*\)\.o.*$,\1.cpp,p'`
336 AC_MSG_CHECKING([whether ${os_src} uses new interface])
337 if grep "smart_interface" "${srcdir}/${os_src}" >/dev/null 2>&1; then
338 os_new_interface=yes
339 else
340 os_new_interface=no
341 os_deps="${os_deps} dev_legacy.o"
342 AC_DEFINE(OLD_INTERFACE, 1, [Define to 1 if os_*.cpp still uses the old interface])
343 fi
344 AC_MSG_RESULT([$os_new_interface])
345
346 dnl Define platform-specific symbol.
347 AM_CONDITIONAL(OS_DARWIN, [echo $host_os | grep '^darwin' > /dev/null])
348 AM_CONDITIONAL(OS_SOLARIS, [echo $host_os | grep '^solaris' > /dev/null])
349 AM_CONDITIONAL(OS_WIN32_MINGW, [echo $host_os | grep '^mingw' > /dev/null])
350 AM_CONDITIONAL(OS_WIN64, [test "$os_win64" = "yes"])
351 AM_CONDITIONAL(OS_FREEBSD, [echo $host_os | grep '^freebsd' > /dev/null])
352
353 dnl Add -Wall and -W if using g++ and its not already specified.
354 if test "$GXX" = "yes"; then
355 if test -z "`echo "$CXXFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
356 CXXFLAGS="$CXXFLAGS -Wall"
357 fi
358 # In the next line, do NOT delete the 2 spaces inside double quotes.
359 if test -z "`echo "$CXXFLAGS " | grep "\-W " 2> /dev/null`" ; then
360 CXXFLAGS="$CXXFLAGS -W"
361 fi
362 case "${host}" in
363 *-*-mingw*)
364 # MinGW uses MSVCRT.DLL which uses printf format "%I64d" and not "%lld" for int64_t
365 CXXFLAGS="$CXXFLAGS -Wno-format";;
366 esac
367
368 # Disable strict aliasing rules by default (see ticket #23).
369 if test -z "`echo "$CXXFLAGS" | grep "\-f[[no-]]*strict-aliasing" 2> /dev/null`" ; then
370 AC_MSG_CHECKING([whether $CXX supports -fno-strict-aliasing])
371 ac_save_CXXFLAGS="$CXXFLAGS"
372 CXXFLAGS="-fno-strict-aliasing"
373 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
374 [gcc_have_fno_strict_aliasing=yes], [gcc_have_fno_strict_aliasing=no])
375 CXXFLAGS="$ac_save_CXXFLAGS"
376 if test "$gcc_have_fno_strict_aliasing" = "yes"; then
377 CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
378 fi
379 AC_MSG_RESULT([$gcc_have_fno_strict_aliasing])
380 fi
381
382 else
383 dnl We are NOT using gcc, so enable host-specific compiler flags
384 case "${host}" in
385 sparc*-*-solaris*)
386 dnl set CXXFLAGS for Solaris/SPARC C++ compiler
387 if test -z "`echo "$CXXFLAGS" | grep "\-xmemalign" 2> /dev/null`" ; then
388 dnl we have to tell the compilers about packed ATA structures
389 CXXFLAGS="-xmemalign=1i $CXXFLAGS"
390 fi
391 esac
392 case "${host}" in
393 *-*-solaris*)
394 if test -z "`echo "$CXXFLAGS" | grep "\-xO" 2> /dev/null`" ; then
395 dnl turn on optimization if user has not explicitly set its value
396 CXXFLAGS="-xO2 $CXXFLAGS"
397 fi
398 if test -z "`echo "$CXXFLAGS" | grep "\-erroff" 2> /dev/null`" ; then
399 dnl suppress trivial warnings
400 CXXFLAGS="-erroff=%none,wbadinitl,wbadasgl,badargtypel2w,badargtype2w $CXXFLAGS"
401 fi
402 esac
403 fi
404
405 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_BUILD_HOST, "${host}", [smartmontools Build Host])
406
407 AC_SUBST(CXXFLAGS)
408
409 AC_OUTPUT(Makefile examplescripts/Makefile)
410 AC_PROG_MAKE_SET
411
412 # Print note that the docdir default value has changed
413 # TODO: Remove this after next release
414 if test "$docdir_is_default" = "yes"; then
415 old_def_docdir='${prefix}/share/doc/${PACKAGE}-${VERSION}'
416 old_def_docdir_eval="`eval eval eval echo $old_def_docdir`"
417 docdir_eval="`eval eval eval echo $docdir`"
418 AC_MSG_NOTICE([********** PLEASE NOTE **********])
419 AC_MSG_NOTICE(['docdir' default has changed])
420 AC_MSG_NOTICE([from: $old_def_docdir_eval])
421 AC_MSG_NOTICE([to: $docdir_eval])
422 AC_MSG_NOTICE([*********************************])
423 fi