blob: 35cc450877838333eddb541af30230417fe13e0c [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
30make-check-find := find . -name 'vendor' -prune
31make-check-find += -o \( -iname makefile -o -name '*.mk' \)
32make-check-find += -type f -print0
33
34make-check := $(MAKE)
35
36make-check-args += --dry-run
37make-check-args += --keep-going
38make-check-args += --warn-undefined-variables
39make-check-args += --no-print-directory
40
41# Quiet internal undef vars
42make-check-args += DEBUG=
43
44##-------------------##
45##---] TARGETS [---##
46##-------------------##
47ifndef NO-LINT-MAKEFILE
48 lint : lint-make
49endif
50
51## -----------------------------------------------------------------------
52## Intent: Perform a lint check on makefile sources
53## -----------------------------------------------------------------------
54lint-make-ignore += JSON_FILES=
55lint-make-ignore += YAML_FILES=
56lint-make:
57 @echo
58 @echo "** -----------------------------------------------------------------------"
59 @echo "** Makefile syntax checking"
60 @echo "** -----------------------------------------------------------------------"
61 $(HIDE)$(env-clean) $(make-check-find) \
62 | $(xargs-n1-local) $(make-check) $(make-check-args) $(lint-make-ignore)
63
64## -----------------------------------------------------------------------
65## Intent: Display command help
66## -----------------------------------------------------------------------
67help-summary ::
68 @echo ' lint-make Syntax check [Mm]akefile and *.mk'
69
70# [EOF]