我最终使用了这个:
#!/usr/bin/env bash
prefix=NONE
test "$prefix" = NONE && prefix=/usr/local
usage ()
{
echo ""
echo "Usage : configure [--prefix=PREFIX]"
echo ""
}
while test x$1 != x; do
case $1 in
--prefix=*)
prefix=`echo $1 | sed 's/--prefix=//'`
;;
--prefix)
shift
prefix=$1
;;
--help)
usage
exit
;;
*)
echo Warning: unknown argument $1 >&2
usage
;;
esac
shift
done
echo -n "SUBDIRS = " > config.make
echo Configuration Summary
echo ---------------------
echo
echo "MyApp has been configured with "
echo " prefix = $prefix"
echo
echo >> config.make
echo
echo -n "prefix=$prefix" >> config.make
然后在 Makefile 中我需要做的第一件事是:
top_srcdir=.
CONFIG_MAKE=$(top_srcdir)/config.make
-include $(top_srcdir)/config.make
如果有比这更好的解决方案,我会很感兴趣。