Blame configure.d/config_project_perl_python

Packit Service b38f0b
# -*- autoconf -*-
Packit Service b38f0b
#########################################
Packit Service b38f0b
##
Packit Service b38f0b
#   Perl & Python support
Packit Service b38f0b
##
Packit Service b38f0b
#########################################
Packit Service b38f0b
Packit Service b38f0b
##
Packit Service b38f0b
#   Check whether Net-SNMP configuration will support Perl
Packit Service b38f0b
##
Packit Service b38f0b
Packit Service b38f0b
#   Inputs:
Packit Service b38f0b
#       install_perl:   whether or not to install the Perl modules
Packit Service b38f0b
#                           yes/no/try   (i.e. 'maybe' - the default)
Packit Service b38f0b
#       embed_perl:     whether or not to embed Perl support within the agent
Packit Service b38f0b
#                           yes/no/try   (i.e. 'maybe' - the default)
Packit Service b38f0b
#
Packit Service b38f0b
#       ac_cv_path_PERLPROG:    Path to perl binary
Packit Service b38f0b
Packit Service b38f0b
Packit Service b38f0b
#       Embedded Perl requires Perl modules, and the perl binary
Packit Service b38f0b
#
Packit Service b38f0b
if test "x$embed_perl" = "xtry" ; then
Packit Service b38f0b
    if test "x$install_perl" = "xno" ; then
Packit Service b38f0b
        install_perl="try"
Packit Service b38f0b
    fi
Packit Service b38f0b
    if test "x$ac_cv_path_PERLPROG" = "x" -o "x$ac_cv_path_PERLPROG" = "xno" ; then
Packit Service b38f0b
        install_perl="no"
Packit Service b38f0b
        embed_perl="no"
Packit Service b38f0b
    fi
Packit Service b38f0b
fi
Packit Service b38f0b
Packit Service b38f0b
#       Perl modules require the perl binary
Packit Service b38f0b
#
Packit Service b38f0b
if test "x$install_perl" != "xno" ; then
Packit Service b38f0b
    myperl=$ac_cv_path_PERLPROG
Packit Service b38f0b
    if test $myperl = "no" ; then
Packit Service b38f0b
        if test "x$install_perl" = "xtry" ; then
Packit Service b38f0b
            install_perl="no"
Packit Service b38f0b
        else
Packit Service b38f0b
            AC_MSG_ERROR(--enable-embedded-perl requested but no perl executable found)
Packit Service b38f0b
        fi
Packit Service b38f0b
    fi
Packit Service b38f0b
fi
Packit Service b38f0b
Packit Service b38f0b
#       Perl modules require shared libraries
Packit Service b38f0b
#
Packit Service b38f0b
if test "x$install_perl" != "xno" ; then
Packit Service b38f0b
    if test "x$enable_shared" != "xyes"; then
Packit Service b38f0b
        if test "x$install_perl" = "xtry" ; then
Packit Service b38f0b
            install_perl="no"
Packit Service b38f0b
        else
Packit Service b38f0b
            AC_MSG_ERROR(Perl support requires --enable-shared)
Packit Service b38f0b
        fi
Packit Service b38f0b
    fi
Packit Service b38f0b
fi
Packit Service b38f0b
Packit Service b38f0b
#       Perl modules can only be installed from within the source tree
Packit Service b38f0b
#
Packit Service b38f0b
if test "x$install_perl" != "xno" ; then
Packit Service b38f0b
    AC_MSG_CHECKING([if we are in the source tree so we can install Perl modules])
Packit Service b38f0b
    if test "x$srcdir" = "x." -o -d perl/agent/default_store ; then
Packit Service b38f0b
        AC_MSG_RESULT([Yes])
Packit Service b38f0b
    else
Packit Service b38f0b
        if test "x$install_perl" = "xtry" ; then
Packit Service b38f0b
            install_perl="no"
Packit Service b38f0b
            AC_MSG_RESULT([No])
Packit Service b38f0b
        else
Packit Service b38f0b
            AC_MSG_ERROR([Perl modules can not be built outside the source directory])
Packit Service b38f0b
        fi
Packit Service b38f0b
    fi
