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