Start integrating new build system with "configure"
[freeradius.git] / src / modules / rlm_perl / configure.in
1 AC_PREREQ([2.53])
2 AC_INIT(rlm_perl.c)
3 AC_REVISION($Revision$)
4 AC_DEFUN(modname,[rlm_perl])
5
6 if test x$with_[]modname != xno; then
7
8         AC_PROG_CC
9         AC_PROG_CPP
10
11         dnl put configuration checks here.
12         dnl set $fail to what's missing, on fatal errors.
13         dnl use AC_MSG_WARN() on important messages.
14
15         AC_CHECK_PROG(PERL, perl, yes, no)
16         if test "$PERL" = "no"; then
17            fail=$fail" perl"
18         else
19           old_CFLAGS=$CFLAGS
20           CFLAGS="$CFLAGS `perl -MExtUtils::Embed -e ccopts`"
21
22           smart_try_dir=
23           FR_SMART_CHECK_INCLUDE(EXTERN.h)
24           if test "x$ac_cv_header_EXTERN_h" = "xyes"; then
25                 perl_cflags='`perl -MExtUtils::Embed -e ccopts`'
26           else
27                 fail="$fail EXTERN.h"
28                 targetname=
29           fi
30
31           FR_SMART_CHECK_INCLUDE(perl.h, [#include <EXTERN.h>])
32           if test "x$ac_cv_header_perl_h" = "xyes"; then
33                 perl_cflags='`perl -MExtUtils::Embed -e ccopts`'
34           else
35                 fail="$fail perl.h"
36                 targetname=
37           fi
38
39           old_LIBS="$LIBS"
40           LIBS="$old_LIBS `perl -MExtUtils::Embed -e ldopts`"
41           AC_TRY_LINK([extern char boot_DynaLoader();],
42                       [ boot_DynaLoader()],
43                       BROKEN=,
44                       BROKEN="yes")
45
46           if test "x$BROKEN" = "x"; then
47                 perl_ldflags='`perl -MExtUtils::Embed -e ldopts`'
48           else
49                 fail="$fail libperl.so"
50                 targetname=
51           fi
52
53           AC_TRY_LINK([extern char Perl_hv_store();],
54                       [ Perl_hv_store()],
55                       BROKEN=,
56                       BROKEN="yes")
57
58          if test "x$BROKEN" != "x"; then
59                 fail="$fail libperl.so"
60                 targetname=
61           fi
62
63           CFLAGS=$old_CFLAGS
64         fi
65         targetname=modname
66
67 else
68         targetname=
69         echo \*\*\* module modname is disabled.  # keep this!  Don't change!
70 fi
71
72 dnl  Don't change this section.
73 if test x"$fail" != x""; then
74         if test x"${enable_strict_dependencies}" = x"yes"; then
75                 AC_MSG_ERROR([set --without-]modname[ to disable it explicitly.])
76         else
77                 AC_MSG_WARN([silently not building ]modname[.])
78                 AC_MSG_WARN([FAILURE: ]modname[ requires: $fail.]);
79                 targetname=""
80                 perl_cflags=""
81                 perl_ldflags=""
82         fi
83 fi
84
85
86 AC_SUBST(perl_cflags)
87 AC_SUBST(perl_ldflags)
88
89 AC_CONFIG_HEADER(config.h)
90
91 AC_SUBST(targetname)
92 AC_OUTPUT(Makefile)
93 AC_OUTPUT(all.mk)