File dmd.spec of Package dmd

#
# spec file for package dmd
#
# 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/
#


%define auto_bootstrap 0
%define build_with_ldc 0
%define lname   libphobos2-0_77
%define soname	0.77
%define phobos  phobos
%define incbase %{_includedir}/dlang
%define include %{incbase}/dmd-%{version}
Name:           dmd
Version:        2.077.1
Release:        0
Summary:        D Programming Language 2.0
License:        BSL-1.0
Group:          Development/Languages/Other
Url:            http://dlang.org/
Source:         https://github.com/D-Programming-Language/dmd/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        https://github.com/D-Programming-Language/druntime/archive/v%{version}.tar.gz#/druntime-%{version}.tar.gz
Source2:        https://github.com/D-Programming-Language/phobos/archive/v%{version}.tar.gz#/phobos-%{version}.tar.gz
Source8:        http://downloads.dlang.org/releases/2.x/2.076.1/dmd.2.076.1.linux.tar.xz
Source9:        dmd.conf
# PATCH-FIX-OPENSUSE dmd_use_tarball_bootstrap.diff So the tarball is not downloaded
Patch0:         dmd_use_tarball_bootstrap.diff
BuildRequires:  gcc-c++
BuildRequires:  git
BuildRequires:  xz
Recommends:     %{phobos}-devel
%if %{build_with_ldc}
BuildRequires:  ldc >= 0.15.0
BuildRequires:  ldc-phobos-devel >= 0.15.0
BuildRequires:  ldc-runtime-devel >= 0.15.0
%else
%if !%{auto_bootstrap}
BuildRequires:  %{phobos}-devel-static >= 2.075.0
BuildRequires:  dmd >= 2.075.0
%endif
%endif

%description
The D programming language is an object-oriented, imperative,
multi-paradigm system programming language. It has type inference,
automatic memory management and syntactic sugar for common types,
bounds checking, design by contract features, and a concurrency-aware
type system.

%package -n %{phobos}
Summary:        Standard Library for DMD
Group:          Development/Libraries/Other

%description -n %{phobos}
Phobos is the standard library for the D Programming Language.

%package -n %{lname}
Summary:        Standard library for the D language
Group:          System/Libraries

%description -n %{lname}
Phobos is the standard library for the D Programming Language.

This package contains the shared library needed to run programs compiled with
dmd.

%package -n %{phobos}-devel
Summary:        Development files for the D standard library
Group:          Development/Libraries/Other
Requires:       %{lname} = %{version}

%description -n %{phobos}-devel
Phobos is the standard library for the D Programming Language.

This package contains the includes needed to compile programs against Phobos.

%package -n %{phobos}-devel-static
Summary:        Development files for the D standard library
Group:          Development/Libraries/Other
Requires:       %{phobos}-devel = %{version}

%description -n %{phobos}-devel-static
Phobos is the standard library for the D Programming Language.

This package contains the static library for static linking. You don't need
this, unless you link statically, which is highly discouraged.

%prep
%setup -q
%setup -q -T -D -a 1
%setup -q -T -D -a 2
%patch0 -p1
echo %{version} > phobos-%{version}/VERSION
cd /home/abuild/rpmbuild/BUILD
ln -s dmd-%{version} dmd
mv dmd-%{version}/druntime-%{version} .
mv  dmd-%{version}/phobos-%{version} .

%build
# DMD
make %{?_smp_mflags} -f posix.mak \
%if %{auto_bootstrap}
	AUTO_BOOTSTRAP=1 \
%endif
%if %{build_with_ldc}
	HOST_DMD=ldmd2 \
%endif
%ifarch x86_64
	MODEL=64 \
%endif
%ifarch i586
	MODEL=32 \
	PIC=1 \
%endif
	RELEASE=1 \
	TARGET=LINUX

# Phobos
cd ../phobos-%{version}
make %{?_smp_mflags} -f posix.mak \
%if %{auto_bootstrap}
	AUTO_BOOTSTRAP=1 \
