File dba-phpcgi-536.spec of Package dba-phpcgi-536

#
# spec file for package dba-phpcgi-535
#

%define version		5.3.6
%define vers		536
%define apavers		2.2.17
%define apapack		2217
%define suhosin_version 0.9.32.1
%define suhosin_patch_version 0.9.10
%define with_suhosin_patch 0
%define run_tests	0
%define with_dynsess	0
%define with_mime	1
%define with_ming	0
%if 0%{?fedora_version}
%define with_mssql	0
%else
%define with_mssql	1
%endif
%define with_mysql	0
%define with_mysqlnd    1
%define with_pear	0
%define with_qdbm	1
%define with_readline	1
%define with_spell	1
%define with_sqlite	0
%define with_unixodbc	1
%define with_xpm	1
%define pkg_name        php5
%define prefix		/DBA/apache/PHP/%{version}-cgi
%define peardir 	/DBA/apache/PEAR/%{version}
%define apahome         /DBA/apache/WWW/%{apavers}
%define extension_dir   %{prefix}/lib/php/extensions/

Name:           	dba-phpcgi-%{vers}
Summary:        	PHP5 Core Files
License:        	The PHP License, version 3.01
Group:          	Development/Languages/Other
%define realver 	%{version}
Version:        	%{version}
Release:        	1
Source0:		php-%{version}.tar.bz2
Source1:        	dba-php-rpmlintrc
Source3:		copy_files.pl
Patch0:			dba-php-disable-inst.patch
%if %{with_suhosin_patch}
Source2:		suhosin-%{suhosin_version}.tar.gz
Patch1:			suhosin-patch-%{version}-%{suhosin_patch_version}.patch.gz
%endif
Url:            	http://www.php.net/
AutoReqProv:    	on
# Provides:		dba-php-%{vers}
BuildRequires:		dba-apache-%{apapack}

BuildRoot:		%{_tmppath}/%{name}-%{version}-build

%if 0%{?suse_version} >= 1100
BuildRequires:          -post-build-checks
%endif

%define apxs            %{apahome}/bin/apxs


%if 0%{?sles_version} == 9
%define with_readline 0
%endif

%if 0%{?sles_version} == 10
%define with_unixodbc 0
%endif

%if %{with_unixodbc}
BuildRequires:  unixODBC-devel
%endif

# for all dists
BuildRequires:  net-snmp-devel mhash-devel libmcrypt-devel
BuildRequires:  postgresql-devel
#!BuildIgnore:  dba-postgresql-839 dba-postgresql-842

%if 0%{?suse_version}
BuildRequires:  bison curl-devel db-devel gmp-devel libtidy-devel libtiff-devel libxslt-devel mm-devel ncurses-devel openldap2 openldap2-devel pam-devel pkgconfig postfix qt3-devel tcpd-devel zip libapr-util1-devel libapr1-devel imap-devel

%if 0%{?suse_version} < 1130
BuildRequires:	orbit-devel gtk-devel
%else
BuildRequires:  gtk2-devel
%endif

%if 0%{?sles_version} == 9
%define with_mysql 0
%else
BuildRequires:  mysql-devel
%endif

%if 0%{?suse_version} < 930
%define with_spell 0
BuildRequires:  heimdal-devel
%else
BuildRequires:  krb5-devel
%endif

%if 0%{?suse_version} < 1100
BuildRequires: mhash-devel imap
%else
BuildRequires:	libbz2-devel
BuildRequires:	libc-client2007e_suse
Requires:	libc-client2007e_suse
%endif

%if 0%{?suse_version} >= 1000
%if 0%{?sles_version} != 10
BuildRequires:  flex-old
%endif
# I would like this to become a hard dependency, as PHP is
# documented to have this modules by default (no addtional libs are needed)
%else
# BuildRequires:  flex libgcrypt-devel rpm-devel
BuildRequires:  libgcrypt-devel rpm-devel
BuildRequires:  libjpeg libjpeg-devel
%endif

%if 0%{?sles_version} == 9
BuildRequires:  xinetd libxml2-devel >= 2.6.11
%else
# BuildRequires:  libedit-devel update-alternatives
BuildRequires:  update-alternatives
%endif

