2 # $Id: configure.ac 4883 2018-12-30 14:48:54Z chrfranke $
4 dnl Process this file with autoconf to produce a configure script.
6 AC_INIT([smartmontools], [7.0], [smartmontools-support@listi.jpberlin.de])
7 AM_INIT_AUTOMAKE([1.10 foreign])
9 # Version of drive database branch
10 smartmontools_drivedb_version=7.0
12 smartmontools_cvs_tag=`echo '$Id: configure.ac 4883 2018-12-30 14:48:54Z chrfranke $'`
13 smartmontools_release_date=2018-12-30
14 smartmontools_release_time="14:47:55 UTC"
16 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_CONFIGURE_ARGS, "$ac_configure_args", [smartmontools Configure Arguments])
17 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_RELEASE_DATE, "$smartmontools_release_date", [smartmontools Release Date])
18 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_RELEASE_TIME, "$smartmontools_release_time", [smartmontools Release Time])
19 AC_DEFINE_UNQUOTED(CONFIG_H_CVSID, "$smartmontools_cvs_tag", [smartmontools CVS Tag])
20 AC_DEFINE_UNQUOTED(PACKAGE_HOMEPAGE, "https://www.smartmontools.org/", [smartmontools Home Page])
22 AC_CONFIG_SRCDIR([smartctl.cpp])
23 AC_CONFIG_HEADER([config.h])
28 dnl Checks for programs.
33 m4_pattern_forbid([^PKG_PROG_])
34 if test "$cross_compiling" = "no"; then
35 m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG],
36 [AC_MSG_WARN([m4/pkg.m4 missing, systemd detection disabled])])
39 AC_ARG_VAR(WINDMC, [Windows message compiler command])
40 AC_ARG_VAR(WINDRES, [Windows resource compiler command])
41 AC_ARG_VAR(MAKENSIS, [NSIS compiler command])
46 AC_CHECK_TOOL(WINDMC, [windmc])
47 AC_CHECK_TOOL(WINDRES, [windres])
49 AC_MSG_CHECKING([for makensis])
50 if test -z "$MAKENSIS"; then
51 if test -n "$PROGRAMFILES" && "$PROGRAMFILES/NSIS/makensis" -VERSION >/dev/null 2>&1; then
52 MAKENSIS="$PROGRAMFILES/NSIS/makensis"
53 elif makensis -VERSION >/dev/null 2>&1; then
57 AC_MSG_RESULT([${MAKENSIS:-no}])
62 AC_MSG_CHECKING([whether this is a build from SVN])
65 if test -f "$srcdir/.svn/wc.db"; then
66 # SVN 1.7, 1.8 working copy
67 svn_deps='${srcdir}/.svn/wc.db'
68 elif test -f "${srcdir}/.svn/entries"; then
69 # SVN <= 1.6 working copy (SVN 1.7 has empty entries file)
70 svn_deps='${srcdir}/.svn/entries'
72 if test -n "$svn_deps"; then
74 if (cd "$srcdir" && svn --version && svnversion && svn info) >/dev/null 2>&1; then
79 AM_CONDITIONAL(IS_SVN_BUILD, [test "$is_svn_build" = "yes"])
80 AC_MSG_RESULT([$is_svn_build])
82 # Note: On Linux, clock_gettime() requires -lrt which implies -lpthreads
83 # Check omitted for now, gettimeofday() provides reasonable precision
84 # AC_SEARCH_LIBS(clock_gettime, rt)
86 # Checks for header files.
87 AC_CHECK_HEADERS([locale.h])
88 AC_CHECK_HEADERS([byteswap.h], [], [], [])
91 *-*-freebsd*|*-*-dragonfly*|*-*-kfreebsd*-gnu*)
92 # Check for FreeBSD twe and twa include files
93 AC_CHECK_HEADERS([sys/tweio.h sys/twereg.h sys/tw_osl_ioctl.h])
94 # Check for the FreeBSD CCISS system header and use internal one if not found
95 AC_CHECK_HEADERS([dev/ciss/cissio.h],
96 [AC_DEFINE([CISS_LOCATION],[<dev/ciss/cissio.h>],[freebsd ciss header location])],
97 [AC_DEFINE([CISS_LOCATION],["cissio_freebsd.h"],[freebsd ciss header location])])
100 # <linux/compiler.h> is needed for cciss_ioctl.h at least on SuSE LINUX
101 AC_CHECK_HEADERS([sys/sysmacros.h linux/compiler.h])
102 # Check for Linux CCISS include file
103 AC_CHECK_HEADERS([linux/cciss_ioctl.h], [], [], [AC_INCLUDES_DEFAULT
104 #ifdef HAVE_LINUX_COMPILER_H
105 # include <linux/compiler.h>
109 *-*-netbsd*|*-*-openbsd*)
110 AC_CHECK_HEADERS([dev/ata/atavar.h])
112 *-*-cygwin*|*-*-mingw*)
113 # Check for Windows DDK header files
114 AC_CHECK_HEADERS([ntdddisk.h ddk/ntdddisk.h], [], [], [AC_INCLUDES_DEFAULT
120 # Checks for typedefs, and compiler characteristics.
121 AC_CHECK_TYPES([__int128])
122 AC_TYPE_LONG_DOUBLE_WIDER
124 # Checks for library functions.
125 AC_CHECK_FUNCS([getopt_long], [need_getopt_long=no], [need_getopt_long=yes])
126 AM_CONDITIONAL(NEED_GETOPT_LONG, [test "$need_getopt_long" = "yes"])
128 AC_CHECK_FUNCS([clock_gettime ftime gettimeofday])
130 # Check byte ordering (defines WORDS_BIGENDIAN)
133 # check for __attribute__((packed))
134 # (sizeof() check is required to avoid false positives if other
135 # __attribute__((x)) are supported)
136 AC_MSG_CHECKING([whether $CXX supports __attribute__((packed))])
137 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[
138 struct s { char a; short b; } __attribute__((packed));
139 typedef char t[sizeof(struct s) == 3 ? 1 : -1];]])],
140 [gcc_have_attr_packed=yes], [gcc_have_attr_packed=no])
141 AC_SUBST(gcc_have_attr_packed)
142 if test "$gcc_have_attr_packed" = "yes"; then
143 AC_DEFINE(HAVE_ATTR_PACKED, 1, [Define to 1 if C++ compiler supports __attribute__((packed))])
145 AC_MSG_RESULT([$gcc_have_attr_packed])
152 AC_ARG_WITH(initscriptdir,
153 [AS_HELP_STRING([--with-initscriptdir=@<:@DIR|no@:>@], [Location of init scripts [no]])],
155 auto|yes) AC_MSG_ERROR(['--with-initscriptdir=$withval' is no longer supported]) ;;
157 *) initddir="$withval" ;;
161 AM_CONDITIONAL(INSTALL_INITSCRIPT, [test -n "$initddir"])
163 # use different init script templates for different OS
166 initdfile="smartd.freebsd.initd"
169 initdfile="com.smartmontools.smartd.plist"
172 initdfile="smartd.cygwin.initd"
175 initdfile="smartd.initd"
180 AC_ARG_WITH(exampledir,
181 [AS_HELP_STRING([--with-exampledir=DIR], [Location of example scripts [DOCDIR/examplescripts]])],
182 [exampledir="$withval"], [exampledir='${docdir}/examplescripts'])
185 drivedbdir='${datadir}/${PACKAGE}'
186 AC_ARG_WITH(drivedbdir,
187 [AS_HELP_STRING([--with-drivedbdir@<:@=DIR|yes|no@:>@], [Location of drive database file [DATADIR/smartmontools]])],
188 [case "$withval" in yes) ;; no) drivedbdir= ;; *) drivedbdir="$withval" ;; esac])
190 AM_CONDITIONAL(ENABLE_DRIVEDB, [test -n "$drivedbdir"])
192 drivedb_version=$smartmontools_drivedb_version
193 AC_ARG_WITH(update-smart_drivedb,
194 [AS_HELP_STRING([--with-update-smart-drivedb@<:@=yes|no|X.Y@:>@],
195 [Install update-smart-drivedb script (and backport it to branches/RELEASE_X_Y_DRIVEDB) [yes]])],
198 5.4[[0-3]]|6.[[0-9]]) drivedb_version=$withval; with_update_smart_drivedb=yes ;;
199 *) AC_MSG_ERROR([Invalid drivedb branch version: $withval]) ;;
202 [with_update_smart_drivedb=yes])
203 test -n "$drivedbdir" || with_update_smart_drivedb=no
204 AC_SUBST(with_update_smart_drivedb)
205 AM_CONDITIONAL(ENABLE_UPDATE_SMART_DRIVEDB, [test "$with_update_smart_drivedb" = "yes"])
208 # Also check for '--with-gnupg[=yes]' because 'yes' is a valid command with infinite output
210 [AS_HELP_STRING([--with-gnupg@<:@=FILE|yes|no@:>@], [GnuPG used to verify drivedb.h [gpg]])],
211 [case "$withval" in yes) ;; no) gnupg= ;; *) gnupg="$withval" ;; esac], [])
214 case "$with_update_smart_drivedb:$gnupg" in
217 '--without-update-smart-drivedb' now requires '--without-gnupg'.
218 NEWS: update-smart-drivedb now verifies the downloaded drivedb.h file with GnuPG.])
222 AC_ARG_WITH(smartdscriptdir,
223 [AS_HELP_STRING([--with-smartdscriptdir=DIR], [Location of smartd_warning.sh script [SYSCONFDIR]])],
224 [smartdscriptdir="$withval"], [smartdscriptdir='${sysconfdir}'])
225 AC_SUBST(smartdscriptdir)
227 AC_ARG_WITH(smartdplugindir,
228 [AS_HELP_STRING([--with-smartdplugindir=@<:@DIR|no@:>@],
229 [Location of smartd_warning.sh plugin scripts [SMARTDSCRIPTDIR/smartd_warning.d]])],
230 [smartdplugindir=; test "$withval" != "no" && smartdplugindir="$withval"],
231 [smartdplugindir='${smartdscriptdir}/smartd_warning.d'])
232 AC_SUBST(smartdplugindir)
234 AC_ARG_WITH(scriptpath,
235 [AS_HELP_STRING([--with-scriptpath=@<:@PATH|no@:>@],
236 [PATH variable set within scripts [/usr/local/bin:/usr/bin:/bin]])],
237 [scriptpath=; test "$withval" != "no" && scriptpath="$withval"],
238 [scriptpath="/usr/local/bin:/usr/bin:/bin"])
240 AM_CONDITIONAL(ENABLE_SCRIPTPATH, [test -n "$scriptpath"])
243 AC_ARG_WITH(savestates,
244 [AS_HELP_STRING([--with-savestates@<:@=PREFIX|yes|no@:>@],
245 [Enable default smartd state files [no] (yes=LOCALSTATEDIR/lib/smartmontools/smartd.)])],
246 [case "$withval" in yes) savestates='${localstatedir}/lib/${PACKAGE}/smartd.' ;;
247 no) ;; *) savestates="$withval" ;; esac])
248 savestatesdir="${savestates%/*}"
250 AC_SUBST(savestatesdir)
251 AM_CONDITIONAL(ENABLE_SAVESTATES, [test -n "$savestates"])
254 AC_ARG_WITH(attributelog,
255 [AS_HELP_STRING([--with-attributelog@<:@=PREFIX|yes|no@:>@],
256 [Enable default smartd attribute log files [no] (yes=LOCALSTATEDIR/lib/smartmontools/attrlog.)])],
257 [case "$withval" in yes) attributelog='${localstatedir}/lib/${PACKAGE}/attrlog.' ;;
258 no) ;; *) attributelog="$withval" ;; esac])
259 attributelogdir="${attributelog%/*}"
260 AC_SUBST(attributelog)
261 AC_SUBST(attributelogdir)
262 AM_CONDITIONAL(ENABLE_ATTRIBUTELOG, [test -n "$attributelog"])
264 AC_ARG_ENABLE(sample,
265 [AS_HELP_STRING([--enable-sample], [Enables appending .sample to the installed smartd rc script and configuration file])],
266 [smartd_suffix=; test "$enableval" = "yes" && smartd_suffix=".sample"],
268 AC_SUBST(smartd_suffix)
270 AC_ARG_ENABLE([scsi-cdb-check],
271 [AS_HELP_STRING([--enable-scsi-cdb-check], [do sanity check on each SCSI cdb])],
272 [ if test "$enableval" = "yes"; then
273 AC_DEFINE(SCSI_CDB_CHECK, 1, [Define to 1 to enable check on each SCSI cdb])
277 AC_ARG_ENABLE([fast-lebe],
278 [AS_HELP_STRING([--disable-fast-lebe], [use generic little-endian/big-endian code instead])],
279 [ if test "$enableval" = "no"; then
280 AC_DEFINE(IGNORE_FAST_LEBE, 1, [Define to 1 to use generic LE/BE code instead])
285 [AS_HELP_STRING([--with-os-deps='os_module.o ...'], [Specify OS dependent module(s) [guessed]])],
286 [ for x in $with_os_deps; do
289 *) AC_MSG_ERROR([non-object file specified by --with-os-deps]) ;;
295 [AS_HELP_STRING([--with-selinux@<:@=yes|no@:>@], [Enables SELinux support [no]])],
296 [ if test "$withval" = "yes"; then
297 AC_CHECK_HEADERS([selinux/selinux.h], [], [AC_MSG_ERROR([Missing SELinux header files])])
298 AC_CHECK_LIB(selinux, matchpathcon, [], [AC_MSG_ERROR([Missing or incorrect SELinux library files])])
302 AC_ARG_WITH(libcap-ng,
303 [AS_HELP_STRING([--with-libcap-ng@<:@=auto|yes|no@:>@], [Add Libcap-ng support to smartd [auto]])],
304 [], [with_libcap_ng=auto])
307 case "$with_libcap_ng:$host_os" in
309 AC_CHECK_HEADERS([cap-ng.h], [AC_CHECK_LIB([cap-ng], [capng_clear],
310 [AC_DEFINE(HAVE_LIBCAP_NG, 1,
311 [Define to 1 if you have the `cap-ng' library (-lcap-ng).]) dnl `vim syntax
312 CAPNG_LDADD="-lcap-ng"; use_libcap_ng=yes],
313 [AC_MSG_ERROR([libcap-ng headers found but library is missing])])],
314 [test "$with_libcap_ng" != "yes" || AC_MSG_ERROR([Missing libcap-ng header files])])
317 AC_SUBST(CAPNG_LDADD)
319 AC_ARG_WITH(libsystemd,
320 [AS_HELP_STRING([--with-libsystemd@<:@=auto|yes|no@:>@],
321 [Add systemd 'Type=notify' support to smartd [auto]])],
322 [], [with_libsystemd=auto])
325 case "$with_libsystemd:$host_os" in
327 AC_CHECK_HEADERS([systemd/sd-daemon.h], [AC_CHECK_LIB([systemd], [sd_notify],
328 [AC_DEFINE(HAVE_LIBSYSTEMD, 1,
329 [Define to 1 if you have the `systemd' library (-lsystemd).]) dnl `vim syntax
330 SYSTEMD_LDADD="-lsystemd"; use_libsystemd=yes],
331 [AC_MSG_ERROR([libsystemd headers found but library is missing])])],
332 [test "$with_libsystemd" != "yes" || AC_MSG_ERROR([Missing libsystemd header files])])
335 AC_SUBST(SYSTEMD_LDADD)
337 AC_ARG_WITH(systemdsystemunitdir,
338 [AS_HELP_STRING([--with-systemdsystemunitdir@<:@=DIR|auto|yes|no@:>@], [Location of systemd service files [auto]])],
339 [], [with_systemdsystemunitdir=auto])
341 systemdsystemunitdir=
342 case "$with_systemdsystemunitdir:$use_libsystemd" in
344 if test -n "$PKG_CONFIG"; then
345 AC_MSG_CHECKING([for systemdsystemunitdir])
346 systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd 2>/dev/null`
347 AC_MSG_RESULT([${systemdsystemunitdir:-no}])
349 case "$with_systemdsystemunitdir:$sysconfdir:$systemdsystemunitdir" in
350 yes:*:) AC_MSG_ERROR([Location of systemd service files not found]) ;;
351 yes:*:*|auto:*:|auto:/etc:*) ;;
352 *) systemdsystemunitdir='${prefix}'$systemdsystemunitdir ;;
355 *:yes) systemdsystemunitdir="$with_systemdsystemunitdir" ;;
356 *) AC_MSG_ERROR(['--with-systemdsystemunitdir=$with_systemdsystemunitdir' now requires '--with-libsystemd']) ;;
358 AC_SUBST(systemdsystemunitdir)
359 AM_CONDITIONAL(INSTALL_SYSTEMDUNIT, [test -n "$systemdsystemunitdir"])
361 AC_ARG_WITH(systemdenvfile,
362 [AS_HELP_STRING([--with-systemdenvfile@<:@=FILE|auto|yes|no@:>@], [Path of systemd EnvironmentFile [auto]])],
363 [], [with_systemdenvfile=auto])
366 case "$with_systemdenvfile:$cross_compiling:$systemdsystemunitdir" in
368 AC_MSG_CHECKING([for path of systemd EnvironmentFile])
369 for dir in sysconfig default; do
370 if test -d /etc/$dir; then
371 systemdenvfile='${sysconfdir}'/$dir/smartmontools
375 AC_MSG_RESULT([${systemdenvfile:-no}])
376 case "$with_systemdenvfile:$systemdenvfile" in
377 yes:) AC_MSG_ERROR([Path of systemd EnvironmentFile not found]) ;;
380 *:*:) AC_MSG_ERROR([Location of systemd service files not found]) ;;
381 *) systemdenvfile="$with_systemdenvfile"
383 AC_SUBST(systemdenvfile)
385 # TODO: Remove when NVMe support is no longer EXPERIMENTAL
386 AC_ARG_WITH(nvme-devicescan,
387 [AS_HELP_STRING([--with-nvme-devicescan@<:@=yes|no@:>@],
388 [Include NVMe devices in smartd DEVICESCAN [Linux,Windows:yes;Others:no]])])
390 AC_ARG_WITH(solaris-sparc-ata,
391 [AS_HELP_STRING([--with-solaris-sparc-ata@<:@=yes|no@:>@],
392 [Enable legacy ATA support on Solaris SPARC (requires os_solaris_ata.s from SVN repository) [no]])])
394 case "$host:$with_solaris_sparc_ata" in
395 sparc-*-solaris*:yes)
396 if test ! -f "$srcdir/os_solaris_ata.s"; then
397 AC_MSG_ERROR([Missing source file: $srcdir/os_solaris_ata.s
398 This file is no longer included in the source tarball but still
399 available in the SVN repository.])
401 AC_DEFINE(WITH_SOLARIS_SPARC_ATA, 1, [Define to 1 to enable legacy ATA support on Solaris SPARC.])
405 AC_ARG_WITH(signal-func,
406 [AS_HELP_STRING([--with-signal-func=@<:@sigaction|sigset|signal@:>@],
407 [Function to set signal(2) action [sigaction]])],
408 [], [with_signal_func=sigaction])
410 case "$host:$with_signal_func" in
413 AC_CHECK_FUNCS([sigaction], [], AC_MSG_ERROR([Missing function 'sigaction()'.
414 Try '--with-signal-func=sigset' or '--with-signal-func=signal'.
415 Please send info about your system to $PACKAGE_BUGREPORT.])) ;;
417 AC_CHECK_FUNCS([sigset], [], AC_MSG_ERROR([Missing function 'sigset()'])) ;;
419 *) AC_MSG_ERROR([Invalid option '--with-signal-func=$with_signal_func']) ;;
422 # TODO: Remove after smartmontools 6.7
423 AC_ARG_WITH(working-snprintf,
424 [AS_HELP_STRING([--with-working-snprintf@<:@=yes|no@:>@],
425 [Function snprintf() handles output truncation as specified by C99 [yes]])],
426 [], [with_working_snprintf=yes])
428 if test "$with_working_snprintf" = "yes"; then
429 AC_DEFINE(HAVE_WORKING_SNPRINTF, 1, [Define to 1 if the `snprintf' function is sane.]) dnl `vim syntax
432 case "$with_working_snprintf:$host_os: $CPPFLAGS $CXXFLAGS" in
433 yes:mingw*:*\ -[[DU]]__USE_MINGW_ANSI_STDIO*)
436 # Older MinGW (4.6.3) do not properly define PRI?64 if __USE_MINGW_ANSI_STDIO is set.
437 # Newer MinGW (4.9.1) set __USE_MINGW_ANSI_STDIO in first C++ include which may be too late.
438 # Set __USE_MINGW_ANSI_STDIO always and fail if not fully supported.
439 AC_MSG_CHECKING([whether $CXX supports __USE_MINGW_ANSI_STDIO])
440 save_CXXFLAGS=$CXXFLAGS
441 CXXFLAGS="-Wformat -Werror -D__USE_MINGW_ANSI_STDIO"
442 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
443 #define __STDC_FORMAT_MACROS 1
444 #include <inttypes.h>
446 void f(char * buf1, char * buf2, size_t size) {
447 snprintf(buf1, size, "%lld", 42LL);
448 snprintf(buf2, size, "%" PRId64, (int64_t)42);
450 [result=yes], [result=no])
451 AC_MSG_RESULT([$result])
452 if test "$result" != "yes"; then
454 This version of $CXX does not support __USE_MINGW_ANSI_STDIO.
455 Use option '--without-working-snprintf' to skip this check.
456 Please send info about your system to $PACKAGE_BUGREPORT.
459 CXXFLAGS="-D__USE_MINGW_ANSI_STDIO $save_CXXFLAGS"
463 AC_ARG_WITH(mingw-aslr,
464 [AS_HELP_STRING([--with-mingw-aslr@<:@=auto|yes|low|no@:>@], [Enable ASLR for MinGW executables [auto]])],
465 [], [with_mingw_aslr=auto])
467 case "$host:${LDFLAGS+set}" in
468 *-*-mingw*:) # MinGW defaults: link statically and indicate DEP and TS compatibility
469 LDFLAGS="-static -Wl,--nxcompat,--tsaware" ;;
472 case "$host:$with_mingw_aslr" in
473 x86_64-*-mingw*:auto)
474 AC_MSG_CHECKING([whether $CXX supports --high-entropy-va])
475 save_LDFLAGS=$LDFLAGS
476 LDFLAGS="$LDFLAGS -pie -Wl,--dynamicbase,-emainCRTStartup,--high-entropy-va,--image-base,0x140000000"
477 # Link libstdc++ to detect MinGW 6.3.0 problems with high --image-base
478 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
480 std::string s(42, '.');]])],
481 [with_mingw_aslr=yes], [with_mingw_aslr=no])
482 LDFLAGS=$save_LDFLAGS
483 AC_MSG_RESULT([$with_mingw_aslr])
484 test "$with_mingw_aslr" = "yes" || with_mingw_aslr=low
488 case "$host:$with_mingw_aslr" in
490 LDFLAGS="$LDFLAGS -pie -Wl,--dynamicbase,-emainCRTStartup,--high-entropy-va,--image-base,0x140000000" ;;
492 LDFLAGS="$LDFLAGS -pie -Wl,--dynamicbase,-emainCRTStartup" ;;
493 *-*-mingw*:auto|*-*-mingw*:yes|*-*-mingw*:low)
494 LDFLAGS="$LDFLAGS -pie -Wl,--dynamicbase,-e_mainCRTStartup" ;;
500 # Newer MinGW may add a default manifest
501 AC_MSG_CHECKING([whether $CXX adds an application manifest])
503 AC_LINK_IFELSE([AC_LANG_PROGRAM()], [
504 if "$WINDRES" -O rc conftest.exe 2>/dev/null | grep '^1.*RT_MANIFEST' >/dev/null 2>&1; then
505 cc_adds_manifest=incomplete
506 # Manifest must provide a Win 10 compatibility ID
507 if "$WINDRES" -O rc conftest.exe 2>/dev/null | grep '{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}' >/dev/null 2>&1; then
511 [AC_MSG_ERROR([test compile failed])])
512 AC_MSG_RESULT([$cc_adds_manifest])
513 test "$cc_adds_manifest" = "yes" || os_win32_manifest='os_win32/default.manifest'
517 AC_ARG_WITH(cxx11-option,
518 [AS_HELP_STRING([--with-cxx11-option=@<:@OPTION|auto|no@:>@],
519 [Compiler option to enable C++11 support for future versions of smartmontools, 'no' if unsupported [auto]])],
520 [], [with_cxx11_option=auto])
522 check_cxx11_support()
524 save_CXXFLAGS=$CXXFLAGS
526 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
527 #if __cplusplus < 201103L
530 // use some C++11 features (and return v * 42 :-)
531 auto cxx11(long v) noexcept -> decltype(v) {
532 typedef decltype(v) t; t r = v;
533 static const t a[] = { -7, -1, 1, 2, 3 };
534 static_assert(sizeof(r) == sizeof(a[0]), "fail");
535 auto f = [](t x, t y){ return x * y; };
536 for (const auto & e : a) r = f(r, e);
539 [CXXFLAGS=$save_CXXFLAGS; return 0], [CXXFLAGS=$save_CXXFLAGS; return 1])
542 case "$with_cxx11_option" in
545 AC_MSG_CHECKING([for $CXX option to accept C++11])
546 with_cxx11_option=unknown
547 for option in "" "-std=gnu++11" "-std=gnu++0x" "-std=c++11" "-std=c++0x"; do
548 if check_cxx11_support "$option"; then with_cxx11_option=$option; break; fi
550 AC_MSG_RESULT([${with_cxx11_option:-none needed}])
551 test "$with_cxx11_option" != "unknown" || AC_MSG_ERROR([
552 This version of smartmontools does not use C++11 features, but future
553 versions possibly will.
554 This script was unable to determine a compiler option to enable C++11.
555 Use option '--with-cxx11-option=OPTION' to specify the compiler option
556 (it will be used in the actual build only if '--with-cxx11-regex' is set).
557 Use option '--without-cxx11-option' to suppress this error message if the
558 compiler lacks C++11 support.
559 In both cases, please send info about compiler and platform to
560 $PACKAGE_BUGREPORT - Thanks!])
563 AC_MSG_CHECKING([whether $CXX $with_cxx11_option accepts C++11])
564 res=no; check_cxx11_support "$with_cxx11_option" && res=yes
565 AC_MSG_RESULT([$res])
566 test "$res" = "yes" || AC_MSG_ERROR([$CXX $with_cxx11_option does not accept C++11])
570 AC_ARG_WITH(cxx11-regex,
571 [AS_HELP_STRING([--with-cxx11-regex@<:@=yes|no@:>@],
572 [Use C++11 std::regex instead of POSIX regex(3) [no]])])
575 if test "$with_cxx11_regex" = "yes"; then
576 AC_DEFINE(WITH_CXX11_REGEX, 1, [Define to 1 to use C++11 std::regex instead of POSIX regex(3)])
577 case "$with_cxx11_option: $CXXFLAGS " in
578 no:*) AC_MSG_ERROR(['--with-cxx11-regex' requires C++11 support]) ;;
579 ?*:*\ $with_cxx11_option\ *) ;;
580 ?*:*) CXXFLAGS="$CXXFLAGS $with_cxx11_option" ;;
583 AC_CHECK_FUNCS([regcomp], [], [need_regex=yes])
585 AM_CONDITIONAL(NEED_REGEX, [test "$need_regex" = "yes"])
587 AC_SUBST(releaseversion,['${PACKAGE}-${VERSION}'])
588 AC_SUBST(smartmontools_release_date)
589 AC_SUBST(smartmontools_release_time)
591 # Set platform-specific modules and symbols
593 os_dltools='curl wget lynx svn'
595 os_hostname="'hostname'"
597 os_nisdomainname="'domainname'"
607 os_deps='os_linux.o cciss.o dev_areca.o'
608 os_dnsdomainname="'dnsdomainname' 'hostname -d'"
609 os_nisdomainname="'nisdomainname' 'hostname -y' 'domainname'"
611 os_nvme_devicescan=yes
613 *-*-freebsd*|*-*-dragonfly*|*-*-kfreebsd*-gnu*)
614 os_deps='os_freebsd.o cciss.o dev_areca.o'
615 os_libs='-lcam -lsbuf'
616 os_dltools='curl wget lynx fetch svn'
617 AC_CHECK_LIB(usb, libusb20_dev_get_device_desc)
618 os_man_filter=FreeBSD
619 os_nvme_devicescan=no
622 os_deps='os_solaris.o'
623 test "$with_solaris_sparc_ata" = "yes" \
624 && os_deps="$os_deps os_solaris_ata.o"
627 os_man_filter=Solaris
630 os_deps='os_solaris.o'
633 os_man_filter=Solaris
636 os_deps='os_netbsd.o'
639 os_nvme_devicescan=no
642 os_deps='os_openbsd.o'
644 os_dltools='curl wget lynx ftp svn'
645 os_man_filter=OpenBSD
648 os_deps='os_win32.o dev_areca.o'
650 os_hostname="'hostname' 'echo "'"${HOSTNAME?unset}"'"'"
651 os_dnsdomainname="'dnsdomainname' 'hostname -d' 'echo "'"${USERDNSDOMAIN?unset}"'"'"
655 os_nvme_devicescan=yes
658 os_deps='os_win32.o dev_areca.o'
662 os_man_filter=Windows
663 os_nvme_devicescan=yes
666 os_deps='os_win32.o dev_areca.o'
669 os_man_filter=Windows
670 os_nvme_devicescan=yes
673 os_deps='os_darwin.o'
674 os_libs='-framework CoreFoundation -framework IOKit'
677 os_nvme_devicescan=no
680 os_deps='os_qnxnto.o'
686 os_deps='os_generic.o'
690 # Replace if '--with-os-deps' was specified
691 test -z "$with_os_deps" || os_deps="$with_os_deps"
693 # Check if we need adapter to old interface (dev_legacy.cpp)
694 os_src=`echo "${os_deps}"|sed -n 's,^\([[^ .]]*\)\.o.*$,\1.cpp,p'`
695 AC_MSG_CHECKING([whether ${os_src} uses new interface])
696 if grep "smart_interface" "${srcdir}/${os_src}" >/dev/null 2>&1; then
700 os_deps="${os_deps} dev_legacy.o"
701 AC_DEFINE(OLD_INTERFACE, 1, [Define to 1 if os_*.cpp still uses the old interface])
703 AC_MSG_RESULT([$os_new_interface])
705 # TODO: Remove when NVMe support is no longer EXPERIMENTAL
706 case "$os_nvme_devicescan:${with_nvme_devicescan+set}" in
708 AC_MSG_CHECKING([whether NVMe device scanning could be safely enabled])
709 with_nvme_devicescan=$os_nvme_devicescan
710 AC_MSG_RESULT([$os_nvme_devicescan])
711 os_nvme_devicescan=used ;;
713 AC_SUBST(with_nvme_devicescan)
714 if test "$with_nvme_devicescan" = "yes"; then
715 AC_DEFINE(WITH_NVME_DEVICESCAN, 1, [Define to 1 to include NVMe devices in smartd DEVICESCAN.])
720 AC_SUBST([os_dltools])
721 AC_SUBST([os_mailer])
722 AC_SUBST([os_hostname])
723 AC_SUBST([os_dnsdomainname])
724 AC_SUBST([os_nisdomainname])
725 AC_SUBST([os_man_filter])
726 AC_SUBST([os_win32_manifest])
728 # Create drivedb.h update branch name from version: 5.41[.X] -> RELEASE_5_41_DRIVEDB
729 DRIVEDB_BRANCH=`echo "$drivedb_version" | sed 's,^\([[0-9]]*\.[[0-9]]*\)\..*$,\1,' \
730 | sed -n 's,^\([[0-9]][[0-9]]*\)\.\([[0-9]][[0-9]]*\)$,RELEASE_\1_\2_DRIVEDB,p'`
731 if test -z "$DRIVEDB_BRANCH"; then
732 AC_MSG_ERROR([Unable to create DRIVEDB_BRANCH for version: $drivedb_version])
734 AC_SUBST([DRIVEDB_BRANCH])
736 # Enable platform-specific makefile sections
737 AM_CONDITIONAL(OS_DARWIN, [test "$os_darwin" = "yes"])
738 AM_CONDITIONAL(OS_SOLARIS, [test "$os_solaris" = "yes"])
739 AM_CONDITIONAL(OS_WIN32, [test "$os_win32" = "yes"])
740 AM_CONDITIONAL(OS_WIN32_MINGW, [test "$os_win32_mingw" = "yes"])
741 AM_CONDITIONAL(OS_WIN32_NSIS, [test -n "$MAKENSIS"])
742 AM_CONDITIONAL(OS_WIN64, [test "$os_win64" = "yes"])
744 if test "$GXX" = "yes"; then
745 orig_CXXFLAGS=$CXXFLAGS
746 # Add -Wall and -W[extra] if its not already specified
747 case " $CXXFLAGS " in
749 *) CXXFLAGS="$CXXFLAGS -Wall" ;;
751 case " $CXXFLAGS " in
752 *\ -W\ *|*\ -Wextra\ *) ;;
753 *) CXXFLAGS="$CXXFLAGS -W" ;;
755 # Add -Wformat=2 (GCC 3.0) -fstack-protector[-strong] (GCC 4.1[4.9]) if supported
756 # and no -W or -f option was set in configure cmdline (TODO: -Wformat-signedness)
757 for option in "-Wformat=2" "-fstack-protector-strong" "-fstack-protector"; do
758 case " $orig_CXXFLAGS:$option" in *\ -W*:-W*|*\ -f*:-f*) continue ;; esac
759 case " $CXXFLAGS:$option" in *\ -fstack-p*:-fstack-p*) continue ;; esac
760 AC_MSG_CHECKING([whether $CXX supports $option])
761 save_CXXFLAGS=$CXXFLAGS
762 CXXFLAGS="$CXXFLAGS $option"
763 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [res=yes], [res=no; CXXFLAGS=$save_CXXFLAGS])
764 AC_MSG_RESULT([$res])
767 # We are NOT using gcc, so enable host-specific compiler flags
770 # Tell the Solaris/SPARC C++ compiler about packed ATA structures
773 *) CXXFLAGS="-xmemalign=1i $CXXFLAGS" ;;
778 # Turn on optimization if user has not explicitly set its value
781 *) CXXFLAGS="-xO2 $CXXFLAGS" ;;
783 # Suppress trivial warnings
786 *) CXXFLAGS="-erroff=%none,wbadinitl,wbadasgl,badargtypel2w,badargtype2w $CXXFLAGS" ;;
791 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_BUILD_HOST, "${host}", [smartmontools Build Host])
795 AC_CONFIG_FILES(Makefile)
799 # Note: Use `...` here as some shells do not properly parse '$(... case $x in X) ...)'
801 echo "-----------------------------------------------------------------------------"
802 echo "${PACKAGE}-${VERSION} configuration:"
803 echo "host operating system: $host"
804 echo "C++ compiler: $CXX"
805 echo "C compiler: $CC"
806 echo "preprocessor flags: $CPPFLAGS"
807 echo "C++ compiler flags: $CXXFLAGS"
808 echo "C compiler flags: $CFLAGS"
809 echo "linker flags: $LDFLAGS"
810 echo "OS specific modules: $os_deps $os_libs $LIBS"
814 echo "application manifest: ${os_win32_manifest:-built-in}"
815 echo "resource compiler: $WINDRES"
816 echo "message compiler: $WINDMC"
817 echo "NSIS compiler: $MAKENSIS"
818 if test -n "$drivedbdir"; then
819 echo "drive database file: EXEDIR/drivedb.h"
820 if test -n "$MAKENSIS"; then
821 echo "database update tool: EXEDIR/update-smart-drivedb.exe"
824 echo "drive database file: [[disabled]]"
826 if test -n "$savestates"; then
827 echo "smartd save files: \`eval eval eval echo $savestates\`MODEL-SERIAL.TYPE.state"
829 if test -n "$attributelog"; then
830 echo "smartd attribute logs: \`eval eval eval echo $attributelog\`MODEL-SERIAL.TYPE.csv"
832 echo "NVMe DEVICESCAN: ${with_nvme_devicescan-no}"
836 echo "binary install path: \`eval eval eval echo $sbindir\`"
837 echo "man page install path: \`eval eval eval echo $mandir\`"
838 echo "doc file install path: \`eval eval eval echo $docdir\`"
839 echo "examples install path: \`eval eval eval echo $exampledir\`"
840 if test -n "$drivedbdir"; then
841 echo "drive database file: \`eval eval eval echo $drivedbdir\`/drivedb.h"
842 if test "$with_update_smart_drivedb" = "yes"; then
843 echo "database update script: \`eval eval eval echo $sbindir\`/update-smart-drivedb"
844 if test "$drivedb_version" = "$smartmontools_drivedb_version"; then
845 echo "database update branch: branches/$DRIVEDB_BRANCH"
847 echo "... backported to: branches/$DRIVEDB_BRANCH"
849 echo "download tools: \`eval eval eval echo $os_dltools\`"
850 if test -n "$gnupg"; then
851 echo "GnuPG for verification: \`eval eval eval echo $gnupg\`"
853 echo "GnuPG for verification: [[disabled]]"
856 echo "database update script: [[disabled]]"
859 echo "drive database file: [[disabled]]"
861 echo "local drive database: \`eval eval eval echo $sysconfdir\`/smart_drivedb.h"
862 echo "smartd config file: \`eval eval eval echo $sysconfdir\`/smartd.conf${smartd_suffix}"
863 echo "smartd warning script: \`eval eval eval echo $smartdscriptdir\`/smartd_warning.sh"
864 if test -n "$smartdplugindir"; then
865 echo "smartd plugin path: \`eval eval eval echo $smartdplugindir\`"
867 echo "smartd plugin path: [[disabled]]"
869 if test -n "$scriptpath"; then
870 echo "PATH within scripts: \`eval eval eval echo $scriptpath\`"
872 echo "PATH within scripts: [[inherited]]"
874 if test -n "$initddir"; then
875 echo "smartd initd script: \`eval eval eval echo $initddir\`/smartd"
876 elif test -z "$systemdsystemunitdir"; then
877 echo "smartd initd script: [[disabled]]"
879 if test -n "$systemdsystemunitdir"; then
880 echo "smartd service file: \`eval eval eval echo $systemdsystemunitdir\`/smartd.service"
881 if test -n "$systemdenvfile"; then
882 echo "smartd environ file: \`eval eval eval echo $systemdenvfile\`"
884 echo "smartd environ file: [[disabled]]"
887 if test -n "$savestates"; then
888 echo "smartd save files: \`eval eval eval echo $savestates\`MODEL-SERIAL.TYPE.state"
890 echo "smartd save files: [[disabled]]"
892 if test -n "$attributelog"; then
893 echo "smartd attribute logs: \`eval eval eval echo $attributelog\`MODEL-SERIAL.TYPE.csv"
895 echo "smartd attribute logs: [[disabled]]"
899 echo "SELinux support: ${with_selinux-no}"
900 echo "libcap-ng support: $use_libcap_ng"
901 echo "systemd notify support: $use_libsystemd" ;;
903 echo "NVMe DEVICESCAN: ${with_nvme_devicescan-[[not implemented]]}"
906 echo "-----------------------------------------------------------------------------"
913 # TODO: Remove when NVMe support is no longer EXPERIMENTAL
914 case "$os_nvme_devicescan:$with_nvme_devicescan" in
915 used:yes) AC_MSG_WARN([
916 The default for the inclusion of NVME devices in smartd.conf
917 'DEVICESCAN' and 'smartctl --scan' has been changed to 'yes' on
918 this platform. If '--without-nvme-devicescan' is still needed,
919 please inform $PACKAGE_BUGREPORT.
920 Use option '--with-nvme-devicescan' to suppress this warning.
922 used:no) AC_MSG_WARN([
923 This version of smartmontools provides NVMe support which is still
924 EXPERIMENTAL. NVMe devices are not yet included in smartd.conf
925 'DEVICESCAN' and 'smartctl --scan' unless '-d nvme' is specified.
926 Use option '--with-nvme-devicescan' to include NVMe devices.
927 Use option '--without-nvme-devicescan' to suppress this warning.
931 # TODO: Remove after smartmontools 6.7
932 if test "$with_working_snprintf" != "yes"; then
934 The option '--without-working-snprintf' is deprecated and will be removed
935 in a future version of smartmontools. If you still need support for
936 pre-C99 snprintf(), please inform $PACKAGE_BUGREPORT.
940 case "$host_os:$with_libsystemd:$use_libsystemd:$PKG_CONFIG" in
942 if $PKG_CONFIG systemd >/dev/null 2>&1; then
944 systemd(1) is used on this system but smartd systemd notify support will
945 not be available because libsystemd-dev[[el]] package is not installed.
946 Use option '--without-libsystemd' to suppress this warning.