Skip to content

Instantly share code, notes, and snippets.

@singpolyma
Created September 25, 2009 17:03
Show Gist options
  • Save singpolyma/193681 to your computer and use it in GitHub Desktop.
Save singpolyma/193681 to your computer and use it in GitHub Desktop.
#!/bin/sh
## If you use source files with space in the name, this will break.
## `make` basically hates such files anyway. Don't use them.
BIN="`basename "$PWD"`"
OBJ=""
SH=""
# GNU Make implicit .o rules
# POSIX set is: c f
EXTS="c cpp cc C p r F f mod s"
IFS=" "
for EXT in $EXTS; do
IFS="
"
for FILE in `find -maxdepth 1 -name "*.$EXT"`; do
OBJ="$OBJ `basename $FILE .$EXT`.o"
done
done
# Main build rule
if [ -n "$OBJ" ]; then
echo "$BIN:$OBJ"
echo ' $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LOADLIBES) $(LDLIBS) -o $@'
echo
fi
# Shell scripts
IFS="
"
for FILE in `find -maxdepth 1 -name '*.sh'`; do
SH="$SH `basename $FILE .sh`"
echo "`basename $FILE .sh`: `basename $FILE`"
echo
done
# clean rule
echo ".PHONY: clean"
echo "clean:"
echo " \$(RM) ${BIN}${OBJ}${SH}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment