Barry version 0.18.1 (debian sid release)
[barry.git] / configure.ac
blob083366534f46d7f8f47f6e1de8cda07d2040b5ca
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 AC_PREREQ(2.61)
5 AC_INIT([barry], [0.18.1], [barry-devel@lists.sourceforge.net])
6 #AM_CONFIG_HEADER(config.h)
7 AC_CONFIG_SRCDIR([src/barry.h])
8 AC_CONFIG_HEADERS([config.h:config.h.in])
9 AC_CONFIG_MACRO_DIR([m4])
10 AM_INIT_AUTOMAKE([dist-bzip2])
12 AC_USE_SYSTEM_EXTENSIONS
14 AM_GNU_GETTEXT([external])
15 # this is the verion of gettext, not barry
16 AM_GNU_GETTEXT_VERSION([0.17])
19 # Barry Version Numbers
21 BARRY_LOGICAL=0
22 BARRY_MAJOR=18
23 BARRY_MINOR=1
24 AC_DEFINE_UNQUOTED([BARRY_LOGICAL], [$BARRY_LOGICAL], [Logical version number])
25 AC_DEFINE_UNQUOTED([BARRY_MAJOR], [$BARRY_MAJOR], [Major library version number])
26 AC_DEFINE_UNQUOTED([BARRY_MINOR], [$BARRY_MINOR], [Minor library version number])
27 AC_DEFINE_UNQUOTED([BARRY_VER_STRING],
28         ["${BARRY_LOGICAL}.${BARRY_MAJOR}.${BARRY_MINOR}"],
29         [Full Barry version in string form])
30 AC_SUBST([BARRY_LOGICAL])
31 AC_SUBST([BARRY_MAJOR])
32 AC_SUBST([BARRY_MINOR])
35 # Checks for programs.
37 AC_PROG_CC
38 AC_PROG_CXX
39 AC_PROG_MAKE_SET
40 AC_PROG_LIBTOOL
42 AX_C_CHECK_FLAG([-fvisibility=hidden], [], [],
43         [HAVE_C_GCCVISIBILITY=1],
44         [HAVE_C_GCCVISIBILITY=0])
45 AX_CXX_CHECK_FLAG([-fvisibility=hidden], [], [],
46         [HAVE_CXX_GCCVISIBILITY=1],
47         [HAVE_CXX_GCCVISIBILITY=0])
48 AM_CONDITIONAL([WITH_GCCVISIBILITY], [test "$HAVE_C_GCCVISIBILITY" = "1" -a "$HAVE_CXX_GCCVISIBILITY" = "1"])
50 AC_LANG([C++])
53 # Checks for libraries.
56 # libtar and libz don't have pkg-config files on many systems.
57 # libz we can assume, but libtar we need to test for
58 AC_ARG_WITH(libtar,
59         [  --with-libtar=<path>    root path of libtar install],
60         [LIBTAR_CFLAGS="-I$with_libtar/include"
61          LIBTAR_LIBS="-L$with_libtar/lib -ltar"],
62         [echo "Guessing libtar location... may not compile...";
63          LIBTAR_CFLAGS=""
64          LIBTAR_LIBS="-ltar"])
65 AC_SUBST(LIBTAR_CFLAGS)
66 AC_SUBST(LIBTAR_LIBS)
68 AC_CHECK_LIB([tar], [tar_open],
69         [LIBTAR_FOUND=1
70         AC_MSG_NOTICE([Found libtar, enabling libbarrybackup]) ],
71         [LIBTAR_FOUND=0
72         AC_MSG_NOTICE([Libtar NOT found, disabling libbarrybackup])],
73         [$LIBTAR_CFLAGS $LIBTAR_LIBS])
75 AC_ARG_WITH(libz,
76         [  --with-zlib=<path>      root path of zlib install],
77         [LIBZ_CFLAGS="-I$with_libtar/include"
78          LIBZ_LIBS="-L$with_libtar/lib -ltar"],
79         [echo "Guessing zlib location... may not compile...";
80          LIBZ_CFLAGS=""
81          LIBZ_LIBS="-lz"])
82 AC_SUBST(LIBZ_CFLAGS)
83 AC_SUBST(LIBZ_LIBS)
85 AM_CONDITIONAL([WITH_BACKUP], [test "$LIBTAR_FOUND" = "1"])
87 # Always use Barry sockets and low level USB access, rather than
88 # attempting to use third party socket APIs.
90 # Currently compiling without this flag won't work, but
91 # it exists to allow areas of code which are only needed
92 # when using Barry sockets to be easily marked
94 # The idea is that this is always set on Linux, but could be
95 # disabled when building on Windows to allow a different
96 # socket API to be used.
97 AC_DEFINE([USE_BARRY_SOCKETS], [], [Define to use the low-level socket and USB code built into Barry.])
98 USE_BARRY_SOCKETS=1
99 AC_SUBST([USE_BARRY_SOCKETS])
100 AM_CONDITIONAL([USE_BARRY_SOCKETS], [test "$USE_BARRY_SOCKETS" = "1"])
102 # Work out which USB library to use.
103 # Ultimately this is all to set a few variables:
104 #    USB_LIBRARY_CFLAGS - Compiler flags for chosen USB library
105 #    USB_LIBRARY_LIBS   - Linker flags for chosen USB library
106 # And one of the following defines:
107 #    USE_LIBUSB_0_1
108 #    USE_LIBUSB_1_0
110 # Check what USB libraries are available
111 PKG_CHECK_MODULES([LIBUSB_0_1], [libusb],
112         [HAVE_LIBUSB_0_1=1],
113         [HAVE_LIBUSB_0_1=0])
115 PKG_CHECK_MODULES([LIBUSB_1_0], [libusb-1.0],
116         [HAVE_LIBUSB_1_0=1],
117         [HAVE_LIBUSB_1_0=0])
119 # Process any user provided 'with' arguments
120 AC_ARG_WITH(libusb,
121         AS_HELP_STRING([--with-libusb@<:@=<path>@:>@],
122                 [use libusb 0.1 as the USB library, optionally providing the root path of libusb 0.1 installation]),
123         [
124          case x"$with_libusb" in
125          xyes)
126                 USE_LIBUSB_0_1=1
127                 ;;
128          xno)
129                 USE_LIBUSB_0_1=0
130                 ;;
131          x*)
132                 LIBUSB_0_1_CFLAGS="-I$with_libusb/include"
133                 LIBUSB_0_1_LIBS="-L$with_libusb/lib -lusb"
134                 USE_LIBUSB_0_1=1
135                 ;;
136          esac
137          ],
138         [])
140 AC_ARG_WITH(libusb1_0,
141         AS_HELP_STRING([--with-libusb1_0@<:@=<path>@:>@],
142                 [use libusb 1.0 as the USB library, optionally providing the root path of libusb 1.0 installation]),
143         [
144          case x"$with_libusb1_0" in
145          xyes)
146                 USE_LIBUSB_1_0=1
147                 ;;
148          xno)
149                 USE_LIBUSB_1_0=0
150                 ;;
151          x*)
152                 LIBUSB_1_0_CFLAGS="-I$with_libusb1_0/include/libusb-1.0"
153                 LIBUSB_1_0_LIBS="-L$with_libusb1_0/lib -lusb-1.0"
154                 USE_LIBUSB_1_0=1
155                 ;;
156          esac
157          ],
158         [])
160 # Work out which USB library should be used.
162 # Count how many libraries have been chosen
163 USB_CHOSEN_COUNT=0
164 if test x"$USE_LIBUSB_1_0" == x1 ; then
165    USB_CHOSEN_COUNT=$(($USB_CHOSEN_COUNT + 1))
167 if test x"$USE_LIBUSB_0_1" == x1 ; then
168    USB_CHOSEN_COUNT=$(($USB_CHOSEN_COUNT + 1))
171 case $USB_CHOSEN_COUNT in
173    # User didn't ask for a specific library, so pick one
174    if test -n "${LIBUSB_1_0_CFLAGS+x}" -a -n "${LIBUSB_1_0_LIBS+x}" -a x"$USE_LIBUSB_1_0" != x0 ; then
175       USE_LIBUSB_1_0=1
176    elif test -n "${LIBUSB_0_1_CFLAGS+x}" -a -n "${LIBUSB_0_1_LIBS+x}" -a x"$USE_LIBUSB_0_1" != x0 ; then
177       USE_LIBUSB_0_1=1
178    fi
179    ;;
181    # User explicitly asked for a library, the code below will pick this.
182    ;;
184    AC_MSG_ERROR([Multiple USB libraries specified, please only specify one --with-<USBLIBRARY> option to the configure script.])
185    ;;
186 esac
188 AC_MSG_CHECKING([for which USB library to use])
189 if test x"$USE_LIBUSB_1_0" = x1 ; then
190    # User explicitly asked for libusb 1.0
191    USB_LIBRARY_CFLAGS="$LIBUSB_1_0_CFLAGS"
192    USB_LIBRARY_LIBS="$LIBUSB_1_0_LIBS"
193    USE_LIBUSB_1_0=1
194    AC_SUBST([USE_LIBUSB_1_0])
195    AC_DEFINE([USE_LIBUSB_1_0], [], [Define if libusb 1.0 interface should be used])
196    AC_MSG_RESULT([libusb-1.0])
198 elif test x"$USE_LIBUSB_0_1" = x1 ; then
199    # User explicitly asked for libusb 0.1
200    USB_LIBRARY_CFLAGS="$LIBUSB_0_1_CFLAGS"
201    USB_LIBRARY_LIBS="$LIBUSB_0_1_LIBS"
202    USE_LIBUSB_0_1=1
203    AC_SUBST([USE_LIBUSB_0_1])
204    AC_DEFINE([USE_LIBUSB_0_1], [], [Define if libusb 0.1 interface should be used])
205    AC_MSG_RESULT([libusb-0.1])
207 else
208    AC_MSG_RESULT([unknown])
209    AC_MSG_WARN("ERROR: No USB library found automatically... build may fail if you don't specify --with-libusb or --with-libusb-1.0")
211 AC_SUBST([USB_LIBRARY_CFLAGS])
212 AC_SUBST([USB_LIBRARY_LIBS])
213 AM_CONDITIONAL([USE_LIBUSB_0_1], [test "$USE_LIBUSB_0_1" = "1"])
214 AM_CONDITIONAL([USE_LIBUSB_1_0], [test "$USE_LIBUSB_1_0" = "1"])
217 # Allow user to disable libbarrysync, since it depends on glib-2.0 which
218 # may not be possible to cross-compile.
220 AC_ARG_ENABLE([sync],
221         AC_HELP_STRING([--disable-sync], [disable Barry sync library]),
222         [
223         if test x"$enableval" = "xno" ; then
224                 SYNC_ENABLED=no
225         else
226                 SYNC_ENABLED=yes
227         fi
228         ],
229         [SYNC_ENABLED=yes])
232 # Boost library configuration
234 # Ok, the requirements:
236 #    - let the user enable/disable Boost support from configure
237 #         - default to disabled
238 #         - if enabled, and not available, error
240 #    - let user specify include path, and lib path, separately,
241 #      since some Boost installations have an additional boost-1.34.1
242 #      style directory in them
243 #         - default to using no path overrides, assuming everything
244 #           that is needed is in default distro locations
246 #    - let user specify the name of the serialization library, since
247 #      the name of the library can change whether you're building
248 #      from source or not
249 #         - default to searching for boost_serialization or
250 #           boost_serialization-mt, and error if not found
252 # Therefore:
254 #    --enable-boost                   Handles enable/disable
255 #    --with-boost-include=path        Override the include path
256 #    --with-boost-lib=path            Override the lib path
257 #    --with-boost-serialization=name  Override the name of serialization
258 #                                     library to link with
261 AC_ARG_ENABLE([boost],
262         AC_HELP_STRING([--enable-boost], [enable Boost support]),
263         [
264         if test x"$enableval" = "xno" ; then
265                 BOOST_ENABLED=no
266         else
267                 BOOST_ENABLED=yes
268         fi
269         ],
270         [BOOST_ENABLED=no])
272 AC_ARG_WITH([boost-include],
273         AC_HELP_STRING(--with-boost-include=path,
274                 [path to Boost include directory in order to make include <boost/something.hpp> valid (defaults to system paths)]),
275         BOOST_INC_PATH="-I$withval",  BOOST_INC_PATH="" )
277 AC_ARG_WITH([boost-lib],
278         AC_HELP_STRING(--with-boost-lib=path,
279                 [path to Boost library directory (defaults to system paths)]),
280         BOOST_LIB_PATH="-L$withval",  BOOST_LIB_PATH="" )
282 AC_ARG_WITH(boost-serialization,
283         AC_HELP_STRING(--with-boost-serialization=name,
284                 [name of serialization library to use with compiler's -l option (defaults to boost_serialization or boost_serialization-mt.)]),
285         boost_serialization_name=$withval, boost_serialization_name="boost_serialization")
287 AC_MSG_NOTICE([using BOOST library... $BOOST_ENABLED])
288 if test x"$BOOST_INC_PATH$BOOST_LIB_PATH" != x ; then
289         AC_MSG_NOTICE([BOOST include options: $BOOST_INC_PATH])
290         AC_MSG_NOTICE([BOOST library options: $BOOST_LIB_PATH])
293 if test x"$BOOST_ENABLED" = "xyes" ; then
294         # Only $BOOST_LIB_PATH is given for this check, since no
295         # headers are included in the autoconf main() test snippet.
296         AC_CHECK_LIB($boost_serialization_name, main,
297                 [BOOST_LDADD="-l$boost_serialization_name"],
298                 [
299                         AC_CHECK_LIB(boost_serialization-mt, main,
300                                 [BOOST_LDADD="-lboost_serialization-mt"],
301                                 [AC_MSG_ERROR(boost_serialization not found)],
302                                 [$BOOST_LIB_PATH]
303                                 )
304                 ],
305                 [$BOOST_LIB_PATH])
307         if test x"$BOOST_LDADD" != x ; then
308                 AC_MSG_NOTICE([BOOST library name: $BOOST_LDADD])
309         else
310                 AC_MSG_ERROR([boost_serialization library not found])
311         fi
314 AC_SUBST(BOOST_LIB_PATH)
315 AC_SUBST(BOOST_INC_PATH)
316 AC_SUBST(BOOST_LDADD)
317 AM_CONDITIONAL([WITH_BOOST], [test "$BOOST_ENABLED" = "yes"])
320 #PKG_CHECK_MODULES([OPENSSL], [openssl])
322 PKG_CHECK_MODULES([FUSE], [fuse >= 2.5],
323         [FUSE_FOUND=1],
324         [echo "FUSE library not found, skipping fuse module."; FUSE_FOUND=0]
325         )
327 PKG_CHECK_MODULES([SDL], [sdl >= 1.2],
328         [SDL_FOUND=1],
329         [echo "SDL library not found, skipping bwatch tool."; SDL_FOUND=0]
330         )
332 PKG_CHECK_MODULES([GLIB2], [glib-2.0],
333         [GLIB2_FOUND=1],
334         [echo "GLIB 2.0 not found, skipping sync library."; GLIB2_FOUND=0]
335         )
337 pkgconfigdir=${libdir}/pkgconfig
338 AC_SUBST(pkgconfigdir)
340 AC_SUBST(LIBUSB_CFLAGS)
341 AC_SUBST(LIBUSB_LIBS)
343 AM_CONDITIONAL([WITH_FUSE], [test "$FUSE_FOUND" = "1"])
344 AM_CONDITIONAL([WITH_SDL],  [test "$SDL_FOUND" = "1"])
345 AM_CONDITIONAL([WITH_SYNC], [test "$GLIB2_FOUND" = "1" -a "$SYNC_ENABLED" = "yes"])
347 # Do not define the success case here, since we rely on -lpthread to be
348 # automatically added to LIBS (the default macro behaviour)
349 AC_CHECK_LIB([pthread], [pthread_create], [], [NEED_PTHREAD_CHECK2=1])
350 if test "$NEED_PTHREAD_CHECK2" = "1"; then
351         # See if pthreads is part of the core library or user provided
352         # LDFLAGS anyway... this is needed for systems like QNX
353         AC_MSG_CHECKING([for pthread_create in standard linker options])
354         AC_CHECK_FUNC([pthread_create], [
355                 AC_MSG_RESULT([ok])
356         ], [
357                 AC_MSG_ERROR([failed])
358         ])
361 AC_CHECK_FUNC([getpwuid], [AC_DEFINE([HAVE_GETPWUID], [], [Defined if getpwuid is available])], [])
364 NETWORK_LIBRARY_LIBS=
365 AC_CHECK_FUNC([bind], [], [
366         AC_CHECK_LIB([socket], [bind], [ NETWORK_LIBRARY_LIBS="-lsocket" ] , [
367                 echo "**************************************************"
368                 echo "WARNING: No networking library found, build errors"
369                 echo "         will probably occur.                     "
370                 echo "**************************************************"
371         ])
373 AC_SUBST([NETWORK_LIBRARY_LIBS])
375 AC_ARG_WITH(zlib,
376         AC_HELP_STRING(--with-zlib, [force usage of zlib, and halt if not available]),
377         force_zlib=$withval, force_zlib=no )
379 AC_CHECK_LIB([z], [crc32],
380         [
381                 AC_DEFINE([HAVE_ZLIB], [1], [Use crc32 when generating packed .cod files])
382                 AC_ARG_VAR([ZLIB_LIBS], [Linker options for zlib])
383                 ZLIB_LIBS="-lz"
384         ],
385         [
386                 echo "*****************************************************************"
387                 echo "WARNING: zlib not found... packed .cod files will fail crc checks"
388                 echo "*****************************************************************"
389                 AC_ARG_VAR([ZLIB_LIBS], [Linker options for zlib])
390                 ZLIB_LIBS=""
391                 if test "x$force_zlib" != xno ; then
392                         AC_MSG_FAILURE([--with-zlib specified, but zlib not found])
393                 fi
394         ]
395         )
397 PKG_CHECK_MODULES([LIBXMLXX], [libxml++-2.6],
398         [LIBXMLXX_FOUND=1],
399         [
400                 echo "*****************************************************************"
401                 echo "WARNING: libxml++ not found... ALX parser not included"
402                 echo "*****************************************************************"
403                 LIBXMLXX_FOUND=0
404         ]
405         )
407 AM_CONDITIONAL([WITH_ALX],  [test "$LIBXMLXX_FOUND" = "1"])
410 AM_ICONV
414 # Checks for header files.
416 AC_HEADER_DIRENT
417 AC_HEADER_STDC
418 AC_CHECK_HEADERS([assert.h stdint.h time.h])
421 # Checks for typedefs, structures, and compiler characteristics.
423 #AC_TYPE_SIZE_T
424 AC_HEADER_TIME
425 AC_STRUCT_TM
428 # Checks for library functions.
431 # checks that are buggy and need a C compiler only
432 AC_LANG([C])
433 # AC_FUNC_STRNLEN changes linker options for us, and depends on a src/strnlen.c
434 HAVE_WORKING_STRNLEN=0
435 AC_FUNC_STRNLEN
436 if test "$ac_cv_func_strnlen_working" = "yes" ; then
437         # If cross compiling for anything other than AIX then AC_FUNC_STRNLEN
438         # will end up saying it's working. Before we trust it, check if the
439         # function exists at all:
440         AC_CHECK_FUNC([strnlen], [HAVE_WORKING_STRNLEN=1], [
441                         HAVE_WORKING_STRNLEN=0
442                         # Need to also add strnlen to AC_LIBOBJ as the
443                         # AC_FUNC_STRNLEN macro won't have done that as it
444                         # has guessed at everything being ok.
445                         AC_LIBOBJ([strnlen])
446                 ])
448 if test "$ac_cv_func_strnlen_working" = "no" ; then
449         HAVE_WORKING_STRNLEN=0
451 AC_DEFINE_UNQUOTED(HAVE_WORKING_STRNLEN, $HAVE_WORKING_STRNLEN,
452                 [Define to 1 if a working strnlen exists, 0 if not.])
454 # checks that work with C++
455 AC_LANG([C++])
456 AC_FUNC_CLOSEDIR_VOID
457 AC_PROG_GCC_TRADITIONAL
458 #AC_FUNC_MALLOC
459 #AC_FUNC_MKTIME
460 #AC_FUNC_REALLOC
461 AC_FUNC_SELECT_ARGTYPES
462 #AC_FUNC_STAT
464 AC_CHECK_FUNCS([bzero gettimeofday memset select strcasecmp strchr strerror strtol strtoul])
465 AC_C_BIGENDIAN
467 AC_CONFIG_FILES([Makefile
468                  po/Makefile.in
469                  src/Makefile
470                  tools/Makefile
471                  examples/Makefile
472                  man/Makefile
473                  test/Makefile
474                  libbarry-0.pc
475                  libbarrydp-0.pc
476                  libbarryjdwp-0.pc
477                  libbarrysync-0.pc
478                  libbarrybackup-0.pc
479                  libbarryalx-0.pc])
482 # nested packages
484 AC_ARG_ENABLE([gui], [AC_HELP_STRING([--enable-gui], [build the gui])])
485 AC_ARG_ENABLE([opensync-plugin], [AC_HELP_STRING([--enable-opensync-plugin], [build the opensync plugin])])
486 AC_ARG_ENABLE([opensync-plugin-4x], [AC_HELP_STRING([--enable-opensync-plugin-4x], [build the opensync 0.4x plugin])])
487 AC_ARG_ENABLE([desktop], [AC_HELP_STRING([--enable-desktop], [build the desktop control panel])])
489 # make sure that the environment is setup before anything else
490 if test "$enable_gui" = yes || test "$enable_opensync_plugin" = yes || test "$enable_opensync_plugin_4x" = yes || test "$enable_desktop" = yes; then
491         export TREE_BUILD_CXXFLAGS="-I`pwd`"
492         export TREE_BUILD_LDFLAGS="-L`pwd`/src"
493         export PKG_CONFIG_PATH="`pwd`:$PKG_CONFIG_PATH"
496 # conditionally enable the subdirectory packages
497 if test "$enable_gui" = yes; then
498         AC_CONFIG_SUBDIRS([gui])
500 if test "$enable_opensync_plugin" = yes; then
501         AC_CONFIG_SUBDIRS([opensync-plugin])
503 if test "$enable_opensync_plugin_4x" = yes; then
504         AC_CONFIG_SUBDIRS([opensync-plugin-0.4x])
506 if test "$enable_desktop" = yes; then
507         AC_CONFIG_SUBDIRS([desktop])
511 # Generate the scripts!
513 AC_OUTPUT
516 # Add a special hack at the end, to let the user disable RPATH if he wants.
518 # http://wiki.debian.org/RpathIssue
519 # http://lists.debian.org/debian-devel/2003/debian-devel-200306/msg00569.html
520 # http://fedoraproject.org/wiki/Packaging:Guidelines#Removing_Rpath
522 AC_ARG_ENABLE([rpathhack],
523         [AC_HELP_STRING([--enable-rpathhack], [patch libtool to remove RPATH])],
524         [
525 AC_MSG_RESULT([patching libtool to fix HIDEOUS BREAKAGE])
526 sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
527 sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
528         ],
529         [])