#
# Makefile for php-apache2 Slackware package
# Copyright (c) 2004 by Robert Stan <robalo@linuxpackages.net>
#

PROGNAME	= php
VERSION		= 5.0.0
ARCH		= i486
BUILD		= 1rob

SOURCE		= http://ro2.php.net/get/php-$(VERSION).tar.bz2/from/this/mirror

DOCS		= CODING_STANDARDS CREDITS EXTENSIONS INSTALL LICENSE NEWS READM* TOD*

CUSTNAME	= php-apache2
PKGNAME		= $(CUSTNAME)-$(VERSION)-$(ARCH)-$(BUILD)

MAINTAINER	= Robert Stan <robalo@linuxpackages.net>

CFLAGS		= "-O2 -pipe -march=$(ARCH) -mcpu=i686"
CXXFLAGS	= $(CFLAGS)
STRIPLIB	= y
STRIPBIN	= y

TMP		= /var/tmp
PKG		= $(TMP)/package-$(PROGNAME)-$(VERSION)

PHPOPTIONS	= --prefix=/usr \
		  --enable-discard-path \
		  --with-config-file-path=/etc/apache2 \
		  --enable-safe-mode \
		  --with-openssl \
		  --with-zlib=/usr \
		  --enable-bcmath \
		  --with-bz2 \
		  --with-pic \
		  --enable-calendar \
		  --enable-ctype \
		  --with-curl=shared \
		  --enable-dba=shared \
		  --with-gdbm \
		  --with-db3 \
		  --with-inifile \
		  --with-flatfile \
		  --enable-dbase=shared \
		  --enable-dio \
		  --enable-filepro \
		  --enable-ftp \
		  --with-gd=/usr \
		  --enable-gd-native-ttf \
		  --with-jpeg-dir=/usr \
		  --with-png-dir=/usr \
		  --with-freetype-dir=/usr \
		  --without-t1lib \
		  --with-gettext=shared,/usr \
		  --with-gmp=shared \
		  --with-imap=shared \
		  --with-imap-ssl \
		  --with-ldap=shared,/usr \
		  --with-mbstring \
		  --with-mcrypt=shared,/usr \
		  --with-mime-magic \
		  --with-mysql=shared,/usr \
		  --without-mysqli \
		  --with-unixODBC=shared,/usr \
		  --with-pgsql=shared,/usr \
		  --with-pspell=shared,/usr \
		  --enable-shmop \
		  --enable-soap \
		  --enable-sockets \
		  --with-regex=php \
		  --enable-sysvmsg \
		  --enable-sysvsem \
		  --enable-sysvshm \
		  --enable-wddx \
		  --enable-xml \
		  --with-libxml-dir=/usr \
		  --with-xsl=/usr \
		  --enable-yp \
		  --with-pear \
		  --enable-inline-optimization \
		  --enable-memory-limit \
		  --enable-zend-multibyte \
		  --with-tsrm-pthreads \
		  --enable-shared \
		  --disable-static \
		  --disable-debug

conf: prep
	mv odbcpgsqlthings.tar.gz odbcpgsqlthings.tgz; \
	installpkg odbcpgsqlthings.tgz; \
	mv odbcpgsqlthings.tgz odbcpgsqlthings.tar.gz; \
	cd $(PROGNAME)-$(VERSION); \
	patch -p1 < ../php.ini.diff; \
	chown -R root.root .; \
	find . -perm 777 -exec chmod 755 {} \;; \
	find . -perm 775 -exec chmod 755 {} \;; \
	find . -perm 666 -exec chmod 644 {} \;; \
	find . -perm 664 -exec chmod 644 {} \;; \
	find . -name "*.h" -exec chmod 644 {} \;; \
	EXTENSION_DIR=/usr/lib/php/extensions \
	CFLAGS=$(CFLAGS) CXXFLAGS=$(CXXFLAGS) \
	    ./configure $(PHPOPTIONS) --with-apxs2=/usr/sbin/apxs

build: conf
	make -j12 -C $(PROGNAME)-$(VERSION)

package: build
	mkdir -p $(PKG)/usr/doc/$(PROGNAME)-$(VERSION)
	cd $(PROGNAME)-$(VERSION); \
	cp -a $(DOCS) $(PKG)/usr/doc/$(PROGNAME)-$(VERSION); \
	chown -R root.root /usr/doc/$(PROGNAME)-$(VERSION); \
	make install INSTALL_ROOT=$(PKG) INSTALL_IT="echo "
	
	mkdir -p $(PKG)/etc/apache2 $(PKG)/var/www/icons $(PKG)/usr/lib/apache2
	cd $(PROGNAME)-$(VERSION); \
	cp -a php.ini-dist php.ini-recommended $(PKG)/etc/apache2; \
	install -m 644 *.gif $(PKG)/var/www/icons; \
	install -m 755 libs/libphp5.so $(PKG)/usr/lib/apache2
	
	cp -a mod_php.conf.example $(PKG)/etc/apache2
	chmod 644 $(PKG)/etc/apache2/*
	chown root.root $(PKG)/etc/apache2/*
	
	cd $(PROGNAME)-$(VERSION); make distclean
	
	cd $(PROGNAME)-$(VERSION); \
	EXTENSION_DIR=/usr/lib/php/extensions \
	CFLAGS=$(CFLAGS) CXXFLAGS=$(CXXFLAGS) \
	./configure $(PHPOPTIONS) --enable-force-cgi-redirect --enable-fastcgi \
	    --with-ncurses --with-readline
	CFLAGS=$(CFLAGS) CXXFLAGS=$(CXXFLAGS) make -j10 -C $(PROGNAME)-$(VERSION)
	
	cd $(PROGNAME)-$(VERSION); \
	cat sapi/cgi/php > $(PKG)/usr/bin/php; \
	chmod 755 $(PKG)/usr/bin/php; \
	chown root.bin $(PKG)/usr/bin/php
	
	removepkg odbcpgsqlthings
	
	STRIPLIB=$(STRIPLIB) STRIPBIN=$(STRIPBIN) ../../preparepkg $(PKG)
	cat slack-desc > ../$(PKGNAME).txt
	cat slack-desc > $(PKG)/install/slack-desc
	cat doinst.sh >> $(PKG)/install/doinst.sh
	cat slack-required > $(PKG)/install/slack-required
	cd $(PKG) ; makepkg -l y -c n $(PKGNAME).tgz
	mv $(PKG)/$(PKGNAME).tgz ..

include ../../Makefile.global
