This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Backport ability to include literal text in prototype checks
authorAaron Crane <arc@cpan.org>
Thu, 25 Apr 2019 09:59:48 +0000 (10:59 +0100)
committerAaron Crane <arc@cpan.org>
Thu, 25 Apr 2019 11:05:15 +0000 (12:05 +0100)
This corresponds to Perl 5 commit 63c1fa6a98bc60234a21de83dd191cd581a5d073

U/perl/Hasproto.U [new file with mode: 0644]

diff --git a/U/perl/Hasproto.U b/U/perl/Hasproto.U
new file mode 100644 (file)
index 0000000..04e91a5
--- /dev/null
@@ -0,0 +1,48 @@
+?RCS: $Id: Hasproto.U $
+?RCS:
+?RCS: Copyright (c) 1998 Andy Dougherty
+?RCS:
+?RCS: You may distribute under the terms of either the GNU General Public
+?RCS: License or the Artistic License, as specified in the README file.
+?RCS:
+?X:    This unit generates a $hasproto string that is used internally
+?X:    by Configure to check if this system has a prototype for a
+?X:    particular function
+?X:
+?X:    To use it, say something like:
+?X:            set d_getnetent_proto getnetent $i_netdb netdb.h
+?X:            eval $hasproto
+?X:    Or, for more complicated sets of headers, do something like
+?X:    hdrs="$define sys/types.h
+?X:            $i_systime sys/time.h
+?X:            $i_sysselct sys/select.h
+?X:            $i_netdb netdb.h"
+?X:    set d_getnetent_proto getnetent $hdrs
+?X:    eval $hasproto
+?X:
+?MAKE:Hasproto: Setvar cppstdin cppflags cppminus contains rm_try test
+?MAKE: -pick add $@ %<
+?T:func varname
+?F:!try.c
+?V:hasproto
+: Define hasproto macro for Configure internal use
+hasproto='varname=$1; func=$2; shift; shift;
+while $test $# -ge 2; do
+       case "$1" in
+       $define) echo "#include <$2>";;
+       literal) echo "$2" ;;
+       esac ;
+    shift 2;
+done > try.c;
+$cppstdin $cppflags $cppminus < try.c > tryout.c 2>/dev/null;
+if $contains "$func.*(" tryout.c >/dev/null 2>&1; then
+       echo "$func() prototype found.";
+       val="$define";
+else
+       echo "$func() prototype NOT found.";
+       val="$undef";
+fi;
+set $varname;
+eval $setvar;
+$rm_try tryout.c'
+