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