From Fedora Project Wiki

(Deprecate this page.)
 
(15 intermediate revisions by 4 users not shown)
Line 1: Line 1:
'''Revision:''' 0.1<BR>
{{OldGuidelinePage|D}}
'''Last Revised:''' Wednesday Jul 28, 2010<BR>


== Packaging Tips ==
== ldc ==
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.


=== File Locations ===
=== Compiler options ===
<code>%{_d_optflags}</code> must be used with ldc (normal <code>%{optflags}</code> do not apply to ldc, only to gcc).


==== Libraries ====
<code>%{_d_optflags}</code> is defined as:
D packages must install assemblies to %{_d_libdir} rather than /usr/lib or %{_datadir}.
<pre>
-release -w -g -O2
</pre>


===== Header =====
-release ''disables asserts, invariants, contracts and boundscheck''<BR>
D package must install header file like .d or .di to %{_d_includedir}/%{name}
-w ''enables warnings''<BR>
-g ''generates debug information''<BR>
-O2 ''is the optimisation level''


=== Libraries ===
Some D packages use Makefiles, which usually use the $DFLAGS variable in the same way that C packages with Makefiles use $CFLAGS. In this case, <code>export DFLAGS="%{_d_optflags}"</code> is usually appropriate. In other cases, the build script in the D package has an option to pass in <code>%{_d_optflags}</code>. It is the responsibility of the packager to ensure that <code>%{_d_optflags}</code> are used with ldc when the package is built.
At this time in D programming only OS X support shared lirbraries. So wait this feature or help ldc project. Feel free.<BR>
For build static librarie in D you need use ar and ranlib tools. ldc compiler support GNU strip.<BR>
short example from makefile:<BR>
<pre>
DC=ldc
HD=-Hd $(IMPORT_DEST)
DFLAGS_REQ=-c -I ../DerelictUtil
AL_SRC= \
    derelict/openal/al.d \
    derelict/openal/alfuncs.d \
    derelict/openal/altypes.d 
   
PACKAGE_PATH=derelict/openal


all : DerelictAL
=== Header Files ===
D packages contain header files, which end with .d or .di. These header files must be installed into <code>%{_d_includedir}/%{name}</code>.


$(LIB_PRE)DerelictAL.$(LIB_EXT) :
<code>%{_d_includedir}</code> is defined as:
$(DC) $(DFLAGS) $(DFLAGS_REQ) $(AL_SRC) $(HD)/$(PACKAGE_PATH)
<pre>
$(AR) rcs $@ $^
/usr/include/d/
$(RANLIB) $@
$(CP) $@ $(LIB_DEST)
$(RM) $@
</pre>
</pre>


=== Macros ===
== Libraries ==
All D package need ldc for build and macro file is in ldc package, every package must have ldc in BuildRequire
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.


==== Compiler options ====
To build static libraries in D, you use the same tools that you would for C, specifically, ar, ranlib, and strip.
%{_d_optflags} need be used for ldc options<BR>
%{_d_optflags} define options ''-release -w -g -O2''<BR>
-release ''disables asserts, invariants, contracts and boundscheck''<BR>
-w ''enable warnings''<BR>
-g ''generate debug information''<BR>
-O2 ''for make a good optimisation''


==== Include directories ====
If your D package contains static libraries, you must disable debuginfo generation, by adding this line to the top of your spec file:
%{_d_includedir} need be used for devel file<BR>
<pre>
%{_d_includedir} define ''/usr/include/d/'' directory
%global debug_package %{nil}
 
</pre>
==== Lib directories ====
Otherwise, it would generate an empty debuginfo package.
%{_d_libdir} lib directory path used for static library (and later i hope shared library)
%{_d_libdir} define ''/usr/lib64/d'' or ''/usr/lib/d'' directory
 
== SPEC ==
=== Tips ===
==== If only static library ====
===== Define global macro =====
If you package do not contain a shared library but only static library you shoul write at top of spec file:
%global debug_package %{nil}


Because GNU strip can't extract debug symbols from static lib achieves.
All static libraries must be placed in the *-devel subpackage. When doing this, you must also have
<code>Provides: %{name}-static = %{version}-%{release}</code> in the devel package definition.


===== Provides static libraries =====
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.
When a package only provides static libraries you can place all the static library files in the *-devel subpackage. When doing this you also must have a virtual Provide for the *-static package.
Then  the root package could be empty, in the template for example they are no %file foo and foo-devel package contain static librarie.


=== Template ===
== Template ==
here an template for D package with static libraries
<pre>
<pre>
%global debug_package %{nil}
%global debug_package %{nil}


Name:          foo
Name:          foo
Version:
Version:       1.2.3
Release:        1%{?dist}
Release:        1%{?dist}
Summary:        Development/Libraries
Summary:        Does foo in D
 
Group:          Development/Libraries
 
License:       LGPLv2+
Group:
URL:           http://anywhere.com/
License:
Source0:       http://anywhere.com/%{name}-%{version}.tar.bz2
URL:
BuildRequires: ldc
Source0:
Requires:       tango
BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
BuildRequires: ldc
Requires:     tango


%description
%description
Foo and bar.


%package devel
%package devel
Line 101: Line 72:


%build
%build
export DFLAGS="%{_d_optflags}"
%configure
%configure
make %{?_smp_mflags}
make %{?_smp_mflags}


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


%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
make install DESTDIR=%{buildroot}


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


%clean
%clean
rm -rf %{buildroot}
rm -rf %{buildroot}


%files devel
%files devel
%defattr(-,root,root,-)
%doc README.txt
%doc README.txt LICENSE.txt
%license LICENSE.txt
%{_d_includedir}/%{name}
%{_d_includedir}/%{name}/
%{_libdir}/%{name}/<static-libraries.a>
%{_libdir}/*.a


%changelog
%changelog
 
* Wed Aug 25 2010 John Doe <jdoe@anywhere.com> 1.2.3-1
- initial package
</pre>
</pre>


[[Category:Packaging guidelines]]
[[Category:Packaging guidelines]]

Latest revision as of 19:55, 21 December 2018

Warning.png
This is an old copy of a packaging guideline, preserved here in the wiki while we complete the transition to the Fedora documentation system. The current version is located at https://docs.fedoraproject.org/en-US/packaging-guidelines/D/. Please update your bookmarks.

ldc

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

Some D packages use Makefiles, which usually use the $DFLAGS variable in the same way that C packages with Makefiles use $CFLAGS. In this case, export DFLAGS="%{_d_optflags}" is usually appropriate. In other cases, the build script in the D package has an option to pass in %{_d_optflags}. It is the responsibility of the packager to ensure that %{_d_optflags} are used with ldc when the package is built.

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:

/usr/include/d/

Libraries

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.

Template

%global debug_package %{nil}

Name:           foo
Version:        1.2.3
Release:        1%{?dist}
Summary:        Does foo in D
Group:          Development/Libraries
License:        LGPLv2+
URL:            http://anywhere.com/
Source0:        http://anywhere.com/%{name}-%{version}.tar.bz2
BuildRequires:  ldc
Requires:       tango

%description
Foo and bar.

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

%prep
%setup -q


%build
export DFLAGS="%{_d_optflags}"
%configure
make %{?_smp_mflags}

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

make install DESTDIR=%{buildroot}

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

%clean
rm -rf %{buildroot}

%files devel
%doc README.txt
%license LICENSE.txt
%{_d_includedir}/%{name}/
%{_libdir}/*.a

%changelog
* Wed Aug 25 2010 John Doe <jdoe@anywhere.com> 1.2.3-1
- initial package