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