]> git.proxmox.com Git - mirror_smartmontools-debian.git/blame - configure.ac
Enhance dh_clean to clean up better
[mirror_smartmontools-debian.git] / configure.ac
CommitLineData
832b75ed 1#
293b5ab8 2# $Id: configure.ac 4109 2015-06-04 16:30:15Z chrfranke $
832b75ed
GG
3#
4dnl Process this file with autoconf to produce a configure script.
5AC_PREREQ(2.50)
d2e702cf 6AC_INIT(smartmontools, 6.4, smartmontools-support@lists.sourceforge.net)
4d59bff9 7AC_CONFIG_SRCDIR(smartctl.cpp)
832b75ed 8
293b5ab8
JD
9smartmontools_cvs_tag=`echo '$Id: configure.ac 4109 2015-06-04 16:30:15Z chrfranke $'`
10smartmontools_release_date=2015-06-04
11smartmontools_release_time="16:29:41 UTC"
832b75ed
GG
12
13AC_DEFINE_UNQUOTED(SMARTMONTOOLS_CONFIGURE_ARGS, "$ac_configure_args", [smartmontools Configure Arguments])
832b75ed
GG
14AC_DEFINE_UNQUOTED(SMARTMONTOOLS_RELEASE_DATE, "$smartmontools_release_date", [smartmontools Release Date])
15AC_DEFINE_UNQUOTED(SMARTMONTOOLS_RELEASE_TIME, "$smartmontools_release_time", [smartmontools Release Time])
16AC_DEFINE_UNQUOTED(CONFIG_H_CVSID, "$smartmontools_cvs_tag", [smartmontools CVS Tag])
17AC_DEFINE_UNQUOTED(PACKAGE_HOMEPAGE, "http://smartmontools.sourceforge.net/", [smartmontools Home Page])
18
d2e702cf 19AC_CONFIG_HEADER([config.h])
832b75ed 20
d008864d 21AM_INIT_AUTOMAKE([foreign])
832b75ed
GG
22
23AM_MAINTAINER_MODE
24
d2e702cf 25AC_LANG([C++])
832b75ed 26dnl Checks for programs.
4d59bff9 27AC_PROG_CXX
832b75ed
GG
28AM_PROG_AS
29AC_PROG_INSTALL
d008864d
GI
30
31m4_pattern_forbid([^PKG_PROG_])
32if test "$cross_compiling" = "no"; then
33 m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG],
34 [AC_MSG_WARN([m4/pkg.m4 missing, systemd detection disabled])])
35fi
832b75ed 36
cfbba5b9
GI
37AC_ARG_VAR(WINDMC, [Windows message compiler command])
38AC_ARG_VAR(WINDRES, [Windows resource compiler command])
39AC_ARG_VAR(MAKENSIS, [NSIS compiler command])
40
832b75ed 41AC_CANONICAL_HOST
832b75ed 42case "${host}" in
cfbba5b9 43 *-*-mingw*)
ee38a438
GI
44 AC_CHECK_TOOL(WINDMC, [windmc])
45 AC_CHECK_TOOL(WINDRES, [windres])
cfbba5b9 46
d2e702cf 47 AC_MSG_CHECKING([for makensis])
cfbba5b9
GI
48 if test -z "$MAKENSIS"; then
49 if test -n "$PROGRAMFILES" && "$PROGRAMFILES/NSIS/makensis" -VERSION >/dev/null 2>&1; then
50 MAKENSIS="$PROGRAMFILES/NSIS/makensis"
51 elif makensis -VERSION >/dev/null 2>&1; then
52 MAKENSIS=makensis
53 fi
54 fi
55 AC_MSG_RESULT([${MAKENSIS:-no}])
cfbba5b9 56 ;;
832b75ed
GG
57esac
58
2127e193
GI
59# Check for SVN.
60AC_MSG_CHECKING([whether this is a build from SVN])
61is_svn_build=no
e165493d 62svn_deps=
3d17a85c
GI
63if test -f "$srcdir/.svn/wc.db"; then
64 # SVN 1.7, 1.8 working copy
65 svn_deps='${srcdir}/.svn/wc.db'
66elif test -f "${srcdir}/.svn/entries"; then
67 # SVN <= 1.6 working copy (SVN 1.7 has empty entries file)
68 svn_deps='${srcdir}/.svn/entries'
69fi
70if test -n "$svn_deps"; then
2127e193
GI
71 is_svn_build=unknown
72 if (cd "$srcdir" && svn --version && svnversion && svn info) >/dev/null 2>&1; then
73 is_svn_build=yes
74 fi
75fi
e165493d 76AC_SUBST([svn_deps])
2127e193
GI
77AM_CONDITIONAL(IS_SVN_BUILD, [test "$is_svn_build" = "yes"])
78AC_MSG_RESULT([$is_svn_build])
79
e165493d
GI
80# Note: On Linux, clock_gettime() requires -lrt which implies -lpthreads
81# Check ommitted for now, gettimeofday() provides reasonable precision
82# AC_SEARCH_LIBS(clock_gettime, rt)
83
832b75ed
GG
84dnl Checks for header files.
85AC_CHECK_HEADERS([locale.h])
832b75ed
GG
86AC_CHECK_HEADERS([dev/ata/atavar.h])
87AC_CHECK_HEADERS([netdb.h])
88dnl we need [u]int64_t and friends.
89AC_CHECK_HEADERS([inttypes.h]) dnl C99, UNIX98, solaris 2.6+
90AC_CHECK_HEADERS([stdint.h]) dnl C99
91AC_CHECK_HEADERS([sys/inttypes.h]) dnl pre-UNIX98
92AC_CHECK_HEADERS([sys/int_types.h]) dnl pre-UNIX98, solaris 2.6+
93dnl Check for FreeBSD twe include files...currently missing on 5.2, but should be there
94AC_CHECK_HEADERS([sys/tweio.h])
95AC_CHECK_HEADERS([sys/twereg.h])
96dnl Check for FreeBSD twa include files...
97AC_CHECK_HEADERS([sys/tw_osl_ioctl.h])
1953ff6d 98dnl This header file is needed for cciss_ioctl.h at least on SuSE LINUX
ba59cff1 99AC_CHECK_HEADERS([linux/compiler.h])
d008864d
GI
100dnl Check for the FreeBSD CCISS system header and use internal one if not found
101AC_CHECK_HEADERS([dev/ciss/cissio.h],
102 [AC_DEFINE([CISS_LOCATION],[<dev/ciss/cissio.h>],[freebsd ciss header location])],
103 [AC_DEFINE([CISS_LOCATION],["cissio_freebsd.h"],[freebsd ciss header location])]
104 )
1953ff6d
GG
105dnl Check for Linux CCISS include file
106AC_CHECK_HEADERS([linux/cciss_ioctl.h], [], [], [AC_INCLUDES_DEFAULT
107#ifdef HAVE_LINUX_COMPILER_H
108# include <linux/compiler.h>
109#endif
110])
cfbba5b9
GI
111dnl Check for Windows DDK and WMI header files
112AC_CHECK_HEADERS([ntdddisk.h ddk/ntdddisk.h], [], [], [AC_INCLUDES_DEFAULT
113#include <windows.h>
114])
115AC_CHECK_HEADERS([wbemcli.h])
832b75ed
GG
116
117dnl Checks for typedefs, structures, and compiler characteristics.
118AC_CHECK_TYPES([int64_t, uint64_t])
119
120dnl Checks for library functions.
e9583e0c
GI
121AC_CHECK_FUNCS([getopt_long], [need_getopt_long=no], [need_getopt_long=yes])
122AM_CONDITIONAL(NEED_GETOPT_LONG, [test "$need_getopt_long" = "yes"])
123AC_CHECK_FUNCS([regcomp], [need_regex=no], [need_regex=yes])
124AM_CONDITIONAL(NEED_REGEX, [test "$need_regex" = "yes"])
2127e193 125
832b75ed
GG
126AC_CHECK_FUNCS([sigset])
127AC_CHECK_FUNCS([strtoull])
128AC_CHECK_FUNCS([uname])
e165493d 129AC_CHECK_FUNCS([clock_gettime ftime gettimeofday])
832b75ed 130
e9583e0c
GI
131# Check byte ordering (defines WORDS_BIGENDIAN)
132AC_C_BIGENDIAN
133
832b75ed 134# check for __attribute__((packed))
d008864d
GI
135# (sizeof() check is required to avoid false positives if other
136# __attribute__((x)) are supported)
7f0798ef 137AC_MSG_CHECKING([whether $CXX supports __attribute__((packed))])
d008864d
GI
138AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[
139 struct s { char a; short b; } __attribute__((packed));
140 typedef char t[sizeof(struct s) == 3 ? 1 : -1];]])],
141 [gcc_have_attr_packed=yes], [gcc_have_attr_packed=no])
832b75ed
GG
142AC_SUBST(gcc_have_attr_packed)
143if test "$gcc_have_attr_packed" = "yes"; then
cfbba5b9 144 AC_DEFINE(HAVE_ATTR_PACKED, 1, [Define to 1 if C++ compiler supports __attribute__((packed))])
832b75ed
GG
145fi
146AC_MSG_RESULT([$gcc_have_attr_packed])
147
148AC_SUBST(CPPFLAGS)
149AC_SUBST(LDFLAGS)
150AC_SUBST(ASFLAGS)
151
a7e8ffec
GI
152AC_ARG_WITH(systemdsystemunitdir,
153 [AS_HELP_STRING([--with-systemdsystemunitdir@<:@=DIR|auto|yes|no@:>@], [Location of systemd service files [auto]])],
293b5ab8 154 [], [with_systemdsystemunitdir=auto])
a7e8ffec
GI
155
156systemdsystemunitdir=
157case "$with_systemdsystemunitdir" in
158 auto|yes)
d008864d
GI
159 if test -n "$PKG_CONFIG"; then
160 AC_MSG_CHECKING([for systemdsystemunitdir])
d2e702cf 161 systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd 2>/dev/null`
d008864d
GI
162 AC_MSG_RESULT([${systemdsystemunitdir:-no}])
163 fi
a7e8ffec
GI
164 case "$with_systemdsystemunitdir:$sysconfdir:$systemdsystemunitdir" in
165 yes:*:) AC_MSG_ERROR([Location of systemd service files not found]) ;;
166 yes:*:*|auto:*:|auto:/etc:*) ;;
167 *) systemdsystemunitdir='${prefix}'$systemdsystemunitdir ;;
168 esac ;;
169 no) ;;
170 *) systemdsystemunitdir="$with_systemdsystemunitdir" ;;
171esac
172AC_SUBST(systemdsystemunitdir)
173AM_CONDITIONAL(INSTALL_SYSTEMDUNIT, [test -n "$systemdsystemunitdir"])
174
293b5ab8
JD
175AC_ARG_WITH(systemdenvfile,
176 [AS_HELP_STRING([--with-systemdenvfile@<:@=FILE|auto|yes|no@:>@], [Path of systemd EnvironmentFile [auto]])],
177 [], [with_systemdenvfile=auto])
178
179systemdenvfile=
180case "$with_systemdenvfile:$cross_compiling:$systemdsystemunitdir" in
181 auto:no:?*|yes:*:?*)
182 AC_MSG_CHECKING([for path of systemd EnvironmentFile])
183 for dir in sysconfig default; do
184 if test -d /etc/$dir; then
185 systemdenvfile='${sysconfdir}'/$dir/smartmontools
186 break
187 fi
188 done
189 AC_MSG_RESULT([${systemdenvfile:-no}])
190 case "$with_systemdenvfile:$systemdenvfile" in
191 yes:) AC_MSG_ERROR([Path of systemd EnvironmentFile not found]) ;;
192 esac ;;
193 auto:*|no:*) ;;
194 *:*:) AC_MSG_ERROR([Location of systemd service files not found]) ;;
195 *) systemdenvfile="$with_systemdenvfile"
196esac
197AC_SUBST(systemdenvfile)
198
a23d5117 199AC_ARG_WITH(initscriptdir,
d2e702cf 200 [AS_HELP_STRING([--with-initscriptdir@<:@=DIR|auto|yes|no@:>@], [Location of init scripts [auto]])],
a7e8ffec
GI
201 [], [with_initscriptdir=auto])
202
d008864d
GI
203initddir=
204case "$with_initscriptdir:$cross_compiling:$systemdsystemunitdir" in
205 auto:no:|yes:*)
206 AC_MSG_CHECKING([for init (rc) directory])
207 for dir in rc.d/init.d init.d rc.d; do
208 if test -d /etc/$dir; then
209 initddir='${sysconfdir}'/$dir
210 break
211 fi
212 done
213 AC_MSG_RESULT([${initddir:-no}])
214 case "$with_initscriptdir:$initddir" in
215 yes:) AC_MSG_ERROR([Location of init scripts not found]) ;;
216 esac ;;
217 auto:*|no:*) ;;
a7e8ffec
GI
218 *) initddir="$with_initscriptdir" ;;
219esac
832b75ed 220AC_SUBST(initddir)
a7e8ffec
GI
221AM_CONDITIONAL(INSTALL_INITSCRIPT, [test -n "$initddir"])
222
223# use different init script templates for different OS
224case "${host}" in
225 *-*-freebsd*)
226 initdfile="smartd.freebsd.initd"
227 ;;
228 *)
229 initdfile="smartd.initd"
230 ;;
231esac
232AC_SUBST(initdfile)
832b75ed 233
293b5ab8 234autoconf_25x=${docdir:-yes}
a23d5117 235AC_ARG_WITH(docdir,
293b5ab8 236 [AS_HELP_STRING([--with-docdir=DIR], [Deprecated (use --docdir=DIR instead)])],
a23d5117
GI
237 [docdir="$withval"],
238 [ if test -z "$docdir"; then
239 # autoconf 2.5x without '--docdir' support
240 docdir='${datadir}/doc/${PACKAGE}'
a23d5117
GI
241 fi
242 ])
832b75ed
GG
243AC_SUBST(docdir)
244
cfbba5b9 245AC_ARG_WITH(exampledir,
d2e702cf 246 [AS_HELP_STRING([--with-exampledir=DIR], [Location of example scripts [DOCDIR/examplescripts]])],
cfbba5b9
GI
247 [exampledir="$withval"], [exampledir='${docdir}/examplescripts'])
248AC_SUBST(exampledir)
249
293b5ab8 250used_deprecated_option=no
cfbba5b9 251AC_ARG_ENABLE(drivedb,
293b5ab8
JD
252 [AS_HELP_STRING([--disable-drivedb], [Deprecated (use --without-drivedbdir instead)])],
253 [used_deprecated_option=yes], [enable_drivedb=yes])
2127e193 254
293b5ab8 255drivedbdir=
2127e193 256AC_ARG_WITH(drivedbdir,
293b5ab8
JD
257 [AS_HELP_STRING([--with-drivedbdir=@<:@DIR|no@:>@], [Location of drive database file [DATADIR/smartmontools]])],
258 [test "$withval" != "no" && drivedbdir="$withval"],
259 [test "$enable_drivedb" != "no" && drivedbdir='${datadir}/${PACKAGE}'])
2127e193 260AC_SUBST(drivedbdir)
293b5ab8 261AM_CONDITIONAL(ENABLE_DRIVEDB, [test -n "$drivedbdir"])
2127e193 262
d2e702cf
GI
263AC_ARG_WITH(smartdscriptdir,
264 [AS_HELP_STRING([--with-smartdscriptdir=DIR], [Location of smartd_warning.sh script [SYSCONFDIR]])],
265 [smartdscriptdir="$withval"], [smartdscriptdir='${sysconfdir}'])
266AC_SUBST(smartdscriptdir)
267
268AC_ARG_WITH(smartdplugindir,
269 [AS_HELP_STRING([--with-smartdplugindir=@<:@DIR|no@:>@],
270 [Location of smartd_warning.sh plugin scripts [SMARTDSCRIPTDIR/smartd_warning.d]])],
271 [smartdplugindir=; test "$withval" != "no" && smartdplugindir="$withval"],
272 [smartdplugindir='${smartdscriptdir}/smartd_warning.d'])
273AC_SUBST(smartdplugindir)
274
293b5ab8
JD
275AC_ARG_ENABLE(savestates,
276 [AS_HELP_STRING([--enable-savestates], [Deprecated (use --with-savestates@<:@=yes@:>@ instead)])],
277 [used_deprecated_option=yes], [enable_savestates=no])
2127e193 278
293b5ab8 279savestates='${localstatedir}/lib/${PACKAGE}/smartd.'
2127e193 280AC_ARG_WITH(savestates,
293b5ab8
JD
281 [AS_HELP_STRING([--with-savestates@<:@=PREFIX|yes|no@:>@],
282 [Enable default smartd state files [no] (yes=LOCALSTATEDIR/lib/smartmontools/smartd.)])],
283 [case "$withval" in yes) ;; no) savestates= ;; *) savestates="$withval" ;; esac],
284 [test "$enable_savestates" != "yes" && savestates=])
2127e193
GI
285savestatesdir="${savestates%/*}"
286AC_SUBST(savestates)
287AC_SUBST(savestatesdir)
293b5ab8 288AM_CONDITIONAL(ENABLE_SAVESTATES, [test -n "$savestates"])
2127e193 289
293b5ab8
JD
290AC_ARG_ENABLE(attributelog,
291 [AS_HELP_STRING([--enable-attributelog], [Deprecated (use --with-attributelog@<:@=yes@:>@ instead)])],
292 [used_deprecated_option=yes], [enable_attributelog=no])
2127e193 293
293b5ab8 294attributelog='${localstatedir}/lib/${PACKAGE}/attrlog.'
2127e193 295AC_ARG_WITH(attributelog,
293b5ab8
JD
296 [AS_HELP_STRING([--with-attributelog@<:@=PREFIX|yes|no@:>@],
297 [Enable default smartd attribute log files [no] (yes=LOCALSTATEDIR/lib/smartmontools/attrlog.)])],
298 [case "$withval" in yes) ;; no) attributelog= ;; *) attributelog="$withval" ;; esac],
299 [test "$enable_attributelog" != "yes" && attributelog=])
2127e193
GI
300attributelogdir="${attributelog%/*}"
301AC_SUBST(attributelog)
302AC_SUBST(attributelogdir)
293b5ab8 303AM_CONDITIONAL(ENABLE_ATTRIBUTELOG, [test -n "$attributelog"])
2127e193 304
cfbba5b9 305AC_ARG_ENABLE(sample,
d2e702cf 306 [AS_HELP_STRING([--enable-sample], [Enables appending .sample to the installed smartd rc script and configuration file])],
cfbba5b9
GI
307 [smartd_suffix=; test "$enableval" = "yes" && smartd_suffix=".sample"],
308 [smartd_suffix=;])
832b75ed 309AC_SUBST(smartd_suffix)
832b75ed 310
2127e193 311AC_ARG_WITH(os-deps,
d2e702cf 312 [AS_HELP_STRING([--with-os-deps='os_module.o ...'], [Specify OS dependent module(s) [guessed]])],
2127e193
GI
313 [ for x in $with_os_deps; do
314 case $x in
315 *.o) ;;
316 *) AC_MSG_ERROR([non-object file specified by --with-os-deps]) ;;
317 esac
318 done
319 ],[])
320
cfbba5b9 321AC_ARG_WITH(selinux,
d2e702cf 322 [AS_HELP_STRING([--with-selinux@<:@=yes|no@:>@], [Enables SELinux support [no]])],
cfbba5b9
GI
323 [ if test "$withval" = "yes"; then
324 AC_CHECK_HEADERS([selinux/selinux.h], [], [AC_MSG_ERROR([Missing SELinux header files])])
325 AC_CHECK_LIB(selinux, matchpathcon, [], [AC_MSG_ERROR([Missing or incorrect SELinux library files])])
326 fi
327 ],[])
2127e193
GI
328AC_SUBST(with_selinux)
329if test "$with_selinux" = "yes"; then
cfbba5b9 330 AC_DEFINE(WITH_SELINUX, 1, [Define to 1 if SELinux support is enabled])
2127e193
GI
331fi
332
a23d5117 333AC_ARG_WITH(libcap-ng,
d2e702cf 334 [AS_HELP_STRING([--with-libcap-ng@<:@=auto|yes|no@:>@], [Add Libcap-ng support to smartd [auto]])],
a7e8ffec 335 [], [with_libcap_ng=auto])
a23d5117
GI
336
337use_libcap_ng=no
338if test "$with_libcap_ng" != "no"; then
339 AC_CHECK_LIB(cap-ng, capng_clear,
293b5ab8 340 [AC_DEFINE(HAVE_LIBCAP_NG, 1, [Define to 1 if you have the `cap-ng' library (-lcap-ng).]) dnl `vim syntax
a23d5117
GI
341 CAPNG_LDADD="-lcap-ng"; use_libcap_ng=yes])
342
343 if test "$use_libcap_ng" = "yes"; then
344 AC_CHECK_HEADER(cap-ng.h, [], [AC_MSG_ERROR([libcap-ng libraries found but headers are missing])])
345 elif test "$with_libcap_ng" = "yes"; then
346 AC_MSG_ERROR([libcap-ng support was requested but the library was not found])
347 fi
348fi
349
350AC_MSG_CHECKING([whether to use libcap-ng])
351AC_SUBST(CAPNG_LDADD)
a23d5117
GI
352AC_MSG_RESULT([$use_libcap_ng])
353
d2e702cf
GI
354# Assume broken snprintf only on Windows with MSVCRT (MinGW without ANSI stdio support)
355libc_have_working_snprintf=yes
356
357case "$host" in
358 *-*-mingw*)
359 case " $CPPFLAGS $CXXFLAGS" in
360 *\ -[[DU]]__USE_MINGW_ANSI_STDIO*)
361 ;;
362 *)
363 # Older MinGW do not properly define PRI?64 if __USE_MINGW_ANSI_STDIO is set
364 # Newer MinGW set __USE_MINGW_ANSI_STDIO in first C++ include which may be too late
365 AC_MSG_CHECKING([whether __USE_MINGW_ANSI_STDIO is defined by C++ includes])
366 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
367 #undef __USE_MINGW_ANSI_STDIO
368 #include <iostream>
369 #ifndef __USE_MINGW_ANSI_STDIO
370 #error false
371 #endif]])],
372 [CXXFLAGS="-D__USE_MINGW_ANSI_STDIO $CXXFLAGS"],
373 [libc_have_working_snprintf=no])
374 AC_MSG_RESULT([$libc_have_working_snprintf])
375 ;;
376 esac ;;
377esac
378
379AC_ARG_WITH(working-snprintf,
380 [AS_HELP_STRING([--with-working-snprintf@<:@=yes|no@:>@],
381 [Function snprintf() handles output truncation as specified by C99 [MinGW:guessed,others:yes]])],
382 [libc_have_working_snprintf=$withval])
383
384if test "$libc_have_working_snprintf" = "yes"; then
293b5ab8 385 AC_DEFINE(HAVE_WORKING_SNPRINTF, 1, [Define to 1 if the `snprintf' function is sane.]) dnl `vim syntax
d2e702cf
GI
386fi
387
832b75ed 388if test "$prefix" = "NONE"; then
293b5ab8 389 # Fix mandir default set by autoconf 2.5x
832b75ed
GG
390 if test "$mandir" = '${prefix}/man'; then
391 AC_SUBST([mandir], ['${prefix}/share/man'])
392 fi
393fi
394
395AC_SUBST(releaseversion,['${PACKAGE}-${VERSION}'])
396AC_SUBST(smartmontools_release_date)
397AC_SUBST(smartmontools_release_time)
398
cfbba5b9
GI
399# Set platform-specific modules and symbols
400os_libs=
401os_dltools='curl wget lynx'
ee38a438
GI
402os_mailer=mail
403os_hostname="'hostname'"
404os_dnsdomainname=
405os_nisdomainname="'domainname'"
cfbba5b9
GI
406os_darwin=no
407os_solaris=no
408os_win32=no
409os_win32_mingw=no
7f0798ef 410os_win64=no
d008864d 411os_man_filter=
832b75ed 412case "${host}" in
cfbba5b9 413 *-*-linux*)
ee38a438
GI
414 os_deps='os_linux.o cciss.o dev_areca.o'
415 os_dnsdomainname="'dnsdomainname' 'hostname -d'"
416 os_nisdomainname="'nisdomainname' 'hostname -y' 'domainname'"
d008864d 417 os_man_filter=Linux
cfbba5b9
GI
418 ;;
419 *-*-freebsd*|*-*-dragonfly*|*-*-kfreebsd*-gnu*)
ee38a438 420 os_deps='os_freebsd.o cciss.o dev_areca.o'
cfbba5b9
GI
421 os_libs='-lcam'
422 os_dltools='curl wget lynx fetch'
423 AC_CHECK_LIB(usb, libusb20_dev_get_device_desc)
d008864d 424 os_man_filter=FreeBSD
cfbba5b9
GI
425 ;;
426 sparc-*-solaris*)
427 os_deps='os_solaris.o os_solaris_ata.o'
428 os_mailer='mailx'
429 os_solaris=yes
d008864d 430 os_man_filter=Solaris
cfbba5b9
GI
431 ;;
432 *-pc-solaris*)
433 os_deps='os_solaris.o'
434 os_mailer='mailx'
435 os_solaris=yes
d008864d 436 os_man_filter=Solaris
cfbba5b9
GI
437 ;;
438 *-*-netbsd*)
439 os_deps='os_netbsd.o'
440 os_libs='-lutil'
d008864d 441 os_man_filter=NetBSD
cfbba5b9
GI
442 ;;
443 *-*-openbsd*)
444 os_deps='os_openbsd.o'
445 os_libs='-lutil'
446 os_dltools='curl wget lynx ftp'
d008864d 447 os_man_filter=OpenBSD
cfbba5b9
GI
448 ;;
449 *-*-cygwin*)
ee38a438 450 os_deps='os_win32.o dev_areca.o'
d2e702cf 451 os_mailer='email'
ee38a438
GI
452 os_hostname="'hostname' 'echo "'"${HOSTNAME?unset}"'"'"
453 os_dnsdomainname="'dnsdomainname' 'hostname -d' 'echo "'"${USERDNSDOMAIN?unset}"'"'"
454 os_nisdomainname=
cfbba5b9 455 os_win32=yes
d008864d 456 os_man_filter=Cygwin
cfbba5b9
GI
457 ;;
458 x86_64-*-mingw*)
ee38a438 459 os_deps='os_win32.o dev_areca.o'
cfbba5b9
GI
460 os_win32=yes
461 os_win32_mingw=yes
462 os_win64=yes
d008864d 463 os_man_filter=Windows
cfbba5b9
GI
464 ;;
465 *-*-mingw*)
ee38a438 466 os_deps='os_win32.o dev_areca.o'
cfbba5b9
GI
467 os_win32=yes
468 os_win32_mingw=yes
d008864d 469 os_man_filter=Windows
cfbba5b9
GI
470 ;;
471 *-*-darwin*)
472 os_deps='os_darwin.o'
473 os_libs='-framework CoreFoundation -framework IOKit'
474 os_darwin=yes
d008864d 475 os_man_filter=Darwin
cfbba5b9
GI
476 ;;
477 *-*-nto-qnx*)
478 os_deps='os_qnxnto.o'
479 ;;
480 *)
481 os_deps='os_generic.o'
482 ;;
832b75ed
GG
483esac
484
2127e193
GI
485# Replace if '--with-os-deps' was specified
486test -z "$with_os_deps" || os_deps="$with_os_deps"
832b75ed 487
2127e193
GI
488# Check if we need adapter to old interface (dev_legacy.cpp)
489os_src=`echo "${os_deps}"|sed -n 's,^\([[^ .]]*\)\.o.*$,\1.cpp,p'`
490AC_MSG_CHECKING([whether ${os_src} uses new interface])
491if grep "smart_interface" "${srcdir}/${os_src}" >/dev/null 2>&1; then
492 os_new_interface=yes
493else
494 os_new_interface=no
495 os_deps="${os_deps} dev_legacy.o"
496 AC_DEFINE(OLD_INTERFACE, 1, [Define to 1 if os_*.cpp still uses the old interface])
497fi
498AC_MSG_RESULT([$os_new_interface])
499
cfbba5b9
GI
500AC_SUBST([os_deps])
501AC_SUBST([os_libs])
502AC_SUBST([os_dltools])
ee38a438
GI
503AC_SUBST([os_mailer])
504AC_SUBST([os_hostname])
505AC_SUBST([os_dnsdomainname])
506AC_SUBST([os_nisdomainname])
d008864d 507AC_SUBST([os_man_filter])
cfbba5b9
GI
508
509# Create drivedb.h update branch name from version: 5.41[.X] -> RELEASE_5_41_DRIVEDB
510DRIVEDB_BRANCH=`echo $VERSION | sed 's,^\([[0-9]]*\.[[0-9]]*\)\..*$,\1,' \
511 | sed -n 's,^\([[0-9]][[0-9]]*\)\.\([[0-9]][[0-9]]*\)$,RELEASE_\1_\2_DRIVEDB,p'`
512if test -z "$DRIVEDB_BRANCH"; then
513 AC_MSG_ERROR([Unable to create DRIVEDB_BRANCH from VERSION=$VERSION])
514fi
515AC_SUBST([DRIVEDB_BRANCH])
516
517# Enable platform-specific makefile sections
518AM_CONDITIONAL(OS_DARWIN, [test "$os_darwin" = "yes"])
519AM_CONDITIONAL(OS_SOLARIS, [test "$os_solaris" = "yes"])
520AM_CONDITIONAL(OS_WIN32, [test "$os_win32" = "yes"])
521AM_CONDITIONAL(OS_WIN32_MINGW, [test "$os_win32_mingw" = "yes"])
522AM_CONDITIONAL(OS_WIN32_NSIS, [test -n "$MAKENSIS"])
7f0798ef 523AM_CONDITIONAL(OS_WIN64, [test "$os_win64" = "yes"])
832b75ed 524
bed94269
GI
525dnl Add -Wall and -W if using g++ and its not already specified.
526if test "$GXX" = "yes"; then
4d59bff9
GG
527 if test -z "`echo "$CXXFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
528 CXXFLAGS="$CXXFLAGS -Wall"
832b75ed
GG
529 fi
530# In the next line, do NOT delete the 2 spaces inside double quotes.
4d59bff9
GG
531 if test -z "`echo "$CXXFLAGS " | grep "\-W " 2> /dev/null`" ; then
532 CXXFLAGS="$CXXFLAGS -W"
832b75ed 533 fi
bed94269 534
832b75ed
GG
535else
536 dnl We are NOT using gcc, so enable host-specific compiler flags
537 case "${host}" in
34ad0c5f
GG
538 sparc*-*-solaris*)
539 dnl set CXXFLAGS for Solaris/SPARC C++ compiler
4d59bff9 540 if test -z "`echo "$CXXFLAGS" | grep "\-xmemalign" 2> /dev/null`" ; then
832b75ed 541 dnl we have to tell the compilers about packed ATA structures
4d59bff9 542 CXXFLAGS="-xmemalign=1i $CXXFLAGS"
832b75ed 543 fi
34ad0c5f
GG
544 esac
545 case "${host}" in
546 *-*-solaris*)
4d59bff9 547 if test -z "`echo "$CXXFLAGS" | grep "\-xO" 2> /dev/null`" ; then
832b75ed 548 dnl turn on optimization if user has not explicitly set its value
4d59bff9 549 CXXFLAGS="-xO2 $CXXFLAGS"
832b75ed 550 fi
4d59bff9 551 if test -z "`echo "$CXXFLAGS" | grep "\-erroff" 2> /dev/null`" ; then
2127e193
GI
552 dnl suppress trivial warnings
553 CXXFLAGS="-erroff=%none,wbadinitl,wbadasgl,badargtypel2w,badargtype2w $CXXFLAGS"
4d59bff9 554 fi
832b75ed
GG
555 esac
556fi
557
558AC_DEFINE_UNQUOTED(SMARTMONTOOLS_BUILD_HOST, "${host}", [smartmontools Build Host])
559
4d59bff9 560AC_SUBST(CXXFLAGS)
832b75ed 561
cfbba5b9
GI
562AC_CONFIG_FILES(Makefile)
563AC_OUTPUT
832b75ed 564AC_PROG_MAKE_SET
a23d5117 565
e9583e0c
GI
566echo "-----------------------------------------------------------------------------" >&AS_MESSAGE_FD
567echo "${PACKAGE}-${VERSION} configuration:" >&AS_MESSAGE_FD
568echo "host operating system: $host" >&AS_MESSAGE_FD
569echo "C++ compiler: $CXX" >&AS_MESSAGE_FD
cfbba5b9 570echo "C compiler: $CC" >&AS_MESSAGE_FD
e9583e0c
GI
571echo "preprocessor flags: $CPPFLAGS" >&AS_MESSAGE_FD
572echo "C++ compiler flags: $CXXFLAGS" >&AS_MESSAGE_FD
cfbba5b9 573echo "C compiler flags: $CFLAGS" >&AS_MESSAGE_FD
e9583e0c 574echo "linker flags: $LDFLAGS" >&AS_MESSAGE_FD
cfbba5b9 575echo "OS specific modules: $os_deps $os_libs $LIBS" >&AS_MESSAGE_FD
e9583e0c
GI
576
577case "$host_os" in
578 mingw*)
cfbba5b9
GI
579 echo "resource compiler: $WINDRES" >&AS_MESSAGE_FD
580 echo "message compiler: $WINDMC" >&AS_MESSAGE_FD
581 echo "NSIS compiler: $MAKENSIS" >&AS_MESSAGE_FD
e9583e0c
GI
582 if test -n "$drivedbdir"; then
583 echo "drive database file: EXEDIR/drivedb.h" >&AS_MESSAGE_FD
cfbba5b9
GI
584 if test -n "$MAKENSIS"; then
585 echo "database update tool: EXEDIR/update-smart-drivedb.exe" >&AS_MESSAGE_FD
586 fi
e9583e0c
GI
587 else
588 echo "drive database file: [[disabled]]" >&AS_MESSAGE_FD
589 fi
590 if test -n "$savestates"; then
591 echo "smartd save files: `eval eval eval echo $savestates`MODEL-SERIAL.TYPE.state" >&AS_MESSAGE_FD
592 fi
593 if test -n "$attributelog"; then
594 echo "smartd attribute logs: `eval eval eval echo $attributelog`MODEL-SERIAL.TYPE.csv" >&AS_MESSAGE_FD
595 fi
596 ;;
597
598 *)
599 echo "binary install path: `eval eval eval echo $sbindir`" >&AS_MESSAGE_FD
600 echo "man page install path: `eval eval eval echo $mandir`" >&AS_MESSAGE_FD
601 echo "doc file install path: `eval eval eval echo $docdir`" >&AS_MESSAGE_FD
cfbba5b9 602 echo "examples install path: `eval eval eval echo $exampledir`" >&AS_MESSAGE_FD
e9583e0c
GI
603 if test -n "$drivedbdir"; then
604 echo "drive database file: `eval eval eval echo $drivedbdir`/drivedb.h" >&AS_MESSAGE_FD
605 echo "database update script: `eval eval eval echo $sbindir`/update-smart-drivedb" >&AS_MESSAGE_FD
cfbba5b9 606 echo "download tools: `eval eval eval echo $os_dltools`" >&AS_MESSAGE_FD
e9583e0c
GI
607 else
608 echo "drive database file: [[disabled]]" >&AS_MESSAGE_FD
e9583e0c
GI
609 fi
610 echo "local drive database: `eval eval eval echo $sysconfdir`/smart_drivedb.h" >&AS_MESSAGE_FD
611 echo "smartd config file: `eval eval eval echo $sysconfdir`/smartd.conf${smartd_suffix}" >&AS_MESSAGE_FD
d2e702cf
GI
612 echo "smartd warning script: `eval eval eval echo $smartdscriptdir`/smartd_warning.sh" >&AS_MESSAGE_FD
613 if test -n "$smartdplugindir"; then
614 echo "smartd plugin path: `eval eval eval echo $smartdplugindir`" >&AS_MESSAGE_FD
615 else
616 echo "smartd plugin path: [[disabled]]" >&AS_MESSAGE_FD
617 fi
a7e8ffec
GI
618 if test -n "$initddir"; then
619 echo "smartd initd script: `eval eval eval echo $initddir`/smartd${smartd_suffix}" >&AS_MESSAGE_FD
620 elif test -z "$systemdsystemunitdir"; then
621 echo "smartd initd script: [[disabled]]" >&AS_MESSAGE_FD
622 fi
623 if test -n "$systemdsystemunitdir"; then
624 echo "smartd systemd file: `eval eval eval echo $systemdsystemunitdir`/smartd.service" >&AS_MESSAGE_FD
d2e702cf
GI
625 if test -n "$systemdenvfile"; then
626 echo "smartd environ file: `eval eval eval echo $systemdenvfile`" >&AS_MESSAGE_FD
627 else
628 echo "smartd environ file: [[disabled]]" >&AS_MESSAGE_FD
629 fi
a7e8ffec 630 fi
e9583e0c
GI
631 if test -n "$savestates"; then
632 echo "smartd save files: `eval eval eval echo $savestates`MODEL-SERIAL.TYPE.state" >&AS_MESSAGE_FD
633 else
634 echo "smartd save files: [[disabled]]" >&AS_MESSAGE_FD
635 fi
636 if test -n "$attributelog"; then
637 echo "smartd attribute logs: `eval eval eval echo $attributelog`MODEL-SERIAL.TYPE.csv" >&AS_MESSAGE_FD
638 else
639 echo "smartd attribute logs: [[disabled]]" >&AS_MESSAGE_FD
640 fi
641 echo "libcap-ng support: $use_libcap_ng" >&AS_MESSAGE_FD
642 case "$host_os" in
643 linux*) echo "SELinux support: ${with_selinux-no}" >&AS_MESSAGE_FD ;;
644 esac
645 ;;
646esac
647echo "-----------------------------------------------------------------------------" >&AS_MESSAGE_FD
293b5ab8
JD
648
649if test "$autoconf_25x" = "yes"; then
650 echo "WARNING:" >&AS_MESSAGE_FD
651 echo "Support for old autoconf 2.5x versions will be removed in a future" >&AS_MESSAGE_FD
652 echo "release of smartmontools." >&AS_MESSAGE_FD
653elif test "${with_docdir+set}" = "set"; then
654 echo "WARNING:" >&AS_MESSAGE_FD
655 echo "Option --with-docdir is deprecated and will be removed in a future" >&AS_MESSAGE_FD
656 echo "release of smartmontools. Use --docdir instead." >&AS_MESSAGE_FD
657fi
658
659if test "$used_deprecated_option" = "yes"; then
660 echo "WARNING:" >&AS_MESSAGE_FD
661 echo "Options --disable-drivedb, --enable-savestates, --enable-attributelog are" >&AS_MESSAGE_FD
662 echo "deprecated and will be removed in a future release of smartmontools." >&AS_MESSAGE_FD
663 echo "Use --without-drivedb, --with-savestates, --with-attributelog instead." >&AS_MESSAGE_FD
664fi