Archive for November 25th, 2008

PHP & mcrypt on Mac OS X

November 25th, 2008

What a pain to get mcrypt installed supporting all the architectures Mac OS X needs. I could only compile with one architecture. I kept getting:
gcc-4.0: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags
as well as:
configure: error: Sorry, I was not able to diagnose which libmcrypt version you have installed.

Well, the secret is –disable-dependency-tracking (more info here).

To build libmcrypt-
libmcrypt-2.5.8:

MACOSX_DEPLOYMENT_TARGET=10.5 \
CFLAGS='-O3 -fno-common -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
LDFLAGS='-O3 -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
./configure --disable-dependency-tracking
make -j6
sudo make install

To build the mcrypt extension -
php-5.2.6/ext/mcrypt:

/usr/local/php5/bin/phpize
MACOSX_DEPLOYMENT_TARGET=10.5 \
CFLAGS='-O3 -fno-common -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
LDFLAGS='-O3 -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
./configure --with-php-config=/usr/local/php5/bin/php-config
make -j6
sudo make install

mcrypt.so (162Kb MD5: 6801f7ea818954405028eeb68d59a5f6)

Here’s the address to download the extension http://saltybeagle.com/downloads/mcrypt.so