This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Backport memmem(3) detection changes from Perl
authorAaron Crane <arc@cpan.org>
Thu, 25 Apr 2019 09:54:42 +0000 (10:54 +0100)
committerAaron Crane <arc@cpan.org>
Thu, 25 Apr 2019 11:05:13 +0000 (12:05 +0100)
This corresponds to Perl 5 commits ca152fd8207cf53816b1407d5f54f6ea160a3ef8
and f8d82a1010426d0eb49c33cb903413b882c85c3e.

U/perl/d_memmem.U

index 404b098..3df4c82 100644 (file)
@@ -1,7 +1,7 @@
 ?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:
-?MAKE:d_memmem: Inlibc
+?MAKE:d_memmem: Inlibc d_gnulibc Hasproto
 ?MAKE: -pick add $@ %<
 ?S:d_memmem:
 ?S:    This variable conditionally defines the HAS_MEMMEM symbol, which
 ?C:.
 ?H:#$d_memmem HAS_MEMMEM               /**/
 ?H:.
-?LINT:set d_memmem
+?T:d_memmem_proto xx1 xx2 xx3 xx4
+?LINT:set d_memmem 
 : see if memmem exists
-set memmem d_memmem
-eval $inlibc
+: We need both a prototype in string.h and the symbol in libc.
+echo " "
+d_memmem_proto=''
+xx1="#$d_gnulibc HAS_GNULIBC"
+xx2='#if defined(HAS_GNULIBC) && !defined(_GNU_SOURCE)'
+xx3='#   define _GNU_SOURCE'
+xx4='#endif'
+set d_memmem_proto memmem literal "$xx1" literal "$xx2" literal "$xx3" literal "$xx4" define string.h
+eval $hasproto
+case "$d_memmem_proto" in
+    define) # see if memmem exists
+       set memmem d_memmem
+       eval $inlibc
+       ;;
+    *)  val=$undef
+       set d_memmem
+       eval $setvar
+       ;;
+esac