]> git.pld-linux.org Git - packages/hhvm.git/blob - hhvm.spec
cmake /usr/usr/ workaround
[packages/hhvm.git] / hhvm.spec
1 #
2 # Conditional build:
3 %bcond_without  system_dconv    # system double-conversion
4 %bcond_without  system_sqlite   # system sqlite3
5 %bcond_without  system_lz4              # system lz4
6 %bcond_without  system_fastlz   # system fastlz
7 %bcond_without  system_libafdt  # system libafdt
8 %bcond_without  system_libzip   # system libzip
9 # cotire breaks sqlite3 on builders: https://github.com/facebook/hhvm/issues/4524
10 %bcond_with     cotire                  # cotire (compile time reducer): Speed up the build by precompiling headers
11
12 # TODO
13 # - system xhp
14 # - system proxygen
15 # - system thrift
16
17 # NOTES:
18 # - hphp/runtime/base/runtime-option.cpp evalJitDefault enables jit if /.hhvm-jit exists (yes, in filesystem root)
19
20 # must be in sync with source. extra check ensuring that it is so is done in %%build
21 %define         hhvm_api_version        20140829
22 # hphp/system/idl/constants.idl.json defines it as 5.6.99-hhvm, but use some saner value
23 %define         php_version                     5.6.0
24
25 # git show HHVM-3.3.2
26 %define         githash 9046034b8d82b06e9feb75b72e2b0106a2707c2c
27 # these hashes are git submodules (be sure to check them on proper branch)
28 %define         thirdparty      fdef620
29 %define         folly           6e46d46
30 Summary:        Virtual Machine, Runtime, and JIT for PHP
31 Name:           hhvm
32 # we prefer LTS versions
33 # see http://hhvm.com/blog/6083/hhvm-long-term-support
34 Version:        3.3.2
35 Release:        1
36 License:        PHP 3.01 and BSD
37 Group:          Development/Languages
38 Source0:        https://github.com/facebook/hhvm/archive/HHVM-%{version}.tar.gz
39 # Source0-md5:  f515560490ece6cbad5d433502c14943
40 Source2:        https://github.com/facebook/folly/archive/%{folly}/folly-3.2-%{folly}.tar.gz
41 # Source2-md5:  c4bdbea4c0ffe0650d12d9ff370b8255
42 Source3:        https://github.com/hhvm/hhvm-third-party/archive/%{thirdparty}/third_party-%{thirdparty}.tar.gz
43 # Source3-md5:  63858096c50c172d6c45ddb3d9b6d721
44 Source5:        %{name}-fcgi.init
45 Source6:        %{name}-fcgi.sysconfig
46 Source7:        php.ini
47 Source100:      get-source.sh
48 Patch1:         no-debug.patch
49 Patch2:         hphpize.patch
50 Patch3:         MAX.patch
51 Patch4:         system-thirdparty.patch
52 Patch5:         cmake.patch
53 URL:            https://github.com/facebook/hhvm/wiki
54 BuildRequires:  ImageMagick-devel
55 BuildRequires:  a52dec-libs-devel
56 BuildRequires:  apr-devel
57 BuildRequires:  autoconf
58 BuildRequires:  binutils-devel
59 # CMake/HPHPFindLibs.cmake:364 - FIND_LIBRARY (BFD_LIB libbfd.a)
60 BuildRequires:  binutils-static
61 BuildRequires:  boost-devel >= 1.50
62 BuildRequires:  cmake >= 2.8.5
63 BuildRequires:  curl-devel >= 7.29.0
64 %{?with_system_dconv:BuildRequires:     double-conversion-devel >= 1.1.1}
65 BuildRequires:  elfutils-devel
66 BuildRequires:  expat-devel
67 %{?with_system_fastlz:BuildRequires:    fastlz-devel >= 0.1.0-0.r12}
68 BuildRequires:  gcc >= 6:4.6.0
69 BuildRequires:  gd-devel
70 BuildRequires:  glog-devel >= 0.3.2
71 BuildRequires:  imap-devel >= 1:2007
72 #BuildRequires: jemalloc-devel >= 3.0.0
73 %{?with_system_libafdt:BuildRequires:   libafdt-devel >= 0.1.0}
74 %{?with_system_libzip:BuildRequires:    libzip-devel >= 0.11.2}
75 BuildRequires:  libcap-devel
76 BuildRequires:  libdwarf-devel >= 20130729
77 BuildRequires:  libicu-devel >= 4.2
78 #BuildRequires: libmbfl-devel
79 BuildRequires:  libmcrypt-devel
80 BuildRequires:  libmemcached-devel >= 1.0.4
81 BuildRequires:  libstdc++-devel >= 6:4.8
82 BuildRequires:  libunwind-devel
83 BuildRequires:  libxml2-devel
84 BuildRequires:  libxslt-devel
85 %{?with_system_lz4:BuildRequires:       lz4-devel >= 0.0-1.r119}
86 BuildRequires:  mysql-devel
87 BuildRequires:  ocaml-findlib
88 BuildRequires:  oniguruma-devel
89 BuildRequires:  openssl-devel
90 BuildRequires:  pcre-devel >= 8.32
91 #BuildRequires: php-xhp-devel >= 1.3.9-6
92 BuildRequires:  readline-devel
93 BuildRequires:  rpmbuild(macros) >= 1.675
94 %{?with_system_sqlite:BuildRequires:    sqlite3-devel >= 3.7.15.2}
95 BuildRequires:  tbb-devel >= 4.0.6000
96 BuildRequires:  zlib-devel
97 # check later, seem unused
98 #BuildRequires: bison >= 2.3
99 #BuildRequires: flex >= 2.5.35
100 #BuildRequires: libafdt-devel >= 0.1.0
101 #BuildRequires: re2c >= 0.13.0
102 Provides:       %{name}(api) = %{hhvm_api_version}
103 Provides:       php(core) = %{php_version}
104 # foreach (get_loaded_extensions() as $ext) printf("Provides:\tphp(%s)\n", strtolower($ext));
105 Provides:       php(apc)
106 Provides:       php(bcmath)
107 Provides:       php(bz2)
108 Provides:       php(calendar)
109 Provides:       php(ctype)
110 Provides:       php(curl)
111 Provides:       php(date)
112 Provides:       php(debugger)
113 Provides:       php(dom)
114 Provides:       php(enum)
115 Provides:       php(exif)
116 Provides:       php(fb)
117 Provides:       php(fileinfo)
118 Provides:       php(filter)
119 Provides:       php(ftp)
120 Provides:       php(gd)
121 Provides:       php(gettext)
122 Provides:       php(gmp)
123 Provides:       php(hash)
124 Provides:       php(hh)
125 Provides:       php(hhvm.debugger)
126 Provides:       php(hhvm.ini)
127 Provides:       php(hotprofiler)
128 Provides:       php(iconv)
129 Provides:       php(idn)
130 Provides:       php(imagick)
131 Provides:       php(imap)
132 Provides:       php(intl)
133 Provides:       php(json)
134 Provides:       php(ldap)
135 Provides:       php(libxml)
136 Provides:       php(mail)
137 Provides:       php(mailparse)
138 Provides:       php(mbstring)
139 Provides:       php(mcrypt)
140 Provides:       php(memcache)
141 Provides:       php(memcached)
142 Provides:       php(mysql)
143 Provides:       php(mysqli)
144 Provides:       php(oauth)
145 Provides:       php(openssl)
146 Provides:       php(pcntl)
147 Provides:       php(pcre)
148 Provides:       php(pcre_zend_compat)
149 Provides:       php(pdo)
150 Provides:       php(pdo_mysql)
151 Provides:       php(pdo_sqlite)
152 Provides:       php(phar)
153 Provides:       php(posix)
154 Provides:       php(redis)
155 Provides:       php(reflection)
156 Provides:       php(server)
157 Provides:       php(session)
158 Provides:       php(simplexml)
159 Provides:       php(soap)
160 Provides:       php(sockets)
161 Provides:       php(spl)
162 Provides:       php(sqlite3)
163 Provides:       php(standard)
164 Provides:       php(standard_zend_compat)
165 Provides:       php(stream)
166 Provides:       php(sysvmsg)
167 Provides:       php(sysvsem)
168 Provides:       php(sysvshm)
169 Provides:       php(thread)
170 Provides:       php(thrift_protocol)
171 Provides:       php(tokenizer)
172 Provides:       php(url)
173 Provides:       php(wddx)
174 Provides:       php(xenon)
175 Provides:       php(xhprof)
176 Provides:       php(xml)
177 Provides:       php(xmlreader)
178 Provides:       php(xmlwriter)
179 Provides:       php(xsl)
180 Provides:       php(yaml)
181 Provides:       php(zip)
182 Provides:       php(zlib)
183 Obsoletes:      hiphop-php < 2.3.2-0.2
184 ExclusiveArch:  %{x8664}
185 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
186
187
188 %define         hhvm_extensiondir       %{_libdir}/hhvm
189
190 %description
191 HHVM (aka the HipHop Virtual Machine) is a new open-source virtual
192 machine designed for executing programs written in PHP. HHVM uses a
193 just-in-time compilation approach to achieve superior performance
194 while maintaining the flexibility that PHP developers are accustomed
195 to. To date, HHVM (and its predecessor HPHPc before it) has realized
196 over a 9x increase in web request throughput and over a 5x reduction
197 in memory consumption for Facebook compared with the Zend PHP 5.2
198 engine + APC.
199
200 HHVM can be run as a standalone webserver (i.e. without the Apache
201 webserver and the "mod_php" extension). HHVM can also be used together
202 with a FastCGI-based webserver, and work is in progress to make HHVM
203 work smoothly with Apache.
204
205 %package fcgi
206 Summary:        Init script to start HHVM as FastCGI daemon
207 Group:          Development/Languages/PHP
208 Requires:       %{name} = %{version}-%{release}
209 Provides:       php(fcgi)
210 Requires(post,preun):   /sbin/chkconfig
211 Requires:       rc-scripts
212
213 %description fcgi
214 Init script to start HHVM as FastCGI daemon
215
216 %package program
217 Summary:        /usr/bin/php symlink
218 Summary(pl.UTF-8):      Dowiązanie symboliczne /usr/bin/php
219 Group:          Development/Languages/PHP
220 Requires:       %{name} = %{version}-%{release}
221 Obsoletes:      /usr/bin/php
222
223 %description program
224 Package providing /usr/bin/php symlink to PHP CLI.
225
226 %description program -l pl.UTF-8
227 Pakiet dostarczający dowiązanie symboliczne /usr/bin/php do PHP CLI.
228
229 %package devel
230 Summary:        Files for HHVM modules development
231 Group:          Development/Languages/PHP
232 URL:            https://github.com/facebook/hhvm/wiki/Extension-API
233 Requires:       boost-devel >= 1.50
234 Requires:       cmake >= 2.8.5
235 Requires:       glog-devel >= 0.3.2
236 Requires:       libstdc++-devel >= 6:4.3
237 Requires:       tbb-devel >= 4.0.6000
238 Requires:       zlib-devel
239
240 %description devel
241 HHVM provides a set of APIs for adding built-in functionality to the
242 runtime either by way of pure PHP code, or a combination of PHP and
243 C++.
244
245 %prep
246 %setup -q -n %{name}-HHVM-%{version} -a2 -a3
247
248 # handle git submodules
249 rmdir third-party
250 mv hhvm-third-party-* third-party
251 rmdir third-party/folly/src
252 mv folly-* third-party/folly/src
253
254 %patch1 -p1
255 %patch2 -p1
256 %patch3 -p1
257 %patch4 -p1
258 %patch5 -p1
259
260 # prefer ones from system
261 rm CMake/FindBISON.cmake
262 rm CMake/FindFLEX.cmake
263 rm CMake/FindFreetype.cmake
264
265 # ensure system libs get used
266 # NOTE: keep sqlite dir, build breaks with 3.8.5.0
267
268 cd third-party
269 rm -r pcre \
270         %{?with_system_lz4:lz4} \
271         %{?with_system_dconv:double-conversion} \
272         %{?with_system_fastlz:fastlz} \
273         %{?with_system_libafdt:libafdt} \
274         %{?with_system_libzip:libzip} \
275         %{nil}
276
277 %build
278 # also in: hphp/tools/hphpize/hphpize.cmake
279 API=$(awk '/#define HHVM_API_VERSION/{v=$3; sub(/L$/, "", v); print v}' hphp/runtime/ext/extension.h)
280
281 if [ $API != %{hhvm_api_version} ]; then
282         echo "Set %%define hhvm_api_version to $API and re-run."
283         exit 1
284 fi
285
286 # out of dir build broken (can't find it's tools, or headers)
287 #install -d build
288 #cd build
289
290 # handle cmake & ccache
291 # http://stackoverflow.com/questions/1815688/how-to-use-ccache-with-cmake
292 # ASM fix: http://lists.busybox.net/pipermail/buildroot/2013-March/069436.html
293 if [[ "%{__cc}" = *ccache* ]]; then
294         cc="%{__cc}"
295         cxx="%{__cxx}"
296         ccache="
297         -DCMAKE_C_COMPILER="ccache" -DCMAKE_C_COMPILER_ARG1="${cc#ccache }" \
298         -DCMAKE_CXX_COMPILER="ccache" -DCMAKE_CXX_COMPILER_ARG1="${cxx#ccache }" \
299         -DCMAKE_ASM_COMPILER="${cc#ccache }" \
300         "
301 fi
302
303 %cmake \
304         $ccache \
305         -DCMAKE_PREFIX_PATH=%{_prefix} \
306         -DHHVM_DYNAMIC_EXTENSION_DIR=%{hhvm_extensiondir} \
307         -DUSE_JEMALLOC=OFF \
308         -DUSE_TCMALLOC=OFF \
309         -DHPHP_NOTEST=ON \
310         -DSYSTEM_PCRE=ON \
311         %{?with_system_sqlite:-DSYSTEM_SQLITE3=ON} \
312         %{?with_system_lz4:-DSYSTEM_LZ4=ON} \
313         %{?with_system_dconv:-DSYSTEM_DOUBLE_CONVERSION=ON} \
314         %{?with_system_fastlz:-DSYSTEM_FASTLZ=ON} \
315         %{?with_system_libafdt:-DSYSTEM_LIBAFDT=ON} \
316         %{?with_system_libzip:-DSYSTEM_LIBZIP=ON} \
317         -DENABLE_COTIRE=%{!?with_cotire:OFF}%{?with_cotire:ON} \
318         .
319
320 # setup COMPILER_ID/HHVM_REPO_SCHEMA so it doesn't look it up from our package git repo
321 # see hphp/util/generate-buildinfo.sh
322 export COMPILER_ID=HHVM-%{version}-%{release}-g%{githash}
323 export HHVM_REPO_SCHEMA=$(date +%N_%s)
324
325 %{__make}
326
327 %install
328 # make install relinks all outputs which is very slow,
329 # so to speedup rebuild, use timestamps to record states
330 #test %{_specdir}/%{name}.spec -nt makeinstall.stamp && %{__rm} -f makeinstall.stamp
331 if [ ! -f makeinstall.stamp -o ! -d $RPM_BUILD_ROOT ]; then
332         rm -rf makeinstall.stamp installed.stamp $RPM_BUILD_ROOT
333
334         %{__make} install \
335                 DESTDIR=$RPM_BUILD_ROOT
336
337         touch makeinstall.stamp
338 fi
339
340 rm -rf $RPM_BUILD_ROOT%{_docdir}
341 if [ ! -f installed.stamp ]; then
342 # begin install block
343
344 # fix broken cmake rules
345 # TODO: fix cmake rules
346 if [ -d $RPM_BUILD_ROOT%{_prefix}/usr ]; then
347         cp -a $RPM_BUILD_ROOT%{_prefix}/usr/* $RPM_BUILD_ROOT%{_prefix}
348         rm -rf $RPM_BUILD_ROOT%{_prefix}/usr
349 fi
350
351 install -d $RPM_BUILD_ROOT{%{_sysconfdir}/%{name},%{_libdir}/%{name}}
352 cp -p %{SOURCE7} $RPM_BUILD_ROOT%{_sysconfdir}/%{name}
353
354 ln -s hhvm $RPM_BUILD_ROOT%{_bindir}/php
355 ln -s hhvm $RPM_BUILD_ROOT%{_bindir}/hphp
356
357 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}/hdf
358 cp -p hphp/doc/mime.hdf $RPM_BUILD_ROOT%{_datadir}/%{name}/hdf/static.mime-types.hdf
359
360 # install fastcgi initscript
361 install -d $RPM_BUILD_ROOT/etc/{sysconfig,rc.d/init.d}
362 cp -p %{SOURCE5} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}-fcgi
363 cp -p %{SOURCE6} $RPM_BUILD_ROOT/etc/sysconfig/%{name}-fcgi
364
365 install -p hphp/hack/bin/hh_{server,client} $RPM_BUILD_ROOT%{_bindir}
366
367 %if 0
368 # setup -devel
369 install -d $RPM_BUILD_ROOT%{_datadir}/cmake/Modules
370 cp -p CMake/*.cmake $RPM_BUILD_ROOT%{_datadir}/cmake/Modules
371
372 HPHP_HOME=$(pwd)
373 sed -e "
374         /HHVM_INCLUDE_DIRS/ s,$HPHP_HOME,%{_includedir},g
375 " hphp/tools/hphpize/hphpize.cmake > $RPM_BUILD_ROOT%{_datadir}/cmake/Modules/hphpize.cmake
376
377 oIFS=$IFS
378 IFS=";"
379 set -- $(sed -ne 's/set(HHVM_INCLUDE_DIRS "\(.*\)")/\1/p' hphp/tools/hphpize/hphpize.cmake)
380 IFS=$oIFS
381 set -- $(
382         for dir in "$@"; do
383                 [[ "$dir" = $HPHP_HOME/hphp/* ]] && echo $dir
384         done
385 )
386
387 set +x
388 for dir in "$@" \
389         $HPHP_HOME/hphp/runtime \
390         $HPHP_HOME/hphp/util \
391         $HPHP_HOME/hphp/neo \
392         $HPHP_HOME/hphp/system \
393         $HPHP_HOME/hphp/parser \
394 ; do
395         echo "D %{_includedir}${dir#$HPHP_HOME}"
396         find $dir -name '*.h' | while read path; do
397                 file=%{_includedir}${path#$HPHP_HOME}
398                 echo "F $file"
399                 install -Dp $path $RPM_BUILD_ROOT$file
400         done
401 done
402 set -x
403 %endif
404
405 # end of install block
406 touch installed.stamp; fi
407
408 %clean
409 rm -rf $RPM_BUILD_ROOT
410
411 %post   -p /sbin/ldconfig
412 %postun -p /sbin/ldconfig
413
414 %post fcgi
415 /sbin/chkconfig --add %{name}-fcgi
416 %service %{name}-fcgi restart
417
418 %preun fcgi
419 if [ "$1" = "0" ]; then
420         %service -q %{name}-fcgi stop
421         /sbin/chkconfig --del %{name}-fcgi
422 fi
423
424 %files
425 %defattr(644,root,root,755)
426 %doc README.md hphp/NEWS
427 %dir %{_sysconfdir}/%{name}
428 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{name}/php.ini
429 %attr(755,root,root) %{_bindir}/hhvm
430 %attr(755,root,root) %{_bindir}/hphp
431 %attr(755,root,root) %{_bindir}/hh_client
432 %attr(755,root,root) %{_bindir}/hh_server
433
434 %dir %{_datadir}/%{name}
435 %dir %{_datadir}/%{name}/hdf
436 %{_datadir}/%{name}/hdf/static.mime-types.hdf
437
438 # dir for extensions
439 %dir %{_libdir}/%{name}
440
441 %files fcgi
442 %defattr(644,root,root,755)
443 %attr(754,root,root) /etc/rc.d/init.d/%{name}-fcgi
444 %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}-fcgi
445
446 %files program
447 %defattr(644,root,root,755)
448 %attr(755,root,root) %{_bindir}/php
449
450 %files devel
451 %defattr(644,root,root,755)
452 %attr(755,root,root) %{_bindir}/hphpize
453 %{_includedir}/hphp
454 %dir %{_libdir}/hhvm
455 %{_libdir}/hhvm/CMake
456 %{_libdir}/hhvm/hphpize
This page took 0.062629 seconds and 4 git commands to generate.