summaryrefslogtreecommitdiff
path: root/tools/notsd-fixup
blob: 71b3bf4dfa32b7cf55eb69316ea7b9147b6739e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env bash
# Copyright (C) 2015-2016  Luke Shumaker

main() {
	set -e
	set -o pipefail
	export LC_COLLATE=C

	# We wrap the programs called by xargs with `sh` because xargs only exits early
	# if the status is 255, but we want to exit early for all non-zero statuses.
	# We use xargs instead of `find -exec` because `-exec` won't do much of
	# anything useful with the exit status.

	# Makefiles
	find "$@" -type f -name Makefile -print0 |
		xargs -r0 sh -c "$0--makefiles \"\$@\" || exit 255" --

	# C includes
	rm -rf -- "$0"--includes.cache
	find "$@" \( -name '*.h' -o -name '*.c' -o -name '*.gperf' -o -name '*.gperf.m4' \) -type f -print0 |
		xargs -r0 sh -c "$0--includes \"\$@\" || exit 255" --
	rm -rf -- "$0"--includes.cache
}

main "$@"