Full automake/autoconf compliance for thrift

Summary: Including the compiler!!!

Reviewed By: automake


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664949 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bootstrap.sh b/bootstrap.sh
index 0d29bbe..d88319a 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -1,36 +1,8 @@
 #!/bin/sh
 
-subdirs="lib/cpp lib/php lib/py"
+subdirs="compiler/cpp lib/cpp lib/php lib/py"
 
-rm -rf \
-AUTHORS \
-COPYING \
-ChangeLog \
-INSTALL \
-Makefile.am \
-Makefile \
-Makefile.in \
-Makefile.orig \
-NEWS \
-aclocal.m4 \
-autom4te.cache \
-autoscan.log \
-config.guess \
-config.h \
-config.hin \
-config.log \
-config.status \
-config.sub \
-configure \
-configure.scan \
-depcomp \
-.deps \
-install-sh \
-.libs \
-libtool \
-ltmain.sh \
-missing
-
+./cleanup.sh
 echo "SUBDIRS = ${subdirs}" > Makefile.am
 
 aclocal
diff --git a/cleanup.sh b/cleanup.sh
new file mode 100755
index 0000000..2cf4c00
--- /dev/null
+++ b/cleanup.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+subdirs="compiler/cpp lib/cpp lib/php lib/py"
+
+rm -rf \
+AUTHORS \
+COPYING \
+ChangeLog \
+INSTALL \
+Makefile.am \
+Makefile \
+Makefile.in \
+Makefile.orig \
+NEWS \
+aclocal.m4 \
+autom4te.cache \
+autoscan.log \
+config.guess \
+config.h \
+config.hin \
+config.log \
+config.status \
+config.sub \
+configure \
+configure.scan \
+depcomp \
+.deps \
+install-sh \
+.libs \
+libtool \
+ltmain.sh \
+missing
+
+for subdir in ${subdirs}; do 
+    if [ -x "${subdir}/cleanup.sh" ]; then 
+	cwd="`pwd`"
+	cd ${subdir}
+	./cleanup.sh
+	cd ${cwd}
+    fi
+done
diff --git a/compiler/cpp/Makefile.am b/compiler/cpp/Makefile.am
new file mode 100644
index 0000000..1678c26
--- /dev/null
+++ b/compiler/cpp/Makefile.am
@@ -0,0 +1,23 @@
+AM_YFLAGS = -d
+
+bin_PROGRAMS = thrift
+
+thrift_OBJDIR = obj
+
+thrift_SOURCES = src/thrifty.yy \
+                 src/thriftl.ll \
+                 src/main.cc \
+                 src/generate/t_generator.cc \
+                 src/generate/t_cpp_generator.cc \
+                 src/generate/t_java_generator.cc \
+                 src/generate/t_php_generator.cc \
+                 src/generate/t_xsd_generator.cc \
+                 src/generate/t_py_generator.cc
+
+thrift_CXXFLAGS = -Wall -Isrc
+thrift_LDFLAGS = -Wall
+
+thrift_LDADD = @LEXLIB@
+
+clean-local:
+	rm -rf thriftl.cc thrifty.cc thrifty.h
diff --git a/compiler/cpp/Makefile.mcslee b/compiler/cpp/Makefile.mcslee
deleted file mode 100644
index 218731c..0000000
--- a/compiler/cpp/Makefile.mcslee
+++ /dev/null
@@ -1,109 +0,0 @@
-# Makefile for Thrift compiler. This Makefile assumes that you are running on
-# some form of *NIX operating system with the following tools and packages
-# installed:
-#
-#   g++
-#   flex
-#   bison
-#   libfl
-# 
-# Author:
-#   Mark Slee <mcslee@facebook.com>
-
-# Default build rule
-target:	thrift
-
-# Tools
-CC    = g++
-LD    = g++
-LEX   = flex
-YACC  = bison
-MKDIR = mkdir
-
-# Source directory
-SRC_DIR = src/
-
-# Object file directory
-OBJ_DIR = obj/
-
-# Generated source dir
-GEN_DIR = $(SRC_DIR)
-
-# Output directory
-BIN_DIR = bin/
-
-# Source files
-SRC_FILES = main.cc \
-            generate/t_generator.cc \
-            generate/t_xsd_generator.cc \
-            generate/t_py_generator.cc \
-            generate/t_java_generator.cc \
-            generate/t_php_generator.cc \
-            generate/t_cpp_generator.cc
-
-# Autogenerated files
-GEN_FILES = thrifty.tab.hh \
-            thrifty.tab.cc \
-            lex.yy.cc
-
-# Object files
-OBJ_FILES = ${SRC_FILES:.cc=.o}
-
-# Generated object files
-GOB_FILES = thrifty.tab.o \
-            lex.yy.o
-
-# Apply directory prefixes
-SRCS = ${addprefix $(SRC_DIR), $(SRC_FILES)}
-GENS = ${addprefix $(GEN_DIR), $(GEN_FILES)}
-OBJS = ${addprefix $(OBJ_DIR), $(OBJ_FILES)}
-GOBS = ${addprefix $(OBJ_DIR), $(GOB_FILES)}
-
-# Compile with strict warnings
-CFL = -g -Wall -I$(SRC_DIR) -I$(OBJ_DIR)
-
-# Flex library
-LIBS = -lfl
-
-# Build directories
-obj_dirs: $(BIN_DIR) $(OBJ_DIR)parse $(OBJ_DIR)generate
-$(BIN_DIR):
-	$(MKDIR) -p $(BIN_DIR)
-$(OBJ_DIR)parse:
-	$(MKDIR) -p $(OBJ_DIR)parse
-$(OBJ_DIR)generate:
-	$(MKDIR) -p $(OBJ_DIR)generate
-
-# Scanner generation
-$(GEN_DIR)lex.yy.cc: $(SRC_DIR)thriftl.ll
-	$(LEX) -o$@ $(SRC_DIR)thriftl.ll
-$(OBJ_DIR)lex.yy.o: $(GEN_DIR)lex.yy.cc
-	$(CC) $(CFL) -c -o $@ $(GEN_DIR)lex.yy.cc
-
-# Parser generation
-$(GEN_DIR)thrifty.tab.hh: $(GEN_DIR)thrifty.tab.cc
-$(GEN_DIR)thrifty.tab.cc: $(SRC_DIR)thrifty.yy
-	$(YACC) -d -o$(GEN_DIR)thrifty.tab.cc $(SRC_DIR)thrifty.yy
-$(OBJ_DIR)thrifty.tab.o: $(GEN_DIR)thrifty.tab.cc
-	$(CC) $(CFL) -c -o $@ $(GEN_DIR)thrifty.tab.cc
-
-# C++ compilation
-$(OBJS): $(SRCS)
-	$(CC) $(CFL) -c -o $@ ${subst $(OBJ_DIR),$(SRC_DIR),$*.cc}
-
-# Main build rule
-thrift:	obj_dirs $(OBJS) $(GOBS)
-	$(LD) $(CFL) -o $(BIN_DIR)thrift $(OBJS) $(GOBS) $(LIBS)
-
-# Install
-install: thrift
-	sudo install bin/thrift /usr/local/bin/thrift
-
-# Remove auto-gen'd files and binaries
-clean:
-	rm -fr \
-	$(OBJ_DIR) \
-	$(GENS) \
-	$(BIN_DIR)thrift.exe \
-	$(BIN_DIR)thrift
-
diff --git a/compiler/cpp/bootstrap.sh b/compiler/cpp/bootstrap.sh
new file mode 100755
index 0000000..3189372
--- /dev/null
+++ b/compiler/cpp/bootstrap.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+./cleanup.sh
+autoscan
+aclocal
+libtoolize --automake
+touch NEWS README AUTHORS ChangeLog
+autoconf
+automake -ac
diff --git a/compiler/cpp/cleanup.sh b/compiler/cpp/cleanup.sh
new file mode 100755
index 0000000..9cea039
--- /dev/null
+++ b/compiler/cpp/cleanup.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+rm -rf \
+AUTHORS \
+COPYING \
+ChangeLog \
+INSTALL \
+Makefile \
+Makefile.in \
+Makefile.orig \
+NEWS \
+README \
+aclocal.m4 \
+autom4te.cache \
+autoscan.log \
+config.guess \
+config.h \
+config.hin \
+config.log \
+config.status \
+config.sub \
+configure \
+configure.scan \
+depcomp \
+.deps \
+install-sh \
+.libs \
+.in \
+libtool \
+ltmain.sh \
+Makefile.in \
+missing
diff --git a/compiler/cpp/configure.ac b/compiler/cpp/configure.ac
new file mode 100644
index 0000000..eadb7f1
--- /dev/null
+++ b/compiler/cpp/configure.ac
@@ -0,0 +1,51 @@
+AC_PREREQ(2.59)
+
+AC_INIT(thrift, 1.0)
+
+AM_PROG_LEX
+
+AC_PROG_YACC
+
+AM_INIT_AUTOMAKE
+
+AC_CHECK_HEADERS([stddef.h])
+
+AC_CHECK_FUNCS([mkdir])
+
+AC_CHECK_FUNCS([realpath])
+
+AC_CHECK_FUNCS([strdup])
+
+AC_FUNC_MALLOC
+
+AC_FUNC_REALLOC
+
+AC_FUNC_STAT
+
+AC_FUNC_VPRINTF
+
+AC_TYPE_SIZE_T
+
+AC_C_CONST
+
+AC_C_VOLATILE
+
+AC_HEADER_STDBOOL
+
+AC_HEADER_STDC
+
+AC_HEADER_TIME
+
+AC_PROG_CC
+
+AC_PROG_CXX
+
+AC_PROG_INSTALL
+
+AC_PROG_LIBTOOL
+
+CFLAGS="-O2"
+
+CXXFLAGS="-O2"
+
+AC_OUTPUT(Makefile)
diff --git a/compiler/cpp/src/thriftl.ll b/compiler/cpp/src/thriftl.ll
index 80cbf87..855443b 100644
--- a/compiler/cpp/src/thriftl.ll
+++ b/compiler/cpp/src/thriftl.ll
@@ -14,7 +14,7 @@
  * Must be included AFTER parse/t_program.h, but I can't remember why anymore
  * because I wrote this a while ago.
  */
