Skip to content

Instantly share code, notes, and snippets.

@christianchristensen
Forked from tobiastom/libpng.rb
Created October 5, 2011 14:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianchristensen/1264605 to your computer and use it in GitHub Desktop.
Save christianchristensen/1264605 to your computer and use it in GitHub Desktop.
PHP Homebrew Formular
require 'formula'
class Libpng < Formula
url 'http://downloads.sourceforge.net/project/libpng/libpng15/1.5.5/libpng-1.5.5.tar.bz2'
homepage 'http://www.libpng.org/pub/png/libpng.html'
md5 '3270bf2990c3174ae939388398de751e'
keg_only :provided_by_osx,
"TODO: Which software depends on this newer version of libpng?"
def install
system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}"
system "make install"
end
end
require 'formula'
class Php53osx <Formula
url 'http://downloads.php.net/johannes/php-5.3.5.tar.bz2'
version '5.3.5'
homepage 'http://php.net'
md5 '8aaf20c95e91f25c5b6a591e5d6d61b9'
@@has_apache = false
# DEPENDENCIES
if(ARGV.include? '--with-gettext')
puts "Requiring gettext"
depends_on 'gettext'
end
if(ARGV.include? '--with-pspell')
puts "Requiring aspell"
depends_on 'aspell'
end
if ARGV.include? '--default-osx'
@@has_apache = true
depends_on 'jpeg'
depends_on 'libpng'
depends_on 'libxml2'
depends_on 'sqlite'
depends_on 'pcre'
else
if (ARGV.include? '--with-mysql') && (!ARGV.include? '--with-native-mysql')
puts "Requiring MySQL"
depends_on 'mysql'
end
if ARGV.include? '--with-sqlite'
depends_on 'sqlite'
end
end
if ARGV.include? '--with-fpm'
depends_on 'libevent'
end
if ARGV.include? '--with-apache'
@@has_apache = true
end
if ARGV.include? '--without-apache'
@@has_apache = false
end
def patches
# Typical Mac OSX+PHP libiconv patch
# Added the Mac OSX mysqli non-native bug fix
DATA
end
def options
[
['--default-osx', "Build like the default OS X PHP install (minus ODBC, Phar)"],
['--with-mysql', "Build with MySQL (PDO) support from homebrew"],
['--with-native-mysql', "Build with native MySQL drivers [supplied by --default-osx]"],
['--with-sqlite', "Build with SQLite3 (PDO) support from homebrew"],
['--with-osx-sqlite', "Build with SQLite3 (PDO) from OS X [supplied by --default-osx]"],
['--with-fpm', "Build with PHP-FPM"],
['--with-apache', "Build with the Apache SAPI [supplied by --default-osx]"],
['--without-apache', "Ignore building the Apache SAPI [only useful with --default-osx]"],
['--with-gettext', "Add gettext support"],
['--with-postgres', "Add PostgreSQL support (PDO and module)"],
['--with-pspell', "Add ASpell support"]
]
end
def caveats
<<-END_CAVEATS
This formula has installed libxml2 and libiconv to bypass some errors included
within the default OS X libraries.
If you would like to customize your php.ini please edit:
#{HOMEBREW_PREFIX}/etc/php.ini
NOTE: You will want to set date.timezone setting to your timezone.
http://www.php.net/manual/en/timezones.php
If you used --with-fpm you need to edit:
#{HOMEBREW_PREFIX}/etc/php-fpm.conf
Switches:
Pass --default-osx to build like the default OS X install of PHP (including binding to default Apache install)
Pass --with-mysql to build with MySQL (PDO) support
Pass --with-native-mysql to build with native MySQL drivers [supplied by --default-osx]
Pass --with-sqlite to build with SQLite3 (PDO) support from homebrew
Pass --with-osx-sqlite to build with SQLite3 (PDO) from OS X [supplied by --default-osx]
Pass --with-fpm to build with PHP-FPM
Pass --with-apache to build the Apache SAPI [supplied by --default-osx]
Pass --without-apache to ignore building the Apache SAPI [only useful with --default-osx]
Pass --with-gettext to build with gettext support
Pass --with-postgres to build with PostGreSQL support
Pass --with-pspell to build ASpell support
END_CAVEATS
end
def skip_clean? path
path == bin+'php'
end
def install
configure_args = [
"--prefix=#{prefix}",
"--disable-debug",
"--disable-dependency-tracking",
"--with-config-file-path=#{HOMEBREW_PREFIX}/etc",
"--sysconfdir=#{prefix}/etc",
"--with-pear=#{prefix}/share/pear/",
"--enable-cgi",
"--mandir=#{man}",
"--with-iconv-dir=/usr"
]
if @@has_apache
puts "Building with Apache SAPI"
configure_args.push("--with-apxs2=/usr/sbin/apxs", "--libexecdir=#{prefix}/libexec")
end
if (ARGV.include? '--default-osx') || (ARGV.include? '--with-mysql')
# Now for the DB stuff
if (ARGV.include? '--with-mysql') && (!ARGV.include? '--with-native-mysql')
puts "Using MySQL (PDO) drivers [homebrew drivers]"
configure_args.push("--with-mysql=#{HOMEBREW_PREFIX}/lib/mysql",
"--with-mysqli=#{HOMEBREW_PREFIX}/bin/mysql_config",
"--with-pdo-mysql=#{HOMEBREW_PREFIX}/bin/mysql_config")
else
puts "Using MySQL (PDO) drivers [native drivers]"
configure_args.push("--with-mysql=mysqlnd",
"--with-mysqli=mysqlnd",
"--with-pdo-mysql=mysqlnd",
"--with-mysql-sock=/tmp/mysql.sock")
end
end
if (ARGV.include? '--default-osx') || (ARGV.include? '--with-osx-sqlite')
if (!ARGV.include? '--with-sqlite')
puts "Building with SQLite3 (PDO) support [OS X libraries]"
configure_args.push("--with-pdo-sqlite=/usr")
end
end
if (ARGV.include? '--with-sqlite')
puts "Building with SQLite3 (PDO) support [homebrew libraries])"
configure_args.push("--with-pdo-sqlite=#{HOMEBREW_PREFIX}")
end
if(ARGV.include? '--with-postgres')
puts "Building with PostGreSQL support"
pg = Formula.factory('postgresql')
configure_args.push(
"--with-pgsql=#{pg.bin + '/pg_config'}",
"--with-pdo-pgsql=#{pg.bin + '/pg_config'}"
)
end
if(ARGV.include? '--with-pspell')
puts "Building with ASpell support"
aspell = Formula.factory('aspell')
configure_args.push("--with-pspell")
end
if (ARGV.include? '--with-gettext')
puts "Building with gettext support"
configure_args.push("--with-gettext")
end
if ARGV.include? '--default-osx'
# Now for the GD stuff
configure_args.push("--with-gd",
"--with-jpeg-dir=#{HOMEBREW_PREFIX}",
"--with-png-dir=#{HOMEBREW_PREFIX}/Cellar/libpng/#{versions_of("libpng").first}",
"--with-freetype-dir=/usr/X11",
"--enable-gd-native-ttf")
# Misc default stuff
configure_args.push("--with-libxml-dir=#{HOMEBREW_PREFIX}",
"--with-openssl=/usr",
"--with-kerberos=/usr",
"--with-ldap=/usr",
"--with-ldap-sasl=/usr",
"--with-pcre-regex",
"--with-zlib=/usr",
"--enable-bcmath",
"--with-bz2",
"--enable-calendar",
"--with-curl=/usr",
"--enable-exif",
"--enable-ftp",
"--enable-mbstring",
"--enable-shmop",
"--enable-soap",
"--enable-sockets",
"--enable-sysvmsg",
"--enable-sysvsem",
"--enable-sysvshm",
"--with-xmlrpc",
"--with-xsl",
"--enable-zip",
"--with-iodbc=/usr")
end
if ARGV.include? '--with-fpm'
puts "Building PHP-FPM"
configure_args.push("--with-libevent-dir=#{HOMEBREW_PREFIX}",
"--enable-fpm")
end
system "./configure", *configure_args
# Taken from http://github.com/ampt/homebrew/blob/php/Library/Formula/php.rb
if @@has_apache
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 "mkdir -p #{prefix}/etc"
system "cp ./php.ini-production #{prefix}/etc/php.ini"
if ARGV.include? '--with-fpm'
system "cp ./sapi/fpm/php-fpm.conf #{prefix}/etc/php-fpm.conf"
system "mkdir -p #{prefix}/var/log"
system "touch #{prefix}/var/log/php-fpm.log"
end
if @@has_apache
puts "To enable PHP in Apache add the following to httpd.conf and restart Apache:"
puts " LoadModule php5_module #{prefix}/libexec/apache2/libphp5.so"
end
end
end
__END__
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index 246e1d5..bc90239 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -183,7 +183,7 @@ static PHP_GINIT_FUNCTION(iconv)
/* }}} */
#if defined(HAVE_LIBICONV) && defined(ICONV_ALIASED_LIBICONV)
-#define iconv libiconv
+#define iconv iconv
#endif
/* {{{ typedef enum php_iconv_enc_scheme_t */
diff --git a/ext/mysqli/php_mysqli_structs.h b/ext/mysqli/php_mysqli_structs.h
index 4a7b40c..80b3ed8 100644
--- a/ext/mysqli/php_mysqli_structs.h
+++ b/ext/mysqli/php_mysqli_structs.h
@@ -54,6 +54,7 @@
#define WE_HAD_MBSTATE_T
#endif
+#define HAVE_ULONG 1
#include <my_global.h>
#if !defined(HAVE_MBRLEN) && defined(WE_HAD_MBRLEN)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment