Thrift compiler now compiles both native Java and C++ code
Summary: Compiles to both C++ and Java, plus a host of other cool options like command line control over which languages to output code in
Reviewed By: aditya
Test Plan: The unit test checkins are coming momentarily...
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664713 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/Makefile b/compiler/Makefile
index 62ce275..49833cb 100644
--- a/compiler/Makefile
+++ b/compiler/Makefile
@@ -35,7 +35,8 @@
# Source files
SRC_FILES = main.cc \
generate/t_generator.cc \
- generate/t_cpp_generator.cc
+ generate/t_cpp_generator.cc \
+ generate/t_java_generator.cc
# Autogenerated files
GEN_FILES = thrift.tab.hh \
@@ -61,21 +62,23 @@
# Flex library
LIBS = -lfl
+# Build directories
+obj_dirs: $(OBJ_DIR)parse $(OBJ_DIR)generate
+$(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)thrift.l
$(LEX) -o$@ $(SRC_DIR)thrift.l
-
-# Parser generation
-$(GEN_DIR)thrift.tab.hh: $(GEN_DIR)thrift.tab.cc
-
-$(GEN_DIR)thrift.tab.cc: $(SRC_DIR)thrift.y
- $(YACC) -d -o$(GEN_DIR)thrift.tab.cc $(SRC_DIR)thrift.y
-
-# C++ compilation
$(OBJ_DIR)lex.yy.o: $(GEN_DIR)lex.yy.cc
$(CC) $(CFL) -c -o $@ $(GEN_DIR)lex.yy.cc
-# C++ compilation
+# Parser generation
+$(GEN_DIR)thrift.tab.hh: $(GEN_DIR)thrift.tab.cc
+$(GEN_DIR)thrift.tab.cc: $(SRC_DIR)thrift.y
+ $(YACC) -d -o$(GEN_DIR)thrift.tab.cc $(SRC_DIR)thrift.y
$(OBJ_DIR)thrift.tab.o: $(GEN_DIR)thrift.tab.cc
$(CC) $(CFL) -c -o $@ $(GEN_DIR)thrift.tab.cc
@@ -84,15 +87,10 @@
$(CC) $(CFL) -c -o $@ ${subst $(OBJ_DIR),$(SRC_DIR),$*.cc}
# Main build rule
-thrift: $(OBJS) $(GOBS)
+thrift: obj_dirs $(OBJS) $(GOBS)
$(LD) $(CFL) -o $(BIN_DIR)thrift $(OBJS) $(GOBS) $(LIBS)
-# Build directory
-obj_dirs:
- $(MKDIR) -p $(OBJ_DIR)parse
- $(MKDIR) -p $(OBJ_DIR)generate
-
-# Install it
+# Install
install: thrift
sudo install bin/thrift /usr/local/bin/thrift