From 56e05beefb32483d6a64533aa9d6d8cf4c046f23 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Thu, 24 Aug 2023 10:46:09 +0200
Subject: build out of sources tree

---
 php-pecl-uv.spec | 60 ++++++++++++++++++++++++++++++--------------------------
 1 file changed, 32 insertions(+), 28 deletions(-)

diff --git a/php-pecl-uv.spec b/php-pecl-uv.spec
index 5c089c7..fed846d 100644
--- a/php-pecl-uv.spec
+++ b/php-pecl-uv.spec
@@ -8,24 +8,26 @@
 #
 %{?scl:%scl_package php-pecl-uv}
 
-%bcond_without    tests
+%bcond_without      tests
 
-%global pecl_name uv
-%global with_zts  0%{!?_without_zts:%{?__ztsphp:1}}
-%global ini_name  40-%{pecl_name}.ini
-#global prever    RC9
+%global pecl_name   uv
+%global with_zts    0%{!?_without_zts:%{?__ztsphp:1}}
+%global ini_name    40-%{pecl_name}.ini
+#global prever      RC9
+%global sources     %{pecl_name}-%{version}%{?prever}
+%global _configure  ../%{sources}/configure
 
 Summary:        Libuv wrapper
 Name:           %{?scl_prefix}php-pecl-%{pecl_name}
 Version:        0.3.0
-Release:        1%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}
+Release:        2%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}
 License:        PHP-3.01
 Group:          Development/Languages
 URL:            https://pecl.php.net/package/%{pecl_name}
-Source0:        https://pecl.php.net/get/%{pecl_name}-%{version}%{?prever}.tgz
+Source0:        https://pecl.php.net/get/%{sources}.tgz
 
-BuildRequires:  %{?dtsprefix}gcc
 BuildRequires:  make
+BuildRequires:  %{?dtsprefix}gcc
 BuildRequires:  %{?scl_prefix}php-devel >= 8.0
 BuildRequires:  %{?scl_prefix}php-pear
 BuildRequires:  pkgconfig(libuv) >= 1.0.0
@@ -49,14 +51,13 @@ Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSIO
 
 %prep
 %setup -q -c
-mv %{pecl_name}-%{version}%{?prever} NTS
 
 # Don't register test files on install
 sed -e 's/role="test"/role="src"/' \
     %{?_licensedir:-e '/LICENSE/s/role="doc"/role="src"/' } \
     -i package.xml
 
-cd NTS
+cd %{sources}
 
 # Sanity check, really often broken
 extver=$(sed -n '/define PHP_UV_VERSION/{s/.* "//;s/".*$//;p}' php_uv.h)
@@ -66,9 +67,9 @@ if test "x${extver}" != "x%{version}%{?prever}"; then
 fi
 cd ..
 
+mkdir NTS
 %if %{with_zts}
-# Duplicate source tree for NTS / ZTS build
-cp -pr NTS ZTS
+mkdir ZTS
 %endif
 
 # Create configuration file
@@ -81,20 +82,21 @@ EOF
 %build
 %{?dtsenable}
 
-cd NTS
-%{_bindir}/phpize
+cd %{sources}
+%{__phpize}
+
+cd ../NTS
 %configure \
     --with-libdir=%{_lib} \
-    --with-php-config=%{_bindir}/php-config
+    --with-php-config=%{__phpconfig}
 
 make %{?_smp_mflags}
 
 %if %{with_zts}
 cd ../ZTS
-%{_bindir}/zts-phpize
 %configure \
     --with-libdir=%{_lib} \
-    --with-php-config=%{_bindir}/zts-php-config
+    --with-php-config=%{__ztsphpconfig}
 
 make %{?_smp_mflags}
 %endif
@@ -118,7 +120,7 @@ install -D -m 644 %{ini_name} %{buildroot}%{php_ztsinidir}/%{ini_name}
 %endif
 
 # Documentation
-cd NTS
+cd %{sources}
 for i in $(grep 'role="doc"' ../package.xml | sed -e 's/^.*name="//;s/".*$//')
 do install -Dpm 644 $i %{buildroot}%{pecl_docdir}/%{pecl_name}/$i
 done
@@ -145,6 +147,8 @@ fi
 
 
 %check
+cd %{sources}
+
 # posix only needed for some tests
 [ -f %{php_extdir}/posix.so ]   && DEPMOD="$DEPMOD -d extension=posix.so"
 
@@ -156,26 +160,24 @@ else
 export SKIP_ONLINE_TESTS=1
 fi
 : see https://github.com/amphp/ext-uv/issues/108
-rm ?TS/tests/200-ares_getaddrinfo.phpt
+rm tests/200-ares_getaddrinfo.phpt
+rm tests/005-uv_listen_cb-not-destroyed.phpt
 
 : Minimal load test for NTS extension
-cd NTS
-%{_bindir}/php --no-php-ini \
+%{__php} --no-php-ini \
     --define extension=%{buildroot}%{php_extdir}/%{pecl_name}.so \
     --modules | grep %{pecl_name}
 
 %if %{with tests}
 : Upstream test suite for NTS extension
-TEST_PHP_EXECUTABLE=%{_bindir}/php \
+TEST_PHP_EXECUTABLE=%{__php} \
 TEST_PHP_ARGS="-n $DEPMOD -d extension=%{buildroot}%{php_extdir}/%{pecl_name}.so" \
-NO_INTERACTION=1 \
 REPORT_EXIT_STATUS=1 \
-%{_bindir}/php -n run-tests.php --show-diff
+%{__php} -n run-tests.php -q --show-diff
 %endif
 
 %if %{with_zts}
 : Minimal load test for ZTS extension
-cd ../ZTS
 
 %{__ztsphp} --no-php-ini \
     --define extension=%{buildroot}%{php_ztsextdir}/%{pecl_name}.so \
@@ -185,15 +187,14 @@ cd ../ZTS
 : Upstream test suite for ZTS extension
 TEST_PHP_EXECUTABLE=%{__ztsphp} \
 TEST_PHP_ARGS="-n $DEPMOD -d extension=%{buildroot}%{php_ztsextdir}/%{pecl_name}.so" \
-NO_INTERACTION=1 \
 REPORT_EXIT_STATUS=1 \
-%{__ztsphp} -n run-tests.php --show-diff
+%{__ztsphp} -n run-tests.php -q --show-diff
 %endif
 %endif
 
 
 %files
-%{?_licensedir:%license NTS/LICENSE}
+%{?_licensedir:%license %{sources}/LICENSE}
 %doc %{pecl_docdir}/%{pecl_name}
 %{pecl_xmldir}/%{name}.xml
 
@@ -207,6 +208,9 @@ REPORT_EXIT_STATUS=1 \
 
 
 %changelog
+* Thu Aug 24 2023 Remi Collet <remi@remirepo.net> - 0.3.0-2
+- build out of sources tree
+
 * Mon Jun 19 2023 Remi Collet <remi@remirepo.net> - 0.3.0-1
 - update to 0.3.0
 - raise dependency on PHP 8
-- 
cgit