# NOTES:
# - hphp/runtime/base/runtime-option.cpp evalJitDefault enables jit if /.hhvm-jit exists (yes, in filesystem root)
+# - patch /usr/lib/hphp/CMake/HPHPIZEFunctions.cmake for %{_libdir}/hhvm as extension dir
# TODO
# - system libmbfl, system xhp, sqlite3
-# git show HHVM-3.0.1
-%define githash c2284b1fc46454432969bfe1b1c205713f7a69e8
-%define folly d9c79af
+# git show HHVM-3.3.1
+%define githash e0c98e21167b425dddf1fc9efe78c9f7a36db268
+# these hashes are git submodules
+%define folly 6e46d46
+%define thirdparty fdef620
Summary: Virtual Machine, Runtime, and JIT for PHP
Name: hhvm
-Version: 3.0.1
-Release: 1
-License: PHP 3.01
+Version: 3.3.1
+Release: 0.1
+License: PHP 3.01 and BSD
Group: Development/Languages
Source0: https://github.com/facebook/hhvm/archive/HHVM-%{version}.tar.gz
-# Source0-md5: 55cbeb7fdb365972e3cb72ba59558453
-# need fb.changes.patch, which is available for 1.4 only
-Source2: https://github.com/facebook/folly/archive/%{folly}/folly-0.1-%{folly}.tar.gz
-# Source2-md5: e14ff4b87c986dbe095547bdf0761dd1
-Source3: %{name}-fcgi.init
-Source4: %{name}-fcgi.sysconfig
+# Source0-md5: bab9490837ff4f54f295bbcf428d7a1c
+Source2: https://github.com/facebook/folly/archive/%{folly}/folly-3.2-%{folly}.tar.gz
+# Source2-md5: c4bdbea4c0ffe0650d12d9ff370b8255
+Source3: https://github.com/hhvm/hhvm-third-party/archive/%{thirdparty}/third_party-%{thirdparty}.tar.gz
+# Source3-md5: 63858096c50c172d6c45ddb3d9b6d721
+Source5: %{name}-fcgi.init
+Source6: %{name}-fcgi.sysconfig
+Source7: php.ini
Source100: get-source.sh
-Patch0: cmake-missing-library.patch
-Patch3: system-xhp.patch
-Patch4: system-libafdt.patch
-Patch5: system-folly.patch
-Patch8: hphpize.patch
-Patch9: notest.patch
-Patch10: no-debug.patch
+Patch1: no-debug.patch
+Patch2: hphpize.patch
URL: https://github.com/facebook/hhvm/wiki
BuildRequires: ImageMagick-devel
BuildRequires: a52dec-libs-devel
BuildRequires: apr-devel
BuildRequires: autoconf
BuildRequires: binutils-devel
+# CMake/HPHPFindLibs.cmake:364 - FIND_LIBRARY (BFD_LIB libbfd.a)
+BuildRequires: binutils-static
BuildRequires: boost-devel >= 1.50
-BuildRequires: cmake >= 2.8.7
+BuildRequires: cmake >= 2.8.5
BuildRequires: curl-devel >= 7.29.0
BuildRequires: elfutils-devel
BuildRequires: expat-devel
#BuildRequires: libmbfl-devel
BuildRequires: libmcrypt-devel
BuildRequires: libmemcached-devel >= 1.0.4
-BuildRequires: libstdc++-devel >= 6:4.3
+BuildRequires: libstdc++-devel >= 6:4.8
BuildRequires: libunwind-devel
BuildRequires: libxml2-devel
BuildRequires: libxslt-devel
#BuildRequires: libafdt-devel >= 0.1.0
#BuildRequires: re2c >= 0.13.0
# foreach (get_loaded_extensions() as $ext) printf("Provides:\tphp(%s)\n", strtolower($ext));
+Provides: %{name}(api) = %{hhvm_api_version}
Provides: php(apache)
Provides: php(apc)
Provides: php(bcmath)
Provides: php(bz2)
+Provides: php(calendar)
+Provides: php(core) = %{php_version}
Provides: php(ctype)
Provides: php(curl)
Provides: php(date)
Provides: php(fb)
Provides: php(fileinfo)
Provides: php(filter)
-Provides: php(function)
+Provides: php(ftp)
Provides: php(gd)
+Provides: php(gettext)
Provides: php(hash)
Provides: php(hh)
Provides: php(hhvm.debugger)
Provides: php(misc)
Provides: php(mysql)
Provides: php(mysqli)
+Provides: php(oauth)
Provides: php(openssl)
Provides: php(pcntl)
Provides: php(pcre)
+Provides: php(pcre_zend_compat)
Provides: php(pdo)
Provides: php(pdo_mysql)
Provides: php(pdo_sqlite)
Provides: php(sockets)
Provides: php(spl)
Provides: php(sqlite3)
+Provides: php(standard)
+Provides: php(standard_zend_compat)
Provides: php(stream)
Provides: php(sysvmsg)
Provides: php(sysvsem)
Provides: php(thrift_protocol)
Provides: php(tokenizer)
Provides: php(url)
+Provides: php(wddx)
+Provides: php(xenon)
Provides: php(xhprof)
Provides: php(xml)
Provides: php(xmlreader)
Provides: php(xmlwriter)
Provides: php(xsl)
+Provides: php(yaml)
Provides: php(zip)
Provides: php(zlib)
Obsoletes: hiphop-php < 2.3.2-0.2
ExclusiveArch: %{x8664}
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+# must be in sync with source. extra check ensuring that it is so is done in %%build
+%define hhvm_api_version 20140829
+# hphp/system/idl/constants.idl.json defines it as 5.6.99-hhvm, but use some saner value
+%define php_version 5.6.0
+
+%define hhvm_extensiondir %{_libdir}/hhvm
+
%description
HHVM (aka the HipHop Virtual Machine) is a new open-source virtual
machine designed for executing programs written in PHP. HHVM uses a
C++.
%prep
-%setup -q -a2 -n %{name}-HHVM-%{version}
+%setup -q -n %{name}-HHVM-%{version} -a2 -a3
-mv folly-*/* hphp/submodules/folly
+# handle git submodules
+rmdir third-party
+mv hhvm-third-party-* third-party
+rmdir third-party/folly/src
+mv folly-* third-party/folly/src
-%patch8 -p1
-%patch9 -p1
-%patch10 -p1
-#%patch5 -p1
+%patch1 -p1
+%patch2 -p1
# prefer ones from system
rm CMake/FindBISON.cmake
rm CMake/FindFLEX.cmake
rm CMake/FindFreetype.cmake
-%if 0
-%patch0 -p1
-%patch1 -p1
-#%patch3 -p1
-%patch4 -p1
-
-#rm -rf src/third_party/libmbfl
-#sed -i -e '/add_subdirectory(third_party\/libmbfl)/d' src/CMakeLists.txt
+%build
+# also in: hphp/tools/hphpize/hphpize.cmake
+API=$(awk '/#define HHVM_API_VERSION/{v=$3; sub(/L$/, "", v); print v}' hphp/runtime/ext/extension.h)
-rm -rf src/third_party/xhp
-rm -rf src/third_party/libafdt
-%endif
+if [ $API != %{hhvm_api_version} ]; then
+ echo "Set %%define hhvm_api_version to $API and re-run."
+ exit 1
+fi
-%build
-export HPHP_HOME=$(pwd)
-export HPHP_LIB=$HPHP_HOME/bin
-install -d $HPHP_LIB
+# out of dir build broken (can't find it's tools, or headers)
+#install -d build
+#cd build
-# asm linking breaks on $CC containing spaces
+# handle cmake & ccache
+# http://stackoverflow.com/questions/1815688/how-to-use-ccache-with-cmakec
+# ASM fix: http://lists.busybox.net/pipermail/buildroot/2013-March/069436.html
if [[ "%{__cc}" = *ccache* ]]; then
- cat <<-'EOF' > $HPHP_LIB/gcc
- #!/bin/sh
- exec %{__cc} "$@"
- EOF
- chmod +x $HPHP_LIB/gcc
- CC=$HPHP_LIB/gcc
+ cc="%{__cc}"
+ cxx="%{__cxx}"
+ ccache="
+ -DCMAKE_C_COMPILER="ccache" -DCMAKE_C_COMPILER_ARG1="${cc#ccache }" \
+ -DCMAKE_CXX_COMPILER="ccache" -DCMAKE_CXX_COMPILER_ARG1="${cxx#ccache }" \
+ -DCMAKE_ASM_COMPILER="${cc#ccache }" \
+ "
fi
-%if 0
-# out of dir build broken (can't find it's tools)
-install -d build
-cd build
-%endif
-
%cmake \
+ $ccache \
-DCMAKE_PREFIX_PATH=%{_prefix} \
+ -DHHVM_DYNAMIC_EXTENSION_DIR=%{hhvm_extensiondir} \
-DUSE_JEMALLOC=OFF \
-DUSE_TCMALLOC=OFF \
-DHPHP_NOTEST=ON \
- ./
+ -DENABLE_COTIRE=ON \
+ .
# setup COMPILER_ID/HHVM_REPO_SCHEMA so it doesn't look it up from our package git repo
# see hphp/util/generate-buildinfo.sh
-export COMPILER_ID=HHVM-%{version}-%{release}-%{githash}
+export COMPILER_ID=HHVM-%{version}-%{release}-g%{githash}
export HHVM_REPO_SCHEMA=$(date +%N_%s)
%{__make}
%install
-rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT%{_sysconfdir}/%{name}
-%{__make} install \
- HPHP_HOME=$(pwd) \
- DESTDIR=$RPM_BUILD_ROOT
+# make install relinks all outputs which is very slow,
+# so to speedup rebuild, use timestamps to record states
+#test %{_specdir}/%{name}.spec -nt makeinstall.stamp && %{__rm} -f makeinstall.stamp
+if [ ! -f makeinstall.stamp -o ! -d $RPM_BUILD_ROOT ]; then
+ rm -rf makeinstall.stamp installed.stamp $RPM_BUILD_ROOT
+
+ %{__make} install -C build \
+ HPHP_HOME__=$(pwd) \
+ DESTDIR=$RPM_BUILD_ROOT
+
+ touch makeinstall.stamp
+fi
+
+rm -rf $RPM_BUILD_ROOT%{_docdir}
+if [ ! -f installed.stamp ]; then
+# begin install block
-# not packaged here
-rm $RPM_BUILD_ROOT%{_includedir}/zip.h
-rm $RPM_BUILD_ROOT%{_includedir}/zipconf.h
-rm $RPM_BUILD_ROOT%{_prefix}/lib/libzip.a
-rm $RPM_BUILD_ROOT%{_prefix}/lib/libzip.so
+install -d $RPM_BUILD_ROOT{%{_sysconfdir}/%{name},%{_libdir}/%{name}}
+cp -p %{SOURCE7} $RPM_BUILD_ROOT%{_sysconfdir}/%{name}
ln -s hhvm $RPM_BUILD_ROOT%{_bindir}/php
ln -s hhvm $RPM_BUILD_ROOT%{_bindir}/hphp
# install fastcgi initscript
install -d $RPM_BUILD_ROOT/etc/{sysconfig,rc.d/init.d}
-cp -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}-fcgi
-cp -p %{SOURCE4} $RPM_BUILD_ROOT/etc/sysconfig/%{name}-fcgi
+cp -p %{SOURCE5} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}-fcgi
+cp -p %{SOURCE6} $RPM_BUILD_ROOT/etc/sysconfig/%{name}-fcgi
+install -p hphp/hack/bin/hh_{server,client} $RPM_BUILD_ROOT%{_bindir}
+
+%if 0
# setup -devel
install -d $RPM_BUILD_ROOT%{_datadir}/cmake/Modules
cp -p CMake/*.cmake $RPM_BUILD_ROOT%{_datadir}/cmake/Modules
done
done
set -x
+%endif
+
+# end of install block
+touch installed.stamp; fi
%clean
rm -rf $RPM_BUILD_ROOT
%defattr(644,root,root,755)
%doc README.md hphp/NEWS
%dir %{_sysconfdir}/%{name}
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{name}/php.ini
%attr(755,root,root) %{_bindir}/hhvm
%attr(755,root,root) %{_bindir}/hphp
+%attr(755,root,root) %{_bindir}/hh_client
+%attr(755,root,root) %{_bindir}/hh_server
%dir %{_datadir}/%{name}
%dir %{_datadir}/%{name}/hdf
%{_datadir}/%{name}/hdf/static.mime-types.hdf
+# dir for extensions
+%dir %{_libdir}/%{name}
+
%files fcgi
%defattr(644,root,root,755)
%attr(754,root,root) /etc/rc.d/init.d/%{name}-fcgi
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/hphpize
%{_includedir}/hphp
-%{_datadir}/cmake/Modules/ExtZendCompat.cmake
-%{_datadir}/cmake/Modules/FindCClient.cmake
-%{_datadir}/cmake/Modules/FindEditline.cmake
-%{_datadir}/cmake/Modules/FindGlog.cmake
-%{_datadir}/cmake/Modules/FindICU.cmake
-%{_datadir}/cmake/Modules/FindLdap.cmake
-%{_datadir}/cmake/Modules/FindLibAfdt.cmake
-%{_datadir}/cmake/Modules/FindLibCh.cmake
-%{_datadir}/cmake/Modules/FindLibDL.cmake
-%{_datadir}/cmake/Modules/FindLibDwarf.cmake
-%{_datadir}/cmake/Modules/FindLibElf.cmake
-%{_datadir}/cmake/Modules/FindLibEvent.cmake
-%{_datadir}/cmake/Modules/FindLibJpeg.cmake
-%{_datadir}/cmake/Modules/FindLibMagickWand.cmake
-%{_datadir}/cmake/Modules/FindLibNuma.cmake
-%{_datadir}/cmake/Modules/FindLibPng.cmake
-%{_datadir}/cmake/Modules/FindLibUODBC.cmake
-%{_datadir}/cmake/Modules/FindLibXed.cmake
-%{_datadir}/cmake/Modules/FindLibYaml.cmake
-%{_datadir}/cmake/Modules/FindLibiconv.cmake
-%{_datadir}/cmake/Modules/FindLibinotify.cmake
-%{_datadir}/cmake/Modules/FindLibmemcached.cmake
-%{_datadir}/cmake/Modules/FindLibpam.cmake
-%{_datadir}/cmake/Modules/FindMcrypt.cmake
-%{_datadir}/cmake/Modules/FindMySQL.cmake
-%{_datadir}/cmake/Modules/FindNcurses.cmake
-%{_datadir}/cmake/Modules/FindOCaml.cmake
-%{_datadir}/cmake/Modules/FindONIGURUMA.cmake
-%{_datadir}/cmake/Modules/FindPCRE.cmake
-%{_datadir}/cmake/Modules/FindPThread.cmake
-%{_datadir}/cmake/Modules/FindReadline.cmake
-%{_datadir}/cmake/Modules/FindTBB.cmake
-%{_datadir}/cmake/Modules/FollySetup.cmake
-%{_datadir}/cmake/Modules/HPHPCompiler.cmake
-%{_datadir}/cmake/Modules/HPHPFindLibs.cmake
-%{_datadir}/cmake/Modules/HPHPFunctions.cmake
-%{_datadir}/cmake/Modules/HPHPSetup.cmake
-%{_datadir}/cmake/Modules/Options.cmake
-%{_datadir}/cmake/Modules/hphpize.cmake
+%dir %{_prefix}/lib/hphp
+%{_prefix}/lib/hphp/CMake
+%{_prefix}/lib/hphp/hphpize