File php5-phalcon.spec of Package php5-phalcon

#
# spec file for package php5-phalcon
#
# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# See also http://en.opensuse.org/openSUSE:Shared_library_packaging_policy

%define _php    php5
%define _name   phalcon

Name:           %{_php}-%{_name}
Version:        2.0.13
Release:        0
Summary:        PHP5 Extension Module
License:        BSD-3-Clause
Group:          Development/Libraries/PHP
Url:            http://phalconphp.com/

Source0:        https://github.com/phalcon/cphalcon/archive/phalcon-v%{version}.tar.gz
Source1:        https://github.com/phalcon/zephir/archive/master.tar.gz#/zephir-master.tar.gz
BuildRoot:      %_tmppath/%name-%version-build
BuildRequires:  gcc
BuildRequires:  re2c
BuildRequires:  %{_php}-devel
BuildRequires:  %{_php}-json
BuildRequires:  %{_php}-ctype
BuildRequires:  %{_php}-pdo

Requires:       %{_php}-pear
Requires:       %{_php}-mysql

%description
Phalcon is an open source, full stack framework for PHP 5 
written as a C-extension, optimized for high performance. 
You don't need learn or use the C language, since the functionality 
is exposed as PHP classes ready for you to use. Zephir is a high level 
language, something between C and PHP. It’s both dynamic and static 
typed and it supports just the features we need to create and maintain 
a project like Phalcon.

%prep
%setup -n cphalcon-phalcon-v%version -a 1

%build
export CC="gcc"
export CFLAGS="%optflags -g3 -O1 -std=gnu90 -DZEPHIR_RELEASE=1"

# Build zephir parser
cd zephir-master/parser/parser
sh build_linux.sh php5
cd ..
phpize
%configure --enable-zephir_parser
make %{?_smp_mflags}
make install INSTALL_ROOT=%{_builddir}

# Build extension
cd ../..
php -d memory_limit=512M -d extension=%{_builddir}%{_libdir}/%{_php}/extensions/zephir_parser.so zephir-master/compiler.php generate --parser-compiled=yes
pushd ext
phpize
%configure --enable-%{_name}
make %{?_smp_mflags}

%install
%{__mkdir_p} %{buildroot}%{_libdir}/%{_php}/extensions
%{__mkdir_p} %{buildroot}%{_sysconfdir}/%{_php}/conf.d
pushd ext
make install INSTALL_ROOT=%{buildroot}

echo "; comment out next line to disable %{_name} extension in php" > %{buildroot}/%{_sysconfdir}/%{_php}/conf.d/%{_name}.ini
echo "extension=%{_name}.so" >> %{buildroot}/%{_sysconfdir}/%{_php}/conf.d/%{_name}.ini

%files
%defattr(-,root,root)
%doc CHANGELOG.md CONTRIBUTING.md README.md docs/LICENSE.md
%{_libdir}/%{_php}/extensions/%{_name}.so
%config(noreplace) %{_sysconfdir}/%{_php}/conf.d/%{_name}.ini

%changelog
openSUSE Build Service is sponsored by