File v8.spec of Package v8.openSUSE_12.1_Update
#
# spec file for package v8
#
# Copyright (c) 2012 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/
#
Name: v8
Version: 3.11.3.0
Release: 0
Summary: JavaScript Engine
License: BSD-3-Clause
Group: System/Libraries
Url: http://code.google.com/p/v8
Source0: %{name}.%{version}.tar.lzma
# PATCH-FIX-OPENSUSE buildfix.diff (Ensure that V8 builds correctly)
Patch0: buildfix.diff
%if %suse_version > 1140
Patch1: adjust-buildflags.diff
%endif
BuildRequires: gcc-c++
BuildRequires: lzma
BuildRequires: readline-devel
BuildRequires: scons
ExclusiveArch: %{ix86} x86_64 %arm
%if 0%{?suse_version} < 1120
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
%global somajor `echo %{version} | cut -f1 -d'.'`
%global sominor `echo %{version} | cut -f2 -d'.'`
%global sobuild `echo %{version} | cut -f3 -d'.'`
%global sover %{somajor}.%{sominor}.%{sobuild}
%description
V8 is Google's open source JavaScript engine. V8 is written in C++ and is used
in Google Chrome, the open source browser from Google. V8 implements ECMAScript
as specified in ECMA-262, 3rd edition.
%package -n libv8-3
Summary: JavaScript Engine
Group: Development/Libraries/Other
Obsoletes: v8 < %{version}
Provides: v8 = %{version}
%description -n libv8-3
Libraries for v8.
%package devel
Summary: Development headers and libraries for v8
Group: Development/Libraries/Other
Requires: lib%{name}-3 = %{version}
%description devel
Development headers and libraries for v8.
%if %suse_version > 1140
%package private-headers-devel
Summary: Private Development headers for v8
Group: Development/Libraries/C and C++
Requires: %{name}-devel = %{version}
%description private-headers-devel
Special Private Development headers for v8.
%endif
%prep
rm -rf %{name}
lzma -cd %{SOURCE0} | tar xf -
%setup -D -T -n %{name}
%patch0 -p0
%if %suse_version > 1140
%patch1 -p0
%endif
# -fno-strict-aliasing is needed with gcc 4.4 to get past some ugly code
%if 0%{?suse_version} > 1110
PARSED_OPT_FLAGS=`echo \'%{optflags} \' | sed "s/ /',/g" | sed "s/',/', '/g"`
sed -i "s|'-O3',|$PARSED_OPT_FLAGS '-fno-strict-aliasing',|g" SConstruct
%endif
%build
env=CCFLAGS:"-fPIC"
scons -j3 library=shared snapshots=on visibility=default mode=release \
%ifarch x86_64
arch=x64 \
%endif
%ifarch %arm
armeabi=hard vfp3=on \
%endif
# When will people learn to create versioned shared libraries by default?
# first, lets get rid of the old .so
rm -rf libv8.so
rm -rf libv8preparser.so
# Now, lets make it right.
g++ %{optflags} -shared -Wl,-soname,libv8preparser.so.%{somajor} -o libv8preparser.so.%{sover} obj/release/allocation.os obj/release/bignum-dtoa.os obj/release/bignum.os obj/release/cached-powers.os obj/release/conversions.os obj/release/diy-fp.os obj/release/dtoa.os obj/release/fast-dtoa.os obj/release/fixed-dtoa.os obj/release/preparse-data.os obj/release/preparser-api.os obj/release/preparser.os obj/release/scanner.os obj/release/strtod.os obj/release/token.os obj/release/unicode.os obj/release/utils.os -lpthread
rm obj/release/preparser-api.os
%ifarch %arm
g++ %{optflags} -shared -Wl,-soname,libv8.so.%{somajor} -o libv8.so.%{sover} obj/release/*.os obj/release/arm/*.os obj/release/extensions/*.os -lpthread
%endif
%ifarch %{ix86}
g++ %{optflags} -shared -Wl,-soname,libv8.so.%{somajor} -o libv8.so.%{sover} obj/release/*.os obj/release/ia32/*.os obj/release/extensions/*.os -lpthread
%endif
%ifarch x86_64
g++ %{optflags} -shared -Wl,-soname,libv8.so.%{somajor} -o libv8.so.%{sover} obj/release/*.os obj/release/x64/*.os obj/release/extensions/*.os -lpthread
%endif
# We need to do this so d8 can link against it.
ln -sf libv8.so.%{sover} libv8.so
ln -sf libv8preparser.so.%{sover} libv8preparser.so
scons d8 mode=release \
%ifarch x86_64
arch=x64 \
%endif
%ifarch %arm
armeabi=hard vfp3=on \
%endif
library=shared snapshots=on console=readline visibility=default
# Sigh. I f*****g hate scons.
rm -rf d8
g++ %{optflags} -o d8 obj/release/d8.os -lv8 -lpthread -lreadline -L.
%install
%if %suse_version > 1140
mkdir -p %{buildroot}%{_includedir}/v8/x64
%else
mkdir -p %{buildroot}%{_includedir}
%endif
mkdir -p %{buildroot}%{_libdir}
install -p include/*.h %{buildroot}%{_includedir}
%if %suse_version > 1140
install -p src/*.h %{buildroot}%{_includedir}/v8
install -p src/x64/*.h %{buildroot}%{_includedir}/v8/x64
%endif
install -p libv8.so.%{sover} %{buildroot}%{_libdir}
install -p libv8preparser.so.%{sover} %{buildroot}%{_libdir}
mkdir -p %{buildroot}%{_bindir}
install -p -m0755 d8 %{buildroot}%{_bindir}
cd %{buildroot}%{_libdir}
ln -sf libv8.so.%{sover} libv8.so
ln -sf libv8.so.%{sover} libv8.so.%{somajor}
ln -sf libv8.so.%{sover} libv8.so.%{somajor}.%{sominor}
ln -sf libv8preparser.so.%{sover} libv8preparser.so.%{somajor}.%{sominor}
ln -sf libv8preparser.so.%{sover} libv8preparser.so.%{somajor}
ln -sf libv8preparser.so.%{sover} libv8preparser.so
chmod -x %{buildroot}%{_includedir}/v8*.h
%if 0%{?suse_version} < 1120
%clean
rm -rf %{buildroot}
%endif
%post -n libv8-3 -p /sbin/ldconfig
%postun -n libv8-3 -p /sbin/ldconfig
%files -n libv8-3
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog LICENSE
%{_bindir}/d8
%{_libdir}/*.so.*
%files devel
%defattr(-,root,root,-)
%{_includedir}/*.h
%{_libdir}/*.so
%if %suse_version > 1140
%files private-headers-devel
%defattr(644,root,root,-)
%{_includedir}/v8/
%endif
%changelog