blob: fde44110dbe787d58dd9e296e01b166052479d7e [file] [log] [blame]
Mark Slee8d7e1f62006-06-07 06:48:56 +00001# Makefile for Thrift C++ library. Generates a shared object that can be
2# installed to /usr/local/lib
3#
4# TODO(mcslee): Add the ability to compile separate statis modules that can
5# be compiled directly into Thrift applications instead of dynamic runtime
6# loading of the full libs
Mark Sleee8540632006-05-30 09:24:40 +00007#
8# Author:
9# Mark Slee <mcslee@facebook.com>
10
Marc Slemko0e53ccd2006-07-17 23:51:05 +000011target: libthrift.so libconcurrency.so
Mark Sleee8540632006-05-30 09:24:40 +000012
13# Tools
14LD = g++
Marc Slemko0e53ccd2006-07-17 23:51:05 +000015CPP = g++
16
17CC_COMMON_FLAGS = -g -c -Wall -Isrc -fPIC -fno-common
18
19LD_COMMON_FLAGS=
20
21LD_APP_FLAGS= $(LD_COMMON_FLAGS)
22
23LD_LIB_FLAGS= -dynamiclib $(LD_COMMON_FLAGS)
Mark Sleee8540632006-05-30 09:24:40 +000024
25# Source files
Mark Slee4e0d9622006-06-26 23:56:08 +000026SRCS = src/protocol/TBinaryProtocol.cc \
27 src/transport/TBufferedTransport.cc \
Mark Slee6e536442006-06-30 18:28:50 +000028 src/transport/TChunkedTransport.cc \
Mark Slee4e0d9622006-06-26 23:56:08 +000029 src/transport/TSocket.cc \
30 src/transport/TServerSocket.cc \
31 src/server/TSimpleServer.cc
Mark Sleee8540632006-05-30 09:24:40 +000032
Marc Slemko0e53ccd2006-07-17 23:51:05 +000033# Concurreny Utility Source files
34CONCURRENCY_SRCS = src/concurrency/Monitor.cc \
35 src/concurrency/Mutex.cc \
36 src/concurrency/PosixThreadFactory.cc \
37 src/concurrency/ThreadManager.cc \
38 src/concurrency/TimerManager.cc
39
40CONCURRENCY_OBJS = $(patsubst %.cc,%.o,$(CONCURRENCY_SRCS))
41
42$(CONCURRENCY_OBJS): %.o : %.cc
43 $(CC) $(CC_COMMON_FLAGS) $< -o $@
44
45CONCURRENCY_TEST_SRCS = src/concurrency/test/TimerManagerTests.cc
46
47CONCURRENCY_TEST_OBJS = $(patsubst %.cc,%.o,$(CONCURRENCY_TEST_SRCS))
48
49$(CONCURRENCY_TEST_OBJS): %.o : %.cc
50 $(CC) $(CC_COMMON_FLAGS) -I src/concurrency $< -o $@
51
52# Linked libraries
53
54# thrift library
55
56THRIFT_OBJS = $(patsubst %.cc,%.o, $(SRCS))
57
58$(THRIFT_OBJS): %.o : %.cc
59 $(CC) $(CC_COMMON_FLAGS) $< -o $@
60
61libthrift.so: $(THRIFT_OBJS)
62 $(LD) -o $@ $(LD_LIB_FLAGS) $(THRIFT_OBJS)
63
64# concurrency util library
65
66libconcurrency.so: $(CONCURRENCY_OBJS)
67 $(LD) -o $@ $(LD_LIB_FLAGS) $(CONCURRENCY_OBJS)
68
69concurrency_tests: libconcurrency.so $(CONCURRENCY_TEST_OBJS)
70 $(LD) -o $@ $(LD_APP_FLAGS) -L. $(CONCURRENCY_TEST_OBJS) libconcurrency.so
71
72tests: concurrency_tests
73
74clean_libthrift:
75 rm -f libthrift.so
76 rm -f $(THRIFT_OBJS)
77
78clean_libconcurrency:
79 rm -f libconcurrency.so
80 rm -f $(CONCURRENCY_OBJS)
81
82clean_tests:
83 rm -f concurrency_tests
84 rm -f $(CONCURRENTY_TEST_OBJS)
Mark Sleee8540632006-05-30 09:24:40 +000085
Mark Slee8d7e1f62006-06-07 06:48:56 +000086# Clean it up
Marc Slemko0e53ccd2006-07-17 23:51:05 +000087clean: clean_libthrift clean_libconcurrency clean_tests
Mark Sleee8540632006-05-30 09:24:40 +000088
89# Install
90install: libthrift
91 sudo install libthrift.so /usr/local/lib