Makefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -fPIC -fno-omit-frame-pointer
  20. HDRS+=$(BRPC_PATH)/output/include
  21. LIBS+=$(BRPC_PATH)/output/lib
  22. HDRPATHS = $(addprefix -I, $(HDRS))
  23. LIBPATHS = $(addprefix -L, $(LIBS))
  24. COMMA=,
  25. SOPATHS=$(addprefix -Wl$(COMMA)-rpath$(COMMA), $(LIBS))
  26. DYNAMIC_LINKINGS += -lreadline -lncurses
  27. PRESS_SOURCES = redis_press.cpp
  28. CLI_SOURCES = redis_cli.cpp
  29. SERVER_SOURCES = redis_server.cpp
  30. PRESS_OBJS = $(addsuffix .o, $(basename $(PRESS_SOURCES)))
  31. CLI_OBJS = $(addsuffix .o, $(basename $(CLI_SOURCES)))
  32. SERVER_OBJS = $(addsuffix .o, $(basename $(SERVER_SOURCES)))
  33. ifeq ($(SYSTEM),Darwin)
  34. ifneq ("$(LINK_SO)", "")
  35. STATIC_LINKINGS += -lbrpc
  36. else
  37. # *.a must be explicitly specified in clang
  38. STATIC_LINKINGS += $(BRPC_PATH)/output/lib/libbrpc.a
  39. endif
  40. LINK_OPTIONS_SO = $^ $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS)
  41. LINK_OPTIONS = $^ $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS)
  42. else ifeq ($(SYSTEM),Linux)
  43. STATIC_LINKINGS += -lbrpc
  44. LINK_OPTIONS_SO = -Xlinker "-(" $^ -Xlinker "-)" $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS)
  45. LINK_OPTIONS = -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS)
  46. endif
  47. .PHONY:all
  48. all: redis_press redis_cli redis_server
  49. .PHONY:clean
  50. clean:
  51. @echo "> Cleaning"
  52. rm -rf redis_press redis_cli $(PRESS_OBJS) $(CLI_OBJS) $(SERVER_OBJS)
  53. redis_press:$(PRESS_OBJS)
  54. @echo "> Linking $@"
  55. ifneq ("$(LINK_SO)", "")
  56. $(CXX) $(LIBPATHS) $(SOPATHS) $(LINK_OPTIONS_SO) -o $@
  57. else
  58. $(CXX) $(LIBPATHS) $(LINK_OPTIONS) -o $@
  59. endif
  60. redis_cli:$(CLI_OBJS)
  61. @echo "> Linking $@"
  62. ifneq ("$(LINK_SO)", "")
  63. $(CXX) $(LIBPATHS) $(SOPATHS) $(LINK_OPTIONS_SO) -o $@
  64. else
  65. $(CXX) $(LIBPATHS) $(LINK_OPTIONS) -o $@
  66. endif
  67. redis_server:$(SERVER_OBJS)
  68. @echo "> Linking $@"
  69. ifneq ("$(LINK_SO)", "")
  70. $(CXX) $(LIBPATHS) $(SOPATHS) $(LINK_OPTIONS_SO) -o $@
  71. else
  72. $(CXX) $(LIBPATHS) $(LINK_OPTIONS) -o $@
  73. endif
  74. %.o:%.cpp
  75. @echo "> Compiling $@"
  76. $(CXX) -c $(HDRPATHS) $(CXXFLAGS) $< -o $@
  77. %.o:%.cc
  78. @echo "> Compiling $@"
  79. $(CXX) -c $(HDRPATHS) $(CXXFLAGS) $< -o $@