1# 2# Copyright 2015-2016 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 file is the automake footer for all coding style-related 20# targets and rules. 21# 22# The recursive target 'pretty', invoked against '$(PRETTY_SUBDIRS)', 23# is intended to reformat a collection of source files, defined by 24# '$(PRETTY_FILES)' using the program '$(PRETTY)' with the arguments 25# '$(PRETTY_ARGS)'. 26# 27# The recursive target 'pretty-check' (and its alias 'lint'), 28# invoked against '$(PRETTY_SUBDIRS)', is intended to only check 29# but NOT reformat a collection of source files, defined by 30# '$(PRETTY_FILES)' using the program '$(PRETTY_CHECK)' with the 31# arguments '$(PRETTY_CHECK_ARGS)'. 32# 33# This represents the minimum integration with GNU autotools 34# (automake inparticular) such that 'make pretty' and 'make 35# pretty-check' may be invoked at the top of the tree and all 36# the prerequisites occur such that it executes successfully 37# with no intervening make target invocations. '$(BUILT_SOURCES)' 38# are the key automake-specific dependencies to ensure that happens. 39# 40 41# nl-make-pretty <TERSE OUTPUT COMMAND> <COMMAND> <COMMAND ARGUMENTS> <PATHS> 42# 43# This function iterates over PATHS, invoking COMMAND with 44# COMMAND ARGUEMENTS on each file. If a non-verbose make has been 45# requested TERSE OUTPUT COMMAND is emitted to standard output. 46 47define nl-make-pretty 48$(AM_V_at)for file in $(4); do \ 49 $(1) \ 50 if test -f $${file}; then d=; else d=$(srcdir)/; fi; \ 51 $(2) $(3) $${d}$${file} \ 52 || exit 1; \ 53done 54endef 55 56.PHONY: pretty pretty-recursive pretty-check pretty-check-recursive lint 57 58pretty: pretty-recursive 59 60pretty pretty-check: $(BUILT_SOURCES) 61 62# Map the build action 'lint' to the more vernacular 'pretty-check'. 63 64lint: pretty-check 65 66pretty-check: pretty-check-recursive 67 68pretty-recursive pretty-check-recursive: 69 $(call nl-make-subdirs-with-dirs,$(PRETTY_SUBDIRS)) 70 71pretty: $(PRETTY_FILES) 72ifneq ($(PRETTY),) 73 $(call nl-make-pretty,$(AM_V_PRETTY),$(PRETTY),$(PRETTY_ARGS),$(filter-out $(@)-recursive,$(PRETTY_FILES))) 74endif 75 76pretty-check: $(PRETTY_FILES) 77ifneq ($(PRETTY_CHECK),) 78 $(call nl-make-pretty,$(AM_V_PRETTY_CHECK),$(PRETTY_CHECK),$(PRETTY_CHECK_ARGS),$(filter-out $(@)-recursive,$(PRETTY_FILES))) 79endif 80