Added --enable-rpathhack options to all configures, to disable RPATH
[barry/progweb.git] / configure.ac
blob98ed1278d3eb95679e99aaad3fd9b75c197d3144
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 AC_PREREQ(2.61)
5 AC_INIT([barry], [0.18.0], [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=0
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.
89
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([GLIB2], [glib-2.0],
328         [GLIB2_FOUND=1],
329         [echo "GLIB 2.0 not found, skipping sync library."; GLIB2_FOUND=0]
330         )
332 pkgconfigdir=${libdir}/pkgconfig
333 AC_SUBST(pkgconfigdir)
335 AC_SUBST(LIBUSB_CFLAGS)
336 AC_SUBST(LIBUSB_LIBS)
338 AM_CONDITIONAL([WITH_FUSE], [test "$FUSE_FOUND" = "1"])
339 AM_CONDITIONAL([WITH_SYNC], [test "$GLIB2_FOUND" = "1" -a "$SYNC_ENABLED" = "yes"])
341 #AC_CHECK_LIB([IOKit], [main])
342 #AC_CHECK_LIB([libusb], [libusb_init])
343 AC_CHECK_LIB([pthread], [main])
345 AC_ARG_WITH(zlib,
346         AC_HELP_STRING(--with-zlib, [force usage of zlib, and halt if not available]),
347         force_zlib=$withval, force_zlib=no )
349 AC_CHECK_LIB([z], [crc32],
350         [
351                 AC_DEFINE([HAVE_ZLIB], [1], [Use crc32 when generating packed .cod files])
352                 AC_ARG_VAR([ZLIB_LIBS], [Linker options for zlib])
353                 ZLIB_LIBS="-lz"
354         ],
355         [
356                 echo "*****************************************************************"
357                 echo "WARNING: zlib not found... packed .cod files will fail crc checks"
358                 echo "*****************************************************************"
359                 AC_ARG_VAR([ZLIB_LIBS], [Linker options for zlib])
360                 ZLIB_LIBS=""
361                 if test "x$force_zlib" != xno ; then
362                         AC_MSG_FAILURE([--with-zlib specified, but zlib not found])
363                 fi
364         ]
365         )
367 PKG_CHECK_MODULES([LIBXMLXX], [libxml++-2.6],
368         [LIBXMLXX_FOUND=1],
369         [
370                 echo "*****************************************************************"
371                 echo "WARNING: libxml++ not found... ALX parser not included"
372                 echo "*****************************************************************"
373                 LIBXMLXX_FOUND=0
374         ]
375         )
377 AM_CONDITIONAL([WITH_ALX],  [test "$LIBXMLXX_FOUND" = "1"])
380 AM_ICONV
384 # Checks for header files.
386 AC_HEADER_DIRENT
387 AC_HEADER_STDC
388 AC_CHECK_HEADERS([assert.h stdint.h time.h])
391 # Checks for typedefs, structures, and compiler characteristics.
393 #AC_TYPE_SIZE_T
394 AC_HEADER_TIME
395 AC_STRUCT_TM
398 # Checks for library functions.
401 # checks that are buggy and need a C compiler only
402 AC_LANG([C])
403 # AC_FUNC_STRNLEN changes linker options for us, and depends on a src/strnlen.c
404 AC_FUNC_STRNLEN
405 if test $ac_cv_func_strnlen_working = yes ; then
406         AC_DEFINE([HAVE_WORKING_STRNLEN], 1,
407                 [Define to 1 if a working strnlen exists.])
409 if test $ac_cv_func_strnlen_working = no ; then
410         AC_DEFINE([HAVE_WORKING_STRNLEN], 0,
411                 [Define to 1 if a working strnlen exists, 0 if not.])
414 # checks that work with C++
415 AC_LANG([C++])
416 AC_FUNC_CLOSEDIR_VOID
417 AC_PROG_GCC_TRADITIONAL
418 #AC_FUNC_MALLOC
419 #AC_FUNC_MKTIME
420 #AC_FUNC_REALLOC
421 AC_FUNC_SELECT_ARGTYPES
422 #AC_FUNC_STAT
424 AC_CHECK_FUNCS([bzero gettimeofday memset select strcasecmp strchr strerror strtol strtoul])
425 AC_C_BIGENDIAN
427 AC_CONFIG_FILES([Makefile
428                  po/Makefile.in
429                  src/Makefile
430                  tools/Makefile
431                  examples/Makefile
432                  man/Makefile
433                  test/Makefile
434                  libbarry-0.pc
435                  libbarrydp-0.pc
436                  libbarryjdwp-0.pc
437                  libbarrysync-0.pc
438                  libbarrybackup-0.pc
439                  libbarryalx-0.pc])
442 # nested packages
444 AC_ARG_ENABLE([gui], [AC_HELP_STRING([--enable-gui], [build the gui])])
445 AC_ARG_ENABLE([opensync-plugin], [AC_HELP_STRING([--enable-opensync-plugin], [build the opensync plugin])])
446 AC_ARG_ENABLE([opensync-plugin-4x], [AC_HELP_STRING([--enable-opensync-plugin-4x], [build the opensync 0.4x plugin])])
447 AC_ARG_ENABLE([desktop], [AC_HELP_STRING([--enable-desktop], [build the desktop control panel])])
449 # make sure that the environment is setup before anything else
450 if test "$enable_gui" = yes || test "$enable_opensync_plugin" = yes || test "$enable_opensync_plugin_4x" = yes || test "$enable_desktop" = yes; then
451         export TREE_BUILD_CXXFLAGS="-I`pwd`"
452         export TREE_BUILD_LDFLAGS="-L`pwd`/src"
453         export PKG_CONFIG_PATH="`pwd`:$PKG_CONFIG_PATH"
456 # conditionally enable the subdirectory packages
457 if test "$enable_gui" = yes; then
458         AC_CONFIG_SUBDIRS([gui])
460 if test "$enable_opensync_plugin" = yes; then
461         AC_CONFIG_SUBDIRS([opensync-plugin])
463 if test "$enable_opensync_plugin_4x" = yes; then
464         AC_CONFIG_SUBDIRS([opensync-plugin-0.4x])
466 if test "$enable_desktop" = yes; then
467         AC_CONFIG_SUBDIRS([desktop])
471 # Generate the scripts!
473 AC_OUTPUT
476 # Add a special hack at the end, to let the user disable RPATH if he wants.
478 # http://wiki.debian.org/RpathIssue
479 # http://lists.debian.org/debian-devel/2003/debian-devel-200306/msg00569.html
480 # http://fedoraproject.org/wiki/Packaging:Guidelines#Removing_Rpath
482 AC_ARG_ENABLE([rpathhack],
483         [AC_HELP_STRING([--enable-rpathhack], [patch libtool to remove RPATH])],
484         [
485 AC_MSG_RESULT([patching libtool to fix HIDEOUS BREAKAGE])
486 sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
487 sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
488         ],
489         [])