dadfc890837a79fa33f7d8695aec7955beb49044
[debian/amanda] / config / amanda / swig.m4
1 # OVERVIEW
2 #
3 #   Set up for building SWIG bindings.  Note that shipped tarballs contain pre-built
4 #   SWIG bindings, so there should be no need for SWIG on non-developer machines.
5 # SYNOPSIS
6 #
7 #   Find perl and SWIG, and substitute PERL_INC, the -I command that will lead the compiler
8 #   to perl.h and friends.
9 #
10 #   Supports --with-perlextlibs, for adding extra LIBS declarations to perl extensions.
11 #
12 AC_DEFUN([AMANDA_SETUP_SWIG],
13 [
14     AC_REQUIRE([AMANDA_PROG_SWIG])
15     AC_REQUIRE([AMANDA_PROG_PERL])
16
17     # If we want cygwin to copy ddl to modules directory.
18     WANT_CYGWIN_COPY_PERL_DLL="false"
19
20     # get the include path for building perl extensions
21     PERL_INC=`$PERL -MExtUtils::Embed -e perl_inc`
22     AC_SUBST(PERL_INC)
23
24     if test x"$enable_shared" = x"no"; then
25         AC_MSG_ERROR([*** Amanda cannot be compiled without shared-library support (do not use --disable-shared)])
26     fi
27
28     case "$target" in
29         *freebsd@<:@123456@:>@*) # up to and including FreeBSD 6.*
30             # Before 7.0, FreeBSD systems don't include a DT_NEEDS segment in
31             # libgthread to automatically pull in the desired threading library.
32             # Instead, they assume that any application linking against
33             # libgthread will pull in the threading library.  This is fine for
34             # Amanda C applications, but for Perl applications this assumption
35             # means that the perl binary would pull in the threading library.
36             # But perl is compiled without threading by default.  
37             #
38             # Specifically, this occurs on any FreeBSD using gcc-3.*: the linking
39             # decision is made in gcc's spec files, which were changed in
40             # gcc-4.0.  For a more in-depth discussion, see
41             #  http://wiki.zmanda.com/index.php/Installation/OS_Specific_Notes/Installing_Amanda_on_FreeBSD
42             #
43             # The easiest solution for the "default" case is to link all perl
44             # extension libraries against the threading library, so it is loaded
45             # when perl loads the extension library.  The default threading
46             # library in FreeBSD is libpthread.  The below default will work on
47             # such a FreeBSD system, but ports maintainers and those with
48             # different configurations may need to override this value with
49             # --with-perlextlibs.
50             #
51             # We can't use -pthread because gcc on FreeBSD ignores -pthread in
52             # combination with -shared.  See
53             #   http://lists.freebsd.org/pipermail/freebsd-stable/2006-June/026229.html
54
55             PERLEXTLIBS="-lpthread"
56             ;;
57         *-pc-cygwin)
58             # When need -lperl and the '-L' where it is located,
59             # we don't want the DynaLoader.a
60             PERLEXTLIBS=`perl -MExtUtils::Embed -e ldopts | sed -e 's/^.*-L/-L/'`
61             WANT_CYGWIN_COPY_PERL_DLL="true";
62             ;;
63     esac
64     AM_CONDITIONAL(WANT_CYGWIN_COPY_PERL_DLL,$WANT_CYGWIN_COPY_PERL_DLL)
65
66     AC_ARG_WITH(perlextlibs,
67         AC_HELP_STRING([--with-perlextlibs=libs],[extra LIBS for Perl extensions]),
68         [
69             case "$withval" in
70                 y|ye|yes) AC_MSG_ERROR([*** You must specify a value for --with-perlextlibs]);;
71                 n|no) PERLEXTLIBS='';;
72                 *) PERLEXTLIBS="$withval" ;;
73             esac
74         ])
75     AC_SUBST(PERLEXTLIBS)
76 ])