From xemacs-m  Wed Dec 11 08:47:52 1996
Received: from susan.logware.de (root@susan.logware.de [192.109.80.15]) by xemacs.cs.uiuc.edu (8.8.3/8.8.3) with SMTP id IAA28803 for <xemacs-beta@xemacs.org>; Wed, 11 Dec 1996 08:47:48 -0600 (CST)
Received: by susan.logware.de (Smail3.1.29.1)
	  id <m0vXpwo-0000AxC>; Wed, 11 Dec 96 15:47 MET
Message-Id: <m0vXpwo-0000AxC@susan.logware.de>
Date: Wed, 11 Dec 96 15:47 MET
From: Michael Diers <mdiers@logware.de>
To: XEmacs beta list <xemacs-beta@xemacs.org>
Subject: [19.15-b3] configure issues, and patch

I still get bitten by the way we use cpp to generate Makefile
from Makefile.in.

In directories lib-src and src, for instance, Makefile is
constructed by running cpp on Makefile.in, producing junk.cpp,
and eventually Makefile. If you happen to use GNU cpp, and the
configuration is "i386-unknown-freebsd2.1.5", cpp will produce a
mangled junk.cpp.

The problem is that -- at least on this platform -- GNU cpp has a
number of "questionable" default defines, viz.

  mdiers@susan [~/tmp] $ gcc -E -dM empty.c 
  #define __FreeBSD__ 2 
  #define __i386__ 1 
  #define __i386 1 
  #define __GNUC_MINOR__ 6 
  #define i386 1 
  #define __unix 1 
  #define __unix__ 1 
  #define __GNUC__ 2 
  #define unix 1 

Now, cpp will happily substitute occurences of `i386' and `unix'
in odd places of Makefile.in.

It seems that this situation has been anticipated for a number of
architectures in Makefile.in (see below), but in a klugy sort of
way.

  /* Some people use these in paths they define.  We don't want their paths
     getting changed on them. */
  #undef sparc
  #undef sun
  #undef unix
  #undef sgi
  #undef NeXT
  #undef mips

A more proper solution seems to be to pass the -undef option to
cpp when generating the makefiles, as in

  mdiers@susan [~/tmp] $ gcc -E -undef -dM empty.c 
  #define __GNUC_MINOR__ 6 
  #define __GNUC__ 2 

Thus, I propose the following change to configure.in.

--- configure.in--dist	Sun Sep 15 20:34:24 1996
+++ configure.in	Wed Dec 11 15:30:49 1996
@@ -2539,8 +2539,16 @@
 #### Some systems specify a CPP to use unless we are using GCC.
 #### Now that we know whether we are using GCC, we can decide whether
 #### to use that one.
-if [ "x$NON_GNU_CPP" = x ] || [ x$GCC = x1 ]
-then true
+
+#### Also, GNU CPP by default defines certain add'l macros that could
+#### hurt us when generating makefiles. We want to switch off these
+#### add'l macros for the purpose of generating makefiles.
+
+CPPFLAGS_MAKEFILEGEN=""
+if [ "x$GCC" = x1 ] ; then
+  CPPFLAGS_MAKEFILEGEN=" -undef "
+elif [ "x$NON_GNU_CPP" = x ] ; then
+  true
 else
   if [ "x$CPP" = x ]; then
     if [ "${with_lcc}" = "yes" ] && [ "${NON_GNU_CPP}" = "yes" ] ; then
