[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

[PATCH: Configure/NDBM_File] Add prototype detection for NDBMheader files



The first of the two attached patches adds prototype detection
for the different ndbm header files to Configure.

Only the presence of prototypes is checked, not prototypes for
individual functions. Since more than one file may be present,
detection is separate for all files.

Note that the detection logic is different for C and C++. For
C++, adding valid prototype indicates the absence of prototypes
if the compile fails. For C, adding an invalid prototype
indicates the presence of prototypes if the compile fails.

The second hunk from the Configure patch is unrelated and adds
a val="$undef" which I thought was missing, but I may be wrong.

I wasn't sure about the correct way to incorporate the changes
into config_h.SH, so I ignored the header and patched it right
away. :-)

The second patch fixes NDBM_File to make use of the new defines
emitted by config_h.SH and make C++ happy again on hopefully
all platforms.

Marcus

-- 
narcolepulacyi, n.:
	The contagious action of yawning, causing everyone in sight
	to also yawn.
		-- "Sniglets", Rich Hall & Friends
--- config_h.SH.orig	2008-11-03 19:49:22.000000000 +0100
+++ config_h.SH	2008-11-03 22:24:53.000000000 +0100
@@ -2423,6 +2423,9 @@
 #$i_ndbm I_NDBM	/**/
 #$i_gdbmndbm I_GDBMNDBM	/**/
 #$i_gdbm_ndbm I_GDBM_NDBM	/**/
+#$d_ndbm_h_uses_prototypes NDBM_H_USES_PROTOTYPES	/**/
+#$d_gdbmndbm_h_uses_prototypes GDBMNDBM_H_USES_PROTOTYPES	/**/
+#$d_gdbm_ndbm_h_uses_prototypes GDBM_NDBM_H_USES_PROTOTYPES	/**/
 
 /* I_NETDB:
  *	This symbol, if defined, indicates that <netdb.h> exists and
--- Configure.orig	2008-11-03 19:17:02.000000000 +0100
+++ Configure	2008-11-03 22:24:30.000000000 +0100
@@ -885,6 +885,9 @@
 i_gdbm_ndbm=''
 i_gdbmndbm=''
 i_ndbm=''
+d_ndbm_h_uses_prototypes=''
+d_gdbmndbm_h_uses_prototypes=''
+d_gdbm_ndbm_h_uses_prototypes=''
 i_netdb=''
 i_neterrno=''
 i_netinettcp=''
@@ -21054,6 +21057,7 @@
 set gdbm-ndbm.h i_gdbm_ndbm
 eval $inhdr
 
+val="$undef"
 if $test "$i_ndbm" = "$define" -o "$i_gdbmndbm" = "$define" -o "$i_gdbm_ndbm" = "$define"; then
 	: see if dbm_open exists
 	set dbm_open d_dbm_open
@@ -21073,6 +21077,30 @@
 set d_ndbm
 eval $setvar
 
+ndbm_hdr_protochk='name=$1; hdr=$2;
+eval "ihdr=\$i_$name";
+val="$undef";
+if $test "$ihdr" = "$define"; then
+	$echo "Checking if your <$hdr> uses prototypes..." >&4;
+	case "$d_cplusplus" in
+	$define) ./protochk "$extern_C void dbm_close(DBM *);" literal "extern \"C\" {" $ihdr $hdr literal "}" && val="$define" ;;
+	*) ./protochk "$extern_C void dbm_close(int, int);" $ihdr $hdr || val="$define" ;;
+	esac;
+	case "$val" in
+	$define) $echo "Your <$hdr> seems to have prototypes";;
+	*) $echo "Your <$hdr> does not seem to have prototypes";;
+	esac;
+fi;
+set "d_${name}_h_uses_prototypes";
+eval $setvar'
+
+set ndbm ndbm.h
+eval $ndbm_hdr_protochk
+set gdbmndbm gdbm/ndbm.h
+eval $ndbm_hdr_protochk
+set gdbm_ndbm gdbm-ndbm.h
+eval $ndbm_hdr_protochk
+
 : see if this is a ieeefp.h system
 case "$i_ieeefp" in
 '' ) set ieeefp.h i_ieeefp
@@ -22322,6 +22350,9 @@
 d_munmap='$d_munmap'
 d_mymalloc='$d_mymalloc'
 d_ndbm='$d_ndbm'
+d_ndbm_h_uses_prototypes='$d_ndbm_h_uses_prototypes'
+d_gdbmndbm_h_uses_prototypes='$d_gdbmndbm_h_uses_prototypes'
+d_gdbm_ndbm_h_uses_prototypes='$d_gdbm_ndbm_h_uses_prototypes'
 d_nice='$d_nice'
 d_nl_langinfo='$d_nl_langinfo'
 d_nv_preserves_uv='$d_nv_preserves_uv'

--- ext/NDBM_File/NDBM_File.xs.orig	2008-11-03 21:42:21.000000000 +0100
+++ ext/NDBM_File/NDBM_File.xs	2008-11-03 21:47:44.000000000 +0100
@@ -1,12 +1,22 @@
 #include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"
+#undef NDBM_HEADER_USES_PROTOTYPES
 #if defined(I_GDBM_NDBM)
 #  include <gdbm-ndbm.h> /* Debian compatibility version */
+#  ifdef GDBM_NDBM_H_USES_PROTOTYPES
+#    define NDBM_HEADER_USES_PROTOTYPES
+#  endif
 #elif defined(I_GDBMNDBM)
 #  include <gdbm/ndbm.h> /* RedHat compatibility version */
+#  ifdef GDBMNDBM_H_USES_PROTOTYPES
+#    define NDBM_HEADER_USES_PROTOTYPES
+#  endif
 #elif defined(I_NDBM)
-#include <ndbm.h>
+#  include <ndbm.h>
+#  ifdef NDBM_H_USES_PROTOTYPES
+#    define NDBM_HEADER_USES_PROTOTYPES
+#  endif
 #endif
 
 typedef struct {
@@ -23,7 +33,7 @@
 typedef datum datum_value ;
 
 
-#if defined(__cplusplus) && defined(HAS_GDBM)
+#if defined(__cplusplus) && !defined(NDBM_HEADER_USES_PROTOTYPES)
 /* gdbm's header file used for compatibility with gdbm */
 /* isn't compatible to C++ syntax, so we need these */
 /* declarations to make everyone happy. */
--- ext/NDBM_File/Makefile.PL.orig	2008-11-03 21:48:35.000000000 +0100
+++ ext/NDBM_File/Makefile.PL	2008-11-03 21:48:47.000000000 +0100
@@ -1,16 +1,7 @@
-use Config;
 use ExtUtils::MakeMaker;
-
-my $define = "";
-
-if($Config{i_gdbm} && $Config{i_gdbm} eq 'define') {
-    $define .= " -DHAS_GDBM";
-}
-
 WriteMakefile(
     NAME	=> 'NDBM_File',
     LIBS => ["-L/usr/local/lib -lndbm", "-ldbm -lucb"],
-    DEFINE => $define,
     MAN3PODS 	=> {}, 	# Pods will be built by installman.
     XSPROTOARG => '-noprototypes', 		# XXX remove later?
     VERSION_FROM => 'NDBM_File.pm',

signature.asc


Follow-Ups from:
Marcus Holland-Moritz <mhx-perl@gmx.net>
"H.Merijn Brand" <h.m.brand@xs4all.nl>
"H.Merijn Brand" <h.m.brand@xs4all.nl>
"H.Merijn Brand" <h.m.brand@xs4all.nl>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]