x86/cet: Check CPU_FEATURE_ACTIVE in permissive mode
[glibc.git] / scripts / lint-makefiles.sh
blob0d202346bd786739175be107bba87bf52e4fe657
1 #!/bin/bash
2 # Copyright (C) 2023 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.
27 export LC_ALL=C
29 tmpfile="$(mktemp)"
31 cleanup () {
32 rm -f -- "$tmpfile"
35 trap cleanup 0
37 PYTHON=$1
38 # Absolute or relative path to the source directory.
39 srcdir=$2
41 # Must specify $PYTHON.
42 if [ -z "$PYTHON" ]; then
43 echo 'Please specify $PYTHON interpreter'
44 exit 1
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'
49 exit 1
52 linted=0
53 failed=0
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
58 failed=$((failed+1))
60 linted=$((linted+1))
61 done
62 # Must have linted at least the top-level Makefile.
63 if [ $linted -lt 1 ]; then
64 echo "Did not lint any Makefiles!"
65 exit 1
67 if [ $failed -gt 0 ]; then
68 echo "---"
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'
71 exit 1
73 # All Makefiles linted clean.
74 exit 0