]> git.proxmox.com Git - mirror_smartmontools-debian.git/blob - configure.in
import upstream version 5.36
[mirror_smartmontools-debian.git] / configure.in
1 #
2 # $Id: configure.in,v 1.114 2006/04/12 17:39:32 ballen4705 Exp $
3 #
4 dnl Process this file with autoconf to produce a configure script.
5 AC_PREREQ(2.50)
6 AC_INIT(smartmontools, 5.36, smartmontools-support@lists.sourceforge.net)
7 AC_CONFIG_SRCDIR(smartctl.c)
8
9 smartmontools_configure_date=`date -u +"%Y/%m/%d %T %Z"`
10 smartmontools_cvs_tag=`echo '$Id: configure.in,v 1.114 2006/04/12 17:39:32 ballen4705 Exp $'`
11 smartmontools_release_date=2006/04/12
12 smartmontools_release_time="17:39:01 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_C
28 dnl Checks for programs.
29 AC_PROG_CC
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 esac
41
42 dnl Checks for libraries.needed for gethostbyname (Solaris needs
43 dnl libnsl, might in the future also need libsocket)
44 # AC_SEARCH_LIBS (FUNCTION, SEARCH-LIBS, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES])
45 AC_SEARCH_LIBS(gethostbyname, nsl, , AC_SEARCH_LIBS(gethostbyname, nsl, , , -lsocket), , )
46
47 dnl Checks for header files.
48 AC_CHECK_HEADERS([locale.h])
49 AC_CHECK_HEADERS([getopt.h])
50 AC_CHECK_HEADERS([dev/ata/atavar.h])
51 AC_CHECK_HEADERS([netdb.h])
52 dnl we need [u]int64_t and friends.
53 AC_CHECK_HEADERS([inttypes.h]) dnl C99, UNIX98, solaris 2.6+
54 AC_CHECK_HEADERS([stdint.h]) dnl C99
55 AC_CHECK_HEADERS([sys/inttypes.h]) dnl pre-UNIX98
56 AC_CHECK_HEADERS([sys/int_types.h]) dnl pre-UNIX98, solaris 2.6+
57 dnl Check for FreeBSD twe include files...currently missing on 5.2, but should be there
58 AC_CHECK_HEADERS([sys/tweio.h])
59 AC_CHECK_HEADERS([sys/twereg.h])
60 dnl Check for FreeBSD twa include files...
61 AC_CHECK_HEADERS([sys/tw_osl_ioctl.h])
62
63 dnl Checks for typedefs, structures, and compiler characteristics.
64 AC_CHECK_TYPES([int64_t, uint64_t])
65
66 dnl Checks for library functions.
67 AC_CHECK_FUNCS([getopt])
68 AC_CHECK_FUNCS([getopt_long])
69 AC_CHECK_FUNCS([getdomainname])
70 AC_CHECK_FUNCS([gethostname])
71 AC_CHECK_FUNCS([gethostbyname])
72 AC_CHECK_FUNCS([sigset])
73 AC_CHECK_FUNCS([strtoull])
74 AC_CHECK_FUNCS([uname])
75
76 # Check whether snprintf appends null char and returns expected length on overflow
77 AH_TEMPLATE(HAVE_WORKING_SNPRINTF, [Define to 1 if the `snprintf' function is sane])
78 AC_MSG_CHECKING([for working snprintf])
79 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[ char buf[]="ABCDEFGHI";
80 int i=snprintf(buf,8,"12345678"); return !(!buf[7] && i==8); ]])],
81 [libc_have_working_snprintf=yes], [libc_have_working_snprintf=no])
82 AC_SUBST(libc_have_working_snprintf)
83 if test "$libc_have_working_snprintf" = "yes"; then
84 AC_DEFINE(HAVE_WORKING_SNPRINTF)
85 fi
86 AC_MSG_RESULT([$libc_have_working_snprintf])
87
88 # check for __attribute__((packed))
89 AH_TEMPLATE(HAVE_ATTR_PACKED, [Define to 1 if C compiler supports __attribute__((packed))])
90 AC_MSG_CHECKING([whether C compiler supports __attribute__((packed))])
91 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[struct a { int b; } __attribute__((packed));]])],
92 [gcc_have_attr_packed=yes], [gcc_have_attr_packed=no])
93 AC_SUBST(gcc_have_attr_packed)
94 if test "$gcc_have_attr_packed" = "yes"; then
95 AC_DEFINE(HAVE_ATTR_PACKED)
96 fi
97 AC_MSG_RESULT([$gcc_have_attr_packed])
98
99 AC_SUBST(CPPFLAGS)
100 AC_SUBST(LDFLAGS)
101 AC_SUBST(ASFLAGS)
102
103 AC_SUBST([exampledir], ['${docdir}/examplescripts'])
104
105 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'])
106 AC_SUBST(initddir)
107
108 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}'])
109 AC_SUBST(docdir)
110
111 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=''])
112 AC_SUBST(smartd_suffix)
113 AM_CONDITIONAL(SMARTD_SUFFIX, test $smartd_suffix)
114
115 if test "$prefix" = "NONE"; then
116 dnl no prefix and no mandir, so use ${prefix}/share/man as default
117 if test "$mandir" = '${prefix}/man'; then
118 AC_SUBST([mandir], ['${prefix}/share/man'])
119 fi
120 fi
121
122 AC_SUBST(releaseversion,['${PACKAGE}-${VERSION}'])
123 AC_SUBST(smartmontools_release_date)
124 AC_SUBST(smartmontools_release_time)
125
126 dnl if OS not recognized, then use the os_generic modules
127 case "${host}" in
128 *-*-linux-gnu*)
129 AC_SUBST([os_deps], ['os_linux.o'])
130 AC_SUBST([os_libs], ['']) ;;
131 *-*-linux*)
132 AC_SUBST([os_deps], ['os_linux.o'])
133 AC_SUBST([os_libs], ['']) ;;
134 *-*-freebsd*)
135 AC_SUBST([os_deps], ['os_freebsd.o'])
136 AC_SUBST([os_libs], ['-lcam']);;
137 sparc-*-solaris*)
138 AC_DEFINE_UNQUOTED(DEFAULT_MAILER, "mailx", [use mailx as default mailer])
139 AC_DEFINE_UNQUOTED(NEED_SOLARIS_ATA_CODE, "os_solaris_ata.s", [need assembly code os_solaris_ata.s])
140 AC_SUBST([os_deps], ['os_solaris.o os_solaris_ata.o'])
141 AC_SUBST([os_libs], ['']) ;;
142 *-pc-solaris*)
143 AC_DEFINE_UNQUOTED(DEFAULT_MAILER, "mailx", [use mailx as default mailer])
144 AC_SUBST([os_deps], ['os_solaris.o'])
145 AC_SUBST([os_libs], ['']) ;;
146 *-*-netbsd*)
147 AC_SUBST([os_deps], ['os_netbsd.o'])
148 AC_SUBST([os_libs], ['-lutil']) ;;
149 *-*-openbsd*)
150 AC_SUBST([os_deps], ['os_openbsd.o'])
151 AC_SUBST([os_libs], ['-lutil']) ;;
152 *-*-cygwin*)
153 AC_SUBST([os_deps], ['os_win32.o'])
154 AC_SUBST([os_libs], ['']) ;;
155 *-*-mingw*)
156 AC_SUBST([os_deps], ['os_win32.o'])
157 AC_SUBST([os_libs], ['']) ;;
158 *-*-darwin*)
159 AC_SUBST([os_deps], ['os_darwin.o'])
160 AC_SUBST([os_libs], ['-framework CoreFoundation -framework IOKit']) ;;
161 *)
162 AC_SUBST([os_deps], ['os_generic.o'])
163 AC_SUBST([os_libs], ['']) ;;
164 esac
165
166 # Define symbols for optional functions in OS specific module
167 case "${os_deps}" in
168 os_win32*)
169 AC_DEFINE(HAVE_ATA_IDENTIFY_IS_CACHED, 1, [Define to 1 if you have the `ata_identify_is_cached' function in os_*.c.]) ;;
170 esac
171 case "${os_deps}" in
172 os_win32*)
173 AC_DEFINE(HAVE_GET_OS_VERSION_STR, 1, [Define to 1 if you have the `get_os_version_str' function in os_*.c.]) ;;
174 esac
175
176 dnl Define platform-specific symbol.
177 AM_CONDITIONAL(OS_DARWIN, [echo $host_os | grep '^darwin' > /dev/null])
178 AM_CONDITIONAL(OS_SOLARIS, [echo $host_os | grep '^solaris' > /dev/null])
179 AM_CONDITIONAL(OS_WIN32_MINGW, [echo $host_os | grep '^mingw' > /dev/null])
180
181 dnl Add -Wall and -W if using gcc and its not already specified.
182 if test "x$GCC" = "xyes"; then
183 if test -z "`echo "$CFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
184 CFLAGS="$CFLAGS -Wall"
185 fi
186 # In the next line, do NOT delete the 2 spaces inside double quotes.
187 if test -z "`echo "$CFLAGS " | grep "\-W " 2> /dev/null`" ; then
188 CFLAGS="$CFLAGS -W"
189 fi
190 case "${host}" in
191 *-*-mingw*)
192 # MinGW uses MSVCRT.DLL which uses printf format "%I64d" and not "%lld" for int64_t
193 CFLAGS="$CFLAGS -Wno-format";;
194 esac
195 else
196 dnl We are NOT using gcc, so enable host-specific compiler flags
197 case "${host}" in
198 *-*-solaris*)
199 dnl set CFLAGS for Solaris C compiler
200 if test -z "`echo "$CFLAGS" | grep "\-xmemalign" 2> /dev/null`" ; then
201 dnl we have to tell the compilers about packed ATA structures
202 CFLAGS="-xmemalign=1i $CFLAGS"
203 fi
204 if test -z "`echo "$CFLAGS" | grep "\-xCC" 2> /dev/null`" ; then
205 dnl we have to tell the compiler to ignore C++ style comments
206 CFLAGS="-xCC $CFLAGS"
207 fi
208 if test -z "`echo "$CFLAGS" | grep "\-xO" 2> /dev/null`" ; then
209 dnl turn on optimization if user has not explicitly set its value
210 CFLAGS="-xO2 $CFLAGS"
211 fi
212 esac
213 fi
214
215 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_BUILD_HOST, "${host}", [smartmontools Build Host])
216
217 AC_SUBST(CFLAGS)
218
219 AC_OUTPUT(Makefile examplescripts/Makefile)
220 AC_PROG_MAKE_SET