Skip to content

Commit

Permalink
Add option to build for i386 architecture on x64 Intel Macs
Browse files Browse the repository at this point in the history
closes rofl0r#26
closes rofl0r#27
  • Loading branch information
nmcv authored and rofl0r committed Jan 2, 2014
1 parent 4415048 commit e2af2f2
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

prefix=/usr/local

ismac() {
uname -s | grep Darwin >/dev/null
}

isx86_64() {
uname -m | grep -i X86_64 >/dev/null
}

isbsd() {
uname -s | grep BSD >/dev/null
}

usage() {
echo "supported arguments"
echo "--prefix=/path default: $prefix"
Expand All @@ -10,6 +22,7 @@ usage() {
echo "--libdir=/path default: $prefix/lib"
echo "--includedir=/path default: $prefix/include"
echo "--sysconfdir=/path default: $prefix/etc"
ismac && isx86_64 && echo "--fat-binary : build for both i386 and x86_64 architectures on 64-bit Macs"
echo "--help : show this text"
exit 1
}
Expand All @@ -21,6 +34,8 @@ spliteq() {
# or echo "$arg" | sed 's/[^=]*=//'
}

fat_binary=

parsearg() {
case "$1" in
--prefix=*) prefix=`spliteq $1`;;
Expand All @@ -29,18 +44,11 @@ parsearg() {
--libdir=*) libdir=`spliteq $1`;;
--includedir=*) includedir=`spliteq $1`;;
--sysconfdir=*) sysconfdir=`spliteq $1`;;
--fat-binary) fat_binary=1;;
--help) usage;;
esac
}

ismac() {
uname -s | grep Darwin >/dev/null
}

isbsd() {
uname -s | grep BSD >/dev/null
}

while true ; do
case $1 in
-*) parsearg "$1"; shift;;
Expand Down Expand Up @@ -85,6 +93,11 @@ if ismac ; then
echo NO_AS_NEEDED=>>config.mak
echo LDSO_SUFFIX=dylib>>config.mak
echo MAC_CFLAGS+=-DIS_MAC=1>>config.mak
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
echo LD_SET_SONAME=-Wl,-install_name,>>config.mak
echo INSTALL_FLAGS=-m>>config.mak
elif isbsd ; then
Expand All @@ -93,5 +106,4 @@ elif isbsd ; then
echo INSTALL_FLAGS=-m>>config.mak
fi

echo done, now run make \&\& make install

echo "Done, now run make && make install"

0 comments on commit e2af2f2

Please sign in to comment.