From FedoraProject

(Difference between revisions)
Jump to: navigation, search
Line 73: Line 73:
mkdir -p %{_libdir}
mkdir -p %{_d_includedir}/%{name}/
make install DESTDIR=%{buildroot}
make install DESTDIR=%{buildroot}
install -m 0644 lib/* %{_libdir}
install -m 0644 lib/*     %{_libdir}
install -m 0644 include/* %{_d_includedir}/%{name}/

Revision as of 09:55, 27 August 2010



All D packages depend on ldc to build, so every package must have ldc as BuildRequires. In addition, the ldc package includes some useful macros for D packages.

Compiler options

%{_d_optflags} must be used with ldc (normal %{optflags} do not apply to ldc, only to gcc).

%{_d_optflags} is defined as:

-release -w -g -O2

-release disables asserts, invariants, contracts and boundscheck
-w enables warnings
-g generates debug information
-O2 is the optimisation level

Header Files

D packages contain header files, which end with .d or .di. These header files must be installed into %{_d_includedir}/%{name}.

%{_d_includedir} is defined as:



At this time, Linux does not support shared libraries for D code (only OSX does). As a result, D packages are explicitly excluded from the restrictions against packaging static libraries.

To build static libraries in D, you use the same tools that you would for C, specifically, ar, ranlib, and strip.

If your D package contains static libraries, you must disable debuginfo generation, by adding this line to the top of your spec file:

%global debug_package %{nil}

Otherwise, it would generate an empty debuginfo package.

All static libraries must be placed in the *-devel subpackage. When doing this, you must also have Provides: %{name}-static = %{version}-%{release} in the devel package definition.

It is possible that this will leave the root package empty, if this is the case, do not list a %files section for the root package, only for the -devel package. This is illustrated in the example template below.


%global debug_package %{nil}

Name:           foo
Version:        1.2.3
Release:        1%{?dist}
Summary:        Does foo in D
Group:          Development/Libraries
License:        LGPLv2+
BuildRequires:  ldc
Requires:       tango

Foo and bar.

%package devel
Provides:       %{name}-static =  %{version}-%{release}
Summary:        Support for developing D application
Group:          Development/Libraries

%setup -q

make %{?_smp_mflags}

mkdir -p %{_libdir}
mkdir -p %{_d_includedir}/%{name}/

make install DESTDIR=%{buildroot}

install -m 0644 lib/*     %{_libdir}
install -m 0644 include/* %{_d_includedir}/%{name}/

rm -rf %{buildroot}

%files devel
%doc README.txt LICENSE.txt

* Wed Aug 25 2010 John Doe <> 1.2.3-1
- initial package