Adding FreeType to PHP on OS X

Native local development environment in OS X
Working with PHP 5 in Mac OS X 10.5
Recompiling PHP 5.3 On Snow Leopard With Freetype Support

Downloading Source Files

  1. cd /usr/local
  2. sudo mkdir src
  3. sudo chown [your username]:staff src
  4. cd src
  5. mkdir pcre
  6. mkdir php
  7. cd pcre
  8. curl -O ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.12.tar.bz2
  9. cd ../php
  10. curl -O http://www.opensource.apple.com/source/apache_mod_php/apache_mod_php-53.3.1/php-5.3.3.tar.bz2
  11. Just because Textile is special

Compile PCRE

  1. cd /usr/local/src/pcre
  2. tar -jxvf pcre-8.12.tar.bz2
  3. cd pcre-8.12
  4. ./configure —disable-shared —enable-static
  5. make && make install DESTDIR=/usr/local/src/pcre/pcre-local
  6. Just because Textile is special

Compile PHP

  1. cd /usr/local/src/php
  2. tar -jxvf php-5.3.3.tar.bz2
  3. cd php-5.3.3
  4. Just because Textile is special

edit ext/iconv/iconv.c

./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
--disable-dependency-tracking --sysconfdir=/private/etc --with-apxs2=/usr/sbin/apxs
--enable-cli --with-config-file-path=/etc --with-libxml-dir=/usr --with-openssl=/usr --with-kerberos=/usr --with-zlib=/usr
--enable-bcmath --with-bz2=/usr --enable-calendar --with-curl=/usr --enable-exif --enable-ftp
--with-gd
--with-jpeg-dir=/BinaryCache/apache_mod_php/apache_mod_php-53.3.1~2/Root/usr/local
--with-png-dir=/BinaryCache/apache_mod_php/apache_mod_php-53.3.1~2/Root/usr/local
--enable-gd-native-ttf --with-ldap=/usr --with-ldap-sasl=/usr --enable-mbstring --enable-mbregex
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
--with-mysql-sock=/var/mysql/mysql.sock
--with-iodbc=/usr --enable-shmop --with-snmp=/usr --enable-soap --enable-sockets
--enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-xmlrpc --with-iconv-dir=/usr --with-xsl=/usr
--enable-zend-multibyte --enable-zip --with-pcre-regex=/usr

# MACOSX_DEPLOYMENT_TARGET=10.6
# 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 MACOSX_DEPLOYMENT_TARGET

# ./configure --prefix=/usr \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--disable-dependency-tracking \
--sysconfdir=/private/etc \
--with-apxs2=/usr/sbin/apxs \
--enable-cli \
--with-config-file-path=/etc \
--with-libxml-dir=/usr \
--with-openssl=/usr \
--with-kerberos=/usr \
--with-zlib=/usr \
--enable-bcmath \
--with-bz2=/usr \
--enable-calendar \
--with-curl=/usr \
--enable-exif \
--enable-ftp \
--with-gd \
--with-jpeg-dir=/usr/local/lib \
--with-png-dir=/usr/X11R6 \
--with-freetype-dir=/usr/X11R6 \
--with-xpm-dir=/usr/X11R6 \
--with-ldap=/usr \
--with-ldap-sasl=/usr \
--enable-mbstring \
--enable-mbregex \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mysql-sock=/tmp/mysql.sock \
--with-iodbc=/usr \
--enable-shmop \
--with-snmp=/usr \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--with-xmlrpc \
--with-iconv-dir=/usr \
--with-xsl=/usr \
--with-pcre-regex=/usr/local/src/pcre/pcre-local/usr/local

libjpeg(a.so) missing!!!

Download libjpeg

  1. cd /usr/local/src
  2. mkdir libjpeg
  3. cd libjpeg
  4. curl -O http://www.ijg.org/files/jpegsrc.v8c.tar.gz
  5. Just because Textile is special

Compile libjpeg

  1. tar xfz jpegsrc.v8c.tar.gz
  2. cd jpeg-8c
  3. ./configure
  4. make
  5. sudo make install
  6. Just because Textile is special

Compile PHP, part 2

  1. cd /usr/local/src/php
  2. tar -jxvf php-5.3.3.tar.bz2
  3. cd php-5.3.3
  4. ./configure —prefix=/usr \
  5. export EXTRA_CFLAGS=”-lresolv”
  6. make
  7. sudo make install
  8. Just because Textile is special
Password:
Installing PHP SAPI module:       apache2handler
/usr/share/httpd/build/instdso.sh SH_LIBTOOL='/usr/share/apr-1/build-1/libtool' libs/libphp5.so /usr/libexec/apache2
/usr/share/apr-1/build-1/libtool --mode=install cp libs/libphp5.so /usr/libexec/apache2/
cp libs/libphp5.so /usr/libexec/apache2/libphp5.so
Warning!  dlname not found in /usr/libexec/apache2/libphp5.so.
Assuming installing a .so rather than a libtool archive.
chmod 755 /usr/libexec/apache2/libphp5.so
[activating module `php5' in /private/etc/apache2/httpd.conf]
Installing PHP CLI binary:        /usr/bin/
Installing PHP CLI man page:      /usr/share/man/man1/
Installing build environment:     /usr/lib/php/build/
Installing header files:          /usr/include/php/
Installing helper programs:       /usr/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/share/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/lib/php/
[PEAR] Archive_Tar    - upgraded:  1.3.7
[PEAR] Console_Getopt - already installed: 1.2.3
[PEAR] Structures_Graph- upgraded:  1.0.3
[PEAR] XML_Util       - already installed: 1.2.1
[PEAR] PEAR           - upgraded:  1.9.1
Warning! a PEAR user config file already exists from a previous PEAR installation at '/Users/artist/.pearrc'. You may probably want to remove it.
Wrote PEAR system config file at: /private/etc/pear.conf
You may want to add: /usr/lib/php to your php.ini include_path
/usr/local/src/php/php-5.3.3/build/shtool install -c ext/phar/phar.phar /usr/bin
ln -s -f /usr/bin/phar.phar /usr/bin/phar
Installing PDO headers:          /usr/include/php/ext/pdo/