blob: 971bfb482f208e4fa1dc33276c2d51f4dd4c581f [file] [log] [blame]
Joey Armstronga8205c22023-10-18 13:35:16 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrongdc04c932024-04-01 12:14:21 -04003# Copyright 2023-2024 Open Networking Foundation Contributors
Joey Armstronga8205c22023-10-18 13:35:16 -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 Armstronga8205c22023-10-18 13:35:16 -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: 2023-2024 Open Networking Foundation Contributors
18# SPDX-License-Identifier: Apache-2.0
19# -----------------------------------------------------------------------
Joey Armstronga5325392024-04-02 13:22:12 -040020# Intent: doc8(s) --config switch will only accept one argument and
21# config(s)/exclusion(s) are needed from multiple sources.
22# This target will merge doc8.ini from onf-make/ and local/ for use.
Joey Armstrongdc04c932024-04-01 12:14:21 -040023# -----------------------------------------------------------------------
Joey Armstronga8205c22023-10-18 13:35:16 -040024
25##-------------------##
26##---] GLOBALS [---##
27##-------------------##
28.PHONY: lint-doc8-ini-tmp
29
30lint-doc8-ini-tmp = $(onf-mk-tmp)/doc8.ini
31.DELETE_ON_ERROR : $(lint-doc8-ini-tmp)
32.PHONY : lint-doc8-ini-tmp $(lint-doc8-ini-tmp)
33
34lint-doc8-ini-tmp : $(lint-doc8-ini-tmp)
35
36# -----------------------------------------------------------------------
Joey Armstronga5325392024-04-02 13:22:12 -040037# doc8 config files to merge: lf/makefiles/{onf-make,local}/
Joey Armstronga8205c22023-10-18 13:35:16 -040038# -----------------------------------------------------------------------
Joey Armstronga5325392024-04-02 13:22:12 -040039lint-doc8-ini-raw := $(onf-mk-dir)/lint/doc8/doc8.ini
40lint-doc8-ini-raw += $(local-mk-dir)/lint/doc8/doc8.ini
Joey Armstronga8205c22023-10-18 13:35:16 -040041
Joey Armstronga5325392024-04-02 13:22:12 -040042lint-doc8-ini-src = $(wildcard $(sort $(lint-doc8-ini-raw)))
Joey Armstronga8205c22023-10-18 13:35:16 -040043$(lint-doc8-ini-tmp):
44
45 $(call banner,Target $@)
46
47 @echo "FILES: $(lint-doc8-ini-src)"
48 mkdir -p $(dir $@)
49
50 @echo "** [doc8.ini] Generate $@"
51 @echo '[doc8]' > $@
52
53 @echo '** [doc8.ini] Merge onf-make and local config options'
54 $(HIDE)grep -v --fixed-strings --no-filename \
55 -e '[doc8]' \
56 -e 'ignore-path' \
57 -e 'max-line-length' \
58 $(lint-doc8-ini-src) \
59 >> $@
60
61 @echo '** [doc8.ini] Construct ignore-path='
62 @echo -n 'ignore-path = ' >> $@
63 $(HIDE)awk -F'=' '/^ignore-path/ {print $$2}' $(lint-doc8-ini-src) \
64 | paste -sd ',' - \
65 >> $@
66
67# # Prefer local config setting
68 @echo '** [doc8.ini] Extract max-line-length'
69 $(HIDE)grep --fixed-strings --no-filename 'max-line-length' $(lint-doc8-ini-src) \
70 | tail -n 1 \
71 >> $@
72
73 $(if $(DEBUG),cat $@)
74
75# -----------------------------------------------------------------------
76# -----------------------------------------------------------------------
77clean ::
78 $(RM) $(lint-doc8-ini-tmp)
79
80# -----------------------------------------------------------------------
81# -----------------------------------------------------------------------
82lint-doc8-help ::
83 @printf ' %-25.25s %s\n' 'lint-doc8-ini-tmp' \
84 'Create doc8.ini from onf-make/ and local/'
85
86# [EOF]