1# 2# Copyright 2017 Nest Labs Inc. All Rights Reserved. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17# 18# Description: 19# This make file header defines common variables, rules, and 20# targets for maintaining nlbuild-autotools distributions. 21# 22 23.DEFAULT_GOAL = all 24 25# 26# This package 27# 28PACKAGE := nlbuild-autotools 29 30# 31# Tools 32# 33CAT ?= cat 34CHMOD ?= chmod 35CMP ?= cmp 36FIND ?= find 37GZIP ?= gzip 38MKDIR ?= mkdir 39MV ?= mv 40RM ?= rm 41SED ?= sed 42TAR ?= tar 43XZ ?= xz 44 45dist_tar_ARCHIVE = $(TAR) -chof - 46 47dist_tgz_ARCHIVE = $(dist_tar_ARCHIVE) 48dist_tgz_COMPRESS = $(GZIP) --best -c 49 50dist_txz_ARCHIVE = $(dist_tar_ARCHIVE) 51dist_txz_COMPRESS = $(XZ) --extreme -c 52 53TGZ_EXTENSION := .tar.gz 54TXZ_EXTENSION := .tar.xz 55 56DIST_TARGETS ?= dist-tgz dist-txz 57DIST_ARCHIVES = $(dist_tgz_TARGETS) $(dist_txz_TARGETS) 58 59# 60# Verbosity 61# 62 63NL_DEFAULT_VERBOSITY = 0 64 65NL_V_AT = $(NL_V_AT_$(V)) 66NL_V_AT_ = $(NL_V_AT_$(NL_DEFAULT_VERBOSITY)) 67NL_V_AT_0 = @ 68NL_V_AT_1 = 69 70NL_V_MAKE = $(NL_V_MAKE_$(V)) 71NL_V_MAKE_ = $(NL_V_MAKE_$(NL_DEFAULT_VERBOSITY)) 72NL_V_MAKE_0 = @echo " MAKE $(@)"; 73NL_V_MAKE_1 = 74 75NL_V_MKDIR_P = $(NL_V_MKDIR_P_$(V)) 76NL_V_MKDIR_P_ = $(NL_V_MKDIR_P_$(NL_DEFAULT_VERBOSITY)) 77NL_V_MKDIR_P_0 = @echo " MKDIR $(1)"; 78NL_V_MKDIR_P_1 = 79 80NL_V_RMDIR = $(NL_V_RMDIR_$(V)) 81NL_V_RMDIR_ = $(NL_V_RMDIR_$(NL_DEFAULT_VERBOSITY)) 82NL_V_RMDIR_0 = @echo " RMDIR $(1)"; 83NL_V_RMDIR_1 = 84 85NL_V_TGZ = $(NL_V_TGZ_$(V)) 86NL_V_TGZ_ = $(NL_V_TGZ_$(NL_DEFAULT_VERBOSITY)) 87NL_V_TGZ_0 = @echo " TGZ $(@)"; 88NL_V_TGZ_1 = 89 90NL_V_TXZ = $(NL_V_TXZ_$(V)) 91NL_V_TXZ_ = $(NL_V_TXZ_$(NL_DEFAULT_VERBOSITY)) 92NL_V_TXZ_0 = @echo " TXZ $(@)"; 93NL_V_TXZ_1 = 94 95# 96# nl-create-dir <directory> 97# 98# Create the specified directory, including any parent directories 99# that may not exist. 100# 101define nl-create-dir 102$(NL_V_AT)echo " MKDIR $(1)"; \ 103$(MKDIR) -p "$(1)" 104endef # nl-create-dir 105 106# 107# nl-remove-dir <directory> 108# 109# If the specified directory exists, then ensure all of the 110# directories are writable by the current user, and then forcibly 111# remove the directory and all of its contents, sleeping for five (5) 112# seconds and failure before trying the removal again. 113# 114define nl-remove-dir 115$(NL_V_RMDIR) \ 116if [ -d "$(1)" ]; then \ 117 $(FIND) "$(1)" -type d ! -perm -200 -exec $(CHMOD) u+w {} ';' \ 118 && $(RM) -rf "$(1)" \ 119 || { sleep 5 && $(RM) -rf "$(1)"; }; \ 120fi 121endef # nl-remove-dir 122 123clean-local: 124 $(NL_V_AT)$(RM) -f *~ "#"* 125 126help: 127 @echo "This make file shold not be needed for end users and system " 128 @echo "integrators of $(PACKAGE). It should only be needed by " 129 @echo "maintainers producing distributions of $(PACKAGE)." 130