%else
# CentOS, RHEL
BuildRequires:  bzip2-devel, curl-devel >= 7.9, db4-devel, expat-devel pam-devel gmp-devel libxml2-devel
BuildRequires:  libstdc++-devel, openssl-devel

%if 0%{?with_sqlite}
BuildRequires:  sqlite-devel >= 3.0.0
%endif

# no xmp for rhel-4
%if 0%{?rhel_version} == 406
%define with_xpm 0
BuildRequires:  pcre-devel
%else
BuildRequires:  pcre-devel >= 6.6
BuildRequires:  libXpm libXpm-devel
%endif

BuildRequires:	zlib-devel, postfix, readline-devel, flex
BuildRequires:	bzip2, perl, libtool >= 1.4.3, gcc-c++
BuildRequires:	tcp_wrappers openldap-devel openldap mysql krb5-devel libc-client-devel
BuildRequires:	libacl-devel libattr-devel mysql-devel openssl-devel
BuildRequires:  libjpeg libjpeg-devel libpng-devel freetype-devel
BuildRequires:  libtidy-devel libtiff-devel libxslt-devel
BuildRequires:	apr-util-devel apr-devel
%endif

%if %{with_spell}
BuildRequires:  aspell-devel
%endif

# use system PCRE and sqlite  on 10.2 an up only, previous versions will not work.
%if 0%{?suse_version} > 1010
BuildRequires:  pcre-devel sqlite-devel
%if 0%{?sles_version} != 11
BuildRequires:  sqlite2-devel
%else
BuildRequires:  libsqlite3-0
%endif

%endif

#%if 0%{?suse_version} == 1030
#BuildRequires:  sqlite2-devel
#%endif

%if %{with_mssql}
BuildRequires:  freetds-devel
%endif

#support t1lib in gd in 10.3 or later
%if 0%{?suse_version} > 1020
BuildRequires:  re2c t1lib-devel
#10.3 does not install sendmail binary with the minimal system
Requires:       smtp_daemon
%endif

%if %{with_ming}
BuildRequires:  ming-devel
%endif

#if %{with_qdbm}
#BuildRequires:  qdbm-devel
#endif


%description

This package contains the PHP5 core files, including PHP binary (CLI)
and PHP configuration (php.ini). This package must be installed in
order to use PHP. Additionally, extension modules and server modules
(e.g. for Apache) may be installed.

Authors:
--------
    The PHP Group
    See http://www.php.net/credits.php for more details


%prep
#  
#  O/ ._ .__ ._
#  /O |_)|(/_|_)
#     |      |
#  
%setup -q -n php-%{version}
%if %{with_suhosin_patch}
%if 0%{?sles_version} == 9 || 0%{?rhel_version} == 406
%{__tar} xpzf %{S:2} -C ext
%else
%{__tar} xf %{S:2} -C ext
%endif
%{__mv} ext/suhosin-%{suhosin_version} ext/suhosin
%endif
%patch0

%if %{with_suhosin_patch}
%patch1 -p1
%endif

%build
#
#  O/ |_    o| _|
#  /O |_)|_|||(_|
#
%if 0%{?with_sqlite}
#%if 0%{?suse_version} > 1010
#%{__rm} -rf ext/pcre/pcrelib ext/pdo_sqlite/sqlite
#%{__rm} -rf ext/pdo_sqlite/sqlite
#%endif
%endif

# regenerate configure etc.
# workaround: suhosin-patch updates timestamp of configure, confusing buildconf
%{__rm} configure
./buildconf --force
# export flags
CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -pipe"
CXXFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -pipe"
%if 0%{?suse_version} > 1000
CFLAGS="$CFLAGS -fstack-protector"
CXXFLAGS="$CXXFLAGS -fstack-protector"
%endif
export CFLAGS
export CXXFLAGS
export NO_INTERACTION=true

# where to install extensions
PEAR_HOME=%{peardir}
EXTENSION_DIR=%{extension_dir}
export EXTENSION_DIR

