#!/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" -- # GNUmakefiles find "$@" -type l -name GNUmakefile -delete # It's OK for the top-level one to fail find "$@" -type f -name Makefile -printf '%h\0' | xargs -r0 -I {} ln -s -r -t {} GNUmakefile # 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 "$@"