Packit Service b38f0b
fi      
Packit Service b38f0b
Packit Service b38f0b
Packit Service b38f0b
#   The rest of the Perl-related checks aren't relevant
Packit Service b38f0b
#       if we're not using the Perl modules
Packit Service b38f0b
#
Packit Service b38f0b
if test "x$install_perl" != "xno" ; then
Packit Service b38f0b
Packit Service b38f0b
Packit Service b38f0b
##
Packit Service b38f0b
#   Check compiler compatability
Packit Service b38f0b
##
Packit Service b38f0b
Packit Service b38f0b
    #       What compiler was used to build the perl binary?
Packit Service b38f0b
    #
Packit Service b38f0b
    if test "x$enable_perl_cc_checks" != "xno" ; then
Packit Service b38f0b
        AC_MSG_CHECKING([for Perl cc])
Packit Service b38f0b
        changequote(, )
Packit Service b38f0b
        PERLCC=`$myperl -V:cc | $myperl -n -e 'print if (s/^\s*cc=.([-=\w\s\/]+).;\s*/$1/);'`
Packit Service b38f0b
        changequote([, ])
Packit Service b38f0b
        if test "x$PERLCC" != "x" ; then
Packit Service b38f0b
            AC_MSG_RESULT([$PERLCC])
Packit Service b38f0b
        else
Packit Service b38f0b
            if test "x$install_perl" = "xtry" ; then
Packit Service b38f0b
                install_perl="no"
Packit Service b38f0b
            else
Packit Service b38f0b
                AC_MSG_ERROR([Could not determine the compiler that was used to build $myperl. Either set the environment variable PERLPROG to a different perl binary or use --without-perl-modules to build without Perl.])
Packit Service b38f0b
            fi
Packit Service b38f0b
        fi
Packit Service b38f0b
    fi
Packit Service b38f0b
Packit Service b38f0b
    #       Was GCC used to build the perl binary?
Packit Service b38f0b
    #
Packit Service b38f0b
    if test "x$install_perl" != "xno" ; then
Packit Service b38f0b
        AC_MSG_CHECKING([whether $PERLCC is a GNU C compiler])
Packit Service b38f0b
        OLDCC=$CC
Packit Service b38f0b
        CC="$PERLCC"
Packit Service b38f0b
        AC_COMPILE_IFELSE([
Packit Service b38f0b
            AC_LANG_PROGRAM([], [[
Packit Service b38f0b
#ifndef __GNUC__
Packit Service b38f0b
  choke me
Packit Service b38f0b
#endif
Packit Service b38f0b
            ]])], [perlcc_is_gnu=yes], [perlcc_is_gnu=no])
Packit Service b38f0b
        AC_MSG_RESULT([$perlcc_is_gnu])
Packit Service b38f0b
        CC=$OLDCC
Packit Service b38f0b
Packit Service b38f0b
        #       Check compatability:  Gnu Net-SNMP vs Non-Gnu perl
Packit Service b38f0b
        #
Packit Service b38f0b
        if test "x$GCC" = "xyes" -a "x$perlcc_is_gnu" = "xno" ; then
Packit Service b38f0b
            if test "x$install_perl" = "xtry" ; then
Packit Service b38f0b
      	        install_perl="no"
Packit Service b38f0b
      	    else