%endif
%ifarch x86_64
	MODEL=64 \
%endif
%ifarch i586
	MODEL=32 \
	PIC=1 \
%endif
	VERSION=VERSION DMD="$PWD/../dmd/src/dmd" DRUNTIME_PATH="$PWD/../druntime-%{version}"

%install
# DMD
make install -f posix.mak \
%if %{auto_bootstrap}
	AUTO_BOOTSTRAP=1 \
%endif
%if %{build_with_ldc}
	HOST_DMD=ldmd2 \
%endif
%ifarch x86_64
	MODEL=64 \
%endif
%ifarch i586
	MODEL=32 \
	PIC=1 \
%endif
	RELEASE=1 \
	TARGET=LINUX INSTALL_DIR=%{buildroot}

mkdir -p %{buildroot}%{_bindir}
mv %{buildroot}/linux/bin*/dmd %{buildroot}%{_bindir}/dmd

mkdir -p %{buildroot}%{_datadir}/%{name}
mv %{buildroot}/man %{buildroot}%{_datadir}
mv %{buildroot}/samples %{buildroot}%{_datadir}/%{name}
rm %{buildroot}%{_datadir}/%{name}/samples/.gitignore

# avoid duplicates
rm %{buildroot}/dmd-boostlicense.txt
rm %{buildroot}/linux/bin*/dmd.conf

mkdir -p %{buildroot}%{_sysconfdir}/
cat %{_sourcedir}/dmd.conf | sed "s/@VERSION@/%{version}/g" > %{buildroot}%{_sysconfdir}/%{name}.conf

# Phobos
cd ..
pushd phobos-%{version}
make install -f posix.mak \
%if %{auto_bootstrap}
	AUTO_BOOTSTRAP=1 \
%endif
%ifarch x86_64
	MODEL=64 \
%endif
%ifarch i586
	MODEL=32 \
	PIC=1 \
%endif
	VERSION=VERSION DMD="$PWD/../dmd/src/dmd" DRUNTIME_PATH="$PWD/../druntime-%{version}" INSTALL_DIR=%{buildroot}

# Relocate installed files into proper directories
mkdir -p %{buildroot}%{_libdir}
mv %{buildroot}/linux/lib*/* %{buildroot}%{_libdir}
mkdir -p %{buildroot}%include/
mv %{buildroot}/src/phobos %{buildroot}%include/
popd

# Repeat for druntime
pushd druntime-%{version}
make install -f posix.mak \
%if %{auto_bootstrap}
	AUTO_BOOTSTRAP=1 \
%endif
%ifarch x86_64
	MODEL=64 \
%endif
%ifarch i586
	MODEL=32 \
	PIC=1 \
%endif
	DMD="$PWD/../src/dmd" INSTALL_DIR=%{buildroot}

mv %{buildroot}/src/druntime/import %{buildroot}%include/druntime
popd

# Remove duplicates and files not packaged by upstream
rm -rf %{buildroot}/lib
rm %{buildroot}/*LICENSE.txt
rm -rf %{buildroot}%include/phobos%{_sysconfdir}/c/zlib

/sbin/ldconfig -N %{buildroot}/%{_libdir}

%post   -n %{lname} -p /sbin/ldconfig
%postun -n %{lname} -p /sbin/ldconfig

%files
%doc LICENSE.txt README.md
%config %{_sysconfdir}/%{name}.conf
%{_bindir}/dmd
%{_datadir}/%{name}
%{_mandir}/man*/*

%files -n %{lname}
%{_libdir}/libphobos2.so.%{soname}
%{_libdir}/libphobos2.so.%{soname}.*

%files -n %{phobos}-devel
%dir %{incbase}
%include/
%{_libdir}/libphobos2.so

%files -n %{phobos}-devel-static
%{_libdir}/libphobos2.a

%changelog
openSUSE Build Service is sponsored by