blob: 9ad866e7cbc19beeed9f6500a480c863f969da0b [file] [log] [blame]
Joey Armstrong0205d332023-04-11 17:29:23 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrongdc04c932024-04-01 12:14:21 -04003# Copyright 2017-2024 Open Networking Foundation Contributors
Joey Armstrong0205d332023-04-11 17:29:23 -04004#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
Joey Armstrongdc04c932024-04-01 12:14:21 -04009# http:#www.apache.org/licenses/LICENSE-2.0
Joey Armstrong0205d332023-04-11 17:29:23 -040010#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# -----------------------------------------------------------------------
Joey Armstrongdc04c932024-04-01 12:14:21 -040017# SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation Contributors
18# SPDX-License-Identifier: Apache-2.0
19# -----------------------------------------------------------------------
20# Intent:
21# -----------------------------------------------------------------------
Joey Armstrong0205d332023-04-11 17:29:23 -040022
23##-------------------##
24##---] GLOBALS [---##
25##-------------------##
26xargs-n1-local := $(subst -t,$(null),$(xargs-n1))# inhibit cmd display
27
28# Gather sources to check
29# TODO: implement deps, only check modified files
Joey Armstrongccab2cf2024-04-06 18:00:59 -040030make-check-find := find .
31# -name 'vendor' -prune
32make-check-find += $(foreach dir,$(onf-excl-dirs),-not -path './$(dir)/*')
33make-check-find += -a \( -iname makefile -o -name '*.mk' \)
Joey Armstrong0205d332023-04-11 17:29:23 -040034make-check-find += -type f -print0
35
36make-check := $(MAKE)
37
38make-check-args += --dry-run
39make-check-args += --keep-going
40make-check-args += --warn-undefined-variables
41make-check-args += --no-print-directory
42
43# Quiet internal undef vars
44make-check-args += DEBUG=
45
46##-------------------##
47##---] TARGETS [---##
48##-------------------##
49ifndef NO-LINT-MAKEFILE
50 lint : lint-make
51endif
52
53## -----------------------------------------------------------------------
54## Intent: Perform a lint check on makefile sources
55## -----------------------------------------------------------------------
56lint-make-ignore += JSON_FILES=
57lint-make-ignore += YAML_FILES=
58lint-make:
59 @echo
60 @echo "** -----------------------------------------------------------------------"
61 @echo "** Makefile syntax checking"
62 @echo "** -----------------------------------------------------------------------"
63 $(HIDE)$(env-clean) $(make-check-find) \
64 | $(xargs-n1-local) $(make-check) $(make-check-args) $(lint-make-ignore)
65
66## -----------------------------------------------------------------------
67## Intent: Display command help
68## -----------------------------------------------------------------------
69help-summary ::
70 @echo ' lint-make Syntax check [Mm]akefile and *.mk'
71
72# [EOF]