blob: 8fa9e60a582ce3766cd107060a86b87449cbfa1f [file] [log] [blame]
Mark Slee31985722006-05-24 21:45:31 +00001# Makefile for Thrift compiler. This Makefile assumes that you are running on
2# some form of *NIX operating system with the following tools and packages
3# installed:
4#
5# g++
6# flex
7# bison
8# libfl
9#
10# Author:
11# Mark Slee <mcslee@facebook.com>
12
13# Default build rule
14target: thrift
15
16# Tools
17CC = g++
18LD = g++
19LEX = flex
20YACC = bison
21MKDIR = mkdir
22
23# Source directory
24SRC_DIR = src/
25
26# Object file directory
27OBJ_DIR = obj/
28
29# Generated source dir
30GEN_DIR = $(SRC_DIR)
31
32# Output directory
33BIN_DIR = bin/
34
35# Source files
36SRC_FILES = main.cc \
37 generate/t_generator.cc \
38 generate/t_cpp_generator.cc
39
40# Autogenerated files
41GEN_FILES = thrift.tab.hh \
42 thrift.tab.cc \
43 lex.yy.cc
44
45# Object files
46OBJ_FILES = thrift.tab.o \
47 lex.yy.o \
48 ${SRC_FILES:.cc=.o}
49
50# Apply directory prefixes
51SRCS = ${addprefix $(SRC_DIR), $(SRC_FILES)}
52GENS = ${addprefix $(GEN_DIR), $(GEN_FILES)}
53OBJS = ${addprefix $(OBJ_DIR), $(OBJ_FILES)}
54
55# Compile with strict warnings
56CFL = -g -Wall -I$(SRC_DIR) -I$(OBJ_DIR)
57
58# Flex library
59LIBS = -lfl
60
61# Scanner generation
62$(GEN_DIR)lex.yy.cc: $(SRC_DIR)thrift.l
63 $(LEX) -o$(GEN_DIR)lex.yy.cc $(SRC_DIR)thrift.l
64
65# Parser generation
66$(GEN_DIR)thrift.tab.hh: $(GEN_DIR)thrift.tab.cc
67
68$(GEN_DIR)thrift.tab.cc: $(SRC_DIR)thrift.y
69 $(YACC) -d -o$(GEN_DIR)thrift.tab.cc $(SRC_DIR)thrift.y
70
71# C++ compilation
72$(OBJS): $(GEN_DIR)thrift.tab.cc $(GEN_DIR)lex.yy.cc obj_dir
73 $(CC) $(CFL) -c -o $@ ${subst $(OBJ_DIR),$(SRC_DIR),$*.cc}
74
75# Header dependency
76$(SRC_DIR)main.cc: $(SRC_DIR)*.h
77
78# Main build rule
79thrift: $(OBJS)
80 $(LD) $(CFL) -o $(BIN_DIR)thrift $(OBJS) $(LIBS)
81
82# Build directory
83obj_dir:
84 $(MKDIR) -p $(OBJ_DIR)parse
85 $(MKDIR) -p $(OBJ_DIR)generate
86
87# This will auto-make dependency rules
88depend:
89 makedepend -- $(CFL) -- $(SRCS)
90
91# Remove auto-gen'd files and binaries
92clean:
93 rm -f \
94 $(OBJS) \
95 $(GENS) \
96 $(BIN_DIR)thrift.exe \
97 $(BIN_DIR)thrift
98# DO NOT DELETE
99
100src/main.o: /usr/include/stdlib.h /usr/include/features.h
101src/main.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
102src/main.o: /usr/include/bits/wordsize.h /usr/include/gnu/stubs-64.h
103src/main.o: /usr/include/stdio.h /usr/include/bits/types.h
104src/main.o: /usr/include/bits/typesizes.h /usr/include/libio.h
105src/main.o: /usr/include/_G_config.h /usr/include/wchar.h
106src/main.o: /usr/include/bits/wchar.h /usr/include/gconv.h
107src/main.o: /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h
108src/main.o: src/globals.h src/main.h src/parse/t_program.h
109src/main.o: src/parse/t_base_type.h src/parse/t_type.h src/parse/t_typedef.h
110src/main.o: src/parse/t_enum.h src/parse/t_constant.h src/parse/t_struct.h
111src/main.o: src/parse/t_list.h src/parse/t_field.h src/parse/t_service.h
112src/main.o: src/parse/t_function.h src/generate/t_cpp_generator.h
113src/main.o: src/generate/t_generator.h
114src/generate/t_generator.o: src/generate/t_generator.h src/parse/t_program.h
115src/generate/t_generator.o: src/parse/t_base_type.h src/parse/t_type.h
116src/generate/t_generator.o: src/parse/t_typedef.h src/parse/t_enum.h
117src/generate/t_generator.o: src/parse/t_constant.h src/parse/t_struct.h
118src/generate/t_generator.o: src/parse/t_list.h src/parse/t_field.h
119src/generate/t_generator.o: src/parse/t_service.h src/parse/t_function.h
120src/generate/t_cpp_generator.o: /usr/include/sys/stat.h
121src/generate/t_cpp_generator.o: /usr/include/features.h
122src/generate/t_cpp_generator.o: /usr/include/sys/cdefs.h
123src/generate/t_cpp_generator.o: /usr/include/gnu/stubs.h
124src/generate/t_cpp_generator.o: /usr/include/bits/wordsize.h
125src/generate/t_cpp_generator.o: /usr/include/gnu/stubs-64.h
126src/generate/t_cpp_generator.o: /usr/include/bits/types.h
127src/generate/t_cpp_generator.o: /usr/include/bits/typesizes.h
128src/generate/t_cpp_generator.o: /usr/include/bits/stat.h
129src/generate/t_cpp_generator.o: src/generate/t_cpp_generator.h
130src/generate/t_cpp_generator.o: src/generate/t_generator.h
131src/generate/t_cpp_generator.o: src/parse/t_program.h src/parse/t_base_type.h
132src/generate/t_cpp_generator.o: src/parse/t_type.h src/parse/t_typedef.h
133src/generate/t_cpp_generator.o: src/parse/t_enum.h src/parse/t_constant.h
134src/generate/t_cpp_generator.o: src/parse/t_struct.h src/parse/t_list.h
135src/generate/t_cpp_generator.o: src/parse/t_field.h src/parse/t_service.h
136src/generate/t_cpp_generator.o: src/parse/t_function.h src/globals.h