Hi,

trying to investigate some problems with GTK + multi-tty, I wanted to
compile Emacs with a debuggable GTK version.  I was weary but not
entirely shocked to find out that Emacs failed to pick up the location
of my locally compiled GTK instance.  Here is my pkg-config output for GTK:

$ pkg-config gtk+-2.0 --cflags
-DXTHREADS -I/home/lorentey/work/emacs/install//include/gtk-2.0 \
-I/home/lorentey/work/emacs/install//lib/gtk-2.0/include \
-I/usr/X11R6/include \
-I/home/lorentey/work/emacs/install//include/atk-1.0 \
-I/home/lorentey/work/emacs/install//include/pango-1.0 \
-I/usr/include/freetype2 \
-I/home/lorentey/work/emacs/install//include/cairo \
-I/home/lorentey/work/emacs/install//include -I/usr/include/libpng12 \
-I/home/lorentey/work/emacs/install/include/glib-2.0 \
-I/home/lorentey/work/emacs/install/lib/glib-2.0/include  

Note the double slashes; these are caused by ending a --prefix with a
slash, and are normally harmless.  In this case, however, the paths
are run through cpp, which thinks that the double slashes start
one-line comments.  The result is that pkg-config's carefully
configured include options are harshly truncated in src/Makefile:

ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(TOOLKIT_DEFINES) $(MYCPPFLAGS) -I. 
-I${srcdir} -D_BSD_SOURCE -I/usr/X11R6/include -DXTHREADS 
-I/home/lorentey/work/emacs/install ${CFLAGS}

For reference, here are the corresponding lines in src/Makefile.in:

/* C_SWITCH_X_SITE must come before C_SWITCH_X_MACHINE and C_SWITCH_X_SYSTEM
   since it may have -I options that should override those two.  */
ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(TOOLKIT_DEFINES) $(MYCPPFLAGS) -I. 
-I${srcdir} C_SWITCH_MACHINE C_SWITCH_SYSTEM C_SWITCH_SITE C_SWITCH_X_SITE 
C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM C_SWITCH_SYSTEM_TEMACS ${CFLAGS}

Passing the -ansi option to (GNU) cpp disables `//' recognition.  To
prevent other people running into this same problem, I think it would
be useful to apply the following patch:

--- orig/configure.in
+++ mod/configure.in
@@ -3126,6 +3126,14 @@
 	CPP_NEED_TRADITIONAL=no,
 	CPP_NEED_TRADITIONAL=yes)
 
+## New-fangled C preprocessors consider `//' to start a one-line comment.
+## The -ansi option forces GCC's cpp to ignore this syntax.
+
+AC_EGREP_CPP(yes//yes,
+	[yes//yes],
+	CPP_NEED_ANSI=no,
+	CPP_NEED_ANSI=yes)
+
 AC_OUTPUT(Makefile lib-src/Makefile.c:lib-src/Makefile.in oldXMenu/Makefile \
 	man/Makefile lwlib/Makefile src/Makefile.c:src/Makefile.in \
 	lisp/Makefile lispref/Makefile lispintro/Makefile leim/Makefile, [
@@ -3160,6 +3168,13 @@
   CPPFLAGS="$CPPFLAGS -traditional"
 fi
 
+# Recent GNU cpp versions understand C++-style one-line comments
+# unless invoked with -ansi.  (Works with GCC 3.3, 3.4, 4.0)
+
+if test "x$GCC" = xyes && test "x$CPP_NEED_ANSI" = xyes; then
+  CPPFLAGS="$CPPFLAGS -ansi"
+fi
+
 echo creating lib-src/Makefile
 ( cd lib-src
   rm -f junk.c junk1.c junk2.c
@@ -3200,7 +3215,7 @@
 # This is how we know whether to re-run configure in certain cases.
 touch src/config.stamp
 
-], [GCC="$GCC" NON_GNU_CPP="$NON_GNU_CPP" CPP="$CPP" CPP_NEED_TRADITIONAL="$CPP_NEED_TRADITIONAL" CPPFLAGS="$CPPFLAGS"])
+], [GCC="$GCC" NON_GNU_CPP="$NON_GNU_CPP" CPP="$CPP" CPP_NEED_TRADITIONAL="$CPP_NEED_TRADITIONAL" CPP_NEED_ANSI="$CPP_NEED_ANSI" CPPFLAGS="$CPPFLAGS"])
 
 m4_if(dnl	Do not change this comment
    arch-tag: 156a4dd5-bddc-4d18-96ac-f37742cf6a5e


Running Makefiles through the C preprocessor is evil.

-- 
KÃroly

Attachment: pgp7IQXQ88yyI.pgp
Description: PGP signature

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

Reply via email to