]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Do not build psql's flex module on its own, but instead include it in
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 10 Nov 2009 23:12:52 +0000 (23:12 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 10 Nov 2009 23:12:52 +0000 (23:12 +0000)
mainloop.c.  This ensures that postgres_fe.h is read before including
any system headers, which is necessary to avoid problems on some platforms
where we make nondefault selections of feature macros for stdio.h or
other headers.  We have had this policy for flex modules in the backend
for many years, but for some reason it was not applied to psql.
Per trouble report from Alexandra Roy and diagnosis by Albe Laurenz.

src/bin/psql/Makefile
src/bin/psql/mainloop.c

index 06fe45133f066c5ed73959843846d7549ee24d96..5edab8388f11a730fbe20417944d6d68f0f01b08 100644 (file)
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/bin/psql/Makefile,v 1.52.4.1 2005/03/25 18:18:40 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/psql/Makefile,v 1.52.4.2 2009/11/10 23:12:51 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -21,7 +21,7 @@ override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS)
 
 OBJS=  command.o common.o help.o input.o stringutils.o mainloop.o copy.o \
        startup.o prompt.o variables.o large_obj.o print.o describe.o \
-       psqlscan.o tab-complete.o mbprint.o $(WIN32RES)
+       tab-complete.o mbprint.o $(WIN32RES)
 
 FLEXFLAGS = -Cfe
 
@@ -41,6 +41,9 @@ $(srcdir)/sql_help.h:
        @echo "*** Perl is needed to build psql help."
 endif
 
+# psqlscan is compiled as part of mainloop
+mainloop.o: psqlscan.c
+
 $(srcdir)/psqlscan.c: psqlscan.l
 ifdef FLEX
        $(FLEX) $(FLEXFLAGS) -o'$@' $<
index 109f23192f84ab044c5aea2d9952d5048e490fbd..9a242625c7d435f30606c9f415551130bc20b458 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2005, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.66 2005/01/01 05:43:08 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.66.4.1 2009/11/10 23:12:52 tgl Exp $
  */
 #include "postgres_fe.h"
 #include "mainloop.h"
@@ -346,3 +346,13 @@ MainLoop(FILE *source)
 
        return successResult;
 }      /* MainLoop() */
+
+
+/*
+ * psqlscan.c is #include'd here instead of being compiled on its own.
+ * This is because we need postgres_fe.h to be read before any system
+ * include files, else things tend to break on platforms that have
+ * multiple infrastructures for stdio.h and so on.  flex is absolutely
+ * uncooperative about that, so we can't compile psqlscan.c on its own.
+ */
+#include "psqlscan.c"