File v8.spec of Package v8

#
# spec file for package v8
#
# Copyright (c) 2017 SUSE LINUX 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/
#


# check the file DEPS for matching the v8 version with its tools; update
# the _service file accordingly

Name:           v8
Version:        5.3.332
Release:        0
Summary:        JavaScript Engine
License:        BSD-3-Clause
Group:          System/Libraries
Url:            http://code.google.com/p/v8

Source0:        %{name}-%{version}.tar.bz2
Source1:        third_party.icu-46.tar.bz2
Source2:        buildtools-00.tar.bz2
Source3:        testing.gmock-00.tar.bz2
Source4:        testing.gtest-00.tar.bz2
Source5:        test.mozilla.data-00.tar.bz2
Source6:        test.simdjs.data-00.tar.bz2
Source7:        test.test262.data-00.tar.bz2
Source8:        tools.swarming_client-00.tar.bz2
Source9:        test.benchmarks.data-00.tar.bz2
Source10:       trace_event-00.tar.bz2
# PATCH-FIX-UPSTREAM v8-gcc6.patch mliska@suse.cz -- Fix build with GCC6
Patch1:         add_ppc64le_arch.patch
Patch2:         v8-gcc6.patch
Patch3:         v8_deprecated_readdir_r.patch
BuildRequires:  gcc-c++
BuildRequires:  gyp
BuildRequires:  libicu-devel >= 4.0
BuildRequires:  lzma
BuildRequires:  python-devel
BuildRequires:  readline-devel
ExclusiveArch:  %{ix86} x86_64 %arm ppc64 ppc64le
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%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-5
Summary:        JavaScript Engine
Group:          System/Libraries
Obsoletes:      v8 < %{version}
Provides:       v8 = %{version}

%description -n libv8-5
V8 is Google\'s open source JavaScript engine. This package contains
libraries for v8.

%package devel
Summary:        Development headers and libraries for v8
Group:          Development/Libraries/C and C++
Requires:       lib%{name}-5 = %{version}

%description devel
V8 is Google\'s open source JavaScript engine. This package contains
development headers and libraries for v8.

%if 0%{?suse_version} > 1140 || 0%{?fedora_version}

%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
%setup -q -T -b 0

for SRC in %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} %{SOURCE5} \
	    %{SOURCE6} %{SOURCE7} %{SOURCE8} %{SOURCE9}; do
    DIRNAME=$(basename $SRC | rev | cut -d'.' -f3 | rev | cut -d'-' -f 1)
    PATHNAME=$(basename $SRC | rev | cut -d'.' -f4- | tr '.' '/' | rev)

    pushd "$PATHNAME"
    mkdir $DIRNAME
    pushd $DIRNAME
    tar --strip-components=1 -xvf $SRC
    popd
    popd
done
mkdir -p base/trace_event/common
pushd base/trace_event/common
tar --strip-components=1 -xvf %{SOURCE10}
popd
%patch1 -p1
%patch2 -p1
%patch3 -p1

%build

# try to fix the build problems on 32 bit ??????
install -d out/Release/lib

#Link the gypfiles directory to a directory called build as that the other sources are 
#expecting the build directory which contains the gyp files
ln -s gypfiles build

export GYP_DEFINES="component=shared_library soname_version=%{somajor} console=readline clang=0 host_clang=0 use_system_icu=1 linux_use_bundled_binutils=0 linux_use_bundled_gold=0 linux_use_gold_flags=0 v8_enable_backtrace=0"

./gypfiles/gyp_v8 -f make gypfiles/all.gyp --depth .

env=CCFLAGS:"-fPIC"
MAKE_EXTRA_FLAGS=""
%ifarch armv7hl
MAKE_EXTRA_FLAGS+=hardfp=on
%endif
# reduce number of parallel builds for i586 on TW
MAKE_SMP_FLAGS=%{?_smp_mflags}
%if 0%{?suse_version} > 1320
%ifarch %{ix86}
MAKE_SMP_FLAGS="-j 1"
%endif
%endif

#cd out
make $MAKE_SMP_FLAGS \
     snapshots=on \
     $MAKE_EXTRA_FLAGS \
     BUILDTYPE=Release V=1

%install
%if 0%{?suse_version} > 1140 || 0%{?fedora_version}
mkdir -p %{buildroot}%{_includedir}/v8/x64
%else
mkdir -p %{buildroot}%{_includedir}
%endif
mkdir -p %{buildroot}%{_libdir}
install -p include/*.h %{buildroot}%{_includedir}

%if 0%{?suse_version} > 1140 || 0%{?fedora_version}
install -p src/*.h %{buildroot}%{_includedir}/v8
install -p src/x64/*.h %{buildroot}%{_includedir}/v8/x64
%endif

install -p out/Release/lib.target/libv8.so* %{buildroot}%{_libdir}/
mkdir -p %{buildroot}%{_bindir}
install -p -m0755 out/Release/d8 %{buildroot}%{_bindir}

cd %{buildroot}%{_libdir}
ln -sf libv8.so.%{somajor} libv8.so

chmod -x %{buildroot}%{_includedir}/v8*.h

%post -n libv8-5 -p /sbin/ldconfig

%postun -n libv8-5 -p /sbin/ldconfig

%files
%defattr(-,root,root)
%doc AUTHORS ChangeLog LICENSE.* OWNERS
%_bindir/d8

%files -n libv8-5
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog LICENSE.* OWNERS
%{_libdir}/*.so.*

%files devel
%defattr(-,root,root,-)
%{_includedir}/*.h
%{_libdir}/*.so

%if 0%{?suse_version} > 1140 || 0%{?fedora_version}

%files private-headers-devel
%defattr(644,root,root,-)
%{_includedir}/v8/
%endif

%changelog
openSUSE Build Service is sponsored by