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/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);