Skip to content

Instantly share code, notes, and snippets.

@singpolyma
Created May 25, 2009 16:32
Show Gist options
  • Save singpolyma/117607 to your computer and use it in GitHub Desktop.
Save singpolyma/117607 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Process Makefile and output files to delete in a clean operation
FILE="$1"
if [ -z "$FILE" ]; then
if [ -f "Makefile" ]; then
FILE="Makefile"
elif [ -f "makefile" ]; then
FILE="makefile"
fi
fi
PHONY="`grep '.PHONY' "$FILE" | cut -d':' -f2`"
IFS="
"
for TARGET in `grep ':' "$FILE" | cut -d':' -f1 | grep -v '^\..*$'`; do
IFS=" "
IN=0
for P in $PHONY; do
if [ "$TARGET" = "$P" ]; then
IN=1
fi
done
if [ $IN -eq 0 ]; then
TARGET="`echo "$TARGET" | sed -e 's/%/*/'`"
echo -n "$TARGET "
fi
done
echo -n "*.o"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment