File dba-php-5428.spec of Package dba-php-5428

#
# spec file for package dba-php-5428
#

%define version		5.4.28
%define vers		5428
%define apavers         2.2.25
%define apapack         2225
%define suhosin_version 0.9.32.1
%define suhosin_patch_version 0.9.10
%define with_suhosin_patch 0
%define run_tests	0
%define autoconf213 	0
%define with_dbaxml	1
%define with_dynsess	0
%define with_imap	1
%define with_intl	1
%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	1
%define with_pear	0
%define with_pg9	0
%define with_qdbm	1
%define with_readline	1
%define with_sasl	1
%if 0%{?rhel_version} == 406
%define with_snmp       0
%else
%define with_snmp       1
%endif
%define with_spell	1
%define with_sqlite	1
%define with_t1lib	0
%define with_unixodbc	1
%define with_xpm	1
%define prefix		/DBA/apache/PHP/%{version}
%define peardir 	/DBA/apache/PEAR/%{version}
%define apahome         /DBA/apache/WWW/%{apavers}
%define extension_dir   %{prefix}/lib/php/extensions/

Name:           	dba-php-%{vers}
Summary:        	PHP scripting language Version 5.4.28
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
Source4:                filter-requires-php.sh
%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
BuildRoot:		%{_tmppath}/%{name}-%{version}-build

BuildRequires:		dba-apache-%{apapack}

%define _use_internal_dependency_generator 0
%define __find_requires %{SOURCE4}

%if 0%{?suse_version} >= 1200
BuildRequires:  automake libtool
%endif

%if 0%{?suse_version} >= 1100
BuildRequires:          -post-build-checks
%define autoconf213 	1
%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 0%{?suse_version} >= 1200
%define with_mssql 0
%endif

%if 0%{?sles_version} == 10 || 0%{?rhel_version} == 406 || 0%{?rhel_version} == 600
%define with_intl	0
%endif

%if 0%{?rhel_version} == 406
%define with_sqlite 0
%endif

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

%if 0%{?rhel_version} >= 600
%define with_imap 0
%endif

%if %{with_imap}
%if 0%{?suse_version}
BuildRequires:  imap-devel
%if 0%{?suse_version} >= 1200
BuildRequires:  libc-client2007e_suse
%endif
%else
BuildRequires:  libc-client-devel
%endif
%endif

%if %{with_intl}
BuildRequires:  libicu-devel
%endif

%if %{autoconf213}
BuildRequires:  autoconf213
%endif

%if %{with_dbaxml}
BuildRequires:  dba-libxml2-291-static
# # !BuildIgnore:  libxml2-devel
BuildRequires:  libxml2-devel
%define xmlpath /DBA/libxml2/2.9.1
%else
BuildRequires:  libxml2-devel
%endif

# for all dists
BuildRequires:  net-snmp-devel mhash-devel libmcrypt-devel

%if %{with_pg9}
BuildRequires:  dba-postgresql-914
%define pg_home /DBA/postgresql/9.1.4
%else
%define pg_home %{_usr}
BuildRequires:  postgresql-devel
%endif

#!BuildIgnore:  dba-openssl-098o dba-openssl-098r dba-openssl-098x dba-openssl-101c
#!BuildIgnore:  dba-libxml2-290 dba-net-snmp-572


%if 0%{?suse_version}
BuildRequires:  bison curl-devel db-devel gmp-devel imap-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
%if 0%{?suse_version} >= 1120
BuildRequires:  orbit2-devel gtk2-devel
%else
BuildRequires:  orbit-devel gtk-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
%if 0%{?sles_version} == 11
# Requires:	imap-lib-2006c1_suse
%else
%if 0%{?suse_version} <= 1120
BuildRequires: imap-lib
# Requires:	imap-lib
%endif
%endif
%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
%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
BuildRequires:  libstdc++-devel, openssl-devel

%if 0%{?with_sqlite}
BuildRequires:  sqlite-devel
%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
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
%if 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
%define with_spell 0
BuildRequires:	apr-util-ldap
%else
BuildRequires:	libc-client-devel
%endif

%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 %{with_sqlite}
%if 0%{?suse_version} >= 1010
BuildRequires:  sqlite-devel
%if 0%{?sles_version} != 11
BuildRequires:  sqlite2-devel
%else
BuildRequires:  libsqlite3-0
%endif
%endif

%endif

%if 0%{?suse_version} >= 1010
BuildRequires:  pcre-devel
%endif

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

%if 0%{?suse_version} > 1020
BuildRequires:  re2c
%endif

%if 0%{?suse_version} >= 1300
%define with_sasl 0
%endif

%if 0%{?suse_version} > 1020 && 0%{?suse_version} < 1300
%define with_t1lib 1
%endif

%if %{with_t1lib}
BuildRequires:  t1lib-devel
%endif

%if %{with_ming}
BuildRequires:  ming-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


%if %{with_mssql}
%package mssql
Summary:        Mssql extension for php
Group:          Productivity/Networking/Ftp/Servers
Requires:       %{name} = %{version}
Requires:	freetds

%description mssql
Mssql extension for php based on freetds

%endif


%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

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

%{__chmod} +x %{SOURCE4}

%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

%if %{autoconf213}
export PHP_AUTOCONF=`which autoconf-2.13`
export PHP_AUTOHEADER=`which autoheader-2.13`
%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

./configure \
    --prefix=%{prefix} \
    --with-apxs2=%{apxs} \
    --with-libdir=%{_lib} \
    --enable-cli \
%if %{with_pear}
    --with-pear=%{peardir} \
%else
    --without-pear \
%endif
    --enable-cgi \
    --enable-fastcgi \
    --enable-fileinfo \
    --enable-bcmath \
    --enable-calendar=shared \
    --enable-ctype \
    --enable-exif=shared \
    --enable-ftp=shared \
    --enable-mbstring \
    --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 \
%if %{with_intl}
    --enable-intl=shared \
%endif
    --with-zlib \
   --with-bz2=shared \
%if 0%{?sles_version} == 9
    --without-curl \
%else
    --with-curl \
%endif
    --with-gd \
    --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 %{with_t1lib}
    --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 \
    --with-kerberos \
%if %{with_imap}
    --with-imap=shared \
    --with-imap-ssl \
%else
    --without-imap \
%endif
    --enable-json=shared \
    --with-ldap=shared \
%if %{with_sasl}
    --with-ldap-sasl=%{_usr} \
%endif
    --with-mcrypt \
    --with-mhash \
%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_unixodbc}
    --with-unixODBC=shared,%{_usr} \
%endif
    --with-openssl=shared \
    --with-pgsql=shared,%{pg_home} \
    --with-pdo-pgsql=shared,%{pg_home} \
%if %{with_spell}
    --with-pspell=shared \
%endif
%if %{with_snmp}
    --with-snmp=shared \
%else
    --without-snmp \
%endif
%if %{with_dbaxml}
    --with-libxml-dir=%{xmlpath} \
%endif
    --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 \
    --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
%if %{with_unixodbc}
    --with-pdo-odbc=shared,unixODBC,%{_usr} \
%endif

# Bug in ARP 
%if 0%{?sles_version} == 10
perl -pi -e 's|apr-1 64/include|apr-1|g' *
perl -pi -e 's|apr-1 /include|apr-1|g' *
%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)
#
# prevent rpath problem on suse
export NO_BRP_CHECK_RPATH=true

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

# 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


%post
cd %{prefix}/..
%{__ln_s} -f %{version} 5.4.latest

%if %{with_mssql}
%files mssql
%defattr(-,root,root)
%{prefix}/lib/php/extensions/*mssql*.so
%{prefix}/lib/php/extensions/*pdo_dblib*.so
%endif


%files
#       _
#  O/ _|_o| _  _
#  /O  | ||(/__>
#  
%defattr(-,root,root)
%dir %{prefix} 
%{prefix}/bin
%{prefix}/include
%{prefix}/lib
%if %{with_mssql}
%exclude %{prefix}/lib/php/extensions/*mssql*.so
%exclude %{prefix}/lib/php/extensions/*pdo_dblib*.so
%endif
%{prefix}/libexec
%{prefix}/man
%if %{with_pear}
%dir %{peardir}
%endif


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


%changelog
* Wed May  7 2014 Holger Manthey <holger.manthey@bertelsmann.de>
- inital version