]> git.proxmox.com Git - mirror_smartmontools-debian.git/blame - configure.in
Fixed quietmode option
[mirror_smartmontools-debian.git] / configure.in
CommitLineData
832b75ed 1#
e9e8c2b1 2# $Id: configure.in 2995 2009-12-09 21:01:43Z chrfranke $
832b75ed
GG
3#
4dnl Process this file with autoconf to produce a configure script.
5AC_PREREQ(2.50)
2127e193 6AC_INIT(smartmontools, 5.39, smartmontools-support@lists.sourceforge.net)
4d59bff9 7AC_CONFIG_SRCDIR(smartctl.cpp)
832b75ed 8
eb07ddf2 9smartmontools_configure_date=`date -u +'%Y-%m-%d %T %Z'`
e9e8c2b1
GI
10smartmontools_cvs_tag=`echo '$Id: configure.in 2995 2009-12-09 21:01:43Z chrfranke $'`
11smartmontools_release_date=2009-12-09
12smartmontools_release_time="21:00:32 UTC"
832b75ed
GG
13
14AC_DEFINE_UNQUOTED(SMARTMONTOOLS_CONFIGURE_ARGS, "$ac_configure_args", [smartmontools Configure Arguments])
15AC_DEFINE_UNQUOTED(SMARTMONTOOLS_CONFIGURE_DATE, "$smartmontools_configure_date", [smartmontools Configure Date])
16AC_DEFINE_UNQUOTED(SMARTMONTOOLS_RELEASE_DATE, "$smartmontools_release_date", [smartmontools Release Date])
17AC_DEFINE_UNQUOTED(SMARTMONTOOLS_RELEASE_TIME, "$smartmontools_release_time", [smartmontools Release Time])
18AC_DEFINE_UNQUOTED(CONFIG_H_CVSID, "$smartmontools_cvs_tag", [smartmontools CVS Tag])
19AC_DEFINE_UNQUOTED(PACKAGE_HOMEPAGE, "http://smartmontools.sourceforge.net/", [smartmontools Home Page])
20
21AM_CONFIG_HEADER(config.h)
22
23AM_INIT_AUTOMAKE
24
25AM_MAINTAINER_MODE
26
4d59bff9 27AC_LANG_CPLUSPLUS
832b75ed 28dnl Checks for programs.
4d59bff9 29AC_PROG_CXX
832b75ed
GG
30AM_PROG_AS
31AC_PROG_INSTALL
32
33AC_CANONICAL_HOST
34dnl Set flags which may affect AC_CHECK_*.
35case "${host}" in
36 *-*-mingw*)
eb07ddf2
GI
37 # If building on Cygwin and not cross-compiling add '-mno-cygwin'
38 # to select MinGW gcc. This does no longer work for gcc 4.x.
39 if test "${build}" = "${host}" && test -x /usr/bin/uname && \
40 /usr/bin/uname | grep -i '^CYGWIN' >/dev/null; then
41 AC_MSG_CHECKING([whether C and C++ compiler support -mno-cygwin])
42 gcc_support_m_no_cygwin=no
43 if $CC -v -mno-cygwin >/dev/null 2>&1 && \
44 $CXX -v -mno-cygwin >/dev/null 2>&1; then
45 gcc_support_m_no_cygwin=yes
46 fi
47 AC_MSG_RESULT([$gcc_support_m_no_cygwin])
48 if test "$gcc_support_m_no_cygwin" != "yes"; then
49 AC_MSG_ERROR([$CC and $CXX do not support -mno-cygwin, see INSTALL file for details.])
50 fi
51 CPPFLAGS="$CPPFLAGS -mno-cygwin"
52 LDFLAGS="$LDFLAGS -mno-cygwin"
53 fi
832b75ed 54 CPPFLAGS="$CPPFLAGS -idirafter ${srcdir}/posix -idirafter ${srcdir}/os_win32"
a37e7145
GG
55 ;;
56 *-*-freebsd*)
57 CPPFLAGS="$CPPFLAGS -I/usr/src/sys"
58 ;;
832b75ed
GG
59esac
60
2127e193
GI
61# Check for SVN.
62AC_MSG_CHECKING([whether this is a build from SVN])
63is_svn_build=no
64if test -f "$srcdir/.svn/entries"; then
65 is_svn_build=unknown
66 if (cd "$srcdir" && svn --version && svnversion && svn info) >/dev/null 2>&1; then
67 is_svn_build=yes
68 fi
69fi
70AM_CONDITIONAL(IS_SVN_BUILD, [test "$is_svn_build" = "yes"])
71AC_MSG_RESULT([$is_svn_build])
72
73dnl Checks for libraries needed for name services (Solaris needs
832b75ed
GG
74dnl libnsl, might in the future also need libsocket)
75# AC_SEARCH_LIBS (FUNCTION, SEARCH-LIBS, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES])
2127e193
GI
76AC_SEARCH_LIBS(socket, socket)
77AC_SEARCH_LIBS(gethostbyname, nsl)
78AC_SEARCH_LIBS(getaddrinfo, nsl)
79AC_SEARCH_LIBS(getdomainname, nsl)
832b75ed
GG
80
81dnl Checks for header files.
82AC_CHECK_HEADERS([locale.h])
832b75ed
GG
83AC_CHECK_HEADERS([dev/ata/atavar.h])
84AC_CHECK_HEADERS([netdb.h])
85dnl we need [u]int64_t and friends.
86AC_CHECK_HEADERS([inttypes.h]) dnl C99, UNIX98, solaris 2.6+
87AC_CHECK_HEADERS([stdint.h]) dnl C99
88AC_CHECK_HEADERS([sys/inttypes.h]) dnl pre-UNIX98
89AC_CHECK_HEADERS([sys/int_types.h]) dnl pre-UNIX98, solaris 2.6+
90dnl Check for FreeBSD twe include files...currently missing on 5.2, but should be there
91AC_CHECK_HEADERS([sys/tweio.h])
92AC_CHECK_HEADERS([sys/twereg.h])
93dnl Check for FreeBSD twa include files...
94AC_CHECK_HEADERS([sys/tw_osl_ioctl.h])
a37e7145
GG
95dnl Check for FreeBSD ciss include files...
96AC_CHECK_HEADERS([dev/ciss/cissio.h])
1953ff6d 97dnl This header file is needed for cciss_ioctl.h at least on SuSE LINUX
ba59cff1 98AC_CHECK_HEADERS([linux/compiler.h])
1953ff6d
GG
99dnl Check for Linux CCISS include file
100AC_CHECK_HEADERS([linux/cciss_ioctl.h], [], [], [AC_INCLUDES_DEFAULT
101#ifdef HAVE_LINUX_COMPILER_H
102# include <linux/compiler.h>
103#endif
104])
832b75ed
GG
105
106dnl Checks for typedefs, structures, and compiler characteristics.
107AC_CHECK_TYPES([int64_t, uint64_t])
108
109dnl Checks for library functions.
2127e193
GI
110AC_CHECK_FUNCS([getopt_long], , [
111 AC_MSG_NOTICE([smartmontools does no longer support platforms without getopt_long().])
112 AC_MSG_NOTICE([Please inform ${PACKAGE_BUGREPORT},])
113 AC_MSG_NOTICE([including details about your build environment.])
114 AC_MSG_ERROR([function getopt_long() not found])
115])
116
832b75ed
GG
117AC_CHECK_FUNCS([getdomainname])
118AC_CHECK_FUNCS([gethostname])
2127e193 119AC_CHECK_FUNCS([getaddrinfo])
832b75ed
GG
120AC_CHECK_FUNCS([gethostbyname])
121AC_CHECK_FUNCS([sigset])
122AC_CHECK_FUNCS([strtoull])
123AC_CHECK_FUNCS([uname])
124
125# Check whether snprintf appends null char and returns expected length on overflow
126AH_TEMPLATE(HAVE_WORKING_SNPRINTF, [Define to 1 if the `snprintf' function is sane])
127AC_MSG_CHECKING([for working snprintf])
128AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[ char buf[]="ABCDEFGHI";
129 int i=snprintf(buf,8,"12345678"); return !(!buf[7] && i==8); ]])],
4d59bff9
GG
130 [libc_have_working_snprintf=yes],
131 [libc_have_working_snprintf=no],
132 [libc_have_working_snprintf=no])
832b75ed
GG
133AC_SUBST(libc_have_working_snprintf)
134if test "$libc_have_working_snprintf" = "yes"; then
135 AC_DEFINE(HAVE_WORKING_SNPRINTF)
136fi
137AC_MSG_RESULT([$libc_have_working_snprintf])
138
139# check for __attribute__((packed))
4d59bff9
GG
140AH_TEMPLATE(HAVE_ATTR_PACKED, [Define to 1 if C++ compiler supports __attribute__((packed))])
141AC_MSG_CHECKING([whether C++ compiler supports __attribute__((packed))])
832b75ed
GG
142AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[struct a { int b; } __attribute__((packed));]])],
143 [gcc_have_attr_packed=yes], [gcc_have_attr_packed=no])
34ad0c5f
GG
144AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
145#error "Sun's compiler cannot handle __attribute__((packed))!"
146#endif]])],
147 [true], [gcc_have_attr_packed=no])
832b75ed
GG
148AC_SUBST(gcc_have_attr_packed)
149if test "$gcc_have_attr_packed" = "yes"; then
150 AC_DEFINE(HAVE_ATTR_PACKED)
151fi
152AC_MSG_RESULT([$gcc_have_attr_packed])
153
154AC_SUBST(CPPFLAGS)
155AC_SUBST(LDFLAGS)
156AC_SUBST(ASFLAGS)
157
158AC_SUBST([exampledir], ['${docdir}/examplescripts'])
159
160AC_ARG_WITH(initscriptdir,[AC_HELP_STRING([--with-initscriptdir=dir],[Location of init scripts (default is ${sysconfdir}/rc.d/init.d)])],[initddir="$withval"],[initddir='${sysconfdir}/rc.d/init.d'])
161AC_SUBST(initddir)
2127e193 162AM_CONDITIONAL(INSTALL_INITSCRIPT, [test "$with_initscriptdir" != "no"])
832b75ed
GG
163
164AC_ARG_WITH(docdir,[AC_HELP_STRING([--with-docdir=dir],[Location of documentation (default is ${prefix}/share/doc/smartmontools-5.X)])],[docdir="$withval"],[docdir='${prefix}/share/doc/${PACKAGE}-${VERSION}'])
165AC_SUBST(docdir)
166
2127e193
GI
167AC_ARG_ENABLE(drivedb, [AC_HELP_STRING([--enable-drivedb],[Enables drive database file])])
168
169AC_ARG_WITH(drivedbdir,
170 [AC_HELP_STRING([--with-drivedbdir=DIR],[Location of drive database file (implies --enable-drivedb) [DATADIR/smartmontools]])],
171 [drivedbdir="$withval"; enable_drivedb="yes"],
172 [drivedbdir=; test "$enable_drivedb" = "yes" && drivedbdir='${datadir}/${PACKAGE}'])
173AC_SUBST(drivedbdir)
174AM_CONDITIONAL(ENABLE_DRIVEDB, [test "$enable_drivedb" = "yes"])
175
176AC_ARG_ENABLE(savestates, [AC_HELP_STRING([--enable-savestates],[Enables default smartd state files])])
177
178AC_ARG_WITH(savestates,
179 [AC_HELP_STRING([--with-savestates=PREFIX],[Prefix for default smartd state files (implies --enable-savestates) [LOCALSTATEDIR/lib/smartmontools/smartd.]])],
180 [savestates="$withval"; enable_savestates="yes"],
181 [savestates=; test "$enable_savestates" = "yes" && savestates='${localstatedir}/lib/${PACKAGE}/smartd.'])
182savestatesdir="${savestates%/*}"
183AC_SUBST(savestates)
184AC_SUBST(savestatesdir)
185AM_CONDITIONAL(ENABLE_SAVESTATES, [test "$enable_savestates" = "yes"])
186
187AC_ARG_ENABLE(attributelog, [AC_HELP_STRING([--enable-attributelog],[Enables default smartd attribute log files])])
188
189AC_ARG_WITH(attributelog,
190 [AC_HELP_STRING([--with-attributelog=PREFIX],[Prefix for default smartd attribute log files (implies --enable-attributelog) [LOCALSTATEDIR/lib/smartmontools/attrlog.]])],
191 [attributelog="$withval"; enable_attributelog="yes"],
192 [attributelog=; test "$enable_attributelog" = "yes" && attributelog='${localstatedir}/lib/${PACKAGE}/attrlog.'])
193attributelogdir="${attributelog%/*}"
194AC_SUBST(attributelog)
195AC_SUBST(attributelogdir)
196AM_CONDITIONAL(ENABLE_ATTRIBUTELOG, [test "$enable_attributelog" = "yes"])
197
832b75ed
GG
198AC_ARG_ENABLE(sample,[AC_HELP_STRING([--enable-sample],[Enables appending .sample to the installed smartd rc script and configuration file])],[smartd_suffix='.sample'],[smartd_suffix=''])
199AC_SUBST(smartd_suffix)
200AM_CONDITIONAL(SMARTD_SUFFIX, test $smartd_suffix)
201
2127e193
GI
202AC_ARG_WITH(os-deps,
203 [AC_HELP_STRING([--with-os-deps='os_module.o ...'],[Specify OS dependent module(s) [guessed]])],
204 [ for x in $with_os_deps; do
205 case $x in
206 *.o) ;;
207 *) AC_MSG_ERROR([non-object file specified by --with-os-deps]) ;;
208 esac
209 done
210 ],[])
211
212AC_ARG_WITH(selinux,[AC_HELP_STRING([--with-selinux],[Enables SELinux support])],
213 [
214 AC_CHECK_HEADERS([selinux/selinux.h], [], [echo "*** Error: Missing SELinux header files";exit 1])
215 AC_CHECK_LIB(selinux, matchpathcon, [with_selinux=yes], [echo "*** Error: Missing or incorrect SELinux library files"; exit 1],)
216 ],[])
217AC_SUBST(with_selinux)
218if test "$with_selinux" = "yes"; then
219 AC_DEFINE(WITH_SELINUX, [1], [Define to 1 if SELinux support is enabled])
220fi
221
832b75ed
GG
222if test "$prefix" = "NONE"; then
223 dnl no prefix and no mandir, so use ${prefix}/share/man as default
224 if test "$mandir" = '${prefix}/man'; then
225 AC_SUBST([mandir], ['${prefix}/share/man'])
226 fi
227fi
228
229AC_SUBST(releaseversion,['${PACKAGE}-${VERSION}'])
230AC_SUBST(smartmontools_release_date)
231AC_SUBST(smartmontools_release_time)
232
2127e193 233AC_MSG_CHECKING([for OS dependent modules and libraries])
832b75ed
GG
234dnl if OS not recognized, then use the os_generic modules
235case "${host}" in
832b75ed 236 *-*-linux*)
a37e7145 237 AC_SUBST([os_deps], ['os_linux.o cciss.o'])
2127e193
GI
238 if test "$with_selinux" = "yes"; then
239 AC_SUBST([os_libs], ['-lselinux'])
240 else
241 AC_SUBST([os_libs], [''])
242 fi;;
34ad0c5f 243 *-*-freebsd*|*-*-dragonfly*|*-*-kfreebsd*-gnu*)
a37e7145 244 AC_SUBST([os_deps], ['os_freebsd.o cciss.o'])
54965743
GI
245 AC_SUBST([os_libs], ['-lcam'])
246 AC_CHECK_LIB(usb, libusb20_dev_get_device_desc)
247 ;;
832b75ed
GG
248 sparc-*-solaris*)
249 AC_DEFINE_UNQUOTED(DEFAULT_MAILER, "mailx", [use mailx as default mailer])
250 AC_DEFINE_UNQUOTED(NEED_SOLARIS_ATA_CODE, "os_solaris_ata.s", [need assembly code os_solaris_ata.s])
251 AC_SUBST([os_deps], ['os_solaris.o os_solaris_ata.o'])
252 AC_SUBST([os_libs], ['']) ;;
253 *-pc-solaris*)
254 AC_DEFINE_UNQUOTED(DEFAULT_MAILER, "mailx", [use mailx as default mailer])
255 AC_SUBST([os_deps], ['os_solaris.o'])
256 AC_SUBST([os_libs], ['']) ;;
257 *-*-netbsd*)
258 AC_SUBST([os_deps], ['os_netbsd.o'])
259 AC_SUBST([os_libs], ['-lutil']) ;;
260 *-*-openbsd*)
261 AC_SUBST([os_deps], ['os_openbsd.o'])
262 AC_SUBST([os_libs], ['-lutil']) ;;
263 *-*-cygwin*)
264 AC_SUBST([os_deps], ['os_win32.o'])
265 AC_SUBST([os_libs], ['']) ;;
266 *-*-mingw*)
267 AC_SUBST([os_deps], ['os_win32.o'])
268 AC_SUBST([os_libs], ['']) ;;
269 *-*-darwin*)
270 AC_SUBST([os_deps], ['os_darwin.o'])
271 AC_SUBST([os_libs], ['-framework CoreFoundation -framework IOKit']) ;;
a37e7145
GG
272 *-*-nto-qnx*)
273 AC_SUBST([os_deps], ['os_qnxnto.o'])
274 AC_SUBST([os_libs], ['']) ;;
275
832b75ed
GG
276 *)
277 AC_SUBST([os_deps], ['os_generic.o'])
278 AC_SUBST([os_libs], ['']) ;;
279esac
280
2127e193
GI
281# Replace if '--with-os-deps' was specified
282test -z "$with_os_deps" || os_deps="$with_os_deps"
283AC_MSG_RESULT([$os_deps $os_libs])
284
832b75ed
GG
285# Define symbols for optional functions in OS specific module
286case "${os_deps}" in
287 os_win32*)
288 AC_DEFINE(HAVE_ATA_IDENTIFY_IS_CACHED, 1, [Define to 1 if you have the `ata_identify_is_cached' function in os_*.c.]) ;;
289esac
290case "${os_deps}" in
291 os_win32*)
292 AC_DEFINE(HAVE_GET_OS_VERSION_STR, 1, [Define to 1 if you have the `get_os_version_str' function in os_*.c.]) ;;
293esac
294
2127e193
GI
295# Check if we need adapter to old interface (dev_legacy.cpp)
296os_src=`echo "${os_deps}"|sed -n 's,^\([[^ .]]*\)\.o.*$,\1.cpp,p'`
297AC_MSG_CHECKING([whether ${os_src} uses new interface])
298if grep "smart_interface" "${srcdir}/${os_src}" >/dev/null 2>&1; then
299 os_new_interface=yes
300else
301 os_new_interface=no
302 os_deps="${os_deps} dev_legacy.o"
303 AC_DEFINE(OLD_INTERFACE, 1, [Define to 1 if os_*.cpp still uses the old interface])
304fi
305AC_MSG_RESULT([$os_new_interface])
306
832b75ed
GG
307dnl Define platform-specific symbol.
308AM_CONDITIONAL(OS_DARWIN, [echo $host_os | grep '^darwin' > /dev/null])
309AM_CONDITIONAL(OS_SOLARIS, [echo $host_os | grep '^solaris' > /dev/null])
310AM_CONDITIONAL(OS_WIN32_MINGW, [echo $host_os | grep '^mingw' > /dev/null])
2127e193 311AM_CONDITIONAL(OS_FREEBSD, [echo $host_os | grep '^freebsd' > /dev/null])
832b75ed 312
bed94269
GI
313dnl Add -Wall and -W if using g++ and its not already specified.
314if test "$GXX" = "yes"; then
4d59bff9
GG
315 if test -z "`echo "$CXXFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
316 CXXFLAGS="$CXXFLAGS -Wall"
832b75ed
GG
317 fi
318# In the next line, do NOT delete the 2 spaces inside double quotes.
4d59bff9
GG
319 if test -z "`echo "$CXXFLAGS " | grep "\-W " 2> /dev/null`" ; then
320 CXXFLAGS="$CXXFLAGS -W"
832b75ed
GG
321 fi
322 case "${host}" in
323 *-*-mingw*)
324 # MinGW uses MSVCRT.DLL which uses printf format "%I64d" and not "%lld" for int64_t
4d59bff9 325 CXXFLAGS="$CXXFLAGS -Wno-format";;
832b75ed 326 esac
bed94269
GI
327
328 # Disable strict aliasing rules by default (see ticket #23).
329 if test -z "`echo "$CXXFLAGS" | grep "\-f[[no-]]*strict-aliasing" 2> /dev/null`" ; then
330 AC_MSG_CHECKING([whether g++ supports -fno-strict-aliasing])
331 ac_save_CXXFLAGS="$CXXFLAGS"
332 CXXFLAGS="-fno-strict-aliasing"
333 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
334 [gcc_have_fno_strict_aliasing=yes], [gcc_have_fno_strict_aliasing=no])
335 CXXFLAGS="$ac_save_CXXFLAGS"
336 if test "$gcc_have_fno_strict_aliasing" = "yes"; then
337 CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
338 fi
339 AC_MSG_RESULT([$gcc_have_fno_strict_aliasing])
340 fi
341
832b75ed
GG
342else
343 dnl We are NOT using gcc, so enable host-specific compiler flags
344 case "${host}" in
34ad0c5f
GG
345 sparc*-*-solaris*)
346 dnl set CXXFLAGS for Solaris/SPARC C++ compiler
4d59bff9 347 if test -z "`echo "$CXXFLAGS" | grep "\-xmemalign" 2> /dev/null`" ; then
832b75ed 348 dnl we have to tell the compilers about packed ATA structures
4d59bff9 349 CXXFLAGS="-xmemalign=1i $CXXFLAGS"
832b75ed 350 fi
34ad0c5f
GG
351 esac
352 case "${host}" in
353 *-*-solaris*)
4d59bff9 354 if test -z "`echo "$CXXFLAGS" | grep "\-xO" 2> /dev/null`" ; then
832b75ed 355 dnl turn on optimization if user has not explicitly set its value
4d59bff9 356 CXXFLAGS="-xO2 $CXXFLAGS"
832b75ed 357 fi
4d59bff9 358 if test -z "`echo "$CXXFLAGS" | grep "\-erroff" 2> /dev/null`" ; then
2127e193
GI
359 dnl suppress trivial warnings
360 CXXFLAGS="-erroff=%none,wbadinitl,wbadasgl,badargtypel2w,badargtype2w $CXXFLAGS"
4d59bff9 361 fi
832b75ed
GG
362 esac
363fi
364
365AC_DEFINE_UNQUOTED(SMARTMONTOOLS_BUILD_HOST, "${host}", [smartmontools Build Host])
366
4d59bff9 367AC_SUBST(CXXFLAGS)
832b75ed
GG
368
369AC_OUTPUT(Makefile examplescripts/Makefile)
370AC_PROG_MAKE_SET