2 # Copyright 2017 Nest Labs Inc. All Rights Reserved.
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
19 # This make file header defines common variables, rules, and
20 # targets for maintaining nlbuild-autotools distributions.
28 PACKAGE := nlbuild-autotools
45 dist_tar_ARCHIVE = $(TAR) -chof -
47 dist_tgz_ARCHIVE = $(dist_tar_ARCHIVE)
48 dist_tgz_COMPRESS = $(GZIP) --best -c
50 dist_txz_ARCHIVE = $(dist_tar_ARCHIVE)
51 dist_txz_COMPRESS = $(XZ) --extreme -c
53 TGZ_EXTENSION := .tar.gz
54 TXZ_EXTENSION := .tar.xz
56 DIST_TARGETS ?= dist-tgz dist-txz
57 DIST_ARCHIVES = $(dist_tgz_TARGETS) $(dist_txz_TARGETS)
63 NL_DEFAULT_VERBOSITY = 0
65 NL_V_AT = $(NL_V_AT_$(V))
66 NL_V_AT_ = $(NL_V_AT_$(NL_DEFAULT_VERBOSITY))
70 NL_V_MAKE = $(NL_V_MAKE_$(V))
71 NL_V_MAKE_ = $(NL_V_MAKE_$(NL_DEFAULT_VERBOSITY))
72 NL_V_MAKE_0 = @echo " MAKE $(@)";
75 NL_V_MKDIR_P = $(NL_V_MKDIR_P_$(V))
76 NL_V_MKDIR_P_ = $(NL_V_MKDIR_P_$(NL_DEFAULT_VERBOSITY))
77 NL_V_MKDIR_P_0 = @echo " MKDIR $(1)";
80 NL_V_RMDIR = $(NL_V_RMDIR_$(V))
81 NL_V_RMDIR_ = $(NL_V_RMDIR_$(NL_DEFAULT_VERBOSITY))
82 NL_V_RMDIR_0 = @echo " RMDIR $(1)";
85 NL_V_TGZ = $(NL_V_TGZ_$(V))
86 NL_V_TGZ_ = $(NL_V_TGZ_$(NL_DEFAULT_VERBOSITY))
87 NL_V_TGZ_0 = @echo " TGZ $(@)";
90 NL_V_TXZ = $(NL_V_TXZ_$(V))
91 NL_V_TXZ_ = $(NL_V_TXZ_$(NL_DEFAULT_VERBOSITY))
92 NL_V_TXZ_0 = @echo " TXZ $(@)";
96 # nl-create-dir <directory>
98 # Create the specified directory, including any parent directories
102 $(NL_V_AT)echo " MKDIR $(1)"; \
104 endef # nl-create-dir
107 # nl-remove-dir <directory>
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.
116 if [ -d "$(1)" ]; then \
117 $(FIND) "$(1)" -type d ! -perm -200 -exec $(CHMOD) u+w {} ';' \
118 && $(RM) -rf "$(1)" \
119 || { sleep 5 && $(RM) -rf "$(1)"; }; \
121 endef # nl-remove-dir
124 $(NL_V_AT)$(RM) -f *~ "#"*
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)."