Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | dc04c93 | 2024-04-01 12:14:21 -0400 | [diff] [blame] | 3 | # Copyright 2017-2024 Open Networking Foundation Contributors |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 4 | # |
| 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 Armstrong | dc04c93 | 2024-04-01 12:14:21 -0400 | [diff] [blame] | 9 | # http:#www.apache.org/licenses/LICENSE-2.0 |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 10 | # |
| 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 Armstrong | dc04c93 | 2024-04-01 12:14:21 -0400 | [diff] [blame] | 17 | # SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation Contributors |
| 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | # ----------------------------------------------------------------------- |
| 20 | # Intent: |
| 21 | # ----------------------------------------------------------------------- |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 22 | |
| 23 | ##-------------------## |
| 24 | ##---] GLOBALS [---## |
| 25 | ##-------------------## |
| 26 | xargs-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 Armstrong | ccab2cf | 2024-04-06 18:00:59 -0400 | [diff] [blame] | 30 | make-check-find := find . |
| 31 | # -name 'vendor' -prune |
| 32 | make-check-find += $(foreach dir,$(onf-excl-dirs),-not -path './$(dir)/*') |
| 33 | make-check-find += -a \( -iname makefile -o -name '*.mk' \) |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 34 | make-check-find += -type f -print0 |
| 35 | |
| 36 | make-check := $(MAKE) |
| 37 | |
| 38 | make-check-args += --dry-run |
| 39 | make-check-args += --keep-going |
| 40 | make-check-args += --warn-undefined-variables |
| 41 | make-check-args += --no-print-directory |
| 42 | |
| 43 | # Quiet internal undef vars |
| 44 | make-check-args += DEBUG= |
| 45 | |
| 46 | ##-------------------## |
| 47 | ##---] TARGETS [---## |
| 48 | ##-------------------## |
| 49 | ifndef NO-LINT-MAKEFILE |
| 50 | lint : lint-make |
| 51 | endif |
| 52 | |
| 53 | ## ----------------------------------------------------------------------- |
| 54 | ## Intent: Perform a lint check on makefile sources |
| 55 | ## ----------------------------------------------------------------------- |
| 56 | lint-make-ignore += JSON_FILES= |
| 57 | lint-make-ignore += YAML_FILES= |
| 58 | lint-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 | ## ----------------------------------------------------------------------- |
| 69 | help-summary :: |
| 70 | @echo ' lint-make Syntax check [Mm]akefile and *.mk' |
| 71 | |
| 72 | # [EOF] |