2006-05-24 21:45:31 +00:00
|
|
|
# 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 \
|
2006-09-04 00:04:39 +00:00
|
|
|
generate/t_py_generator.cc \
|
2006-09-02 04:17:07 +00:00
|
|
|
generate/t_java_generator.cc \
|
2006-08-09 00:03:43 +00:00
|
|
|
generate/t_php_generator.cc \
|
2006-09-02 04:17:07 +00:00
|
|
|
generate/t_cpp_generator.cc
|
2006-05-24 21:45:31 +00:00
|
|
|
|
|
|
|
# Autogenerated files
|
|
|
|
GEN_FILES = thrift.tab.hh \
|
|
|
|
thrift.tab.cc \
|
|
|
|
lex.yy.cc
|
|
|
|
|
|
|
|
# Object files
|
2006-05-30 09:24:40 +00:00
|
|
|
OBJ_FILES = ${SRC_FILES:.cc=.o}
|
|
|
|
|
|
|
|
# Generated object files
|
|
|
|
GOB_FILES = thrift.tab.o \
|
|
|
|
lex.yy.o
|
2006-05-24 21:45:31 +00:00
|
|
|
|
|
|
|
# Apply directory prefixes
|
|
|
|
SRCS = ${addprefix $(SRC_DIR), $(SRC_FILES)}
|
|
|
|
GENS = ${addprefix $(GEN_DIR), $(GEN_FILES)}
|
|
|
|
OBJS = ${addprefix $(OBJ_DIR), $(OBJ_FILES)}
|
2006-05-30 09:24:40 +00:00
|
|
|
GOBS = ${addprefix $(OBJ_DIR), $(GOB_FILES)}
|
2006-05-24 21:45:31 +00:00
|
|
|
|
|
|
|
# Compile with strict warnings
|
|
|
|
CFL = -g -Wall -I$(SRC_DIR) -I$(OBJ_DIR)
|
|
|
|
|
|
|
|
# Flex library
|
|
|
|
LIBS = -lfl
|
|
|
|
|
2006-06-07 06:46:24 +00:00
|
|
|
# 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
|
|
|
|
|
2006-05-24 21:45:31 +00:00
|
|
|
# Scanner generation
|
|
|
|
$(GEN_DIR)lex.yy.cc: $(SRC_DIR)thrift.l
|
2006-05-30 09:24:40 +00:00
|
|
|
$(LEX) -o$@ $(SRC_DIR)thrift.l
|
2006-06-07 06:46:24 +00:00
|
|
|
$(OBJ_DIR)lex.yy.o: $(GEN_DIR)lex.yy.cc
|
|
|
|
$(CC) $(CFL) -c -o $@ $(GEN_DIR)lex.yy.cc
|
2006-05-24 21:45:31 +00:00
|
|
|
|
|
|
|
# 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
|
2006-05-30 09:24:40 +00:00
|
|
|
$(OBJ_DIR)thrift.tab.o: $(GEN_DIR)thrift.tab.cc
|
|
|
|
$(CC) $(CFL) -c -o $@ $(GEN_DIR)thrift.tab.cc
|
|
|
|
|
|
|
|
# C++ compilation
|
|
|
|
$(OBJS): $(SRCS)
|
|
|
|
$(CC) $(CFL) -c -o $@ ${subst $(OBJ_DIR),$(SRC_DIR),$*.cc}
|
2006-05-24 21:45:31 +00:00
|
|
|
|
|
|
|
# Main build rule
|
2006-06-07 06:46:24 +00:00
|
|
|
thrift: obj_dirs $(OBJS) $(GOBS)
|
2006-05-30 09:24:40 +00:00
|
|
|
$(LD) $(CFL) -o $(BIN_DIR)thrift $(OBJS) $(GOBS) $(LIBS)
|
2006-05-24 21:45:31 +00:00
|
|
|
|
2006-06-07 06:46:24 +00:00
|
|
|
# Install
|
2006-05-30 09:24:40 +00:00
|
|
|
install: thrift
|
|
|
|
sudo install bin/thrift /usr/local/bin/thrift
|
2006-05-24 21:45:31 +00:00
|
|
|
|
|
|
|
# Remove auto-gen'd files and binaries
|
|
|
|
clean:
|
2006-06-07 06:57:01 +00:00
|
|
|
rm -fr \
|
|
|
|
$(OBJ_DIR) \
|
2006-05-24 21:45:31 +00:00
|
|
|
$(GENS) \
|
|
|
|
$(BIN_DIR)thrift.exe \
|
|
|
|
$(BIN_DIR)thrift
|
2006-05-30 09:24:40 +00:00
|
|
|
|