| # 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. |
| |
| #use "g++" to compile source files |
| CC := g++ |
| |
| BUILD_PATH := build |
| DEBUG_PATH := $(BUILD_PATH)/debug |
| RELEASE_PATH := $(BUILD_PATH)/release |
| MODULES := if |
| SRC_DIR := $(BUILD_PATH)/src/hbase/$(MODULES) |
| DEBUG_BUILD_DIR := $(addprefix $(DEBUG_PATH)/hbase/,$(MODULES)) |
| RELEASE_BUILD_DIR := $(addprefix $(RELEASE_PATH)/hbase/,$(MODULES)) |
| INCLUDE_DIR := . $(BUILD_PATH)/src/hbase/if |
| |
| #flags to pass to the CPP compiler & linker |
| CPPFLAGS_DEBUG := -D_GLIBCXX_USE_CXX11_ABI=0 -g -Wall -std=c++14 -pedantic -fPIC -MMD -MP |
| CPPFLAGS_RELEASE := -D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG -O2 -Wall -std=c++14 -pedantic -fPIC -MMD -MP |
| |
| #define list of source files and object files |
| SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cc)) |
| DEBUG_OBJ := $(patsubst $(SRC_DIR)/%.cc,$(DEBUG_PATH)/hbase/if/%.o,$(SRC)) |
| RELEASE_OBJ := $(patsubst $(SRC_DIR)/%.cc,$(RELEASE_PATH)/hbase/if/%.o,$(SRC)) |
| INCLUDES := $(addprefix -I,$(INCLUDE_DIR)) |
| |
| all: $(DEBUG_BUILD_DIR) $(RELEASE_BUILD_DIR) $(DEBUG_OBJ) $(RELEASE_OBJ) |
| |
| vpath %.cc $(SRC_DIR) |
| |
| $(DEBUG_OBJ): |
| define make-goal-dbg |
| DEPS := $(DEBUG_OBJ:.o=.d) |
| -include $(DEPS) |
| $1/%.o: %.cc |
| $(CC) -c $$< -o $$@ -MF$$(@:%.o=%.d) -MT$$@ $(CPPFLAGS_DEBUG) $(INCLUDES) |
| endef |
| |
| $(RELEASE_OBJ): |
| define make-goal-rel |
| DEPS := $(RELEASE_OBJ:.o=.d) |
| -include $(DEPS) |
| $1/%.o: %.cc |
| $(CC) -c $$< -o $$@ -MF$$(@:%.o=%.d) -MT$$@ $(CPPFLAGS_RELEASE) $(INCLUDES) |
| endef |
| |
| .PHONY: all clean |
| |
| $(DEBUG_BUILD_DIR): |
| @mkdir -p $@ |
| |
| $(RELEASE_BUILD_DIR): |
| @mkdir -p $@ |
| |
| clean: |
| @rm -rf $(DEBUG_BUILD_DIR) $(RELEASE_BUILD_DIR) |
| |
| $(foreach bdir,$(DEBUG_BUILD_DIR),$(eval $(call make-goal-dbg,$(bdir)))) |
| |
| $(foreach bdir,$(RELEASE_BUILD_DIR),$(eval $(call make-goal-rel,$(bdir)))) |
| |
| help: |
| @echo "This Makefile invocation will only work when protobuf sources and headers have been generated by running 'make protos'" |
| @echo "Available targets:" |
| @echo "" |
| @echo " all : creates objects for the generated PB src." |
| @echo " clean : removes PB objects." |