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