public
Created

  • Download Gist
/usr/local/Library/Formula/php.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
require 'formula'
 
def mysql_installed?
`which mysql_config`.length > 0
end
 
class Php <Formula
url 'http://www.php.net/get/php-5.3.5.tar.gz/from/this/mirror'
homepage 'http://php.net/'
md5 'fb727a3ac72bf0ce37e1a20468a7bb81'
version '5.3.5'
 
# So PHP extensions don't report missing symbols
skip_clean ['bin', 'sbin']
 
 
depends_on 'libxml2'
depends_on 'jpeg'
depends_on 'libpng'
depends_on 'mcrypt'
depends_on 'gettext'
if ARGV.include? '--with-mysql'
depends_on 'mysql' => :recommended unless mysql_installed?
end
if ARGV.include? '--with-fpm'
depends_on 'libevent'
end
if ARGV.include? '--with-pgsql'
depends_on 'postgresql'
end
if ARGV.include? '--with-mssql'
depends_on 'freetds'
end
def options
[
['--with-mysql', 'Include MySQL support'],
['--with-pgsql', 'Include PostgreSQL support'],
['--with-mssql', 'Include MSSQL-DB support'],
['--with-fpm', 'Enable building of the fpm SAPI executable'],
['--with-apache', 'Build shared Apache 2.0 Handler module']
]
end
 
def patches
DATA
end
def configure_args
args = [
"--prefix=#{prefix}",
"--disable-debug",
"--disable-dependency-tracking",
"--with-config-file-path=#{prefix}/etc",
"--with-iconv-dir=/usr/local/Cellar/libiconv/1.13.1/",
"--enable-exif",
"--enable-soap",
"--enable-sqlite-utf8",
"--enable-wddx",
"--enable-ftp",
"--enable-sockets",
"--enable-zip",
"--enable-pcntl",
"--enable-shmop",
"--enable-sysvsem",
"--enable-sysvshm",
"--enable-sysvmsg",
"--enable-memory-limit",
"--enable-mbstring",
"--enable-bcmath",
"--enable-calendar",
"--enable-memcache",
"--with-openssl=/usr",
"--with-zlib=/usr",
"--with-bz2=/usr",
"--with-ldap",
"--with-ldap-sasl=/usr",
"--with-xmlrpc",
"--with-iodbc",
"--with-kerberos=/usr",
"--with-libxml-dir=#{Formula.factory('libxml2').prefix}",
"--with-xsl=/usr",
"--with-curl=/usr",
"--with-gd",
"--enable-gd-native-ttf",
"--with-mcrypt=#{Formula.factory('mcrypt').prefix}",
"--with-jpeg-dir=#{Formula.factory('jpeg').prefix}",
"--with-png-dir=#{Formula.factory('libpng').prefix}",
"--with-gettext=#{Formula.factory('gettext').prefix}",
"--with-tidy",
"--mandir=#{man}"
]
 
# Free type support
if File.exist? "/usr/X11"
args.push "--with-freetype-dir=/usr/X11"
end
 
# Bail if both php-fpm and apxs are enabled
# http://bugs.php.net/bug.php?id=52419
if (ARGV.include? '--with-fpm') && (ARGV.include? '--with-apache')
onoe "You can only enable PHP FPM or Apache, not both"
puts "http://bugs.php.net/bug.php?id=52419"
exit 99
end
 
# Enable PHP FPM
if ARGV.include? '--with-fpm'
args.push "--enable-fpm"
end
 
# Build Apache module
if ARGV.include? '--with-apache'
args.push "--with-apxs2=/usr/sbin/apxs"
args.push "--libexecdir=#{prefix}/libexec"
end
 
if ARGV.include? '--with-mysql'
args.push "--with-mysql-sock=/tmp/mysql.sock"
args.push "--with-mysqli=mysqlnd"
args.push "--with-mysql=mysqlnd"
args.push "--with-pdo-mysql=mysqlnd"
end
 
if ARGV.include? '--with-pgsql'
args.push "--with-pgsql=#{Formula.factory('postgresql').prefix}"
args.push "--with-pdo-pgsql=#{Formula.factory('postgresql').prefix}"
end
 
