THRIFT-916: Commit a partial fix for flex-generated code infested with warnings on Mac OS X

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1038844 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/Makefile.am b/compiler/cpp/Makefile.am
index ac69b34..cbb12f5 100644
--- a/compiler/cpp/Makefile.am
+++ b/compiler/cpp/Makefile.am
@@ -26,11 +26,11 @@
 
 bin_PROGRAMS = thrift
 
+noinst_LIBRARIES = libparse.a
+
 thrift_OBJDIR = obj
 
-thrift_SOURCES = src/thrifty.yy \
-                 src/thriftl.ll \
-                 src/main.cc \
+thrift_SOURCES = src/main.cc \
                  src/md5.c \
                  src/generate/t_generator.cc \
                  src/generate/t_generator_registry.h \
@@ -115,10 +115,15 @@
 thrift_SOURCES += src/generate/t_javame_generator.cc
 endif
 
-thrift_CXXFLAGS = -Wall -I$(srcdir)/src
-thrift_LDFLAGS = -Wall
+thrift_CPPFLAGS = -I$(srcdir)/src
+thrift_CXXFLAGS = -Wall
+thrift_LDADD = @LEXLIB@ libparse.a
 
-thrift_LDADD = @LEXLIB@
+libparse_a_CPPFLAGS = -I$(srcdir)/src
+libparse_a_CXXFLAGS = -Wall -Wno-sign-compare -Wno-unused
+
+libparse_a_SOURCES = src/thrifty.yy \
+                     src/thriftl.ll
 
 EXTRA_DIST = README
 
diff --git a/compiler/cpp/src/thriftl.ll b/compiler/cpp/src/thriftl.ll
index a6229f4..762cb2f 100644
--- a/compiler/cpp/src/thriftl.ll
+++ b/compiler/cpp/src/thriftl.ll
@@ -25,6 +25,14 @@
 
 %{
 
+/* This is redundant with some of the flags in Makefile.am, but it works
+ * when people override CXXFLAGS without being careful. The pragmas are
+ * the 'right' way to do it, but don't work on old-enough GCC (in particular
+ * the GCC that ship on Mac OS X 10.6.5, *counter* to what the GNU docs say)
+ *
+ * We should revert the Makefile.am changes once Apple ships a reasonable
+ * GCC.
+ */
 #pragma GCC diagnostic ignored "-Wunused-function"
 #pragma GCC diagnostic ignored "-Wunused-label"
 
diff --git a/lib/cpp/Makefile.am b/lib/cpp/Makefile.am
index c15cbe0..402a294 100644
--- a/lib/cpp/Makefile.am
+++ b/lib/cpp/Makefile.am
@@ -80,7 +80,8 @@
 # Flags for the various libraries
 libthriftnb_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBEVENT_CPPFLAGS)
 libthriftz_la_CPPFLAGS  = $(AM_CPPFLAGS) $(ZLIB_CPPFLAGS)
-
+libthriftnb_la_CXXFLAGS = $(AM_CXXFLAGS)
+libthriftz_la_CXXFLAGS  = $(AM_CXXFLAGS)
 
 include_thriftdir = $(includedir)/thrift
 include_thrift_HEADERS = \
diff --git a/lib/cpp/test/Makefile.am b/lib/cpp/test/Makefile.am
index 02c26ad..1829268 100644
--- a/lib/cpp/test/Makefile.am
+++ b/lib/cpp/test/Makefile.am
@@ -176,6 +176,7 @@
 	-I$(top_srcdir)/lib/cpp/src
 
 AM_CPPFLAGS = $(BOOST_CPPFLAGS)
+AM_CXXFLAGS = -Wall
 
 clean-local:
 	$(RM) -r gen-cpp