File dmd.spec of Package dmd

#
# spec file for package dmd
#
# Copyright (c) 2014 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/
#

%define build_with_ldc 1

%define lname   libphobos2-0_70
%define soname	0.70
%define phobos  phobos

Name:           dmd
Version:        2.070.0
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/%{name}/archive/v%{version}.tar.gz
# Conflicting filename from https://github.com/D-Programming-Language/druntime/archive/v%%{version}.tar.gz
Source1:        druntime-%{version}.tar.gz
# Conflicting filename from https://github.com/D-Programming-Language/phobos/archive/v%%{version}.tar.gz
Source2:        phobos-%{version}.tar.gz
Source9:        dmd.conf
BuildRequires:  gcc-c++
%if %{build_with_ldc}
BuildRequires:	ldc >= 0.15.0, ldc <= 0.17.0beta1
BuildRequires:  ldc-runtime-devel >= 0.15.0, ldc-runtime-devel <= 0.17.0beta1
BuildRequires:  ldc-phobos-devel >= 0.15.0, ldc-phobos-devel <= 0.17.0beta1
%else
BuildRequires:  dmd >= 2.069.0, dmd <= 2.070.0
BuildRequires:  %{phobos}-devel-static >= 2.069.0, %{phobos}-devel-static <= 2.070.0
%endif
Recommends:     %{phobos}-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%define incbase %{_includedir}/dlang
%define include %{incbase}/dmd-%{version}

%description
A systems programming language. Its focus is on combining the power
and high performance of C and C++ with the programmer productivity
of modern languages like Ruby and Python. Special attention is given
to the needs of quality assurance, documentation, management,
portability and reliability.

%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
echo %{version} > phobos-%{version}/VERSION

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

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

%install
# DMD
make install -f posix.mak \
%if %{build_with_ldc}
	HOST_DMD=ldmd2 \
%endif
%ifarch x86_64
	MODEL=64 \
%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}/dmd-backendlicense.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
pushd phobos-%{version}
make install -f posix.mak \
%ifarch x86_64
        MODEL=64 \
%endif
        VERSION=VERSION DMD="$PWD/../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 \
%ifarch x86_64
        MODEL=64 \
%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/etc/c/zlib

/sbin/ldconfig -N %buildroot/%_libdir

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

%files
%defattr(-,root,root)
%doc README.md src/boostlicense.txt
%config %{_sysconfdir}/%{name}.conf
%{_bindir}/dmd
%{_datadir}/%{name}
%{_mandir}/man*/*

%files -n %lname
%defattr(-,root,root)
%{_libdir}/libphobos2.so.%{soname}
%{_libdir}/libphobos2.so.%{soname}.*

%files -n %{phobos}-devel
%defattr(-,root,root)
%dir %{incbase}
%{include}/
%{_libdir}/libphobos2.so

%files -n %{phobos}-devel-static
%defattr(-,root,root)
%{_libdir}/libphobos2.a

%changelog
openSUSE Build Service is sponsored by