+# NOTES:
+# - hphp/runtime/base/runtime-option.cpp evalJitDefault enables jit if /.hhvm-jit exists (yes, in filesystem root)
# TODO
# - system libevent2: https://github.com/facebook/hiphop-php/pull/421
-# - build with newer libmemcached than 1.0.7, https://github.com/facebook/hiphop-php/issues/560
# - system libmbfl, system xhp, sqlite3
-# - there should be a bit more packaged into files
-# - linking segfaults
-# using bfd and gcc-6:4.6.2-2.x86_64 binutils-3:2.22.51.0.1-1.x86_64
-# cd /home/users/glen/rpm/packages/BUILD.x86_64-linux/hiphop-php-1.000_cf9b612/src/hphpi && /home/users/glen/rpm/BUILD.x86_64-linux/hiphop-php-1.000_cf9b612/build/src/hphp/hphp -t cpp -f exe --input-dir . -i hphpi.php -o gen -vEnableEval=2 --log=1
-# Segmentation fault
-# make[2]: *** [src/hphp/hphp] Error 139
-# relinking succeeds, but resulting binary segfaults as well:
-# 0x0000000000b9cc0b in HPHP::Extension::LoadModules(HPHP::Hdf) ()
+%define githash 78394ee
+%define rel 3
Summary: Virtual Machine, Runtime, and JIT for PHP
Name: hiphop-php
Version: 2.1.0
-Release: 0.1
+Release: 0.%{githash}.%{rel}
License: PHP 3.01
Group: Development/Languages
-Source0: https://github.com/facebook/hiphop-php/archive/HPHP-%{version}.tar.gz
-# Source0-md5: edd3d8b4371d38286c7c5f0c2582f5e1
+Source0: https://github.com/facebook/hiphop-php/archive/%{githash}/HPHP-%{version}.%{githash}.tar.gz
+# Source0-md5: 81742a0535a6bab906208d3756b206d1
# need fb.changes.patch, which is available for 1.4 only
Source1: http://www.monkey.org/~provos/libevent-1.4.14b-stable.tar.gz
# Source1-md5: a00e037e4d3f9e4fe9893e8a2d27918c
Patch4: system-libafdt.patch
Patch5: system-folly.patch
Patch6: boost-system-category.patch
-Patch7: gcc4.8.patch
URL: http://wiki.github.com/facebook/hiphop-php/
BuildRequires: binutils-devel
BuildRequires: bison >= 2.3
BuildRequires: elfutils-devel
BuildRequires: expat-devel
BuildRequires: flex >= 2.5.35
+BuildRequires: gcc >= 6:4.6.0
BuildRequires: gd-devel
BuildRequires: glog-devel >= 0.3.2
BuildRequires: imap-devel >= 1:2007
BuildRequires: libicu-devel >= 4.2
#BuildRequires: libmbfl-devel
BuildRequires: libmcrypt-devel
-BuildRequires: libmemcached-devel < 1.0.8
BuildRequires: libmemcached-devel >= 1.0.4
BuildRequires: libstdc++-devel >= 6:4.3
BuildRequires: libunwind-devel
#BuildRequires: php-xhp-devel >= 1.3.9-6
BuildRequires: re2c >= 0.13.0
BuildRequires: readline-devel
-BuildRequires: rpmbuild(macros) >= 1.600
+BuildRequires: rpmbuild(macros) >= 1.675
BuildRequires: tbb-devel >= 4.0.6000
BuildRequires: zlib-devel
+Provides: php(apc)
+Provides: php(bcmath)
+Provides: php(ctype)
+Provides: php(curl)
+Provides: php(date)
+Provides: php(dom)
+Provides: php(exif)
+Provides: php(fb)
+Provides: php(filter)
+Provides: php(gd)
+Provides: php(hash)
+Provides: php(hotprofiler)
+Provides: php(iconv)
+Provides: php(icu_ucsdet)
+Provides: php(icu_uspoof)
+Provides: php(idn)
+Provides: php(imap)
+Provides: php(json)
+Provides: php(ldap)
+Provides: php(mbstring)
+Provides: php(mcrypt)
+Provides: php(memcache)
+Provides: php(memcached)
+Provides: php(mysql)
+Provides: php(openssl)
+Provides: php(pcntl)
+Provides: php(pcre)
+Provides: php(pdo)
+Provides: php(pdo_mysql)
+Provides: php(pdo_sqlite)
+Provides: php(phar)
+Provides: php(posix)
+Provides: php(reflection)
+Provides: php(server)
+Provides: php(session)
+Provides: php(simplexml)
+Provides: php(soap)
+Provides: php(sockets)
+Provides: php(spl)
+Provides: php(sqlite3)
+Provides: php(sysvmsg)
+Provides: php(sysvsem)
+Provides: php(sysvshm)
+Provides: php(thread)
+Provides: php(thrift_protocol)
+Provides: php(tokenizer)
+Provides: php(xhprof)
+Provides: php(xml)
+Provides: php(xmlreader)
+Provides: php(xmlwriter)
+Provides: php(zlib)
+ExclusiveArch: %{x8664}
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
Apache and mod_php.
%prep
-%setup -q -n %{name}-HPHP-%{version} -a1
-%patch5 -p1
+%setup -qc -a1
+mv %{name}-%{githash}*/* .
+
+#%patch5 -p1
%patch6 -p1
-%patch7 -p1
ln -s libevent-1.4.*-stable libevent
%{__patch} -d libevent -p1 < hphp/third_party/libevent-1.4.14.fb-changes.diff
export HPHP_HOME=$(pwd)
export HPHP_LIB=$HPHP_HOME/bin
+# asm linking breaks on $CC containing spaces
+if [[ "%{__cc}" = *ccache* ]]; then
+ cat <<-'EOF' > $HPHP_LIB/gcc
+ #!/bin/sh
+ exec %{__cc} "$@"
+ EOF
+ chmod +x $HPHP_LIB/gcc
+ CC=$HPHP_LIB/gcc
+fi
+
%if 0
export LIBEVENT_PREFIX=$HPHP_HOME/libevent
cd build
%endif
-CPPFLAGS="%{rpmcppflags} -fno-permissive"
%cmake \
-DLIBEVENT_LIB=$HPHP_HOME/libevent/lib/libevent.so \
-DLIBEVENT_INCLUDE_DIR=$HPHP_HOME/libevent \
-DUSE_JEMALLOC=OFF \
-DUSE_TCMALLOC=OFF \
./
+
+# setup COMPILER_ID/HHVM_REPO_SCHEMA so it doesn't look it up from our package git repo
+# see hphp/util/generate-buildinfo.sh
+sha=$(echo %{name}-%{githash}*)
+export COMPILER_ID=HPHP-%{version}-%{release}-${sha#%{name}-}
+export HHVM_REPO_SCHEMA=$(date +%N_%s)
+
%{__make}
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT%{_bindir}
-install -p build/src/hphp/hphp $RPM_BUILD_ROOT%{_bindir}
+%{__make} install \
+ HPHP_HOME=$(pwd) \
+ DESTDIR=$RPM_BUILD_ROOT
+
+install -d $RPM_BUILD_ROOT%{_datadir}/%{name}/hdf
+cp -p hphp/doc/mime.hdf $RPM_BUILD_ROOT%{_datadir}/%{name}/hdf/static.mime-types.hdf
+
+# install our libevent for now
+install -d $RPM_BUILD_ROOT%{_libdir}
+libtool --mode=install install -p libevent/libevent.la $RPM_BUILD_ROOT%{_libdir}
+%{__rm} $RPM_BUILD_ROOT%{_libdir}/libevent.{a,la,so}
%clean
rm -rf $RPM_BUILD_ROOT
+%post -p /sbin/ldconfig
+%postun -p /sbin/ldconfig
+
%files
%defattr(644,root,root,755)
-%attr(755,root,root) %{_bindir}/hphp
+%doc README.md hphp/NEWS
+%attr(755,root,root) %{_bindir}/hhvm
+%attr(755,root,root) %{_libdir}/libevent-1.4.so.*.*.*
+%ghost %{_libdir}/libevent-1.4.so.2
+
+%dir %{_datadir}/%{name}
+%dir %{_datadir}/%{name}/hdf
+%{_datadir}/%{name}/hdf/static.mime-types.hdf