File dba-apa24-php-5622-zend.spec of Package dba-apa24-php-5622-zend

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

%define version		5.6.22
%define vers		5622
%define apavers		2.4.20
%define apapack		2420
%define dbassl		1
%define run_tests	0
%define autoconf213 	0
%define dba_mcrypt	1
%define with_dbaxml	1
%define with_debug	0
%define with_dynsess	0
%define with_intl	0
%define with_imap	1
%define with_mime	1
%define with_ming	0
%define with_mssql	1
%define with_mysql	1
%define with_pear	0
%define with_pg		1
%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_tidy	1
%define with_unixodbc	1
%define with_xpm	1
%define prefix		/DBA/apache24/PHP/%{version}-zend
%define peardir 	/DBA/apache24/PEAR/%{version}-zend
%define apahome         /DBA/apache24/WWW/%{apavers}
%define extension_dir   %{prefix}/lib/php/extensions/

Name:           	dba-apa24-php-%{vers}-zend
Summary:        	PHP scripting language Version 5.6.22 build with Apache 2.4.x for Zend Engine
License:        	The PHP License, version 3.01
Group:          	Development/Languages/Other
%define realver 	%{version}
Version:        	%{version}
Release:        	4
Source0:		php-%{version}.tar.bz2
Source1:        	dba-php-rpmlintrc
Source3:		copy_files.pl
Source4:		filter-requires-php.sh
Source6:		set_php_5.6.latest.sh
Url:            	http://www.php.net/
AutoReqProv:    	on
# Provides:		dba-php-%{vers}
BuildRequires:		dba-apache-%{apapack}

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

%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%{?sles_version} == 11 || 0%{?centos_version} >= 600
%define with_intl	1
%endif

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

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

%if 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 700
%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-292-static
BuildRequires:  libxml2-devel
%define xmlpath /DBA/libxml2/2.9.2
%else
BuildRequires:  libxml2-devel
%endif

%if %{dbassl}
BuildRequires:  dba-openssl-102h-static
%define ssldir /DBA/openssl/1.0.2h
%if 0%{?rhel_version} >= 700 || 0%{?centos_version} >= 700 || 0%{?fedora_version} >= 20
BuildRequires:  openssl-devel
%else
#!BuildIgnore:  openssl-devel
%endif
%else
BuildRequires:  openssl-devel
%endif

# for all dists

BuildRequires:  net-snmp-devel mhash-devel
%if %{dba_mcrypt}
BuildRequires:  dba-libmcrypt-258-static
%define mcryptpath /DBA/libmcrypt/2.5.8
%else
BuildRequires:  libmcrypt-devel
%endif

%if %{with_pg9}
BuildRequires:  dba-postgresql-9115
%define pg_home /DBA/postgresql/9.1.15
%else
%if %{with_pg}
%define pg_home %{_usr}
BuildRequires:  postgresql-devel
%endif
%endif

#!BuildIgnore:  dba-postgresql-839 dba-postgresql-8319 dba-postgresql-842 dba-postgresql-845 dba-postgresql-846 dba-postgresql-8412
#!BuildIgnore:  dba-postgresql-901 dba-postgresql-902 dba-postgresql-904 dba-postgresql-905 dba-postgresql-906 dba-postgresql-908
#!BuildIgnore:  dba-postgresql-909 dba-postgresql-9011
#!BuildIgnore:  dba-postgresql-910 dba-postgresql-911 dba-postgresql-912 dba-postgresql-914 dba-postgresql-915
#!BuildIgnore:  dba-postgresql-920
#!BuildIgnore:  dba-openssl-098o dba-openssl-098r dba-openssl-098x dba-openssl-101c dba-openssl-101e
#!BuildIgnore:  dba-libxml2-290 dba-net-snmp-572


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

%if 0%{?suse_version} >= 1120
BuildRequires:  orbit2-devel gtk2-devel
%else
BuildRequires:  orbit-devel gtk-devel
%endif

%if 0%{?suse_version} == 1315
%define with_tidy 0
%define with_xpm 0
%else
BuildRequires:  mm-devel qt3-devel libtidy-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

%if 0%{?rhel_version} >= 700 || 0%{?centos_version} >= 700
BuildRequires:  libdb
%define with_tidy 0
%else
BuildRequires:  db4-devel libtidy-devel
%endif

BuildRequires:  bzip2-devel, curl-devel >= 7.9, expat-devel pam-devel gmp-devel
BuildRequires:  libstdc++-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
BuildRequires:  libjpeg libjpeg-devel libpng-devel freetype-devel
BuildRequires:  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
%if 0%{?rhel_version} == 406 || 0%{?rhel_version} == 505 || 0%{?centos_version} == 505
BuildRequires:  libc-client-devel
%endif
%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 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:	dba-freetds-091112-static
%define tdsdir  /DBA/freetds/0.91.112
%endif

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

#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


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

%description mssql
Mssql extension for php based on freetds

%endif


%prep
#  
#  O/ ._ .__ ._
#  /O |_)|(/_|_)
#     |      |
#  
%setup -q -n php-%{version}

%{__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
%if %{dbassl}
CFLAGS="$CFLAGS -I%{ssldir}/include"
LDFLAGS="$LDFLAGS -L%{ssldir}/lib"
%endif
%if %{dba_mcrypt}
CFLAGS="$CFLAGS -I%{mcryptpath}/include"
LDFLAGS="$LDFLAGS -L%{mcryptpath}/lib"
export PHP_MCRYPT=%{mcryptpath}
%endif
export CFLAGS
export CXXFLAGS
export LDFLAGS
export NO_INTERACTION=true

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

./configure \
    --prefix=%{prefix} \
    --with-apxs2=%{apxs} \
    --with-libdir=%{_lib} \
    --enable-cli \
%if %{with_pear}
    --with-pear=%{peardir} \
%else
    --without-pear \
%endif
%if %{with_debug}
    --enable-debug \
    --disable-zts \
    --disable-maintainer-zts \
%endif
    --enable-cgi \
    --enable-phpdbg \
    --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 \
%else
    --without-icu \
%endif
    --with-zlib \
   --with-bz2=shared \
%if 0%{?sles_version} == 9 || 0%{?rhel_version} == 406
    --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
%if %{dba_mcrypt}
    --with-mcrypt=%{mcryptpath} \
%else
    --with-mcrypt \
%endif
    --with-mhash \
%if 0%{?_with_ming:1}
    --with-ming=shared,%{_usr} \
%endif
%if %{with_mssql}
    --with-mssql=shared,%{tdsdir} \
    --with-pdo_dblib=shared,%{tdsdir} \
%else
    --without-mssql \
%endif
%if %{with_mysql}
    --with-mysql=shared,%{_usr} \
    --with-mysql-sock=/var/lib/mysql/mysql.sock \
    --with-mysqli=shared \
%else
    --without-mysql \
%endif
%if %{with_unixodbc}
    --with-unixODBC=shared,%{_usr} \
%endif
%if %{dbassl}
    --with-openssl-dir=%{ssldir} \
%endif
    --with-openssl=shared \
%if %{with_pg}
    --with-pgsql=shared,%{pg_home} \
    --with-pdo-pgsql=shared,%{pg_home} \
%else
    --without-pgsql \
%endif
%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 \
%if 0%{?with_tidy}
    --with-tidy=shared,%{_usr} \
%endif
    --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 \
%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 ./sapi/phpdbg/phpdbg %{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

# script for latest link
%{__install} -m 0755 %{SOURCE6} %{buildroot}%{prefix}/bin/set_php_5.6.latest.sh


%post
cd %{prefix}/..
%{prefix}/bin/set_php_5.6.latest.sh


%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
* Tue Jul 19 2016 Holger Manthey <holger.manthey@bertelsmann.de>
- build without debug
* Wed Jul  6 2016 Holger Manthey <holger.manthey@bertelsmann.de>
- build with disable-maintainer-zts
* Mon Jul  4 2016 Holger Manthey <holger.manthey@bertelsmann.de>
- add option disable-zts
* Mon Jun 27 2016 Holger Manthey <holger.manthey@bertelsmann.de>
- inital version