Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame^] | 1 | # 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 |
| 14 | target: thrift |
| 15 | |
| 16 | # Tools |
| 17 | CC = g++ |
| 18 | LD = g++ |
| 19 | LEX = flex |
| 20 | YACC = bison |
| 21 | MKDIR = mkdir |
| 22 | |
| 23 | # Source directory |
| 24 | SRC_DIR = src/ |
| 25 | |
| 26 | # Object file directory |
| 27 | OBJ_DIR = obj/ |
| 28 | |
| 29 | # Generated source dir |
| 30 | GEN_DIR = $(SRC_DIR) |
| 31 | |
| 32 | # Output directory |
| 33 | BIN_DIR = bin/ |
| 34 | |
| 35 | # Source files |
| 36 | SRC_FILES = main.cc \ |
| 37 | generate/t_generator.cc \ |
| 38 | generate/t_cpp_generator.cc |
| 39 | |
| 40 | # Autogenerated files |
| 41 | GEN_FILES = thrift.tab.hh \ |
| 42 | thrift.tab.cc \ |
| 43 | lex.yy.cc |
| 44 | |
| 45 | # Object files |
| 46 | OBJ_FILES = thrift.tab.o \ |
| 47 | lex.yy.o \ |
| 48 | ${SRC_FILES:.cc=.o} |
| 49 | |
| 50 | # Apply directory prefixes |
| 51 | SRCS = ${addprefix $(SRC_DIR), $(SRC_FILES)} |
| 52 | GENS = ${addprefix $(GEN_DIR), $(GEN_FILES)} |
| 53 | OBJS = ${addprefix $(OBJ_DIR), $(OBJ_FILES)} |
| 54 | |
| 55 | # Compile with strict warnings |
| 56 | CFL = -g -Wall -I$(SRC_DIR) -I$(OBJ_DIR) |
| 57 | |
| 58 | # Flex library |
| 59 | LIBS = -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 |
| 79 | thrift: $(OBJS) |
| 80 | $(LD) $(CFL) -o $(BIN_DIR)thrift $(OBJS) $(LIBS) |
| 81 | |
| 82 | # Build directory |
| 83 | obj_dir: |
| 84 | $(MKDIR) -p $(OBJ_DIR)parse |
| 85 | $(MKDIR) -p $(OBJ_DIR)generate |
| 86 | |
| 87 | # This will auto-make dependency rules |
| 88 | depend: |
| 89 | makedepend -- $(CFL) -- $(SRCS) |
| 90 | |
| 91 | # Remove auto-gen'd files and binaries |
| 92 | clean: |
| 93 | rm -f \ |
| 94 | $(OBJS) \ |
| 95 | $(GENS) \ |
| 96 | $(BIN_DIR)thrift.exe \ |
| 97 | $(BIN_DIR)thrift |
| 98 | # DO NOT DELETE |
| 99 | |
| 100 | src/main.o: /usr/include/stdlib.h /usr/include/features.h |
| 101 | src/main.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h |
| 102 | src/main.o: /usr/include/bits/wordsize.h /usr/include/gnu/stubs-64.h |
| 103 | src/main.o: /usr/include/stdio.h /usr/include/bits/types.h |
| 104 | src/main.o: /usr/include/bits/typesizes.h /usr/include/libio.h |
| 105 | src/main.o: /usr/include/_G_config.h /usr/include/wchar.h |
| 106 | src/main.o: /usr/include/bits/wchar.h /usr/include/gconv.h |
| 107 | src/main.o: /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h |
| 108 | src/main.o: src/globals.h src/main.h src/parse/t_program.h |
| 109 | src/main.o: src/parse/t_base_type.h src/parse/t_type.h src/parse/t_typedef.h |
| 110 | src/main.o: src/parse/t_enum.h src/parse/t_constant.h src/parse/t_struct.h |
| 111 | src/main.o: src/parse/t_list.h src/parse/t_field.h src/parse/t_service.h |
| 112 | src/main.o: src/parse/t_function.h src/generate/t_cpp_generator.h |
| 113 | src/main.o: src/generate/t_generator.h |
| 114 | src/generate/t_generator.o: src/generate/t_generator.h src/parse/t_program.h |
| 115 | src/generate/t_generator.o: src/parse/t_base_type.h src/parse/t_type.h |
| 116 | src/generate/t_generator.o: src/parse/t_typedef.h src/parse/t_enum.h |
| 117 | src/generate/t_generator.o: src/parse/t_constant.h src/parse/t_struct.h |
| 118 | src/generate/t_generator.o: src/parse/t_list.h src/parse/t_field.h |
| 119 | src/generate/t_generator.o: src/parse/t_service.h src/parse/t_function.h |
| 120 | src/generate/t_cpp_generator.o: /usr/include/sys/stat.h |
| 121 | src/generate/t_cpp_generator.o: /usr/include/features.h |
| 122 | src/generate/t_cpp_generator.o: /usr/include/sys/cdefs.h |
| 123 | src/generate/t_cpp_generator.o: /usr/include/gnu/stubs.h |
| 124 | src/generate/t_cpp_generator.o: /usr/include/bits/wordsize.h |
| 125 | src/generate/t_cpp_generator.o: /usr/include/gnu/stubs-64.h |
| 126 | src/generate/t_cpp_generator.o: /usr/include/bits/types.h |
| 127 | src/generate/t_cpp_generator.o: /usr/include/bits/typesizes.h |
| 128 | src/generate/t_cpp_generator.o: /usr/include/bits/stat.h |
| 129 | src/generate/t_cpp_generator.o: src/generate/t_cpp_generator.h |
| 130 | src/generate/t_cpp_generator.o: src/generate/t_generator.h |
| 131 | src/generate/t_cpp_generator.o: src/parse/t_program.h src/parse/t_base_type.h |
| 132 | src/generate/t_cpp_generator.o: src/parse/t_type.h src/parse/t_typedef.h |
| 133 | src/generate/t_cpp_generator.o: src/parse/t_enum.h src/parse/t_constant.h |
| 134 | src/generate/t_cpp_generator.o: src/parse/t_struct.h src/parse/t_list.h |
| 135 | src/generate/t_cpp_generator.o: src/parse/t_field.h src/parse/t_service.h |
| 136 | src/generate/t_cpp_generator.o: src/parse/t_function.h src/globals.h |