Makefile 2.18 KB
Newer Older
zhujiashun's avatar
zhujiashun committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

18 19
BRPC_PATH = ../../
include $(BRPC_PATH)/config.mk
20
CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -fPIC -fno-omit-frame-pointer
21 22 23 24 25
HDRS+=$(BRPC_PATH)/output/include
LIBS+=$(BRPC_PATH)/output/lib
HDRPATHS = $(addprefix -I, $(HDRS))
LIBPATHS = $(addprefix -L, $(LIBS))
COMMA=,
26
SOPATHS=$(addprefix -Wl$(COMMA)-rpath$(COMMA), $(LIBS))
gejun's avatar
gejun committed
27

28 29
SOURCES = $(wildcard *.cpp)
OBJS = $(addsuffix .o, $(basename $(SOURCES))) 
gejun's avatar
gejun committed
30

31 32 33 34 35 36 37 38 39 40
ifeq ($(SYSTEM),Darwin)
 ifneq ("$(LINK_SO)", "")
	STATIC_LINKINGS += -lbrpc
 else
	# *.a must be explicitly specified in clang
	STATIC_LINKINGS += $(BRPC_PATH)/output/lib/libbrpc.a
 endif
	LINK_OPTIONS_SO = $^ $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS)
	LINK_OPTIONS = $^ $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS)
else ifeq ($(SYSTEM),Linux)
zyearn's avatar
zyearn committed
41
	STATIC_LINKINGS += -lbrpc
42 43 44 45
	LINK_OPTIONS_SO = -Xlinker "-(" $^ -Xlinker "-)" $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS)
	LINK_OPTIONS = -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS)
endif

gejun's avatar
gejun committed
46 47 48 49 50 51
.PHONY:all
all: memcache_client

.PHONY:clean
clean:
	@echo "Cleaning"
52
	@rm -rf memcache_client $(OBJS)
gejun's avatar
gejun committed
53

54
memcache_client:$(OBJS)
gejun's avatar
gejun committed
55
	@echo "Linking $@"
56
ifneq ("$(LINK_SO)", "")
57
	@$(CXX) $(LIBPATHS) $(SOPATHS) $(LINK_OPTIONS_SO) -o $@
58
else
59
	@$(CXX) $(LIBPATHS) $(LINK_OPTIONS) -o $@
60
endif
gejun's avatar
gejun committed
61 62 63

%.o:%.cpp
	@echo "Compiling $@"
64
	@$(CXX) -c $(HDRPATHS) $(CXXFLAGS) $< -o $@
gejun's avatar
gejun committed
65 66 67

%.o:%.cc
	@echo "Compiling $@"
68
	@$(CXX) -c $(HDRPATHS) $(CXXFLAGS) $< -o $@