2 # Copyright (C) 2023-2024 Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
5 # The GNU C Library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # The GNU C Library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with the GNU C Library; if not, see
17 # <https://www.gnu.org/licenses/>.
19 # This script checks to see that all Makefiles in the source tree
20 # conform to the sorted variable rules as defined by:
21 # scripts/sort-makefile-lines.py.
22 # Any difference is an error and should be corrected e.g. the lines
23 # reordered to sort correctly.
24 # The intent with this check is to ensure that changes made by
25 # developers match the expected format for the project.
38 # Absolute or relative path to the source directory.
41 # Must specify $PYTHON.
42 if [ -z "$PYTHON" ]; then
43 echo 'Please specify $PYTHON interpreter'
46 # Absolute or relative $srcdir must exist and be a directory.
47 if [ ! -d "$srcdir" ]; then
48 echo 'Please specify $srcdir in which to look for Makefiles'
54 for mfile
in `find "$srcdir" -name Makefile`; do
55 $PYTHON "${srcdir}/scripts/sort-makefile-lines.py" < "$mfile" > "$tmpfile"
56 # Printed the expected -> actual difference on error.
57 if ! diff -u --label "$mfile.expected" "$tmpfile" "$mfile"; then
62 # Must have linted at least the top-level Makefile.
63 if [ $linted -lt 1 ]; then
64 echo "Did not lint any Makefiles!"
67 if [ $failed -gt 0 ]; then
69 echo "Tested $linted Makefiles and $failed were incorrectly sorted"
70 echo 'Please use `patch -R -pN` and the output above to correct the sorting'
73 # All Makefiles linted clean.