source: box/invisnet/configure.ac @ 2719

Revision 2719, 13.1 KB checked in by chris, 21 months ago (diff)

Log which features are enabled in a file for future reference during
testing.

  • Property svn:eol-style set to native
Line 
1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ(2.59)
5AC_INIT([Box Backup], 0.11, [boxbackup@boxbackup.org])
6AC_CONFIG_SRCDIR([lib/common/Box.h])
7AC_CONFIG_HEADERS([lib/common/BoxConfig.h])
8
9touch install-sh
10AC_CANONICAL_SYSTEM
11test -s install-sh || rm install-sh
12
13### Checks for programs.
14
15AC_LANG([C++])
16AC_PROG_CC
17AC_PROG_CXX
18AC_CXX_EXCEPTIONS
19AC_CXX_NAMESPACES
20if test "x$ac_cv_cxx_exceptions" != "xyes" || \
21   test "x$ac_cv_cxx_namespaces" != "xyes"; then
22  AC_MSG_ERROR([[basic compile checks failed, the C++ compiler is broken]])
23fi
24
25if test "x$GXX" = "xyes"; then
26  # Use -Wall if we have gcc. This gives better warnings
27  AC_SUBST([CXXFLAGS_STRICT], ['-Wall -Wundef'])
28
29  # Use -rdynamic if we have gcc, but not mingw. This is needed for backtrace
30  case $target_os in
31    mingw*) ;;
32    *) AC_SUBST([LDADD_RDYNAMIC], ['-rdynamic']) ;;
33  esac
34fi
35
36AC_PATH_PROG([PERL], [perl], [AC_MSG_ERROR([[perl executable was not found]])])
37
38case $target_os in
39mingw*)
40        TARGET_PERL=perl
41        ;;
42*)
43        TARGET_PERL=$PERL
44        ;;
45esac
46
47AC_SUBST([TARGET_PERL])
48AC_DEFINE_UNQUOTED([PERL_EXECUTABLE], ["$TARGET_PERL"],
49        [Location of the perl executable])
50
51AC_CHECK_TOOL([AR],     [ar],   
52        [AC_MSG_ERROR([[cannot find ar executable]])])
53AC_CHECK_TOOL([RANLIB], [ranlib],
54        [AC_MSG_ERROR([[cannot find ranlib executable]])])
55
56case $target_os in
57mingw*)
58        AC_CHECK_TOOL([WINDRES], [windres],
59                [AC_MSG_ERROR([[cannot find windres executable]])])
60        ;;
61esac
62
63### Checks for libraries.
64
65case $target_os in
66mingw32*) ;;
67winnt)    ;;
68*)
69  AC_SEARCH_LIBS([nanosleep], [rt], [ac_have_nanosleep=yes],
70                 [AC_MSG_ERROR([[cannot find a short sleep function (nanosleep)]])])
71        ;;
72esac
73
74AC_CHECK_HEADER([zlib.h],, [AC_MSG_ERROR([[cannot find zlib.h]])])
75AC_CHECK_LIB([z], [zlibVersion],, [AC_MSG_ERROR([[cannot find zlib]])])
76VL_LIB_READLINE([have_libreadline=yes], [have_libreadline=no])
77
78## Check for Berkely DB. Restrict to certain versions
79AX_PATH_BDB([1.x or 4.1], [
80  LIBS="$BDB_LIBS $LIBS"
81  LDFLAGS="$BDB_LDFLAGS $LDFLAGS"
82  CPPFLAGS="$CPPFLAGS $BDB_CPPFLAGS"
83
84  AX_COMPARE_VERSION([$BDB_VERSION],[ge],[4.1],,
85    [AX_COMPARE_VERSION([$BDB_VERSION],[lt],[2],,
86      [AC_MSG_ERROR([[only Berkely DB versions 1.x or at least 4.1 are currently supported]])]
87      )]
88  )
89  AX_SPLIT_VERSION([BDB_VERSION], [$BDB_VERSION])
90])
91
92## Check for Open SSL, use old versions only if explicitly requested
93AC_SEARCH_LIBS([gethostbyname], [nsl socket resolv])
94AC_SEARCH_LIBS([shutdown], [nsl socket resolv])
95AX_CHECK_SSL(, [AC_MSG_ERROR([[OpenSSL is not installed but is required]])])
96AC_ARG_ENABLE(
97  [old-ssl],
98  [AC_HELP_STRING([--enable-old-ssl],
99                  [Allow use of pre-0.9.7 Open SSL - NOT RECOMMENDED, read the documentation])])
100AC_CHECK_LIB(
101  [crypto],
102  [EVP_CipherInit_ex],, [
103  if test "x$enable_old_ssl" = "xyes"; then
104    AC_DEFINE([HAVE_OLD_SSL], 1, [Define to 1 if SSL is pre-0.9.7])
105  else
106    AC_MSG_ERROR([[found an old (pre 0.9.7) version of SSL.
107Upgrade or read the documentation for alternatives]])
108  fi
109  ])
110
111
112### Checks for header files.
113
114case $target_os in
115mingw32*) ;;
116winnt*)   ;;
117*)
118  AC_HEADER_DIRENT
119  ;;
120esac
121
122AC_HEADER_STDC
123AC_HEADER_SYS_WAIT
124AC_CHECK_HEADERS([dlfcn.h execinfo.h getopt.h process.h pwd.h signal.h])
125AC_CHECK_HEADERS([syslog.h time.h cxxabi.h])
126AC_CHECK_HEADERS([netinet/in.h])
127AC_CHECK_HEADERS([sys/param.h sys/socket.h sys/time.h sys/types.h sys/wait.h])
128AC_CHECK_HEADERS([sys/uio.h sys/xattr.h])
129
130AC_CHECK_HEADER([regex.h], [have_regex_h=yes])
131
132if test "$have_regex_h" = "yes"; then
133  AC_DEFINE([HAVE_REGEX_H], [1], [Define to 1 if regex.h is available])
134else
135  AC_CHECK_HEADER([pcreposix.h], [have_pcreposix_h=yes])
136fi
137
138if test "$have_pcreposix_h" = "yes"; then
139  AC_DEFINE([PCRE_STATIC], [1], [Box Backup always uses static PCRE])
140  AC_SEARCH_LIBS([regcomp], ["pcreposix -lpcre"],,[have_pcreposix_h=no_regcomp])
141fi
142
143if test "$have_pcreposix_h" = "yes"; then
144  AC_DEFINE([HAVE_PCREPOSIX_H], [1], [Define to 1 if pcreposix.h is available])
145fi
146
147if test "$have_regex_h" = "yes" -o "$have_pcreposix_h" = "yes"; then
148  have_regex_support=yes
149  AC_DEFINE([HAVE_REGEX_SUPPORT], [1], [Define to 1 if regular expressions are supported])
150else
151  have_regex_support=no
152fi
153
154AC_SEARCH_LIBS([dlsym], ["dl"])
155
156### Checks for typedefs, structures, and compiler characteristics.
157
158AC_CHECK_TYPES([u_int8_t, u_int16_t, u_int32_t, u_int64_t])
159AC_CHECK_TYPES([uint8_t, uint16_t, uint32_t, uint64_t])
160
161AC_HEADER_STDBOOL
162AC_C_CONST
163AC_C_BIGENDIAN
164AC_TYPE_UID_T
165AC_TYPE_MODE_T
166AC_TYPE_OFF_T
167AC_TYPE_PID_T
168AC_TYPE_SIZE_T
169
170AC_CHECK_MEMBERS([struct stat.st_flags])
171AC_CHECK_MEMBERS([struct stat.st_mtimespec])
172AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec])
173AC_CHECK_MEMBERS([struct stat.st_atimensec])
174AC_CHECK_MEMBERS([struct sockaddr_in.sin_len],,, [[
175  #include <sys/types.h>
176  #include <netinet/in.h>
177  ]])
178AC_CHECK_MEMBERS([DIR.d_fd],,,  [[#include <dirent.h>]])
179AC_CHECK_MEMBERS([DIR.dd_fd],,, [[#include <dirent.h>]])
180
181AC_CHECK_DECLS([INFTIM],,, [[#include <poll.h>]])
182AC_CHECK_DECLS([SO_PEERCRED],,, [[#include <sys/socket.h>]])
183AC_CHECK_DECLS([O_BINARY],,,)
184
185# Solaris provides getpeerucred() instead of getpeereid() or SO_PEERCRED
186AC_CHECK_HEADERS([ucred.h])
187AC_CHECK_FUNCS([getpeerucred])
188
189AC_CHECK_DECLS([optreset],,, [[#include <getopt.h>]])
190AC_CHECK_DECLS([dirfd],,,
191        [[
192                #include <getopt.h>
193                #include <dirent.h>
194        ]])
195
196AC_HEADER_TIME
197AC_STRUCT_TM
198AX_CHECK_DIRENT_D_TYPE
199AC_SYS_LARGEFILE
200AX_CHECK_DEFINE_PRAGMA
201if test "x$ac_cv_c_bigendian" != "xyes"; then
202  AX_BSWAP64
203fi
204
205case $target_os in
206mingw32*) ;;
207winnt*)   ;;
208*)
209  AX_RANDOM_DEVICE
210  AX_CHECK_MOUNT_POINT(,[
211    AC_MSG_ERROR([[cannot work out how to discover mount points on your platform]])
212  ])
213  AC_CHECK_MEMBERS([struct dirent.d_ino],,, [[#include <dirent.h>]])
214;;
215esac
216
217AX_CHECK_MALLOC_WORKAROUND
218
219
220### Checks for library functions.
221
222AC_FUNC_CLOSEDIR_VOID
223AC_FUNC_ERROR_AT_LINE
224AC_TYPE_SIGNAL
225AC_FUNC_STAT
226AC_CHECK_FUNCS([getpeereid lchown setproctitle getpid gettimeofday waitpid])
227
228# NetBSD implements kqueue too differently for us to get it fixed by 0.10
229# TODO: Remove this when NetBSD kqueue implementation is working
230netbsd_hack=`echo $target_os | sed 's/netbsd.*/netbsd/'`
231if test "$netbsd_hack" != "netbsd"; then
232  AC_CHECK_FUNCS([kqueue])
233fi
234
235AX_FUNC_SYSCALL
236AX_CHECK_SYSCALL_LSEEK
237AC_CHECK_FUNCS([listxattr llistxattr getxattr lgetxattr setxattr lsetxattr])
238AC_CHECK_DECLS([XATTR_NOFOLLOW],,, [[#include <sys/xattr.h>]])
239
240
241### Miscellaneous complicated feature checks
242
243## Check for large file support active. AC_SYS_LARGEFILE has already worked
244## out how to enable it if necessary, we just use this to report to the user
245AC_CACHE_CHECK([if we have large file support enabled],
246  [box_cv_have_large_file_support],
247  [AC_TRY_RUN([
248    $ac_includes_default
249    int main()
250    {
251      return sizeof(off_t)==4;
252    }
253    ],
254    [box_cv_have_large_file_support=yes],
255    [box_cv_have_large_file_support=no],
256    [box_cv_have_large_file_support=no # safe for cross-compile]
257    )
258  ])
259
260if test "x$box_cv_have_large_file_support" = "xyes"; then
261        AC_DEFINE([HAVE_LARGE_FILE_SUPPORT], [1],
262                [Define to 1 if large files are supported])
263fi
264
265## Find out how to do file locking
266AC_CHECK_FUNCS([flock])
267AC_CHECK_DECLS([O_EXLOCK],,, [[#include <fcntl.h>]])
268AC_CHECK_DECLS([F_SETLK],,, [[#include <fcntl.h>]])
269
270case $target_os in
271mingw32*) ;;
272winnt*)   ;;
273*)
274if test "x$ac_cv_func_flock" != "xyes" && \
275   test "x$ac_cv_have_decl_O_EXLOCK" != "xyes" && \
276   test "x$ac_cv_have_decl_F_SETLK" != "xyes"
277then
278  AC_MSG_ERROR([[cannot work out how to do file locking on your platform]])
279fi
280;;
281esac
282
283## Get tmpdir
284temp_directory_name="/tmp"
285AC_ARG_WITH(
286  [tmp-dir],
287  [AC_HELP_STRING([--with-tmp-dir=DIR], [Directory for temporary files [/tmp]])],
288  [temp_directory_name="$withval"])
289AC_DEFINE_UNQUOTED([TEMP_DIRECTORY_NAME], ["$temp_directory_name"], [TMP directory name])
290
291## Allow linking binaries with static libraries
292AC_ARG_ENABLE(
293  [static-bin],
294  [AC_HELP_STRING([--enable-static-bin], [Link binaries with static libraries])])
295if test "x$enable_static_bin" = "xyes"; then
296  AC_CHECK_LIB([ssl],[SSL_read],,, [crypto])
297  LIBS="-Wl,-Bstatic $LIBS -Wl,-Bdynamic"
298fi
299
300# override default sysconfdir, for backwards compatibility
301test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc
302test "$localstatedir" = '${prefix}/var' && localstatedir=/var
303
304## Kludge to allow makeparcels.pl to use bindir. This is not a good long term
305## solution because it prevents use of "make exec_prefix=/some/dir"
306saved_prefix=$prefix
307saved_exec_prefix=$exec_prefix
308test "x$prefix" = xNONE && prefix=$ac_default_prefix
309test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
310eval bindir_expanded=`       eval "echo $bindir"`
311eval sbindir_expanded=`      eval "echo $sbindir"`
312eval sysconfdir_expanded=`   eval "echo $sysconfdir"`
313eval localstatedir_expanded=`eval "echo $localstatedir"`
314prefix=$saved_prefix
315exec_prefix=$saved_exec_prefix
316AC_SUBST([bindir_expanded])
317AC_SUBST([sbindir_expanded])
318AC_SUBST([sysconfdir_expanded])
319AC_SUBST([localstatedir_expanded])
320
321## Figure out the client parcel directory and substitute it
322build_dir=`dirname $0`
323build_dir=`cd $build_dir && pwd`
324client_parcel_dir=`$PERL infrastructure/parcelpath.pl backup-client $target_os`
325
326if test "$build_os" = "cygwin"; then
327        client_parcel_dir=`cygpath -wa $client_parcel_dir | sed -e 's|\\\|/|g'`
328        build_dir=`        cygpath -wa $build_dir         | sed -e 's|\\\|/|g'`
329fi
330
331AC_SUBST([client_parcel_dir])
332AC_SUBST([build_dir])
333
334## Figure out version and substitute it in
335box_version=`$PERL infrastructure/printversion.pl`
336AC_SUBST([box_version])
337
338### Output files
339AC_CONFIG_FILES([infrastructure/BoxPlatform.pm
340                 contrib/mac_osx/org.boxbackup.bbackupd.plist
341                 contrib/mac_osx/org.boxbackup.bbstored.plist
342                 contrib/solaris/bbackupd-manifest.xml
343                 contrib/solaris/bbstored-manifest.xml
344                 lib/common/BoxPortsAndFiles.h
345                 test/bbackupd/testfiles/bbackupd.conf
346                 test/bbackupd/testfiles/bbackupd-exclude.conf
347                 test/bbackupd/testfiles/bbackupd-snapshot.conf
348                 test/bbackupd/testfiles/bbackupd-symlink.conf
349                 ])
350AX_CONFIG_SCRIPTS([bin/bbackupd/bbackupd-config
351                   bin/bbackupquery/makedocumentation.pl
352                   bin/bbstored/bbstored-certs
353                   bin/bbstored/bbstored-config
354                   contrib/debian/bbackupd
355                   contrib/debian/bbstored
356                   contrib/redhat/bbackupd
357                   contrib/redhat/bbstored
358                   contrib/suse/bbackupd
359                   contrib/suse/bbstored
360                   contrib/solaris/bbackupd-smf-method
361                   contrib/solaris/bbstored-smf-method
362                   contrib/windows/installer/boxbackup.mpi
363                   infrastructure/makebuildenv.pl
364                   infrastructure/makeparcels.pl
365                   infrastructure/makedistribution.pl
366                   lib/common/makeexception.pl
367                   lib/raidfile/raidfile-config
368                   lib/server/makeprotocol.pl
369                   runtest.pl
370                   test/backupstorefix/testfiles/testbackupstorefix.pl
371                   test/bbackupd/testfiles/extcheck1.pl
372                   test/bbackupd/testfiles/extcheck2.pl
373                   test/bbackupd/testfiles/notifyscript.pl
374                   test/bbackupd/testfiles/syncallowscript.pl])
375# TODO: Need to do contrib/cygwin/install-cygwin-service.pl but location varies
376AC_OUTPUT
377
378# Configure the Box build system
379echo
380if ! $PERL ./infrastructure/makebuildenv.pl \
381|| ! $PERL ./infrastructure/makeparcels.pl; then
382        echo "Making infrastructure failed!"
383        exit 1
384fi
385
386cat parcels.txt | sed -e 's/#.*//' | while read cmd subdir configure_args; do
387        if test "$cmd" = "configure"; then
388                echo
389                export CC CXX CXXFLAGS LDFLAGS LIBS
390                args="$configure_args --target=$target_alias"
391                echo "Configuring $subdir with: $args"
392
393                cd $subdir
394                if ! ./configure $args; then
395                        echo "Configuring $subdir with $args failed!" >&2
396                        exit 1
397                fi
398        fi
399done || exit $?
400
401# Write summary of important info
402cat <<EOC
403A summary of the build configuration is below. Box Backup will function
404without these features, but will work better where they are present. Refer
405to the documentation for more information on each feature.
406
407Regular expressions: $have_regex_support
408Large files:         $box_cv_have_large_file_support
409Berkeley DB:         $ax_path_bdb_ok
410Readline:            $have_libreadline
411Extended attributes: $ac_cv_header_sys_xattr_h
412EOC | tee config.log.features
413
414
415### Warnings at end for visibility
416
417if test "x$box_cv_gcc_3_plus" != "xyes" && test "x$box_cv_malloc_workaround" != "xyes"; then
418  echo
419  AC_MSG_WARN([[the implementation of the C++ STL on this platform may
420have a flaw which causes it to apparently leak memory, and this flaw cannot be
421worked around.
422
423When running the daemons, check their memory usage does not constantly
424increase. The STL flaw can cause excessive memory use.]])
425fi
426
427case "$vl_cv_lib_readline" in
428  *readline*)
429    echo
430    AC_MSG_WARN([[do not distribute binaries compiled against GNU readline,
431as this could violate the GNU readline licence, which is GPL. You may use
432libedit or libeditline instead.]])
433    ;;
434esac
Note: See TracBrowser for help on using the repository browser.