Created
September 25, 2009 17:03
-
-
Save singpolyma/193681 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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