[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: 8-gary-obstack-portability.patch
From: |
Gary V. Vaughan |
Subject: |
FYI: 8-gary-obstack-portability.patch |
Date: |
Thu, 6 Sep 2001 21:19:34 +0100 |
User-agent: |
Mutt/1.3.21i |
Index: ChangeLog
from Gary V. Vaughan <address@hidden>
Fix the obstack.h problem once and for all! At configure time we
can test for a system supplied obstack.h: depending on the
result, we now generate system.h with an #include of the correct
header. As a bonus, I've also added a --with-included-obstack,
incase the user doesn't like the system obstack for some
reason... and also we can test the shipped obstack on a system
that has oe of its own. We also now need to be careful to add
build directories to the include search path, since the generated
system.h will be in the build tree.
* configure.in (AC_CONFIG_FILES): Generate system.h from
system-h.in.
* config/gnu-obstack.m4 (M4_AC_FUNC_OBSTACK): Determine whether to
include the system obstack header or the copy shipped with M4.
Allow the user to override configure and force the build to use
the shipped version.
* m4/system-h.in: New file, template for...
* m4/system.h: ...this. Now deleted.
* m4/m4module.h: Include system.h before everything else.
* src/freeze.c: Ditto.
* m4/Makefile.am (dist-hook): Remove generated system.h.
(INCLUDES): Check builddir for generated headers before checking
srcdir.
* modules/Makefile.am (INCLUDES): Ditto.
* src/Makefile.am (INCLUDES): Ditto.
Index: configure.in
===================================================================
RCS file: /cvsroot/m4/m4/configure.in,v
retrieving revision 1.20
diff -u -p -u -r1.20 configure.in
--- configure.in 2001/09/01 10:31:19 1.20
+++ configure.in 2001/09/06 20:11:40
@@ -140,7 +140,7 @@ AC_SUBST(ac_aux_dir)
# Outputs.
AC_CONFIG_FILES(Makefile config/Makefile doc/Makefile m4/Makefile
- src/Makefile modules/Makefile tests/Makefile
- examples/Makefile)
+ m4/system.h:m4/system-h.in src/Makefile modules/Makefile
+ tests/Makefile examples/Makefile)
AC_OUTPUT
Index: config/gnu-obstack.m4
===================================================================
RCS file: /cvsroot/m4/m4/config/gnu-obstack.m4,v
retrieving revision 1.7
diff -u -p -u -r1.7 gnu-obstack.m4
--- config/gnu-obstack.m4 2001/09/01 10:31:19 1.7
+++ config/gnu-obstack.m4 2001/09/06 20:11:40
@@ -18,17 +18,8 @@
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
-# serial 5
+# serial 6
-# FIXME: This might not be portable... When obstack.h is found, we
-# want to use the system's obstack.h. But we don't want to install
-# config.h, so we _need_ m4/obstack.h. The current proposal is based
-# on `#include_next', which is certainly not portable, but chances are
-# very high that a system with a proper obstack implementation has a
-# good compiler. It might be chimeric to try some more robust
-# solution. One such solution would be to hard code the _path_ of the
-# native obstack.h into an `#include' in our obstack.h.
-
AC_PREREQ(2.52)
# M4_AC_FUNC_OBSTACK
@@ -38,30 +29,49 @@ AC_DEFUN([M4_AC_FUNC_OBSTACK],
[AC_CHECK_HEADER(obstack.h)
m4_pattern_allow([^m4_cv_func_obstack$])dnl
m4_pattern_allow([^m4_obstack_h$])dnl
-AC_CACHE_CHECK([for obstack in libc], m4_cv_func_obstack,
+
+AC_ARG_WITH([included-obstack],
+ [AC_HELP_STRING([--with-included-obstack],
+ [use the obstack imlementation included here])])
+
+if test "x${with_included_obstack-no}" = xno; then
+ AC_CACHE_CHECK([for obstack in libc], m4_cv_func_obstack,
[AC_TRY_LINK([#include "obstack.h"],
[struct obstack *mem;obstack_free(mem,(char *) 0)],
- m4_cv_func_obstack=yes,
- m4_cv_func_obstack=no)])
+ [m4_cv_func_obstack=yes],
+ [m4_cv_func_obstack=no])])
+else
+ m4_cv_func_obstack=no
+fi
+
OBSTACK_H=
m4_obstack_h=m4/obstack.h
rm -f $m4_obstack_h
if test $m4_cv_func_obstack = yes; then
+
+ # The system provides obstack.h, `#include <obstack.h>' will work
+ INCLUDE_OBSTACK_H='<obstack.h>'
AC_DEFINE(HAVE_OBSTACK, 1, [Define if libc includes obstacks.])
- # We are in the core of configure, when build directories do not
- # exist yet, as they are created by config.status.
- test -d m4 || mkdir m4
- cat >$m4_obstack_h <<EOF
-/* The native header works properly. */
-#include_next <obstack.h>
-EOF
+
else
- LIBOBJS="$LIBOBJS obstack.$ac_objext"
- AC_CONFIG_LINKS($m4_obstack_h:./gnu-obstack.h)
+
+ # The system does not provide obstack.h, or the user has specified
+ # to build without it. Unfortunately we can't leave an obstack.h
+ # file around anywhere in the include path if the system also
+ # provides an implementation: So we ship m4/gnu-obstack.h, and link
+ # it to m4/obstack.h here (to substitute the missing system supplied
+ # version). Hence, `#include <m4/obstack.h>' will work.
+ INCLUDE_OBSTACK_H='<m4/obstack.h>'
+ AC_CONFIG_LINKS($m4_obstack_h:${top_srcdir}/m4/gnu-obstack.h)
if test x"$ac_cv_header_obstack_h" != xyes; then
OBSTACK_H=obstack.h
fi
+
+ # In the absence of a system implementation, we must compile our own:
+ LIBOBJS="$LIBOBJS obstack.$ac_objext"
+
fi
AC_SUBST(OBSTACK_H)
+AC_SUBST(INCLUDE_OBSTACK_H)
])# M4_AC_FUNC_OBSTACK
Index: m4/Makefile.am
===================================================================
RCS file: /cvsroot/m4/m4/m4/Makefile.am,v
retrieving revision 1.10
diff -u -p -u -r1.10 Makefile.am
--- m4/Makefile.am 2001/09/01 20:05:27 1.10
+++ m4/Makefile.am 2001/09/06 20:11:40
@@ -25,12 +25,13 @@ MODULE_PATH = $(pkglibexecdir)
pkgincdir = $(includedir)/@PACKAGE@
LDFLAGS = -no-undefined -export-dynamic
-INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src @INTLINCL@
+INCLUDES = -I$(top_builddir) -I$(top_srcdir) \
+ -I$(top_builddir)/src -I$(top_srcdir)/src @INTLINCL@
include_HEADERS = m4module.h
noinst_HEADERS = m4private.h
pkginc_HEADERS = error.h hash.h ltdl.h regex.h system.h @OBSTACK_H@
-EXTRA_HEADERS = gnu-obstack.h
+EXTRA_HEADERS = system-h.in gnu-obstack.h
EXTRA_DIST = $(EXTRA_HEADERS) obstack.c
@@ -44,3 +45,7 @@ libm4_la_LIBADD = @LTLIBOBJS@ @LIBADD_D
module.o module.lo: $(srcdir)/module.c pathconf.h
pathconf.h: Makefile
@echo "#define MODULE_PATH \"${MODULE_PATH}\"" > pathconf.h
+
+# This file needs to be regenerated at configure time.
+dist-hook:
+ rm -f $(distdir)/system.h
Index: m4/m4module.h
===================================================================
RCS file: /cvsroot/m4/m4/m4/m4module.h,v
retrieving revision 1.20
diff -u -p -u -r1.20 m4module.h
--- m4/m4module.h 2001/09/05 07:51:41 1.20
+++ m4/m4module.h 2001/09/06 20:11:41
@@ -20,15 +20,9 @@
#ifndef M4MODULE_H
#define M4MODULE_H 1
-#if HAVE_OBSTACK
-# include <obstack.h>
-#else
-# include <m4/obstack.h>
-#endif
-
+#include <m4/system.h>
#include <m4/error.h>
#include <m4/ltdl.h>
-#include <m4/system.h>
#include <m4/hash.h>
BEGIN_C_DECLS
Index: m4/system-h.in
===================================================================
RCS file: system-h.in
diff -N system-h.in
--- /dev/null Sat Apr 14 17:46:23 2001
+++ m4/system-h.in Thu Sep 6 13:11:42 2001
@@ -0,0 +1,184 @@
+/* GNU m4 -- A simple macro processor
+ Copyright 2000 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+*/
+
+/**
+ * @configure_generated@
+ *
+ * This file is installed, so cannot rely on the contents of config.h.
+ * It works best if included _after_ system headers.
+ **/
+
+#ifndef M4_SYSTEM_H
+#define M4_SYSTEM_H 1
+
+/* I have yet to see a system that doesn't have these... */
+#include <stdio.h>
+#include <sys/types.h>
+#include @INCLUDE_OBSTACK_H@
+
+/* This is okay in an installed file, because it will not change the
+ behaviour of the including program whether ENABLE_NLS is defined
+ or not. */
+#ifndef _
+# ifdef ENABLE_NLS
+# include <libintl.h>
+# define _(Text) gettext ((Text))
+# else
+# define _(Text) (Text)
+# endif
+#endif
+
+
+/* All header files should be inside BEGIN_C_DECLS ... END_C_DECLS, so
+ that the library can be linked into a C++ program. The multi-include
+ guard macros must be outside, as should any #includes -- for simplicity
+ everything else should go inside. */
+
+#ifndef BEGIN_C_DECLS
+# ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+# else /* !__cplusplus */
+# define BEGIN_C_DECLS /* empty */
+# define END_C_DECLS /* empty */
+# endif /* __cplusplus */
+#endif /* !BEGIN_C_DECLS */
+
+BEGIN_C_DECLS
+
+
+
+/* Canonicalise Windows and Cygwin recognition macros. */
+#if defined __CYGWIN32__ && !defined __CYGWIN__
+# define __CYGWIN__ __CYGWIN32__
+#endif
+#if defined _WIN32 && !defined WIN32
+# define WIN32 _WIN32
+#endif
+
+#if defined WIN32 && !defined __CYGWIN__
+/* M4_DIRSEP_CHAR is accepted *in addition* to '/' as a directory
+ separator when it is set. */
+# define M4_DIRSEP_CHAR '\\'
+# define M4_PATHSEP_CHAR ';'
+#endif
+#ifndef M4_PATHSEP_CHAR
+# define M4_PATHSEP_CHAR ':'
+#endif
+
+
+
+/* M4_STMT_START/END are used to create macros which expand to a
+ a single compound statement in a portable way, but crucially in
+ a way sympathetic to the compiler to maximise optimisation. */
+#undef M4_STMT_START
+#undef M4_STMT_END
+#if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus)
+# define M4_STMT_START (void)(
+# define M4_STMT_END )
+#else
+# if (defined (sun) || defined (__sun__))
+# define M4_STMT_START if (1)
+# define M4_STMT_END else (void)0
+# else
+# define M4_STMT_START do
+# define M4_STMT_END while (0)
+# endif
+#endif
+
+
+
+/* Take advantage of GNU C compiler source level optimisation hints,
+ using portable macros. */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
+# define M4_GNUC_ATTRIBUTE(args) __attribute__(args)
+#else
+# define M4_GNUC_ATTRIBUTE(args)
+#endif /* __GNUC__ */
+
+#define M4_GNUC_PRINTF(fmt, arg) M4_GNUC_ATTRIBUTE((format (printf, fmt, arg)))
+#define M4_GNUC_SCANF(fmt, arg) M4_GNUC_ATTRIBUTE((format (scanf, fmt,
arg)))
+#define M4_GNUC_FORMAT(arg_idx) M4_GNUC_ATTRIBUTE((format_arg
(arg_idx)))
+#define M4_GNUC_NORETURN M4_GNUC_ATTRIBUTE((noreturn))
+#define M4_GNUC_CONST M4_GNUC_ATTRIBUTE((const))
+#define M4_GNUC_UNUSED M4_GNUC_ATTRIBUTE((unused))
+
+
+
+#if !defined __PRETTY_FUNCTION__
+# define __PRETTY_FUNCTION__ "<unknown>"
+#endif
+
+
+/* Preprocessor token manipulation. */
+
+/* The extra indirection to the _STR and _CONC macros is required so that
+ if the arguments to STR() (or CONC()) are themselves macros, they will
+ be expanded before being quoted. */
+#ifndef STR
+# define _STR(arg) #arg
+# define STR(arg) _STR(arg)
+#endif
+
+#ifndef CONC
+# define _CONC(a, b) a##b
+# define CONC(a, b) _CONC(a, b)
+#endif
+
+
+
+/* Make sure these are defined. */
+#ifndef EXIT_FAILURE
+# define EXIT_SUCCESS 0
+# define EXIT_FAILURE 1
+#endif
+
+
+
+/* If FALSE is defined, we presume TRUE is defined too. In this case,
+ merely typedef boolean as being int. Or else, define these all. */
+#ifndef FALSE
+/* Do not use `enum boolean': this tag is used in SVR4 <sys/types.h>. */
+typedef enum { FALSE = 0, TRUE = 1 } m4_boolean;
+#else
+typedef int m4_boolean;
+#endif
+/* `boolean' is already a macro on some systems. */
+#ifndef boolean
+# define boolean m4_boolean
+#endif
+
+
+
+/* Memory allocation. */
+#define XCALLOC(type, num) ((type *) xcalloc ((num), sizeof(type)))
+#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
+#define XREALLOC(type, p, num) ((type *) xrealloc ((p), (num) * sizeof(type)))
+#define XFREE(p) ((p) = xfree (p))
+
+extern void *xcalloc (size_t n, size_t s);
+extern void *xmalloc (size_t n);
+extern void *xrealloc (void *p, size_t n);
+extern void *xfree (void *stale);
+
+extern char *xstrdup (const char *string);
+
+END_C_DECLS
+
+#endif /* !M4_SYSTEM_H */
Index: m4/system.h
===================================================================
RCS file: system.h
diff -N system.h
--- m4/system.h Thu Sep 6 13:11:56 2001
+++ /dev/null Sat Apr 14 17:46:23 2001
@@ -1,181 +0,0 @@
-/* GNU m4 -- A simple macro processor
- Copyright 2000 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA
-*/
-
-/**
- * This file is installed, so cannot rely on the contents of config.h.
- * It works best if included _after_ system headers.
- **/
-
-#ifndef M4_SYSTEM_H
-#define M4_SYSTEM_H 1
-
-/* I have yet to see a system that doesn't have these... */
-#include <stdio.h>
-#include <sys/types.h>
-
-/* This is okay in an installed file, because it will not change the
- behaviour of the including program whether ENABLE_NLS is defined
- or not. */
-#ifndef _
-# ifdef ENABLE_NLS
-# include <libintl.h>
-# define _(Text) gettext ((Text))
-# else
-# define _(Text) (Text)
-# endif
-#endif
-
-
-/* All header files should be inside BEGIN_C_DECLS ... END_C_DECLS, so
- that the library can be linked into a C++ program. The multi-include
- guard macros must be outside, as should any #includes -- for simplicity
- everything else should go inside. */
-
-#ifndef BEGIN_C_DECLS
-# ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-# else /* !__cplusplus */
-# define BEGIN_C_DECLS /* empty */
-# define END_C_DECLS /* empty */
-# endif /* __cplusplus */
-#endif /* !BEGIN_C_DECLS */
-
-BEGIN_C_DECLS
-
-
-
-/* Canonicalise Windows and Cygwin recognition macros. */
-#if defined __CYGWIN32__ && !defined __CYGWIN__
-# define __CYGWIN__ __CYGWIN32__
-#endif
-#if defined _WIN32 && !defined WIN32
-# define WIN32 _WIN32
-#endif
-
-#if defined WIN32 && !defined __CYGWIN__
-/* M4_DIRSEP_CHAR is accepted *in addition* to '/' as a directory
- separator when it is set. */
-# define M4_DIRSEP_CHAR '\\'
-# define M4_PATHSEP_CHAR ';'
-#endif
-#ifndef M4_PATHSEP_CHAR
-# define M4_PATHSEP_CHAR ':'
-#endif
-
-
-
-/* M4_STMT_START/END are used to create macros which expand to a
- a single compound statement in a portable way, but crucially in
- a way sympathetic to the compiler to maximise optimisation. */
-#undef M4_STMT_START
-#undef M4_STMT_END
-#if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus)
-# define M4_STMT_START (void)(
-# define M4_STMT_END )
-#else
-# if (defined (sun) || defined (__sun__))
-# define M4_STMT_START if (1)
-# define M4_STMT_END else (void)0
-# else
-# define M4_STMT_START do
-# define M4_STMT_END while (0)
-# endif
-#endif
-
-
-
-/* Take advantage of GNU C compiler source level optimisation hints,
- using portable macros. */
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
-# define M4_GNUC_ATTRIBUTE(args) __attribute__(args)
-#else
-# define M4_GNUC_ATTRIBUTE(args)
-#endif /* __GNUC__ */
-
-#define M4_GNUC_PRINTF(fmt, arg) M4_GNUC_ATTRIBUTE((format (printf, fmt, arg)))
-#define M4_GNUC_SCANF(fmt, arg) M4_GNUC_ATTRIBUTE((format (scanf, fmt,
arg)))
-#define M4_GNUC_FORMAT(arg_idx) M4_GNUC_ATTRIBUTE((format_arg
(arg_idx)))
-#define M4_GNUC_NORETURN M4_GNUC_ATTRIBUTE((noreturn))
-#define M4_GNUC_CONST M4_GNUC_ATTRIBUTE((const))
-#define M4_GNUC_UNUSED M4_GNUC_ATTRIBUTE((unused))
-
-
-
-#if !defined __PRETTY_FUNCTION__
-# define __PRETTY_FUNCTION__ "<unknown>"
-#endif
-
-
-/* Preprocessor token manipulation. */
-
-/* The extra indirection to the _STR and _CONC macros is required so that
- if the arguments to STR() (or CONC()) are themselves macros, they will
- be expanded before being quoted. */
-#ifndef STR
-# define _STR(arg) #arg
-# define STR(arg) _STR(arg)
-#endif
-
-#ifndef CONC
-# define _CONC(a, b) a##b
-# define CONC(a, b) _CONC(a, b)
-#endif
-
-
-
-/* Make sure these are defined. */
-#ifndef EXIT_FAILURE
-# define EXIT_SUCCESS 0
-# define EXIT_FAILURE 1
-#endif
-
-
-
-/* If FALSE is defined, we presume TRUE is defined too. In this case,
- merely typedef boolean as being int. Or else, define these all. */
-#ifndef FALSE
-/* Do not use `enum boolean': this tag is used in SVR4 <sys/types.h>. */
-typedef enum { FALSE = 0, TRUE = 1 } m4_boolean;
-#else
-typedef int m4_boolean;
-#endif
-/* `boolean' is already a macro on some systems. */
-#ifndef boolean
-# define boolean m4_boolean
-#endif
-
-
-
-/* Memory allocation. */
-#define XCALLOC(type, num) ((type *) xcalloc ((num), sizeof(type)))
-#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
-#define XREALLOC(type, p, num) ((type *) xrealloc ((p), (num) * sizeof(type)))
-#define XFREE(p) ((p) = xfree (p))
-
-extern void *xcalloc (size_t n, size_t s);
-extern void *xmalloc (size_t n);
-extern void *xrealloc (void *p, size_t n);
-extern void *xfree (void *stale);
-
-extern char *xstrdup (const char *string);
-
-END_C_DECLS
-
-#endif /* !M4_SYSTEM_H */
Index: modules/Makefile.am
===================================================================
RCS file: /cvsroot/m4/m4/modules/Makefile.am,v
retrieving revision 1.12
diff -u -p -u -r1.12 Makefile.am
--- modules/Makefile.am 2001/08/30 21:57:00 1.12
+++ modules/Makefile.am 2001/09/06 20:11:42
@@ -27,7 +27,8 @@ ETAGS_ARGS = --regex='/M4BUILTIN_HANDLER
EXTRA_DIST = modtest.m4 shadow.m4 time.m4 time2.m4 stdlib.m4 format.c
-INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/m4 $(INCLTDL) $(INTLINCL)
+INCLUDES = -I$(top_builddir) -I$(top_srcdir) \
+ -I$(top_builddir)/m4 -I$(top_srcdir)/m4 $(INCLTDL) $(INTLINCL)
LIBS = $(top_builddir)/m4/libm4.la
LDFLAGS = -no-undefined
Index: src/Makefile.am
===================================================================
RCS file: /cvsroot/m4/m4/src/Makefile.am,v
retrieving revision 1.7
diff -u -p -u -r1.7 Makefile.am
--- src/Makefile.am 2001/09/01 10:31:19 1.7
+++ src/Makefile.am 2001/09/06 20:11:55
@@ -21,7 +21,8 @@
CLEANFILES = m4$(EXEEXT)
MAINTAINERCLEANFILES = Makefile.in
-INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/m4 $(INCLTDL) $(INTLINCL)
+INCLUDES = -I$(top_builddir) -I$(top_srcdir) \
+ -I$(top_builddir)/m4 -I$(top_srcdir)/m4 $(INCLTDL) $(INTLINCL)
noinst_HEADERS = gnu-getopt.h
Index: src/freeze.c
===================================================================
RCS file: /cvsroot/m4/m4/src/freeze.c,v
retrieving revision 1.12
diff -u -p -u -r1.12 freeze.c
--- src/freeze.c 2001/09/01 20:05:27 1.12
+++ src/freeze.c 2001/09/06 20:11:56
@@ -19,12 +19,7 @@
/* This module handles frozen files. */
-#if HAVE_OBSTACK
-# include <obstack.h>
-#else
-# include <m4/obstack.h>
-#endif
-
+#include "m4/system.h"
#include "m4.h"
#include "m4private.h"
--
())_. Gary V. Vaughan gary@(oranda.demon.co.uk|gnu.org)
( '/ Research Scientist http://www.oranda.demon.co.uk ,_())____
/ )= GNU Hacker http://www.gnu.org/software/libtool \' `&
`(_~)_ Tech' Author http://sources.redhat.com/autobook =`---d__/
- FYI: 8-gary-obstack-portability.patch,
Gary V. Vaughan <=