Makefile 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Licensed to the Apache Software Foundation (ASF) under one
  2. # or more contributor license agreements. See the NOTICE file
  3. # distributed with this work for additional information
  4. # regarding copyright ownership. The ASF licenses this file
  5. # to you under the Apache License, Version 2.0 (the
  6. # "License"); you may not use this file except in compliance
  7. # with the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing,
  12. # software distributed under the License is distributed on an
  13. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. # KIND, either express or implied. See the License for the
  15. # specific language governing permissions and limitations
  16. # under the License.
  17. BRPC_PATH = ../../
  18. include $(BRPC_PATH)/config.mk
  19. # Notes on the flags:
  20. # 1. Added -fno-omit-frame-pointer: perf/tcmalloc-profiler use frame pointers by default
  21. # 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8
  22. CXXFLAGS = $(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer
  23. HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS))
  24. LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS))
  25. STATIC_LINKINGS += $(BRPC_PATH)/output/lib/libbrpc.a
  26. CLIENT_SOURCES = rpc_view.cpp
  27. PROTOS = $(wildcard *.proto)
  28. PROTO_OBJS = $(PROTOS:.proto=.pb.o)
  29. PROTO_GENS = $(PROTOS:.proto=.pb.h) $(PROTOS:.proto=.pb.cc)
  30. CLIENT_OBJS = $(addsuffix .o, $(basename $(CLIENT_SOURCES)))
  31. .PHONY:all
  32. all: rpc_view
  33. .PHONY:clean
  34. clean:
  35. @echo "> Cleaning"
  36. rm -rf rpc_view $(PROTO_GENS) $(PROTO_OBJS) $(CLIENT_OBJS)
  37. rpc_view:$(PROTO_OBJS) $(CLIENT_OBJS)
  38. @echo "> Linking $@"
  39. ifeq ($(SYSTEM),Linux)
  40. $(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) -o $@
  41. else ifeq ($(SYSTEM),Darwin)
  42. $(CXX) $(LIBPATHS) $^ $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS) -o $@
  43. endif
  44. %.pb.cc %.pb.h:%.proto
  45. @echo "> Generating $@"
  46. $(PROTOC) --cpp_out=. --proto_path=. $(PROTOC_EXTRA_ARGS) $<
  47. %.o:%.cpp
  48. @echo "> Compiling $@"
  49. $(CXX) -c $(HDRPATHS) $(CXXFLAGS) $< -o $@
  50. %.o:%.cc
  51. @echo "> Compiling $@"
  52. $(CXX) -c $(HDRPATHS) $(CXXFLAGS) $< -o $@