]> git.proxmox.com Git - mirror_smartmontools-debian.git/blob - configure.in
Imported Upstream version 5.38+svn2993
[mirror_smartmontools-debian.git] / configure.in
1 #
2 # $Id: configure.in 2992 2009-12-04 17:05:21Z chrfranke $
3 #
4 dnl Process this file with autoconf to produce a configure script.
5 AC_PREREQ(2.50)
6 AC_INIT(smartmontools, 5.39, smartmontools-support@lists.sourceforge.net)
7 AC_CONFIG_SRCDIR(smartctl.cpp)
8
9 smartmontools_configure_date=`date -u +'%Y-%m-%d %T %Z'`
10 smartmontools_cvs_tag=`echo '$Id: configure.in 2992 2009-12-04 17:05:21Z chrfranke $'`
11 smartmontools_release_date=2009-11-30
12 smartmontools_release_time="20:24:12 UTC"
13
14 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_CONFIGURE_ARGS, "$ac_configure_args", [smartmontools Configure Arguments])
15 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_CONFIGURE_DATE, "$smartmontools_configure_date", [smartmontools Configure Date])
16 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_RELEASE_DATE, "$smartmontools_release_date", [smartmontools Release Date])
17 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_RELEASE_TIME, "$smartmontools_release_time", [smartmontools Release Time])
18 AC_DEFINE_UNQUOTED(CONFIG_H_CVSID, "$smartmontools_cvs_tag", [smartmontools CVS Tag])
19 AC_DEFINE_UNQUOTED(PACKAGE_HOMEPAGE, "http://smartmontools.sourceforge.net/", [smartmontools Home Page])
20
21 AM_CONFIG_HEADER(config.h)
22
23 AM_INIT_AUTOMAKE
24
25 AM_MAINTAINER_MODE
26
27 AC_LANG_CPLUSPLUS
28 dnl Checks for programs.
29 AC_PROG_CXX
30 AM_PROG_AS
31 AC_PROG_INSTALL
32
33 AC_CANONICAL_HOST
34 dnl Set flags which may affect AC_CHECK_*.
35 case "${host}" in
36 *-*-mingw*)
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
54 CPPFLAGS="$CPPFLAGS -idirafter ${srcdir}/posix -idirafter ${srcdir}/os_win32"
55 ;;
56 *-*-freebsd*)
57 CPPFLAGS="$CPPFLAGS -I/usr/src/sys"
58 ;;
59 esac
60
61 # Check for SVN.
62 AC_MSG_CHECKING([whether this is a build from SVN])
63 is_svn_build=no
64 if 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
69 fi
70 AM_CONDITIONAL(IS_SVN_BUILD, [test "$is_svn_build" = "yes"])
71 AC_MSG_RESULT([$is_svn_build])
72
73 dnl Checks for libraries needed for name services (Solaris needs
74 dnl libnsl, might in the future also need libsocket)
75 # AC_SEARCH_LIBS (FUNCTION, SEARCH-LIBS, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES])
76 AC_SEARCH_LIBS(socket, socket)
77 AC_SEARCH_LIBS(gethostbyname, nsl)
78 AC_SEARCH_LIBS(getaddrinfo, nsl)
79 AC_SEARCH_LIBS(getdomainname, nsl)
80
81 dnl Checks for header files.
82 AC_CHECK_HEADERS([locale.h])
83 AC_CHECK_HEADERS([dev/ata/atavar.h])
84 AC_CHECK_HEADERS([netdb.h])
85 dnl we need [u]int64_t and friends.
86 AC_CHECK_HEADERS([inttypes.h]) dnl C99, UNIX98, solaris 2.6+
87 AC_CHECK_HEADERS([stdint.h]) dnl C99
88 AC_CHECK_HEADERS([sys/inttypes.h]) dnl pre-UNIX98
89 AC_CHECK_HEADERS([sys/int_types.h]) dnl pre-UNIX98, solaris 2.6+
90 dnl Check for FreeBSD twe include files...currently missing on 5.2, but should be there
91 AC_CHECK_HEADERS([sys/tweio.h])
92 AC_CHECK_HEADERS([sys/twereg.h])
93 dnl Check for FreeBSD twa include files...
94 AC_CHECK_HEADERS([sys/tw_osl_ioctl.h])
95 dnl Check for FreeBSD ciss include files...
96 AC_CHECK_HEADERS([dev/ciss/cissio.h])
97 dnl This header file is needed for cciss_ioctl.h at least on SuSE LINUX
98 AC_CHECK_HEADERS([linux/compiler.h])
99 dnl Check for Linux CCISS include file
100 AC_CHECK_HEADERS([linux/cciss_ioctl.h], [], [], [AC_INCLUDES_DEFAULT
101 #ifdef HAVE_LINUX_COMPILER_H
102 # include <linux/compiler.h>
103 #endif
104 ])
105
106 dnl Checks for typedefs, structures, and compiler characteristics.
107 AC_CHECK_TYPES([int64_t, uint64_t])
108
109 dnl Checks for library functions.
110 AC_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
117 AC_CHECK_FUNCS([getdomainname])
118 AC_CHECK_FUNCS([gethostname])
119 AC_CHECK_FUNCS([getaddrinfo])
120 AC_CHECK_FUNCS([gethostbyname])
121 AC_CHECK_FUNCS([sigset])
122 AC_CHECK_FUNCS([strtoull])
123 AC_CHECK_FUNCS([uname])
124
125 # Check whether snprintf appends null char and returns expected length on overflow
126 AH_TEMPLATE(HAVE_WORKING_SNPRINTF, [Define to 1 if the `snprintf' function is sane])
127 AC_MSG_CHECKING([for working snprintf])
128 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[ char buf[]="ABCDEFGHI";
129 int i=snprintf(buf,8,"12345678"); return !(!buf[7] && i==8); ]])],
130 [libc_have_working_snprintf=yes],
131 [libc_have_working_snprintf=no],
132 [libc_have_working_snprintf=no])
133 AC_SUBST(libc_have_working_snprintf)
134 if test "$libc_have_working_snprintf" = "yes"; then
135 AC_DEFINE(HAVE_WORKING_SNPRINTF)
136 fi
137 AC_MSG_RESULT([$libc_have_working_snprintf])
138
139 # check for __attribute__((packed))
140 AH_TEMPLATE(HAVE_ATTR_PACKED, [Define to 1 if C++ compiler supports __attribute__((packed))])
141 AC_MSG_CHECKING([whether C++ compiler supports __attribute__((packed))])
142 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[struct a { int b; } __attribute__((packed));]])],
143 [gcc_have_attr_packed=yes], [gcc_have_attr_packed=no])
144 AC_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])
148 AC_SUBST(gcc_have_attr_packed)
149 if test "$gcc_have_attr_packed" = "yes"; then
150 AC_DEFINE(HAVE_ATTR_PACKED)
151 fi
152 AC_MSG_RESULT([$gcc_have_attr_packed])
153
154 AC_SUBST(CPPFLAGS)
155 AC_SUBST(LDFLAGS)
156 AC_SUBST(ASFLAGS)
157
158 AC_SUBST([exampledir], ['${docdir}/examplescripts'])
159
160 AC_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'])
161 AC_SUBST(initddir)
162 AM_CONDITIONAL(INSTALL_INITSCRIPT, [test "$with_initscriptdir" != "no"])
163
164 AC_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}'])
165 AC_SUBST(docdir)
166
167 AC_ARG_ENABLE(drivedb, [AC_HELP_STRING([--enable-drivedb],[Enables drive database file])])
168
169 AC_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}'])
173 AC_SUBST(drivedbdir)
174 AM_CONDITIONAL(ENABLE_DRIVEDB, [test "$enable_drivedb" = "yes"])
175
176 AC_ARG_ENABLE(savestates, [AC_HELP_STRING([--enable-savestates],[Enables default smartd state files])])
177
178 AC_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.'])
182 savestatesdir="${savestates%/*}"
183 AC_SUBST(savestates)
184 AC_SUBST(savestatesdir)
185 AM_CONDITIONAL(ENABLE_SAVESTATES, [test "$enable_savestates" = "yes"])
186
187 AC_ARG_ENABLE(attributelog, [AC_HELP_STRING([--enable-attributelog],[Enables default smartd attribute log files])])
188
189 AC_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.'])
193 attributelogdir="${attributelog%/*}"
194 AC_SUBST(attributelog)
195 AC_SUBST(attributelogdir)
196 AM_CONDITIONAL(ENABLE_ATTRIBUTELOG, [test "$enable_attributelog" = "yes"])
197
198 AC_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=''])
199 AC_SUBST(smartd_suffix)
200 AM_CONDITIONAL(SMARTD_SUFFIX, test $smartd_suffix)
201
202 AC_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
212 AC_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 ],[])
217 AC_SUBST(with_selinux)
218 if test "$with_selinux" = "yes"; then
219 AC_DEFINE(WITH_SELINUX, [1], [Define to 1 if SELinux support is enabled])
220 fi
221
222 if 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
227 fi
228
229 AC_SUBST(releaseversion,['${PACKAGE}-${VERSION}'])
230 AC_SUBST(smartmontools_release_date)
231 AC_SUBST(smartmontools_release_time)
232
233 AC_MSG_CHECKING([for OS dependent modules and libraries])
234 dnl if OS not recognized, then use the os_generic modules
235 case "${host}" in
236 *-*-linux*)
237 AC_SUBST([os_deps], ['os_linux.o cciss.o'])
238 if test "$with_selinux" = "yes"; then
239 AC_SUBST([os_libs], ['-lselinux'])
240 else
241 AC_SUBST([os_libs], [''])
242 fi;;
243 *-*-freebsd*|*-*-dragonfly*|*-*-kfreebsd*-gnu*)
244 AC_SUBST([os_deps], ['os_freebsd.o cciss.o'])
245 AC_SUBST([os_libs], ['-lcam'])
246 AC_CHECK_LIB(usb, libusb20_dev_get_device_desc)
247 ;;
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']) ;;
272 *-*-nto-qnx*)
273 AC_SUBST([os_deps], ['os_qnxnto.o'])
274 AC_SUBST([os_libs], ['']) ;;
275
276 *)
277 AC_SUBST([os_deps], ['os_generic.o'])
278 AC_SUBST([os_libs], ['']) ;;
279 esac
280
281 # Replace if '--with-os-deps' was specified
282 test -z "$with_os_deps" || os_deps="$with_os_deps"
283 AC_MSG_RESULT([$os_deps $os_libs])
284
285 # Define symbols for optional functions in OS specific module
286 case "${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.]) ;;
289 esac
290 case "${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.]) ;;
293 esac
294
295 # Check if we need adapter to old interface (dev_legacy.cpp)
296 os_src=`echo "${os_deps}"|sed -n 's,^\([[^ .]]*\)\.o.*$,\1.cpp,p'`
297 AC_MSG_CHECKING([whether ${os_src} uses new interface])
298 if grep "smart_interface" "${srcdir}/${os_src}" >/dev/null 2>&1; then
299 os_new_interface=yes
300 else
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])
304 fi
305 AC_MSG_RESULT([$os_new_interface])
306
307 dnl Define platform-specific symbol.
308 AM_CONDITIONAL(OS_DARWIN, [echo $host_os | grep '^darwin' > /dev/null])
309 AM_CONDITIONAL(OS_SOLARIS, [echo $host_os | grep '^solaris' > /dev/null])
310 AM_CONDITIONAL(OS_WIN32_MINGW, [echo $host_os | grep '^mingw' > /dev/null])
311 AM_CONDITIONAL(OS_FREEBSD, [echo $host_os | grep '^freebsd' > /dev/null])
312
313 dnl Add -Wall and -W if using g++ and its not already specified.
314 if test "$GXX" = "yes"; then
315 if test -z "`echo "$CXXFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
316 CXXFLAGS="$CXXFLAGS -Wall"
317 fi
318 # In the next line, do NOT delete the 2 spaces inside double quotes.
319 if test -z "`echo "$CXXFLAGS " | grep "\-W " 2> /dev/null`" ; then
320 CXXFLAGS="$CXXFLAGS -W"
321 fi
322 case "${host}" in
323 *-*-mingw*)
324 # MinGW uses MSVCRT.DLL which uses printf format "%I64d" and not "%lld" for int64_t
325 CXXFLAGS="$CXXFLAGS -Wno-format";;
326 esac
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
342 else
343 dnl We are NOT using gcc, so enable host-specific compiler flags
344 case "${host}" in
345 sparc*-*-solaris*)
346 dnl set CXXFLAGS for Solaris/SPARC C++ compiler
347 if test -z "`echo "$CXXFLAGS" | grep "\-xmemalign" 2> /dev/null`" ; then
348 dnl we have to tell the compilers about packed ATA structures
349 CXXFLAGS="-xmemalign=1i $CXXFLAGS"
350 fi
351 esac
352 case "${host}" in
353 *-*-solaris*)
354 if test -z "`echo "$CXXFLAGS" | grep "\-xO" 2> /dev/null`" ; then
355 dnl turn on optimization if user has not explicitly set its value
356 CXXFLAGS="-xO2 $CXXFLAGS"
357 fi
358 if test -z "`echo "$CXXFLAGS" | grep "\-erroff" 2> /dev/null`" ; then
359 dnl suppress trivial warnings
360 CXXFLAGS="-erroff=%none,wbadinitl,wbadasgl,badargtypel2w,badargtype2w $CXXFLAGS"
361 fi
362 esac
363 fi
364
365 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_BUILD_HOST, "${host}", [smartmontools Build Host])
366
367 AC_SUBST(CXXFLAGS)
368
369 AC_OUTPUT(Makefile examplescripts/Makefile)
370 AC_PROG_MAKE_SET