Packit Service b38f0b
      	        AC_MSG_ERROR([This build is using a GNU C compiler ($CC) while Perl has been compiled with a non-GNU (or non-working) compiler ($PERLCC). This likely won't work for building with Perl support. Either specify a different compiler (--with-cc=PATH), disable this check (--disable-perl-cc-checks) or build without Perl (--without-perl-modules).])
Packit Service b38f0b
      	    fi
Packit Service b38f0b
        fi
Packit Service b38f0b
    fi
Packit Service b38f0b
Packit Service b38f0b
    #       Check compatability:  Non-Gnu Net-SNMP vs Gnu perl
Packit Service b38f0b
    #
Packit Service b38f0b
    if test "x$install_perl" != "xno" ; then
Packit Service b38f0b
        if test "x$GCC" != "xyes" -a "x$perlcc_is_gnu" = "xyes" ; then
Packit Service b38f0b
      	    if test "x$install_perl" = "xtry" ; then
Packit Service b38f0b
      	        install_perl="no"
Packit Service b38f0b
      	    else
Packit Service b38f0b
                AC_MSG_ERROR([This build is using a non-GNU C compiler ($CC) while Perl has been compiled with a GNU compiler ($PERLCC). This likely won't work for building with Perl support. Either specify a different compiler (--with-cc=PATH), disable this check (--disable-perl-cc-checks) or build without Perl (--without-perl-modules).])
Packit Service b38f0b
      	    fi
Packit Service b38f0b
        fi
Packit Service b38f0b
    fi
Packit Service b38f0b
Packit Service b38f0b
    #       Are we clear to proceed?
Packit Service b38f0b
    #
Packit Service b38f0b
    if test "x$install_perl" = "xtry" ; then
Packit Service b38f0b
        install_perl="yes"
Packit Service b38f0b
    else
Packit Service b38f0b
        if test "x$install_perl" = "xno" ; then
Packit Service b38f0b
            install_perl="no"
Packit Service b38f0b
            embed_perl="no"
Packit Service b38f0b
        fi
Packit Service b38f0b
    fi
Packit Service b38f0b
Packit Service b38f0b
Packit Service b38f0b
##
Packit Service b38f0b
#   Determine compilation environment needed for embedded Perl
Packit Service b38f0b
##
Packit Service b38f0b
Packit Service b38f0b
#       System-specific requirements
Packit Service b38f0b
#
Packit Service b38f0b
case $target_os in
Packit Service b38f0b
    solaris*)
Packit Service b38f0b
      if test "x$embed_perl" != "xno" ; then
Packit Service b38f0b
          #   Check for LARGEFILE support               (Solaris)
Packit Service b38f0b
          #
Packit Service b38f0b
          AC_MSG_CHECKING([for problematic Perl cc flags on Suns])
Packit Service b38f0b
          if $myperl -V:ccflags | $GREP LARGEFILE > /dev/null ; then
Packit Service b38f0b
            if test "x$embed_perl" = "xtry" ; then
Packit Service b38f0b
              embed_perl="no"
Packit Service b38f0b
            else
Packit Service b38f0b
              AC_MSG_ERROR([Perl was compiled with LARGEFILE support which will break Net-SNMP. Either set the environment variable PERLPROG to a different perl binary or use --disable-embedded-perl to turn off embedded Perl functionality altogether.])
Packit Service b38f0b
            fi
Packit Service b38f0b
          else
Packit Service b38f0b
            AC_MSG_RESULT([none known])
Packit Service b38f0b
          fi
Packit Service b38f0b
      fi
Packit Service b38f0b
    ;;
Packit Service b38f0b
Packit Service b38f0b
    # Embedded perl typically fails on HP-UX and Mac OS X
Packit Service b38f0b
    # We really need to investigate why, and check for this explicitly
Packit Service b38f0b
    # But for the time being, turn this off by default
Packit Service b38f0b
    hpux*|darwin8*|darwin9*|darwin10*)
Packit Service b38f0b
        if test "x$embed_perl" = "xtry" ; then
Packit Service b38f0b
            AC_MSG_WARN([Embedded perl defaulting to off])
Packit Service b38f0b
            embed_perl="no"
Packit Service b38f0b
        fi
Packit Service b38f0b
    ;;
Packit Service b38f0b
Packit Service b38f0b
    *)
Packit Service b38f0b
    ;;
Packit Service b38f0b
esac
Packit Service b38f0b
Packit Service b38f0b
#       Compiler flags
Packit Service b38f0b
#
Packit Service b38f0b
if test "x$embed_perl" != "xno" ; then
Packit Service b38f0b
    AC_MSG_CHECKING([for Perl CFLAGS])
Packit Service b38f0b
    perlcflags=`$myperl -MExtUtils::Embed -e ccopts`
Packit Service b38f0b
    if test "x$perlcflags" != "x" ; then
Packit Service b38f0b
      AC_MSG_RESULT([$perlcflags])
Packit Service b38f0b
      CFLAGS="$CFLAGS $perlcflags"
Packit Service b38f0b
    else
Packit Service b38f0b
      if test "x$embed_perl" = "xtry" ; then
Packit Service b38f0b
        embed_perl="no"
Packit Service b38f0b
      else
Packit Service b38f0b
        AC_MSG_ERROR([Could not determine the C compiler flags that were used to build $myperl. Either set the environment variable PERLPROG to a different Perl binary or use --disable-embedded-perl to turn off embedded Perl functionality altogether.])
Packit Service b38f0b
      fi
Packit Service b38f0b
    fi
Packit Service b38f0b
fi
Packit Service b38f0b
Packit Service b38f0b
#       Linker flags
Packit Service b38f0b
#
Packit Service b38f0b
if test "x$embed_perl" != "xno" ; then
Packit Service b38f0b
    AC_MSG_CHECKING([for Perl LDFLAGS])
Packit Service b38f0b
    netsnmp_perlldopts=`$myperl -MExtUtils::Embed -e ldopts`
Packit Service b38f0b
    if test "x$netsnmp_perlldopts" != "x" ; then
Packit Service b38f0b
      AC_MSG_RESULT([$netsnmp_perlldopts])
Packit Service b38f0b
    else
Packit Service b38f0b
      if test "x$embed_perl" = "xtry" ; then
Packit Service b38f0b
        embed_perl="no"
Packit Service b38f0b
      else
Packit Service b38f0b
        AC_MSG_ERROR([Could not determine the linker options that were used to build $myperl. Either set the environment variable PERLPROG to a different Perl binary or use --disable-embedded-perl to turn off embedded Perl functionality altogether.])
Packit Service b38f0b
      fi
Packit Service b38f0b
    fi
Packit Service b38f0b
    if test "x$enable_as_needed" != "xno" ; then
Packit Service b38f0b
      #   Just-in-time linking will embed the Perl library within
Packit Service b38f0b
      #       the Net-SNMP library (rather than the agent application)
Packit Service b38f0b
      #
Packit Service b38f0b
      PERLLDOPTS_FOR_LIBS="$netsnmp_perlldopts"
Packit Service b38f0b
      #   Perl ccdlflags (RPATH to libperl, hopefully)
Packit Service b38f0b
      #
Packit Service b38f0b
      AC_MSG_CHECKING([for Perl CCDLFLAGS])
Packit Service b38f0b
      changequote(, )
Packit Service b38f0b
      netsnmp_perlccdlflags=`$myperl -V:ccdlflags | $myperl -n -e 'print $1 '"if (/^\s*ccdlflags='([^']+)';/);"`
Packit Service b38f0b
      changequote([, ])
Packit Service b38f0b
      AC_MSG_RESULT([$netsnmp_perlccdlflags])
Packit Service b38f0b
      PERLLDOPTS_FOR_APPS="$netsnmp_perlccdlflags"
Packit Service b38f0b
    else
Packit Service b38f0b
      #   Otherwise embed the Perl library within the application
Packit Service b38f0b
      #
Packit Service b38f0b
      PERLLDOPTS_FOR_LIBS="$netsnmp_perlldopts"
Packit Service b38f0b
      # link *applications* against libperl
Packit Service b38f0b
      PERLLDOPTS_FOR_APPS="$netsnmp_perlldopts"
Packit Service b38f0b
    fi
Packit Service b38f0b
fi
Packit Service b38f0b
Packit Service b38f0b
#       'Perl_eval_pv' function (and equivalents)
Packit Service b38f0b
#
Packit Service b38f0b
if test "x$embed_perl" != "xno" ; then
Packit Service b38f0b
    #   Three possible versions of this routine:
Packit Service b38f0b
    #       eval_pv                                     (to 5.003_97d)
Packit Service b38f0b
    #       perl_eval_pv                                (5.004/5.005)
Packit Service b38f0b
    #       Perl_eval_pv                                (from 5.6ff)
Packit Service b38f0b
    #
Packit Service b38f0b
    OLDLIBS="$LIBS"
Packit Service b38f0b
    LIBS="$LIBS $netsnmp_perlldopts"
Packit Service b38f0b
    AC_CHECK_FUNCS(eval_pv)
Packit Service b38f0b
    AC_CHECK_FUNC(perl_eval_pv,
Packit Service b38f0b
      AC_DEFINE(HAVE_PERL_EVAL_PV_LC, 1,
Packit Service b38f0b
        [Define to 1 if you have `the perl_eval_pv' function.]))
Packit Service b38f0b
    AC_CHECK_FUNC(Perl_eval_pv,
Packit Service b38f0b
      AC_DEFINE(HAVE_PERL_EVAL_PV_UC, 1,
Packit Service b38f0b
        [Define to 1 if you have the `Perl_eval_pv' function.]))
Packit Service b38f0b
    LIBS="$OLDLIBS"
Packit Service b38f0b
    #
Packit Service b38f0b
    #   Note that autoconf flattens case when defining tokens,
Packit Service b38f0b
    #   so we need to explicitly distinguish between the latter two.
Packit Service b38f0b
Packit Service b38f0b
    if test "x$ac_cv_func_perl_eval_pv" != "xyes" -a "x$ac_cv_func_Perl_eval_pv" != "xyes" -a "x$ac_cv_func_eval_pv" != "xyes" ; then
Packit Service b38f0b
      if test "x$embed_perl" = "xtry" ; then
Packit Service b38f0b
        embed_perl="no"
Packit Service b38f0b
      else
Packit Service b38f0b
        AC_MSG_ERROR([Could not find the eval_pv, perl_eval_pv or Perl_eval_pv functions needed for embedded Perl support. Either set the environment variable PERLPROG to a different perl binary or use --disable-embedded-perl to turn off embedded Perl functionality altogether.])
Packit Service b38f0b
      fi
Packit Service b38f0b
    else
Packit Service b38f0b
      #   Activate Embedded Perl
Packit Service b38f0b
      #
Packit Service b38f0b
      AC_DEFINE(NETSNMP_EMBEDDED_PERL, 1,
Packit Service b38f0b
        [Define if you are embedding perl in the main agent.])
Packit Service b38f0b
      OTHERAGENTLIBOBJS="snmp_perl.o"
Packit Service b38f0b
      OTHERAGENTLIBLOBJS="snmp_perl.lo"
Packit Service b38f0b
      OTHERAGENTLIBLFTS="snmp_perl.ft"
Packit Service b38f0b
Packit Service b38f0b
      EMBEDPERLINSTALL="embedperlinstall"
Packit Service b38f0b
      EMBEDPERLUNINSTALL="embedperluninstall"
Packit Service b38f0b
      embed_perl="yes"
Packit Service b38f0b
    fi
Packit Service b38f0b
else
Packit Service b38f0b
      EMBEDPERLINSTALL=""
Packit Service b38f0b
      EMBEDPERLUNINSTALL=""
Packit Service b38f0b
      embed_perl="no"
Packit Service b38f0b
    fi
Packit Service b38f0b
fi
Packit Service b38f0b
Packit Service b38f0b
Packit Service b38f0b
##
Packit Service b38f0b
#   Report and configure results
Packit Service b38f0b
##
Packit Service b38f0b
Packit Service b38f0b
AC_SUBST(EMBEDPERLINSTALL)
Packit Service b38f0b
AC_SUBST(EMBEDPERLUNINSTALL)
Packit Service b38f0b
AC_SUBST(PERLLDOPTS_FOR_LIBS)
Packit Service b38f0b
AC_SUBST(PERLLDOPTS_FOR_APPS)
Packit Service b38f0b
Packit Service b38f0b
#       Results of Embedded Perl checks
Packit Service b38f0b
#
Packit Service b38f0b
AC_MSG_CHECKING([for potential embedded Perl support])
Packit Service b38f0b
if test "x$embed_perl" != "xyes" ; then
Packit Service b38f0b
  AC_MSG_CACHE_ADD(Embedded Perl support:      disabled)
Packit Service b38f0b
  AC_MSG_RESULT([disabled])
Packit Service b38f0b
else
Packit Service b38f0b
  AC_MSG_CACHE_ADD(Embedded Perl support:      enabled)
Packit Service b38f0b
  AC_MSG_RESULT([enabled])
Packit Service b38f0b
fi
Packit Service b38f0b
Packit Service b38f0b
#       Results of Perl Module checks
Packit Service b38f0b
#
Packit Service b38f0b
PERLTARGS=""
Packit Service b38f0b
PERLINSTALLTARGS=""
Packit Service b38f0b
PERLUNINSTALLTARGS=""
Packit Service b38f0b
PERLFEATURES=""
Packit Service b38f0b
AC_MSG_CHECKING([if we can install the Perl modules])
Packit Service b38f0b
if test "x$install_perl" = "xyes" ; then
Packit Service b38f0b
    PERLTARGS="perlmodules"
Packit Service b38f0b
    PERLINSTALLTARGS="perlinstall"
Packit Service b38f0b
    PERLUNINSTALLTARGS="perluninstall"
Packit Service b38f0b
    PERLFEATURES="perlfeatures"
Packit Service b38f0b
    if test "x$embed_perl" = "xyes" ; then
Packit Service b38f0b
      AC_MSG_CACHE_ADD(SNMP Perl modules:          building -- embeddable)
Packit Service b38f0b
      AC_MSG_RESULT([yes -- and embeddable])
Packit Service b38f0b
    else
Packit Service b38f0b
      AC_MSG_CACHE_ADD(SNMP Perl modules:          building -- not embeddable)
Packit Service b38f0b
      AC_MSG_RESULT([yes -- not embeddable])
Packit Service b38f0b
    fi
Packit Service b38f0b
else
Packit Service b38f0b
    AC_MSG_RESULT([no])
Packit Service b38f0b
    AC_MSG_CACHE_ADD(SNMP Perl modules:          disabled)
Packit Service b38f0b
fi
Packit Service b38f0b
AC_SUBST(PERLTARGS)
Packit Service b38f0b
AC_SUBST(PERLINSTALLTARGS)
Packit Service b38f0b
AC_SUBST(PERLUNINSTALLTARGS)
Packit Service b38f0b
AC_SUBST(PERLARGS)
Packit Service b38f0b
AC_SUBST(PERLFEATURES)
Packit Service b38f0b
Packit Service b38f0b
Packit Service b38f0b
#       Reset LIBS to pre-libwrap value   (???)
Packit Service b38f0b
#
Packit Service b38f0b
AGENTLIBS=$LIBS
Packit Service b38f0b
LIBS=$NONAGENTLIBS
Packit Service b38f0b
Packit Service b38f0b
Packit Service b38f0b
Packit Service b38f0b
##
Packit Service b38f0b
#   Python checks
Packit Service b38f0b
##
Packit Service b38f0b
Packit Service b38f0b
PYTHONTARGS=""
Packit Service b38f0b
PYTHONINSTALLTARGS=""
Packit Service b38f0b
PYTHONUNINSTALLTARGS=""
Packit Service b38f0b
PYTHONCLEANTARGS=""
Packit Service b38f0b
PYTHONFEATURES=""
Packit Service b38f0b
AC_MSG_CHECKING([if we should install the python bindings])
Packit Service b38f0b
if test "x$install_python" = "xyes" ; then
Packit Service b38f0b
    PYTHONTARGS="pythonmodules"
Packit Service b38f0b
    PYTHONINSTALLTARGS="pythoninstall"
Packit Service b38f0b
    PYTHONUNINSTALLTARGS="pythonuninstall"
Packit Service b38f0b
    PYTHONCLEANTARGS="pythonclean"
Packit Service b38f0b
    PYTHONFEATURES="pythonfeatures"
Packit Service b38f0b
    AC_MSG_CACHE_ADD(SNMP Python modules:        building for $PYTHONPROG)
Packit Service b38f0b
    AC_MSG_RESULT([yes])
Packit Service b38f0b
else
Packit Service b38f0b
    AC_MSG_CACHE_ADD(SNMP Python modules:        disabled)
Packit Service b38f0b
    AC_MSG_RESULT([no])
Packit Service b38f0b
fi
Packit Service b38f0b
AC_SUBST(PYTHONTARGS)
Packit Service b38f0b
AC_SUBST(PYTHONINSTALLTARGS)
Packit Service b38f0b
AC_SUBST(PYTHONUNINSTALLTARGS)
Packit Service b38f0b
AC_SUBST(PYTHONCLEANTARGS)
Packit Service b38f0b
AC_SUBST(PYTHONARGS)
Packit Service b38f0b
AC_SUBST(PYTHONFEATURES)
Packit Service b38f0b
Packit Service b38f0b