#   --enable-dom=shared
#%if 0%{?suse_version} > 1010
#    --with-pdo_sqlite=shared,%{_usr} \
#%else
#    --with-pdo_sqlite=shared \
#%endif
#%if 0%{?sles_version} != 9
#        --with-libedit=shared,%{_usr}
#%endif
#    --with-apxs2=%{apxs} \
#    --enable-cli \

./configure \
    --prefix=%{prefix} \
    --with-libdir=%{_lib} \
    --enable-force-cgi-redirect \
    --disable-discard-path \
    --enable-cgi \
%if %{with_pear}
    --with-pear=%{peardir} \
%else
    --without-pear \
%endif
    --with-tiff-dir \
    --with-tiff \
    --enable-fileinfo=shared \
    --enable-ereg=shared \
    --enable-bcmath=shared \
    --enable-calendar=shared \
    --enable-ctype=shared \
    --enable-dbase=shared \
    --enable-exif=shared \
    --enable-ftp=shared \
    --enable-mbstring=shared \
    --enable-mbregex \
    --enable-pcntl=shared \
    --enable-posix=shared \
    --enable-shmop=shared \
    --enable-soap=shared \
    --enable-sockets=shared \
    --enable-sysvmsg=shared \
    --enable-sysvsem=shared \
    --enable-sysvshm=shared \
    --enable-tokenizer=shared \
    --enable-wddx=shared \
    --enable-zip=shared \
    --with-zlib=shared \
   --with-bz2=shared \
%if 0%{?sles_version} == 9
    --without-curl \
%else
    --with-curl=shared \
%endif
    --with-gd=shared \
    --enable-gd-native-ttf \
%if %{with_xpm}
    --with-xpm-dir=%{_x11prefix} \
%endif
    --with-freetype-dir=%{_usr} \
    --with-png-dir=%{_usr} \
    --with-jpeg-dir=%{_usr} \
    --with-zlib-dir=%{_usr} \
%if 0%{?suse_version} > 1020
    --with-t1lib=%{_usr} \
%endif
    --with-gettext=shared \
    --with-gmp=shared \
%if %{with_dynsess}
    --enable-hash=shared \
    --enable-session=shared \
%else
    --enable-session \
    --enable-hash \
%endif
    --with-iconv=shared \
    --with-imap=shared \
    --with-kerberos \
    --with-imap-ssl \
    --enable-json=shared \
    --with-ldap=shared \
    --with-ldap-sasl=%{_usr} \
    --with-mcrypt=shared \
    --with-mhash=shared \
%if 0%{?_with_ming:1}
    --with-ming=shared,%{_usr} \
%endif
%if %{with_mssql}
    --with-mssql=shared \
    --with-pdo_dblib=shared \
%endif
%if %{with_mysql}
    --with-mysql=shared,%{_usr} \
    --with-mysql-sock=/var/lib/mysql/mysql.sock \
    --with-mysqli=shared \
%endif
%if %{with_mysqlnd}
    --with-mysql=mysqlnd \
    --with-mysqli=mysqlnd \
    --with-pdo-mysql=shared,mysqlnd \
%endif
    --with-ncurses=shared \
%if %{with_unixodbc}
    --with-unixODBC=shared,%{_usr} \
%endif
    --with-openssl=shared \
    --with-pgsql=shared,%{_usr} \
%if %{with_spell}
    --with-pspell=shared \
%endif
    --with-snmp=shared \
    --with-xmlrpc=shared \
    --enable-xmlreader=shared \
    --enable-xmlwriter=shared \
    --with-xsl=shared \
    --with-tidy=shared,%{_usr} \
    --enable-dba=shared \
    --enable-dom=shared \
    --with-db4=%{_usr} \
    --without-gdbm \
    --with-cdb \
    --with-inifile \
    --with-flatfile \
    --enable-pdo=shared,%{_usr} \
%if 0%{?with_sqlite}
    --with-sqlite=shared,%{_usr} \
    --with-pdo_sqlite=shared,%{_usr} \
%else
    --without-pdo-sqlite \
    --without-sqlite \
%endif
%if %{with_mysql}
    --with-pdo-mysql=shared,%{_usr} \
%endif
    --with-pdo-pgsql=shared,%{_usr} \
%if %{with_unixodbc}
    --with-pdo-odbc=shared,unixODBC,%{_usr} \
