-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcleanall
executable file
·36 lines (32 loc) · 886 Bytes
/
cleanall
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
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# Simple hack to clean all Makefile projects in a directory
# Copyright (c) 2018 Benjamin Holt -- MIT License
if [ "$1" == "-h" -o "$1" == "--help" ]; then
cat <<USAGE
usage: cleanall [DIR] Cleans all projects with a Makefile immediately in
DIR or the current directory
cleanall -h|--help Print this message and exit
USAGE
exit 0
fi
pushd "${1:-.}" >> /dev/null
for ProjMake in */Makefile; do
Proj="${ProjMake%/Makefile}"
if [ "$Proj" == "*" ]; then
echo "cleanall: no Makefile projects found" >&2
popd >> /dev/null
exit 1
fi
echo "-- $Proj --"
if grep -E "^clean( ?):" "$ProjMake" >> /dev/null; then
pushd "$Proj" >> /dev/null
make clean
echo
popd >> /dev/null
else
echo "[ No 'clean:' target found ]"
echo
fi
done
popd >> /dev/null
###