if ARGV.include? '--with-mssql'
args.push "--with-mssql=#{Formula.factory('freetds').prefix}"
end
 
return args
end
def install
ENV.O3 # Speed things up
system "./configure", *configure_args
 
if ARGV.include? '--with-apache'
# Use Homebrew prefix for the Apache libexec folder
inreplace "Makefile",
"INSTALL_IT = $(mkinstalldirs) '$(INSTALL_ROOT)/usr/libexec/apache2' && $(mkinstalldirs) '$(INSTALL_ROOT)/private/etc/apache2' && /usr/sbin/apxs -S LIBEXECDIR='$(INSTALL_ROOT)/usr/libexec/apache2' -S SYSCONFDIR='$(INSTALL_ROOT)/private/etc/apache2' -i -a -n php5 libs/libphp5.so",
"INSTALL_IT = $(mkinstalldirs) '#{prefix}/libexec/apache2' && $(mkinstalldirs) '$(INSTALL_ROOT)/private/etc/apache2' && /usr/sbin/apxs -S LIBEXECDIR='#{prefix}/libexec/apache2' -S SYSCONFDIR='$(INSTALL_ROOT)/private/etc/apache2' -i -a -n php5 libs/libphp5.so"
end
system "make"
system "make install"
 
system "cp ./php.ini-production #{prefix}/etc/php.ini"
 
if ARGV.include? '--with-fpm'
(prefix+'org.php.php-fpm.plist').write startup_plist
system "cp #{prefix}/etc/php-fpm.conf.default #{prefix}/etc/php-fpm.conf"
(prefix+'var/log').mkpath
touch prefix+'var/log/php-fpm.log'
end
end
 
def caveats; <<-EOS
For 10.5 and Apache:
Apache needs to run in 32-bit mode. You can either force Apache to start
in 32-bit mode or you can thin the Apache executable.
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php5_module #{prefix}/libexec/apache2/libphp5.so
 
The php.ini file can be found in:
#{prefix}/etc/php.ini
EOS
end
 
 
def startup_plist; <<-EOPLIST.undent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.php.php-fpm</string>
<key>Program</key>
<string>#{sbin}/php-fpm</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOPLIST
end
end
 
__END__
diff -Naur php-5.3.2/ext/iconv/iconv.c php/ext/iconv/iconv.c
--- php-5.3.2/ext/iconv/iconv.c 2010-12-01 17:03:36.000000000 +0300
+++ php/ext/iconv/iconv.c 2011-02-09 17:10:59.000000000 +0300
@@ -51,10 +51,6 @@
#include <gnu/libc-version.h>
#endif
-#ifdef HAVE_LIBICONV
-#undef iconv
-#endif
-
#include "ext/standard/php_smart_str.h"
#include "ext/standard/base64.h"
#include "ext/standard/quot_print.h"
 
diff -Naur php-5.3.2/ext/tidy/tidy.c php/ext/tidy/tidy.c
--- php-5.3.2/ext/tidy/tidy.c 2010-02-12 04:36:40.000000000 +1100
+++ php/ext/tidy/tidy.c 2010-05-23 19:49:47.000000000 +1000
@@ -22,6 +22,8 @@
#include "config.h"
#endif
+#include "tidy.h"
+
#include "php.h"
#include "php_tidy.h"
@@ -31,7 +33,6 @@
#include "ext/standard/info.h"
#include "safe_mode.h"
-#include "tidy.h"
#include "buffio.h"
/* compatibility with older versions of libtidy */
gistfile1.txt
1 2 3 4 5 6
brew install libiconv
mv /usr/lib/libiconv.dylib /usr/lib/libiconv.dylib.orig
mv /usr/include/iconv.h /usr/include/iconv.h.orig
ln -s /usr/local/Cellar/libiconv/1.13.1/lib/libiconv.dylib /usr/lib/libiconv.dylib
ln -s /usr/local/Cellar/libiconv/1.13.1/include/iconv.h /usr/include/iconv.h
brew install php --with-mysql --with-apache

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.