Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
6.0KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_perl_ext.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_PERL_EXT
  8. #
  9. # DESCRIPTION
  10. #
  11. # Fetches the linker flags and C compiler flags for compiling and linking
  12. # Perl binary extensions. The macro substitutes PERL_EXT_PREFIX,
  13. # PERL_EXT_INC, PERL_EXT_LIB, PERL_EXT_CPPFLAGS, PERL_EXT_LDFLAGS and
  14. # PERL_EXT_DLEXT variables if Perl executable was found. It also checks
  15. # the same variables before trying to retrieve them from the Perl
  16. # configuration.
  17. #
  18. # PERL_EXT_PREFIX: top-level perl installation path (--prefix)
  19. # PERL_EXT_INC: XS include directory
  20. # PERL_EXT_LIB: Perl extensions destination directory
  21. # PERL_EXT_CPPFLAGS: C preprocessor flags to compile extensions
  22. # PERL_EXT_LDFLAGS: linker flags to build extensions
  23. # PERL_EXT_DLEXT: extensions suffix for perl modules (e.g. ".so")
  24. #
  25. # Examples:
  26. #
  27. # AX_PERL_EXT
  28. # if test x"$PERL" = x; then
  29. # AC_ERROR(["cannot find Perl"])
  30. # fi
  31. #
  32. # LICENSE
  33. #
  34. # Copyright (c) 2011 Stanislav Sedov <stas@FreeBSD.org>
  35. # Copyright (c) 2014 Thomas Klausner <tk@giga.or.at>
  36. #
  37. # Redistribution and use in source and binary forms, with or without
  38. # modification, are permitted provided that the following conditions are
  39. # met:
  40. #
  41. # 1. Redistributions of source code must retain the above copyright
  42. # notice, this list of conditions and the following disclaimer.
  43. #
  44. # 2. Redistributions in binary form must reproduce the above copyright
  45. # notice, this list of conditions and the following disclaimer in the
  46. # documentation and/or other materials provided with the distribution.
  47. #
  48. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  49. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  50. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  51. # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
  52. # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  53. # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  54. # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  55. # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  56. # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  57. # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  58. # THE POSSIBILITY OF SUCH DAMAGE.
  59. #serial 3
  60. AC_DEFUN([AX_PERL_EXT],[
  61. #
  62. # Check if perl executable exists.
  63. #
  64. AC_PATH_PROGS(PERL, ["${PERL-perl}"], [])
  65. if test -n "$PERL" ; then
  66. #
  67. # Check for Perl prefix.
  68. #
  69. AC_ARG_VAR(PERL_EXT_PREFIX, [Perl PREFIX])
  70. AC_MSG_CHECKING([for Perl prefix])
  71. if test -z "$PERL_EXT_PREFIX" ; then
  72. [PERL_EXT_PREFIX=`$PERL -MConfig -e 'print $Config{prefix};'`];
  73. fi
  74. AC_MSG_RESULT([$PERL_EXT_PREFIX])
  75. AC_SUBST(PERL_EXT_PREFIX)
  76. #
  77. # Check for Perl extensions include path.
  78. #
  79. AC_ARG_VAR(PERL_EXT_INC, [Directory to include XS headers from])
  80. AC_MSG_CHECKING([for Perl extension include path])
  81. if test -z "$PERL_EXT_INC" ; then
  82. [PERL_EXT_INC=`$PERL -MConfig -e 'print $Config{archlibexp}, "/CORE";'`];
  83. fi
  84. AC_MSG_RESULT([$PERL_EXT_INC])
  85. AC_SUBST(PERL_EXT_INC)
  86. #
  87. # Check for the extensions target directory.
  88. #
  89. AC_ARG_VAR(PERL_EXT_LIB, [Directory to install perl files into])
  90. AC_MSG_CHECKING([for Perl extension target directory])
  91. if test -z "$PERL_EXT_LIB" ; then
  92. [PERL_EXT_LIB=`$PERL -MConfig -e 'print $Config{sitearch};'`];
  93. fi
  94. AC_MSG_RESULT([$PERL_EXT_LIB])
  95. AC_SUBST(PERL_EXT_LIB)
  96. #
  97. # Check for Perl CPP flags.
  98. #
  99. AC_ARG_VAR(PERL_EXT_CPPFLAGS, [CPPFLAGS to compile perl extensions])
  100. AC_MSG_CHECKING([for Perl extensions C preprocessor flags])
  101. if test -z "$PERL_EXT_CPPFLAGS" ; then
  102. [PERL_EXT_CPPFLAGS=`$PERL -MConfig -e 'print $Config{cppflags};'`];
  103. fi
  104. AC_MSG_RESULT([$PERL_EXT_CPPFLAGS])
  105. AC_SUBST(PERL_EXT_CPPFLAGS)
  106. #
  107. # Check for Perl extension link flags.
  108. #
  109. AC_ARG_VAR(PERL_EXT_LDFLAGS, [LDFLAGS to build perl extensions])
  110. AC_MSG_CHECKING([for Perl extensions linker flags])
  111. if test -z "$PERL_EXT_LDFLAGS" ; then
  112. [PERL_EXT_LDFLAGS=`$PERL -MConfig -e 'print $Config{lddlflags};'`];
  113. fi
  114. # Fix LDFLAGS for OS X. We don't want any -arch flags here, otherwise
  115. # linking will fail. Also, OS X Perl LDFLAGS contains "-arch ppc" which
  116. # is not supported by XCode anymore.
  117. case "${host}" in
  118. *darwin*)
  119. PERL_EXT_LDFLAGS=`echo ${PERL_EXT_LDFLAGS} | sed -e "s,-arch [[^ ]]*,,g"`
  120. ;;
  121. esac
  122. AC_MSG_RESULT([$PERL_EXT_LDFLAGS])
  123. AC_SUBST(PERL_EXT_LDFLAGS)
  124. #
  125. # Check for Perl dynamic library extension.
  126. #
  127. AC_ARG_VAR(PERL_EXT_DLEXT, [Perl dynamic library extension])
  128. AC_MSG_CHECKING([for Perl dynamic library extension])
  129. if test -z "$PERL_EXT_DLEXT" ; then
  130. [PERL_EXT_DLEXT=`$PERL -MConfig -e 'print ".", $Config{'dlext'};'`];
  131. fi
  132. AC_MSG_RESULT([$PERL_EXT_DLEXT])
  133. AC_SUBST(PERL_EXT_DLEXT)
  134. fi
  135. ])