SnowLeopardにphp5.2.13をインストール

参考
Compiling PHP with OCI8/Oracle on Mac OS X Snow Leopard
サーバー管理 « chibiegg日誌


MacPorts使うと面倒...

  • gettext0.18だとphp5.2.13がコンパイルできない...
  • gdの依存関連がグダグダ
  • libiconv関連のリンク時のエラー

なので、必要そうなものをいちいちインストールする。


gettext

% curl -O ftp://ftp.gnu.org/gnu/gettext/gettext-0.17.tar.gz
% tar xzf gettext-0.17.tar.gz
% cd gettext-0.17/
% CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bind_at_load" ./configure --prefix=/usr/local
% make
% sudo make install


FreeType

% curl -O http://mirrors.zerg.biz/nongnu/freetype/freetype-2.3.12.tar.bz2
% tar xjf freetype-2.3.12.tar.bz2
% cd freetype-2.3.12/
% CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bind_at_load" ./configure --prefix=/usr/local
% make
% sudo make install


jpeg

% curl -O http://www.ijg.org/files/jpegsrc.v8.tar.gz
% tar xzf jpegsrc.v8.tar.gz
% cd jpeg-8/
% CFLAGS="-arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch x86_64 -g -Os -pipe" CXXFLAGS="-arch x86_64 -g -Os -pipe" LDFLAGS="-arch x86_64 -bind_at_load" ./configure --enable-shared
% make
% sudo make install


libpng

% curl -O ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.4.1.tar.gz
% tar xzf libpng-1.4.1.tar.gz 
% cd libpng-1.4.1/
% CFLAGS="-arch x86_64" CCFLAGS="-arch x86_64" CXXFLAGS="-arch x86_64" LDFLAGS="-arch x86_64" ./configure
% make
% sudo make install


t1lib

% curl -O ftp://sunsite.unc.edu/pub/linux/libs/graphics/t1lib-5.1.2.tar.gz
% tar xzf t1lib-5.1.2.tar.gz
% cd t1lib-5.1.2/
% CFLAGS="-arch x86_64" CCFLAGS="-arch x86_64" CXXFLAGS="-arch x86_64" LDFLAGS="-arch x86_64" ./configure
% make without_doc
% sudo make install


mcrypt

% curl -O http://sunet.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2
% tar xjf libmcrypt-2.5.8.tar.bz2
% cd libmcrypt-2.5.8/
% CFLAGS="-arch x86_64" CCFLAGS="-arch x86_64" CXXFLAGS="-arch x86_64" LDFLAGS="-arch x86_64" ./configure
% make
% sudo make install


php-5.2.13/ext/iconv/iconv.cの修正
http://bugs-beta.php.net/bug.php?id=49267

--- iconv.c.org 2010-05-02 10:08:22.000000000 +0900
+++ iconv.c     2010-05-02 10:08:33.000000000 +0900
@@ -194,7 +194,7 @@
 /* }}} */
 
 #ifdef HAVE_LIBICONV
-#define iconv libiconv
+#define iconv iconv
 #endif
 
 /* {{{ typedef enum php_iconv_enc_scheme_t */

パッチとかある...
http://opensource.apple.com/source/apache_mod_php/apache_mod_php-53/patches/iconv.patch


#!/bin/sh
PREFIX='/usr/local/'
PWD=`pwd`

build() {
  make distclean

  EXTENSION_DIR=${1}/lib/extensions/
  export EXTENSION_DIR

  CFLAGS='-arch x86_64 -g -Os -pipe -no-cpp-precomp'
  CCFLAGS='-arch x86_64 -g -Os -pipe'
  CXXFLAGS='-arch x86_64 -g -Os -pipe'
  LDFLAGS='-arch x86_64 -bind_at_load'
  export CFLAGS CXXFLAGS LDFLAGS CCFLAGS

  ./configure \
  --prefix=${1} \
  --with-apxs2=/usr/sbin/apxs \
  --with-config-file-path=${1}/etc/ \
  --with-pear=${1}/pear \
  --enable-cli \
  --enable-force-cgi-redirect \
  --enable-mbstring \
  --enable-mbregex \
  --enable-zend-multibyte \
  --with-iconv-dir=/usr/local \
  --with-gettext=/usr/local \
  --enable-sockets \
  --enable-ftp \
  --with-curl \
  --with-mysql='/usr/local/mysql' \
  --with-mysqli='/usr/local/mysql/bin/mysql_config' \
  --enable-pdo \
  --with-pdo-mysql='/usr/local/mysql' \
  --with-pgsql=/usr/local/postgresql \
  --enable-sqlite-utf8 \
  --enable-zip \
  --with-zlib \
  --enable-xml \
  --enable-dom \
  --with-xmlrpc \
  --with-xsl \
  --enable-exif \
  --with-gd \
  --with-jpeg-dir=/usr/local \
  --with-png-dir=/usr/local \
  --with-freetype-dir=/usr/local \
  --with-t1lib=/usr/local \
  --with-ttf \
  --enable-gd-native-ttf \
  --enable-gd-jis-conv \
  --with-kerberos=/usr \
  --with-mcrypt \
  && make all
}

VER=`basename $PWD`
PREFIX=${PREFIX}${VER}

build ${PREFIX} 

if [ -e ${PREFIX} -a -d ${PREFIX} ]
then
  sudo rm -rf ${PREFIX}
fi

sudo mkdir -p ${PREFIX} 
sudo make install'