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.

139 lines
4.8KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_sys_perlsharpbang.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_SYS_PERLSHARPBANG
  8. #
  9. # DESCRIPTION
  10. #
  11. # Determine how the perl interpreter is located by the OS kernel and make
  12. # substitution variable PERL_SHEBANG available. Does AC_PATH_PROG to find
  13. # the path to perl. As a side-effect, that sets PERLINTERP and makes it
  14. # available as a substitution variable.
  15. #
  16. # Note: The macro allows for the possibility (expected to be seldom used)
  17. # of an explicit user override (the "user" being the operator executing
  18. # the final 'configure' script, in this context) by making the option
  19. # argument like:
  20. #
  21. # --with-perl-shebang='#! /my/funky/perlpath' # OR
  22. # --with-perl-shebang='/my/funky/perlpath' # we just throw away the #! anyway
  23. # # bec it must be absent in Makefile
  24. #
  25. # Rationale: The are various ways of starting an interpreter on different
  26. # *nix-like systems. Many use the simple
  27. #
  28. # #!/usr/bin/perl
  29. #
  30. # but it could be instead
  31. #
  32. # #!/usr/local/bin/perl
  33. #
  34. # and there is even the possibility that the user wants
  35. #
  36. # #!/usr/bin/env perl
  37. #
  38. # to find whichever perl comes first in the current $PATH. This is
  39. # preferred by some of us because we run multiple perl installations on
  40. # the same box. Adjusting our $PATH then allows us to set precedence over
  41. # other perls, even whatever the "house" version is.
  42. #
  43. # Users on very non-unix systems like MS Windows do not have a kernel that
  44. # does this kind of thing from the first line of script files, but instead
  45. # the perl on their machine is started and merely notices whatever comes
  46. # after the interpreter path on this first line of the script (options
  47. # like "-w").
  48. #
  49. # Acknowledgement: this macro was in part inspired by Dean Povey's
  50. # AC_PROG_PERL_VERSION.
  51. #
  52. # LICENSE
  53. #
  54. # Copyright (c) 2009 Soren Andersen <somian@pobox.com>
  55. #
  56. # Copying and distribution of this file, with or without modification, are
  57. # permitted in any medium without royalty provided the copyright notice
  58. # and this notice are preserved. This file is offered as-is, without any
  59. # warranty.
  60. #serial 14
  61. AC_DEFUN([AX_SYS_PERLSHARPBANG],[dnl
  62. AC_PATH_PROG(PERLINTERP,perl,perl)
  63. ac_cv_path_perlinterp="$PERLINTERP"
  64. _sHpB='#!'
  65. AC_ARG_WITH(perl-shebang,
  66. AS_HELP_STRING([--with-perl-shebang],
  67. [override what perl thinks is the way for the kernel to start it (seldom needed)]dnl
  68. ),
  69. [opt_perl_shebang="$withval"]dnl
  70. ,dnl
  71. [opt_perl_shebang="not_set"]dnl
  72. )dnl
  73. AC_CACHE_CHECK([whether explicit instead of detected sharpbang is to be used],
  74. ax_cv_opt_perl_shebang,
  75. [ case "$opt_perl_shebang" in
  76. not_set ) ax_cv_opt_perl_shebang=''
  77. ;;
  78. * )
  79. ax_cv_opt_perl_shebang=`echo "$opt_perl_shebang" | sed -e's|^#!\s*\(.*\)$|\1|'`
  80. esac
  81. ]dnl
  82. )dnl
  83. if test "A$ax_cv_opt_perl_shebang" != "A"
  84. then
  85. ac_cv_sys_kernshrpbang_perl="$ax_cv_opt_perl_shebang"
  86. PERL_SHEBANG="$ac_cv_sys_kernshrpbang_perl"
  87. AC_SUBST(PERL_SHEBANG)dnl
  88. AC_MSG_NOTICE([OK - PERL_SHEBANG is $_sHpB$PERL_SHEBANG.])
  89. # Automatic detection of sharpbang formula starts here
  90. else dnl
  91. _somian_shbangperl=`$PERLINTERP -V:startperl`
  92. negclass="[[^']]"; dnl
  93. # must leave this comment: m4 will remove the outer brackets for us, heheh
  94. AC_CACHE_CHECK([for kernel sharpbang invocation to start perl],
  95. ac_cv_sys_kernshrpbang_perl,
  96. [_somian_kspb_perl=`echo "$_somian_shbangperl" | sed -ne"s|.*='\($negclass*\)';$|\1|p"`
  97. if test "x$_somian_kspb_perl" == x
  98. then _somian_ksbp_warn_empty='durnit'
  99. else
  100. case "A$_somian_kspb_perl" in
  101. A#!*perl* )
  102. ac_cv_sys_kernshrpbang_perl=`echo "$_somian_kspb_perl" | sed -e's|#!\(.*\)$|\1|'`
  103. ;;
  104. A* ) _somian_ksbp_warn_defau='trouble'
  105. ac_cv_sys_kernshrpbang_perl="$PERLINTERP"
  106. esac
  107. fi
  108. ])dnl Done with testing sharpbang
  109. # The above prints Checking ... result message to user.
  110. PERL_SHEBANG="$ac_cv_sys_kernshrpbang_perl"
  111. AC_SUBST(PERL_SHEBANG)
  112. if test A${_somian_ksbp_warn_empty+set} == Aset
  113. then AC_MSG_WARN([dnl
  114. In last check, doing $PERLINTERP -V:startperl yielded empty result! That should not happen.])
  115. fi
  116. # Inform user after printing result value
  117. if test A${_somian_ksbp_warn_defau+set} == Aset
  118. then AC_MSG_NOTICE([Maybe Not good -])
  119. AC_MSG_WARN([dnl
  120. In last check perl's Config query did not work so we bunted: $_sHpB$PERLINTERP])
  121. else AC_MSG_NOTICE([OK Good result - ])
  122. AC_MSG_NOTICE([dnl
  123. In last check we got a proper-looking answer from perl's Config: $_somian_shbangperl])
  124. dnl Done with user info messages
  125. fi
  126. dnl Outer loop checked for user override term here
  127. fi dnl
  128. ])dnl EOMACRO DEF