@@ -4456,7 +4464,7 @@
 ( cd ./src;
   rm -f junk.c;
   sed -e '\''s/^# Generated.*//'\'' -e '\''s%/\*\*/#.*%%'\'' < Makefile.in > junk.c;
-  eval `echo ${CPP} -I. -I${topsrcdir}/src ${CPPFLAGS} junk.c \>junk.cpp`;
+  eval `echo ${CPP} ${CPPFLAGS_MAKEFILEGEN} -I. -I${topsrcdir}/src ${CPPFLAGS} junk.c \>junk.cpp`;
   < junk.cpp							'\
 '    sed -e '\''s/^#.*//'\''					'\
 '	-e '\''s/^[ \f\t][ \f\t]*$//'\''			'\
@@ -4473,7 +4481,7 @@
 ( cd ./lwlib;
   rm -f junk.c;
   sed -e '\''s/^# Generated.*//'\'' -e '\''s%/\*\*/#.*%%'\'' < Makefile.in > junk.c;
-  eval `echo ${CPP} -I. -I${topsrcdir}/src ${CPPFLAGS} junk.c \>junk.cpp`;
+  eval `echo ${CPP} ${CPPFLAGS_MAKEFILEGEN} -I. -I${topsrcdir}/src ${CPPFLAGS} junk.c \>junk.cpp`;
   < junk.cpp							'\
 '    sed -e '\''s/^#.*//'\''					'\
 '	-e '\''s/^[ \f\t][ \f\t]*$//'\''			'\
@@ -4490,7 +4498,7 @@
 ( cd ./lib-src;
   rm -f junk.c;
   sed -e '\''s/^# Generated.*//'\'' -e '\''s%/\*\*/#.*%%'\'' < Makefile.in > junk.c;
-  eval `echo ${CPP} -I. -I${topsrcdir}/src ${CPPFLAGS} junk.c \>junk.cpp`;
+  eval `echo ${CPP} ${CPPFLAGS_MAKEFILEGEN} -I. -I${topsrcdir}/src ${CPPFLAGS} junk.c \>junk.cpp`;
   < junk.cpp							'\
 '    sed -e '\''s/^#.*//'\''					'\
 '	-e '\''s/^[ \f\t][ \f\t]*$//'\''			'\
@@ -4507,7 +4515,7 @@
 ( cd ./dynodump;
   rm -f junk.c;
   sed -e '\''s/^# Generated.*//'\'' -e '\''s%/\*\*/#.*%%'\'' < Makefile.in > junk.c;
-  eval `echo ${CPP} -I. -I${topsrcdir}/src ${CPPFLAGS} junk.c \>junk.cpp`;
+  eval `echo ${CPP} ${CPPFLAGS_MAKEFILEGEN} -I. -I${topsrcdir}/src ${CPPFLAGS} junk.c \>junk.cpp`;
   < junk.cpp							'\
 '    sed -e '\''s/^#.*//'\''					'\
 '	-e '\''s/^[ \f\t][ \f\t]*$//'\''			'\
@@ -4524,7 +4532,7 @@
 ( cd ./man;
   rm -f junk.c;
   sed -e '\''s/^# Generated.*//'\'' -e '\''s%/\*\*/#.*%%'\'' < Makefile.in > junk.c;
-  eval `echo ${CPP} -I. -I${topsrcdir}/src ${CPPFLAGS} junk.c \>junk.cpp`;
+  eval `echo ${CPP} ${CPPFLAGS_MAKEFILEGEN} -I. -I${topsrcdir}/src ${CPPFLAGS} junk.c \>junk.cpp`;
   < junk.cpp							'\
 '    sed -e '\''s/^#.*//'\''					'\
 '	-e '\''s/^[ \f\t][ \f\t]*$//'\''			'\
@@ -4542,7 +4550,7 @@
 ( cd ./lwlib/energize;
   rm -f junk.c;
   sed -e '\''s/^# Generated.*//'\'' -e '\''s%/\*\*/#.*%%'\'' < Makefile.in > junk.c;
-  eval `echo ${CPP} -I. -I${topsrcdir}/src ${CPPFLAGS} junk.c \>junk.cpp`;
+  eval `echo ${CPP} ${CPPFLAGS_MAKEFILEGEN} -I. -I${topsrcdir}/src ${CPPFLAGS} junk.c \>junk.cpp`;
   < junk.cpp							'\
 '    sed -e '\''s/^#.*//'\''					'\
 '	-e '\''s/^[ \f\t][ \f\t]*$//'\''			'\

