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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#!/bin/sh
test_libc_features() {
CFLAGS="-D_GNU_SOURCE"
: ${CC:=cc}
2>/dev/null $CC -xc $CFLAGS -o /dev/null - <<-EOF
#include <string.h>
int main(void) {
char dst[4];
strlcpy(dst, "1234", sizeof dst);
return 0;
}
EOF
}
copy_mk() {
cmd="cp Makefile.$1 Makefile"
echo "+ $cmd"; $cmd
}
usage() {
cat <<-HELP
Usage: configure [-h]
Example: build a static binary and install to your home directory
./configure
CFLAGS="-static" make
PREFIX=\$HOME/local make install
HELP
exit 1
}
while [ $# -gt 0 ]; do
case $1 in
-h) usage ;;
*) echo "configure: unused argument: $1" ;;
esac
shift
done
case "${TARGET_OS:-`uname`}" in
Darwin)
copy_mk macos
;;
FreeBSD)
copy_mk freebsd
;;
Linux)
test_libc_features && copy_mk linux || copy_mk linux-compat
;;
*)
copy_mk bsd
;;
esac
|