%endif

 
make CFLAGS="$RPM_OPT_FLAGS -fPIC \
		-fno-strict-aliasing \
		-Wall " \
		%{?jobs:-j%jobs} 
 
%install
#
#  O/ o._  __|_ _.||
#  /O || |_> |_(_|||
#  
#
# (most installation (to build root) has already been done in %%build)
#
mkdir -p %{buildroot}%{prefix}/bin
mkdir -p %{buildroot}%{prefix}/man/man1
mkdir -p %{buildroot}%{prefix}/libexec
mkdir -p %{buildroot}%{prefix}/include/php
mkdir -p %{buildroot}%{extension_dir}
mkdir -p %{buildroot}%{prefix}/lib/php/build
# make DESTDIR=$RPM_BUILD_ROOT install
# make DESTDIR=$RPM_BUILD_ROOT install-cli
# make DESTDIR=$RPM_BUILD_ROOT install-headers

# %{__mv} -f %{buildroot}%{apahome}/modules/libphp5.so %{buildroot}%{prefix}/libexec
%{__install} -m 0755 ./sapi/cli/php %{buildroot}%{prefix}/bin
%{__install} -m 0755 ./sapi/cgi/php-cgi %{buildroot}%{prefix}/bin
%{__install} -m 0755 scripts/php-config %{buildroot}%{prefix}/bin
%{__install} -m 0755 scripts/phpize %{buildroot}%{prefix}/bin
# %{__install} -m 0755 ext/phar/phar.phar %{buildroot}%{prefix}/bin
%{__install} -m 0644 ./sapi/cli/php.1 %{buildroot}%{prefix}/man/man1
%{__install} -m 0644 ./scripts/man1/*.1 %{buildroot}%{prefix}/man/man1
#%{__install} -m 0755 ./libs/libphp5.so %{buildroot}%{prefix}/libexec/libphp5.so
%{__install} -m 0755 ./modules/*.so %{buildroot}%{extension_dir}
# %{__install} -m 0644 ext/*/*.h %{buildroot}%{prefix}/include/php
%{__install} -m 0644 Makefile.global acinclude.m4 config.guess config.sub %{buildroot}%{prefix}/lib/php/build/
%{__install} -m 0644 build/libtool.m4 build/mkdep.awk scripts/phpize.m4 run-tests.php build/scan_makefile_in.awk %{buildroot}%{prefix}/lib/php/build
%{__install} -m 0755 ltmain.sh build/shtool %{buildroot}%{prefix}/lib/php/build

find ext/ -name "*.h" | perl %{S:3} %{buildroot}%{prefix}/include/php
find main/ -name "*.h" | perl %{S:3} %{buildroot}%{prefix}/include/php
find sapi/ -name "*.h" | perl %{S:3} %{buildroot}%{prefix}/include/php
find TSRM/ -name "*.h" | perl %{S:3} %{buildroot}%{prefix}/include/php
find Zend/ -name "*.h" | perl %{S:3} %{buildroot}%{prefix}/include/php
find %{buildroot}%{prefix}/include/ -name "*.h" -exec chmod 644 {} \;

# install phar
if [ -e %{buildroot}%{prefix}/bin/phar ]; then
  %{__rm} -fv %{buildroot}%{prefix}/bin/phar
fi
# cd %{buildroot}%{prefix}/bin
# %{__ln_s} phar.phar phar

# remove buildroot from prefix
# %{__perl} -pi -e 's|%{buildroot}||g;' %{buildroot}%{prefix}/bin/phpize
# %{__perl} -pi -e 's|%{buildroot}||g;' %{buildroot}%{prefix}/bin/php-config


%files
#       _
#  O/ _|_o| _  _
#  /O  | ||(/__>
#  
%defattr(-,root,root)
%dir %{prefix} 
%{prefix}/bin
%{prefix}/include
%{prefix}/lib
%{prefix}/libexec
%{prefix}/man
%if %{with_pear}
%dir %{peardir}
%endif


%clean
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}


%changelog
* Fri Apr  8 2011 Holger Manthey <holger.manthey@bertelsmann.de>
- initial build without suhosin
openSUSE Build Service is sponsored by