]> git.proxmox.com Git - mirror_smartmontools-debian.git/blob - configure.in
Imported Upstream version 5.38+svn2879
[mirror_smartmontools-debian.git] / configure.in
1 #
2 # $Id: configure.in 2870 2009-08-02 20:38:30Z manfred99 $
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 2870 2009-08-02 20:38:30Z manfred99 $'`
11 smartmontools_release_date=2008/03/10
12 smartmontools_release_time="10:44:07 GMT"
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 CPPFLAGS="$CPPFLAGS -mno-cygwin"
38 LDFLAGS="$LDFLAGS -mno-cygwin"
39 CPPFLAGS="$CPPFLAGS -idirafter ${srcdir}/posix -idirafter ${srcdir}/os_win32"
40 ;;
41 *-*-freebsd*)
42 CPPFLAGS="$CPPFLAGS -I/usr/src/sys"
43 ;;
44 esac
45
46 # Check for SVN.
47 AC_MSG_CHECKING([whether this is a build from SVN])
48 is_svn_build=no
49 if test -f "$srcdir/.svn/entries"; then
50 is_svn_build=unknown
51 if (cd "$srcdir" && svn --version && svnversion && svn info) >/dev/null 2>&1; then
52 is_svn_build=yes
53 fi
54 fi
55 AM_CONDITIONAL(IS_SVN_BUILD, [test "$is_svn_build" = "yes"])
56 AC_MSG_RESULT([$is_svn_build])
57
58 dnl Checks for libraries needed for name services (Solaris needs
59 dnl libnsl, might in the future also need libsocket)
60 # AC_SEARCH_LIBS (FUNCTION, SEARCH-LIBS, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES])
61 AC_SEARCH_LIBS(socket, socket)
62 AC_SEARCH_LIBS(gethostbyname, nsl)
63 AC_SEARCH_LIBS(getaddrinfo, nsl)
64 AC_SEARCH_LIBS(getdomainname, nsl)
65
66 dnl Checks for header files.
67 AC_CHECK_HEADERS([locale.h])
68 AC_CHECK_HEADERS([dev/ata/atavar.h])
69 AC_CHECK_HEADERS([netdb.h])
70 dnl we need [u]int64_t and friends.
71 AC_CHECK_HEADERS([inttypes.h]) dnl C99, UNIX98, solaris 2.6+
72 AC_CHECK_HEADERS([stdint.h]) dnl C99
73 AC_CHECK_HEADERS([sys/inttypes.h]) dnl pre-UNIX98
74 AC_CHECK_HEADERS([sys/int_types.h]) dnl pre-UNIX98, solaris 2.6+
75 dnl Check for FreeBSD twe include files...currently missing on 5.2, but should be there
76 AC_CHECK_HEADERS([sys/tweio.h])
77 AC_CHECK_HEADERS([sys/twereg.h])
78 dnl Check for FreeBSD twa include files...
79 AC_CHECK_HEADERS([sys/tw_osl_ioctl.h])
80 dnl Check for FreeBSD ciss include files...
81 AC_CHECK_HEADERS([dev/ciss/cissio.h])
82 dnl This header file is needed for cciss_ioctl.h at least on SuSE LINUX
83 AC_CHECK_HEADERS([linux/compiler.h])
84 dnl Check for Linux CCISS include file
85 AC_CHECK_HEADERS([linux/cciss_ioctl.h], [], [], [AC_INCLUDES_DEFAULT
86 #ifdef HAVE_LINUX_COMPILER_H
87 # include <linux/compiler.h>
88 #endif
89 ])
90
91 dnl Checks for typedefs, structures, and compiler characteristics.
92 AC_CHECK_TYPES([int64_t, uint64_t])
93
94 dnl Checks for library functions.
95 AC_CHECK_FUNCS([getopt_long], , [
96 AC_MSG_NOTICE([smartmontools does no longer support platforms without getopt_long().])
97 AC_MSG_NOTICE([Please inform ${PACKAGE_BUGREPORT},])
98 AC_MSG_NOTICE([including details about your build environment.])
99 AC_MSG_ERROR([function getopt_long() not found])
100 ])
101
102 AC_CHECK_FUNCS([getdomainname])
103 AC_CHECK_FUNCS([gethostname])
104 AC_CHECK_FUNCS([getaddrinfo])
105 AC_CHECK_FUNCS([gethostbyname])
106 AC_CHECK_FUNCS([sigset])
107 AC_CHECK_FUNCS([strtoull])
108 AC_CHECK_FUNCS([uname])
109
110 # Check whether snprintf appends null char and returns expected length on overflow
111 AH_TEMPLATE(HAVE_WORKING_SNPRINTF, [Define to 1 if the `snprintf' function is sane])
112 AC_MSG_CHECKING([for working snprintf])
113 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[ char buf[]="ABCDEFGHI";
114 int i=snprintf(buf,8,"12345678"); return !(!buf[7] && i==8); ]])],
115 [libc_have_working_snprintf=yes],
116 [libc_have_working_snprintf=no],
117 [libc_have_working_snprintf=no])
118 AC_SUBST(libc_have_working_snprintf)
119 if test "$libc_have_working_snprintf" = "yes"; then
120 AC_DEFINE(HAVE_WORKING_SNPRINTF)
121 fi
122 AC_MSG_RESULT([$libc_have_working_snprintf])
123
124 # check for __attribute__((packed))
125 AH_TEMPLATE(HAVE_ATTR_PACKED, [Define to 1 if C++ compiler supports __attribute__((packed))])
126 AC_MSG_CHECKING([whether C++ compiler supports __attribute__((packed))])
127 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[struct a { int b; } __attribute__((packed));]])],
128 [gcc_have_attr_packed=yes], [gcc_have_attr_packed=no])
129 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
130 #error "Sun's compiler cannot handle __attribute__((packed))!"
131 #endif]])],
132 [true], [gcc_have_attr_packed=no])
133 AC_SUBST(gcc_have_attr_packed)
134 if test "$gcc_have_attr_packed" = "yes"; then
135 AC_DEFINE(HAVE_ATTR_PACKED)
136 fi
137 AC_MSG_RESULT([$gcc_have_attr_packed])
138
139 AC_SUBST(CPPFLAGS)
140 AC_SUBST(LDFLAGS)
141 AC_SUBST(ASFLAGS)
142
143 AC_SUBST([exampledir], ['${docdir}/examplescripts'])
144
145 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'])
146 AC_SUBST(initddir)
147 AM_CONDITIONAL(INSTALL_INITSCRIPT, [test "$with_initscriptdir" != "no"])
148
149 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}'])
150 AC_SUBST(docdir)
151
152 AC_ARG_ENABLE(drivedb, [AC_HELP_STRING([--enable-drivedb],[Enables drive database file])])
153
154 AC_ARG_WITH(drivedbdir,
155 [AC_HELP_STRING([--with-drivedbdir=DIR],[Location of drive database file (implies --enable-drivedb) [DATADIR/smartmontools]])],
156 [drivedbdir="$withval"; enable_drivedb="yes"],
157 [drivedbdir=; test "$enable_drivedb" = "yes" && drivedbdir='${datadir}/${PACKAGE}'])
158 AC_SUBST(drivedbdir)
159 AM_CONDITIONAL(ENABLE_DRIVEDB, [test "$enable_drivedb" = "yes"])
160
161 AC_ARG_ENABLE(savestates, [AC_HELP_STRING([--enable-savestates],[Enables default smartd state files])])
162
163 AC_ARG_WITH(savestates,
164 [AC_HELP_STRING([--with-savestates=PREFIX],[Prefix for default smartd state files (implies --enable-savestates) [LOCALSTATEDIR/lib/smartmontools/smartd.]])],
165 [savestates="$withval"; enable_savestates="yes"],
166 [savestates=; test "$enable_savestates" = "yes" && savestates='${localstatedir}/lib/${PACKAGE}/smartd.'])
167 savestatesdir="${savestates%/*}"
168 AC_SUBST(savestates)
169 AC_SUBST(savestatesdir)
170 AM_CONDITIONAL(ENABLE_SAVESTATES, [test "$enable_savestates" = "yes"])
171
172 AC_ARG_ENABLE(attributelog, [AC_HELP_STRING([--enable-attributelog],[Enables default smartd attribute log files])])
173
174 AC_ARG_WITH(attributelog,
175 [AC_HELP_STRING([--with-attributelog=PREFIX],[Prefix for default smartd attribute log files (implies --enable-attributelog) [LOCALSTATEDIR/lib/smartmontools/attrlog.]])],
176 [attributelog="$withval"; enable_attributelog="yes"],
177 [attributelog=; test "$enable_attributelog" = "yes" && attributelog='${localstatedir}/lib/${PACKAGE}/attrlog.'])
178 attributelogdir="${attributelog%/*}"
179 AC_SUBST(attributelog)
180 AC_SUBST(attributelogdir)
181 AM_CONDITIONAL(ENABLE_ATTRIBUTELOG, [test "$enable_attributelog" = "yes"])
182
183 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=''])
184 AC_SUBST(smartd_suffix)
185 AM_CONDITIONAL(SMARTD_SUFFIX, test $smartd_suffix)
186
187 AC_ARG_WITH(os-deps,
188 [AC_HELP_STRING([--with-os-deps='os_module.o ...'],[Specify OS dependent module(s) [guessed]])],
189 [ for x in $with_os_deps; do
190 case $x in
191 *.o) ;;
192 *) AC_MSG_ERROR([non-object file specified by --with-os-deps]) ;;
193 esac
194 done
195 ],[])
196
197 AC_ARG_WITH(selinux,[AC_HELP_STRING([--with-selinux],[Enables SELinux support])],
198 [
199 AC_CHECK_HEADERS([selinux/selinux.h], [], [echo "*** Error: Missing SELinux header files";exit 1])
200 AC_CHECK_LIB(selinux, matchpathcon, [with_selinux=yes], [echo "*** Error: Missing or incorrect SELinux library files"; exit 1],)
201 ],[])
202 AC_SUBST(with_selinux)
203 if test "$with_selinux" = "yes"; then
204 AC_DEFINE(WITH_SELINUX, [1], [Define to 1 if SELinux support is enabled])
205 fi
206
207 if test "$prefix" = "NONE"; then
208 dnl no prefix and no mandir, so use ${prefix}/share/man as default
209 if test "$mandir" = '${prefix}/man'; then
210 AC_SUBST([mandir], ['${prefix}/share/man'])
211 fi
212 fi
213
214 AC_SUBST(releaseversion,['${PACKAGE}-${VERSION}'])
215 AC_SUBST(smartmontools_release_date)
216 AC_SUBST(smartmontools_release_time)
217
218 AC_MSG_CHECKING([for OS dependent modules and libraries])
219 dnl if OS not recognized, then use the os_generic modules
220 case "${host}" in
221 *-*-linux*)
222 AC_SUBST([os_deps], ['os_linux.o cciss.o'])
223 if test "$with_selinux" = "yes"; then
224 AC_SUBST([os_libs], ['-lselinux'])
225 else
226 AC_SUBST([os_libs], [''])
227 fi;;
228 *-*-freebsd*|*-*-dragonfly*|*-*-kfreebsd*-gnu*)
229 AC_SUBST([os_deps], ['os_freebsd.o cciss.o'])
230 AC_SUBST([os_libs], ['-lcam']);;
231 sparc-*-solaris*)
232 AC_DEFINE_UNQUOTED(DEFAULT_MAILER, "mailx", [use mailx as default mailer])
233 AC_DEFINE_UNQUOTED(NEED_SOLARIS_ATA_CODE, "os_solaris_ata.s", [need assembly code os_solaris_ata.s])
234 AC_SUBST([os_deps], ['os_solaris.o os_solaris_ata.o'])
235 AC_SUBST([os_libs], ['']) ;;
236 *-pc-solaris*)
237 AC_DEFINE_UNQUOTED(DEFAULT_MAILER, "mailx", [use mailx as default mailer])
238 AC_SUBST([os_deps], ['os_solaris.o'])
239 AC_SUBST([os_libs], ['']) ;;
240 *-*-netbsd*)
241 AC_SUBST([os_deps], ['os_netbsd.o'])
242 AC_SUBST([os_libs], ['-lutil']) ;;
243 *-*-openbsd*)
244 AC_SUBST([os_deps], ['os_openbsd.o'])
245 AC_SUBST([os_libs], ['-lutil']) ;;
246 *-*-cygwin*)
247 AC_SUBST([os_deps], ['os_win32.o'])
248 AC_SUBST([os_libs], ['']) ;;
249 *-*-mingw*)
250 AC_SUBST([os_deps], ['os_win32.o'])
251 AC_SUBST([os_libs], ['']) ;;
252 *-*-darwin*)
253 AC_SUBST([os_deps], ['os_darwin.o'])
254 AC_SUBST([os_libs], ['-framework CoreFoundation -framework IOKit']) ;;
255 *-*-nto-qnx*)
256 AC_SUBST([os_deps], ['os_qnxnto.o'])
257 AC_SUBST([os_libs], ['']) ;;
258
259 *)
260 AC_SUBST([os_deps], ['os_generic.o'])
261 AC_SUBST([os_libs], ['']) ;;
262 esac
263
264 # Replace if '--with-os-deps' was specified
265 test -z "$with_os_deps" || os_deps="$with_os_deps"
266 AC_MSG_RESULT([$os_deps $os_libs])
267
268 # Define symbols for optional functions in OS specific module
269 case "${os_deps}" in
270 os_win32*)
271 AC_DEFINE(HAVE_ATA_IDENTIFY_IS_CACHED, 1, [Define to 1 if you have the `ata_identify_is_cached' function in os_*.c.]) ;;
272 esac
273 case "${os_deps}" in
274 os_win32*)
275 AC_DEFINE(HAVE_GET_OS_VERSION_STR, 1, [Define to 1 if you have the `get_os_version_str' function in os_*.c.]) ;;
276 esac
277
278 # Check if we need adapter to old interface (dev_legacy.cpp)
279 os_src=`echo "${os_deps}"|sed -n 's,^\([[^ .]]*\)\.o.*$,\1.cpp,p'`
280 AC_MSG_CHECKING([whether ${os_src} uses new interface])
281 if grep "smart_interface" "${srcdir}/${os_src}" >/dev/null 2>&1; then
282 os_new_interface=yes
283 else
284 os_new_interface=no
285 os_deps="${os_deps} dev_legacy.o"
286 AC_DEFINE(OLD_INTERFACE, 1, [Define to 1 if os_*.cpp still uses the old interface])
287 fi
288 AC_MSG_RESULT([$os_new_interface])
289
290 dnl Define platform-specific symbol.
291 AM_CONDITIONAL(OS_DARWIN, [echo $host_os | grep '^darwin' > /dev/null])
292 AM_CONDITIONAL(OS_SOLARIS, [echo $host_os | grep '^solaris' > /dev/null])
293 AM_CONDITIONAL(OS_WIN32_MINGW, [echo $host_os | grep '^mingw' > /dev/null])
294 AM_CONDITIONAL(OS_FREEBSD, [echo $host_os | grep '^freebsd' > /dev/null])
295
296 dnl Add -Wall and -W if using gcc and its not already specified.
297 if test "x$GCC" = "xyes"; then
298 if test -z "`echo "$CXXFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
299 CXXFLAGS="$CXXFLAGS -Wall"
300 fi
301 # In the next line, do NOT delete the 2 spaces inside double quotes.
302 if test -z "`echo "$CXXFLAGS " | grep "\-W " 2> /dev/null`" ; then
303 CXXFLAGS="$CXXFLAGS -W"
304 fi
305 case "${host}" in
306 *-*-mingw*)
307 # MinGW uses MSVCRT.DLL which uses printf format "%I64d" and not "%lld" for int64_t
308 CXXFLAGS="$CXXFLAGS -Wno-format";;
309 esac
310 else
311 dnl We are NOT using gcc, so enable host-specific compiler flags
312 case "${host}" in
313 sparc*-*-solaris*)
314 dnl set CXXFLAGS for Solaris/SPARC C++ compiler
315 if test -z "`echo "$CXXFLAGS" | grep "\-xmemalign" 2> /dev/null`" ; then
316 dnl we have to tell the compilers about packed ATA structures
317 CXXFLAGS="-xmemalign=1i $CXXFLAGS"
318 fi
319 esac
320 case "${host}" in
321 *-*-solaris*)
322 if test -z "`echo "$CXXFLAGS" | grep "\-xO" 2> /dev/null`" ; then
323 dnl turn on optimization if user has not explicitly set its value
324 CXXFLAGS="-xO2 $CXXFLAGS"
325 fi
326 if test -z "`echo "$CXXFLAGS" | grep "\-erroff" 2> /dev/null`" ; then
327 dnl suppress trivial warnings
328 CXXFLAGS="-erroff=%none,wbadinitl,wbadasgl,badargtypel2w,badargtype2w $CXXFLAGS"
329 fi
330 esac
331 fi
332
333 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_BUILD_HOST, "${host}", [smartmontools Build Host])
334
335 AC_SUBST(CXXFLAGS)
336
337 AC_OUTPUT(Makefile examplescripts/Makefile)
338 AC_PROG_MAKE_SET