2011-09-11 14:45:40 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
prefix=/usr/local
|
|
|
|
|
2014-01-02 00:11:04 +00:00
|
|
|
ismac() {
|
|
|
|
uname -s | grep Darwin >/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
isx86_64() {
|
|
|
|
uname -m | grep -i X86_64 >/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
isbsd() {
|
|
|
|
uname -s | grep BSD >/dev/null
|
|
|
|
}
|
|
|
|
|
2012-07-07 22:35:59 +00:00
|
|
|
usage() {
|
|
|
|
echo "supported arguments"
|
|
|
|
echo "--prefix=/path default: $prefix"
|
|
|
|
echo "--exec_prefix=/path default: $prefix/bin"
|
|
|
|
echo "--bindir=/path default: $prefix/bin"
|
|
|
|
echo "--libdir=/path default: $prefix/lib"
|
|
|
|
echo "--includedir=/path default: $prefix/include"
|
|
|
|
echo "--sysconfdir=/path default: $prefix/etc"
|
2014-01-02 00:11:04 +00:00
|
|
|
ismac && isx86_64 && echo "--fat-binary : build for both i386 and x86_64 architectures on 64-bit Macs"
|
2012-07-07 22:35:59 +00:00
|
|
|
echo "--help : show this text"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2011-09-11 14:45:40 +00:00
|
|
|
spliteq() {
|
|
|
|
arg=$1
|
|
|
|
echo "${arg#*=}"
|
|
|
|
#alternatives echo "$arg" | cut -d= -f2-
|
|
|
|
# or echo "$arg" | sed 's/[^=]*=//'
|
|
|
|
}
|
|
|
|
|
2014-01-02 00:11:04 +00:00
|
|
|
fat_binary=
|
|
|
|
|
2011-09-11 14:45:40 +00:00
|
|
|
parsearg() {
|
|
|
|
case "$1" in
|
2012-01-30 17:26:38 +00:00
|
|
|
--prefix=*) prefix=`spliteq $1`;;
|
2011-09-11 14:45:40 +00:00
|
|
|
--exec_prefix=*) exec_prefix=`spliteq $1`;;
|
|
|
|
--bindir=*) bindir=`spliteq $1`;;
|
|
|
|
--libdir=*) libdir=`spliteq $1`;;
|
|
|
|
--includedir=*) includedir=`spliteq $1`;;
|
2012-01-30 17:26:38 +00:00
|
|
|
--sysconfdir=*) sysconfdir=`spliteq $1`;;
|
2014-01-02 00:11:04 +00:00
|
|
|
--fat-binary) fat_binary=1;;
|
2012-07-07 22:35:59 +00:00
|
|
|
--help) usage;;
|
2011-09-11 14:45:40 +00:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
while true ; do
|
|
|
|
case $1 in
|
|
|
|
-*) parsearg "$1"; shift;;
|
|
|
|
*) break ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2012-01-30 17:35:03 +00:00
|
|
|
if [ -z "$exec_prefix" ] ; then
|
2011-09-11 14:45:40 +00:00
|
|
|
exec_prefix=$prefix
|
|
|
|
fi
|
|
|
|
|
2012-01-30 17:35:03 +00:00
|
|
|
if [ -z "$libdir" ] ; then
|
2011-09-11 14:45:40 +00:00
|
|
|
libdir=$prefix/lib
|
|
|
|
fi
|
|
|
|
|
2012-01-30 17:35:03 +00:00
|
|
|
if [ -z "$includedir" ] ; then
|
2011-09-11 14:45:40 +00:00
|
|
|
includedir=$prefix/include
|
|
|
|
fi
|
|
|
|
|
2012-01-30 17:35:03 +00:00
|
|
|
if [ -z "$sysconfdir" ] ; then
|
2012-01-30 17:26:38 +00:00
|
|
|
sysconfdir=$prefix/etc
|
|
|
|
fi
|
|
|
|
|
2012-01-30 17:35:03 +00:00
|
|
|
if [ -z "$bindir" ] ; then
|
2011-09-11 14:45:40 +00:00
|
|
|
bindir=$exec_prefix/bin
|
|
|
|
fi
|
|
|
|
|
2012-01-30 17:35:03 +00:00
|
|
|
if [ -z "$CC" ] ; then
|
2011-09-11 14:45:40 +00:00
|
|
|
CC=cc
|
|
|
|
fi
|
|
|
|
|
2012-01-24 06:29:04 +00:00
|
|
|
echo CC?=$CC>config.mak
|
|
|
|
[ -z "$CPPFLAGS" ] || echo CPPFLAGS?=$CPPFLAGS>>config.mak
|
|
|
|
[ -z "$CFLAGS" ] || echo USER_CFLAGS?=$CFLAGS>>config.mak
|
2011-09-11 14:45:40 +00:00
|
|
|
echo prefix=$prefix>>config.mak
|
|
|
|
echo exec_prefix=$exec_prefix>>config.mak
|
|
|
|
echo bindir=$bindir>>config.mak
|
|
|
|
echo libdir=$libdir>>config.mak
|
|
|
|
echo includedir=$includedir>>config.mak
|
2012-01-30 17:26:38 +00:00
|
|
|
echo sysconfdir=$sysconfdir>>config.mak
|
2014-07-22 12:56:49 +00:00
|
|
|
make_cmd=make
|
2012-01-27 19:21:06 +00:00
|
|
|
if ismac ; then
|
2012-12-16 01:39:28 +00:00
|
|
|
echo NO_AS_NEEDED=>>config.mak
|
2012-01-27 19:21:06 +00:00
|
|
|
echo LDSO_SUFFIX=dylib>>config.mak
|
2012-01-27 19:48:24 +00:00
|
|
|
echo MAC_CFLAGS+=-DIS_MAC=1>>config.mak
|
2014-01-02 00:11:04 +00:00
|
|
|
if isx86_64 && [ "$fat_binary" = 1 ] ; then
|
|
|
|
echo "Configuring a fat binary for i386 and x86_64"
|
|
|
|
echo MAC_CFLAGS+=-arch i386 -arch x86_64>>config.mak
|
|
|
|
echo LDFLAGS+=-arch i386 -arch x86_64>>config.mak
|
|
|
|
fi
|
2012-01-27 19:48:24 +00:00
|
|
|
echo LD_SET_SONAME=-Wl,-install_name,>>config.mak
|
2012-12-25 18:08:05 +00:00
|
|
|
elif isbsd ; then
|
|
|
|
echo LIBDL=>>config.mak
|
|
|
|
echo "CFLAGS+=-DIS_BSD">>config.mak
|
2014-07-22 12:56:49 +00:00
|
|
|
make_cmd=gmake
|
2012-01-27 19:21:06 +00:00
|
|
|
fi
|
2011-09-11 14:45:40 +00:00
|
|
|
|
2014-07-22 12:56:49 +00:00
|
|
|
echo "Done, now run $make_cmd && $make_cmd install"
|