-#include "thrift.tab.hh"
+#include "thrifty.h"
 
 void thrift_reserved_keyword(char* keyword) {
   yyerror("Cannot use reserved language keyword: \"%s\"\n", keyword);
diff --git a/lib/cpp/bootstrap.sh b/lib/cpp/bootstrap.sh
index 607655d..34df69d 100755
--- a/lib/cpp/bootstrap.sh
+++ b/lib/cpp/bootstrap.sh
@@ -1,36 +1,6 @@
 #!/bin/sh
 
-rm -rf \
-AUTHORS \
-COPYING \
-ChangeLog \
-INSTALL \
-Makefile \
-Makefile.in \
-Makefile.orig \
-NEWS \
-README \
-aclocal.m4 \
-autom4te.cache \
-autoscan.log \
-config.guess \
-config.h \
-config.hin \
-config.log \
-config.status \
-config.sub \
-configure \
-configure.scan \
-depcomp \
-.deps \
-install-sh \
-.libs \
-libtool \
-ltmain.sh \
-Makefile.in \
-missing
-
-
+./cleanup.sh
 autoscan
 autoheader
 aclocal -I ./aclocal
diff --git a/lib/cpp/cleanup.sh b/lib/cpp/cleanup.sh
new file mode 100755
index 0000000..8e5d217
--- /dev/null
+++ b/lib/cpp/cleanup.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+rm -rf \
+AUTHORS \
+COPYING \
+ChangeLog \
+INSTALL \
+Makefile \
+Makefile.in \
+Makefile.orig \
+NEWS \
+README \
+aclocal.m4 \
+autom4te.cache \
+autoscan.log \
+config.guess \
+config.h \
+config.hin \
+config.log \
+config.status \
+config.sub \
+configure \
+configure.scan \
+depcomp \
+.deps \
+install-sh \
+.libs \
+libtool \
+ltmain.sh \
+Makefile.in \
+missing
diff --git a/lib/cpp/configure.ac b/lib/cpp/configure.ac
index 8763a4a..d0fc7c1 100644
--- a/lib/cpp/configure.ac
+++ b/lib/cpp/configure.ac
@@ -48,6 +48,8 @@
 
 AC_CHECK_HEADERS([unistd.h])
 
+AC_C_INLINE
+
 AX_BOOST_BASE([1.33.1])
 
 AX_EVENT_BASE([1.2.0])
diff --git a/lib/cpp/src/server/TThreadPoolServer.cpp b/lib/cpp/src/server/TThreadPoolServer.cpp
index 2f85c8b..1407b8c 100644
--- a/lib/cpp/src/server/TThreadPoolServer.cpp
+++ b/lib/cpp/src/server/TThreadPoolServer.cpp
@@ -26,7 +26,7 @@
 
   ~Task() {}
     
-  void run() {     
+  void run() {
     try {
       while (processor_->process(input_, output_)) {
         if (!input_->getTransport()->peek()) {
diff --git a/lib/java/src/transport/TTransport.java b/lib/java/src/transport/TTransport.java
index 4664f3f..890a810 100644
--- a/lib/java/src/transport/TTransport.java
+++ b/lib/java/src/transport/TTransport.java
@@ -16,6 +16,15 @@
   public abstract boolean isOpen();
 
   /**
+   * Is there more data to be read?
+   *
+   * @return True if the remote side is still alive and feeding us
+   */
+  public boolean peek() {
+    return isOpen();
+  }
+
+  /**
    * Opens the transport for reading/writing.
    *
    * @throws TTransportException if the transport could not be opened
diff --git a/lib/php/bootstrap.sh b/lib/php/bootstrap.sh
index 11f41a9..b79e431 100755
--- a/lib/php/bootstrap.sh
+++ b/lib/php/bootstrap.sh
@@ -1,35 +1,6 @@
 #!/bin/sh
 
-rm -rf \
-AUTHORS \
-COPYING \
-ChangeLog \
-INSTALL \
-Makefile \
-Makefile.in \
-Makefile.orig \
-NEWS \
-README \
-aclocal.m4 \
-autom4te.cache \
-autoscan.log \
-config.guess \
-config.h \
-config.hin \
-config.log \
-config.status \
-config.sub \
-configure \
-configure.scan \
-depcomp \
-.deps \
-install-sh \
-.libs \
-libtool \
-ltmain.sh \
-Makefile.in \
-missing
-
+./cleanup.sh
 aclocal
 touch NEWS README AUTHORS ChangeLog
 autoconf
diff --git a/lib/php/cleanup.sh b/lib/php/cleanup.sh
new file mode 100755
index 0000000..8e5d217
--- /dev/null
+++ b/lib/php/cleanup.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+rm -rf \
+AUTHORS \
+COPYING \
+ChangeLog \
+INSTALL \
+Makefile \
+Makefile.in \
+Makefile.orig \
+NEWS \
+README \
+aclocal.m4 \
+autom4te.cache \
+autoscan.log \
+config.guess \
+config.h \
+config.hin \
+config.log \
+config.status \
+config.sub \
+configure \
+configure.scan \
+depcomp \
+.deps \
+install-sh \
+.libs \
+libtool \
+ltmain.sh \
+Makefile.in \
+missing
diff --git a/lib/py/bootstrap.sh b/lib/py/bootstrap.sh
index 11f41a9..b79e431 100755
--- a/lib/py/bootstrap.sh
+++ b/lib/py/bootstrap.sh
@@ -1,35 +1,6 @@
 #!/bin/sh
 
-rm -rf \
-AUTHORS \
-COPYING \
-ChangeLog \
-INSTALL \
-Makefile \
-Makefile.in \
-Makefile.orig \
-NEWS \
-README \
-aclocal.m4 \
-autom4te.cache \
-autoscan.log \
-config.guess \
-config.h \
-config.hin \
-config.log \
-config.status \
-config.sub \
-configure \
-configure.scan \
-depcomp \
-.deps \
-install-sh \
-.libs \
-libtool \
-ltmain.sh \
-Makefile.in \
-missing
-
+./cleanup.sh
 aclocal
 touch NEWS README AUTHORS ChangeLog
 autoconf
diff --git a/lib/py/cleanup.sh b/lib/py/cleanup.sh
new file mode 100755
index 0000000..8e5d217
--- /dev/null
+++ b/lib/py/cleanup.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+rm -rf \
+AUTHORS \
+COPYING \
+ChangeLog \
+INSTALL \
+Makefile \
+Makefile.in \
+Makefile.orig \
+NEWS \
+README \
+aclocal.m4 \
+autom4te.cache \
+autoscan.log \
+config.guess \
+config.h \
+config.hin \
+config.log \
+config.status \
+config.sub \
+configure \
+configure.scan \
+depcomp \
+.deps \
+install-sh \
+.libs \
+libtool \
+ltmain.sh \
+Makefile.in \
+missing