Joey Armstrong | a8205c2 | 2023-10-18 13:35:16 -0400 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
| 3 | # Copyright 2023 Open Networking Foundation |
| 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 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 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 | # ----------------------------------------------------------------------- |
| 17 | |
| 18 | ##-------------------## |
| 19 | ##---] GLOBALS [---## |
| 20 | ##-------------------## |
| 21 | .PHONY: lint-doc8-ini-tmp |
| 22 | |
| 23 | lint-doc8-ini-tmp = $(onf-mk-tmp)/doc8.ini |
| 24 | .DELETE_ON_ERROR : $(lint-doc8-ini-tmp) |
| 25 | .PHONY : lint-doc8-ini-tmp $(lint-doc8-ini-tmp) |
| 26 | |
| 27 | lint-doc8-ini-tmp : $(lint-doc8-ini-tmp) |
| 28 | |
| 29 | # ----------------------------------------------------------------------- |
| 30 | # Intent: Doc8(s) --config switch will only accept one argument and |
| 31 | # configs/exclusions are needed from multiple sources. |
| 32 | # This target will merge doc8.ini from onf-make/ and local/ for use. |
| 33 | # ----------------------------------------------------------------------- |
| 34 | # repo:onf-make is special, MAKEDIR=makefiles/local does not exist. |
| 35 | # ----------------------------------------------------------------------- |
| 36 | lint-doc8-ini-raw := $(ONF_MAKEDIR)/lint/doc8/doc8.ini |
| 37 | ifneq ($(--repo-name--),onf-make) |
| 38 | lint-doc8-ini-raw += $(MAKEDIR)/lint/doc8/doc8.ini |
| 39 | endif |
| 40 | |
| 41 | lint-doc8-ini-src = $(wildcard $(lint-doc8-ini-raw)) |
| 42 | $(lint-doc8-ini-tmp): |
| 43 | |
| 44 | $(call banner,Target $@) |
| 45 | |
| 46 | @echo "FILES: $(lint-doc8-ini-src)" |
| 47 | mkdir -p $(dir $@) |
| 48 | |
| 49 | @echo "** [doc8.ini] Generate $@" |
| 50 | @echo '[doc8]' > $@ |
| 51 | |
| 52 | @echo '** [doc8.ini] Merge onf-make and local config options' |
| 53 | $(HIDE)grep -v --fixed-strings --no-filename \ |
| 54 | -e '[doc8]' \ |
| 55 | -e 'ignore-path' \ |
| 56 | -e 'max-line-length' \ |
| 57 | $(lint-doc8-ini-src) \ |
| 58 | >> $@ |
| 59 | |
| 60 | @echo '** [doc8.ini] Construct ignore-path=' |
| 61 | @echo -n 'ignore-path = ' >> $@ |
| 62 | $(HIDE)awk -F'=' '/^ignore-path/ {print $$2}' $(lint-doc8-ini-src) \ |
| 63 | | paste -sd ',' - \ |
| 64 | >> $@ |
| 65 | |
| 66 | # # Prefer local config setting |
| 67 | @echo '** [doc8.ini] Extract max-line-length' |
| 68 | $(HIDE)grep --fixed-strings --no-filename 'max-line-length' $(lint-doc8-ini-src) \ |
| 69 | | tail -n 1 \ |
| 70 | >> $@ |
| 71 | |
| 72 | $(if $(DEBUG),cat $@) |
| 73 | |
| 74 | # ----------------------------------------------------------------------- |
| 75 | # ----------------------------------------------------------------------- |
| 76 | clean :: |
| 77 | $(RM) $(lint-doc8-ini-tmp) |
| 78 | |
| 79 | # ----------------------------------------------------------------------- |
| 80 | # ----------------------------------------------------------------------- |
| 81 | lint-doc8-help :: |
| 82 | @printf ' %-25.25s %s\n' 'lint-doc8-ini-tmp' \ |
| 83 | 'Create doc8.ini from onf-make/ and local/' |
| 84 | |
| 85 | # [EOF] |