pandora_with_perl.m4 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. dnl -*- mode: m4; c-basic-offset: 2; indent-tabs-mode: nil; -*-
  2. dnl vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
  3. dnl
  4. dnl pandora-build: A pedantic build system
  5. dnl Copyright (C) 2009 Sun Microsystems, Inc.
  6. dnl This file is free software; Sun Microsystems
  7. dnl gives unlimited permission to copy and/or distribute it,
  8. dnl with or without modifications, as long as this notice is preserved.
  9. dnl
  10. dnl From Monty Taylor
  11. AC_DEFUN([PANDORA_WITH_PERL], [
  12. AC_ARG_WITH([perl],
  13. [AS_HELP_STRING([--with-perl],
  14. [Build Perl Bindings @<:@default=yes@:>@])],
  15. [with_perl=$withval],
  16. [with_perl=yes])
  17. AC_ARG_WITH([perl-arch],
  18. [AS_HELP_STRING([--with-perl-arch],
  19. [Install Perl bindings into system location @<:@default=no@:>@])],
  20. [with_perl_arch=$withval],
  21. [with_perl_arch=no])
  22. AS_IF([test "x$with_perl" != "xno"],[
  23. AS_IF([test "x$with_perl" != "xyes"],
  24. [ac_chk_perl=$with_perl],
  25. [ac_chk_perl=perl])
  26. AC_CHECK_PROGS(PERL,$ac_chk_perl)
  27. ])
  28. AS_IF([test "x$PERL" != "x"],[
  29. AC_CACHE_CHECK([for Perl include path],[pandora_cv_perl_include],[
  30. pandora_cv_perl_include=`$PERL -MConfig -e 'print $Config{archlib};'`
  31. pandora_cv_perl_include="${pandora_cv_perl_include}/CORE"
  32. ])
  33. AC_CACHE_CHECK([for Perl CPPFLAGS],[pandora_cv_perl_cppflags],[
  34. pandora_cv_perl_cppflags=`$PERL -MConfig -e 'print $Config{cppflags};'`
  35. pandora_cv_perl_cppflags="${pandora_cv_perl_cppflags}"
  36. ])
  37. PERL_CPPFLAGS="-I${pandora_cv_perl_include} ${pandora_cv_perl_cppflags}"
  38. AC_CACHE_CHECK([for Perl development headers],
  39. [pandora_cv_perl_dev],[
  40. save_CPPFLAGS="${CPPFLAGS}"
  41. CPPFLAGS="${CPPFLAGS} ${PERL_CPPFLAGS}"
  42. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  43. #include <math.h>
  44. #include <stdlib.h>
  45. #include "EXTERN.h"
  46. #include "perl.h"
  47. #include "XSUB.h"
  48. ]])],
  49. [pandora_cv_perl_dev=yes],
  50. [pandora_cv_perl_dev=no])
  51. CPPFLAGS="${save_CPPFLAGS}"
  52. ])
  53. AS_IF([test "${pandora_cv_perl_dev}" = "no"],
  54. [with_perl=no])
  55. AC_CACHE_CHECK([for Perl install location],
  56. [pandora_cv_perl_archdir],[
  57. AS_IF([test "${with_perl_arch}" = "no"],[
  58. pandora_cv_perl_archdir=`$PERL -MConfig -e 'print $Config{sitearch}'`
  59. ],[
  60. pandora_cv_perl_archdir=`$PERL -MConfig -e 'print $Config{archlib}'`
  61. ])
  62. pandora_cv_perl_archdir="${pandora_cv_perl_archdir}"
  63. ])
  64. PERL_ARCHDIR="${pandora_cv_perl_archdir}"
  65. ])
  66. AC_SUBST([PERL_CPPFLAGS])
  67. AC_SUBST([PERL_ARCHDIR])
  68. AM_CONDITIONAL(BUILD_PERL, [test "$with_perl" != "no"])
  69. ])