Imported Upstream version 3.2.0
[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     WANT_CYGWIN_COPY_PERL_DLL=false
18     WANT_MANDATORY_THREAD_CHECK=false
19
20     # test for ExtUtils::Embed
21     AC_PERL_MODULE_VERSION([ExtUtils::Embed 0.0], [], [
22         AC_MSG_ERROR([*** Amanda requires the perl package ExtUtils::Embed to build its perl modules])
23     ])
24
25     # get the include path for building perl extensions
26     PERL_INC=`$PERL -MExtUtils::Embed -e perl_inc`
27     AC_SUBST(PERL_INC)
28
29     if test x"$enable_shared" = x"no"; then
30         AC_MSG_ERROR([*** Amanda cannot be compiled without shared-library support (do not use --disable-shared)])
31     fi
32
33     case "$host" in
34         *freebsd@<:@123456@:>@.*) # up to and including FreeBSD 6.*
35             # Before 7.0, FreeBSD systems don't include a DT_NEEDS segment in
36             # libgthread to automatically pull in the desired threading library.
37             # Instead, they assume that any application linking against
38             # libgthread will pull in the threading library.  This is fine for
39             # Amanda C applications, but for Perl applications this assumption
40             # means that the perl binary would pull in the threading library.
41             # But perl is compiled without threading by default.  
42             #
43             # Specifically, this occurs on any FreeBSD using gcc-3.*: the linking
44             # decision is made in gcc's spec files, which were changed in
45             # gcc-4.0.  For a more in-depth discussion, see
46             #  http://wiki.zmanda.com/index.php/Installation/OS_Specific_Notes/Installing_Amanda_on_FreeBSD
47             #
48             # The easiest solution for the "default" case is to link all perl
49             # extension libraries against the threading library, so it is loaded
50             # when perl loads the extension library.  The default threading
51             # library in FreeBSD is libpthread.  The below default will work on
52             # such a FreeBSD system, but ports maintainers and those with
53             # different configurations may need to override this value with
54             # --with-perlextlibs.
55             #
56             # We can't use -pthread because gcc on FreeBSD ignores -pthread in
57             # combination with -shared.  See
58             #   http://lists.freebsd.org/pipermail/freebsd-stable/2006-June/026229.html
59
60             PERLEXTLIBS="-lpthread"
61             WANT_MANDATORY_THREAD_CHECK=true
62             ;;
63
64         *freebsd*) # all FreeBSD not matched above
65             # for all FreeBSD (including 1.0-6.0, above), we want to run the
66             # thread-check rule in perl/Makefile.am to double-check that a Perl
67             # script can call a C extension that uses threads.
68             WANT_MANDATORY_THREAD_CHECK=true
69             ;;
70
71         *-pc-cygwin)
72             # When need -lperl and the '-L' where it is located,
73             # we don't want the DynaLoader.a
74             PERLEXTLIBS=`perl -MExtUtils::Embed -e ldopts | sed -e 's/^.*-L/-L/'`
75             # we want cygwin to copy ddl to modules directory.
76             WANT_CYGWIN_COPY_PERL_DLL="true";
77             ;;
78     esac
79     AM_CONDITIONAL(WANT_CYGWIN_COPY_PERL_DLL,$WANT_CYGWIN_COPY_PERL_DLL)
80     AM_CONDITIONAL(WANT_MANDATORY_THREAD_CHECK,$WANT_MANDATORY_THREAD_CHECK)
81
82     AC_ARG_WITH(perlextlibs,
83         AC_HELP_STRING([--with-perlextlibs=libs],[extra LIBS for Perl extensions]),
84         [
85             case "$withval" in
86                 y|ye|yes) AC_MSG_ERROR([*** You must specify a value for --with-perlextlibs]);;
87                 n|no) PERLEXTLIBS='';;
88                 *) PERLEXTLIBS="$withval" ;;
89             esac
90         ])
91     AC_SUBST(PERLEXTLIBS)
92 ])