~ubuntu-branches/debian/sid/ocaml/sid

« back to all changes in this revision

Viewing changes to debian/policy/chapter-progpack.xml

  • Committer: Bazaar Package Importer
  • Author(s): Stefano Zacchiroli
  • Date: 2009-02-22 08:49:13 UTC
  • mfrom: (12.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090222084913-3i0uw2bhd0lgw0ok
* Uploading to unstable
* debian/control: bump dh-ocaml to (>= 0.4) to avoid buggy ocamlinit.mk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<section>
2
 
    <title>Creating Packages for OCaml Programs</title>
3
 
    <para>
4
 
        Any package providing executables built from OCaml source should conform to the following guidelines.
5
 
    </para>
6
 
 
7
 
    <para>
8
 
        The source package should, if possible, use the name of the upstream
9
 
        package without modifications.
10
 
    </para>
11
 
 
12
 
    <para>
13
 
      Programs which are not particularly CPU hungry should be
14
 
      compiled into bytecode form, and the corresponding binary packages
15
 
      should be <code>Architecture: all</code> in order to minimize
16
 
      archive usage and avoid the need of rebuilding them on all
17
 
      architectures. See <xref linkend="bytecode-prog" /> for details on
18
 
      this kind of packages.
19
 
    </para>
20
 
 
21
 
    <para>
22
 
      Other programs
23
 
      should be compiled into native form on architectures where the native
24
 
      compiler is available, and into bytecode on other architectures.
25
 
      See <xref linkend="bytecode-native-prog" /> for details on how to achieve
26
 
      this.  The corresponding binary packages should be <code>Architecture:
27
 
        any</code> and will need to be built on any architecture.
28
 
    </para>
29
 
 
30
 
    <para>
31
 
      All bytecode executables should be linked dynamically against the shared libraries for C bindings, so as to not bloat the archive.
32
 
      <!-- ZACK: which cases? -->
33
 
      <!--However, there may be special cases, were using statically linked bytecode is necessary, in these cases, it is naturally ok to link statically.-->
34
 
      That said, often the upstream authors will favor statically linked bytecode executables, because so they don't need to worry about the presence of the dll stub libraries and such. This is not a valid reason to use statically linked bytecode in a Debian package.
35
 
      <!-- ZACK: related to the commented stuff above -->
36
 
      <!--If statically linked bytecode is provided, a justification of this use should be provided in the <filename>README.Debian</filename> file.-->
37
 
    </para>
38
 
</section>
39
 
 
40
 
<section id="bytecode-prog">
41
 
<title>Bytecode Packages</title>
42
 
<para>
43
 
A bytecode package has all
44
 
its binaries compiled into bytecode. It depends on a package
45
 
containing the OCaml runtime system. By consequence, such a package
46
 
has its architecture field set to <code>all</code>.
47
 
</para>
48
 
 
49
 
<para>
50
 
A bytecode package must depend on
51
 
<filename>ocaml-base-nox-&ocaml-version;</filename> (or
52
 
<filename>ocaml-base-&ocaml-version;</filename> if the program either
53
 
uses the <code>Graphics</code> or the <code>LablTk</code> module). In
54
 
order for the package to be able to be rebuilt or even binNMUed
55
 
without a change in the packaging, <emphasis>this version should not
56
 
be hardcoded in the <filename>debian/control</filename>
57
 
file.</emphasis> Instead, the package should depend on
58
 
<varname>ocaml-base-nox-${F:OCamlABI}</varname> and use <code>OCAMLABI
59
 
:= $(shell ocamlc -version)</code> and <code>dh_gencontrol --
60
 
-VF:OCamlABI="$(OCAMLABI)"</code> in the
61
 
<filename>debian/rules</filename> file.  
62
 
</para>
63
 
 
64
 
<para>
65
 
A bytecode package must build-depend-indep on
66
 
<filename>ocaml-nox-&ocaml-version;</filename> (or
67
 
<filename>ocaml-&ocaml-version;</filename> if the program either uses
68
 
the <code>Graphics</code> or the <code>LablTk</code> module).  The
69
 
current version number of OCaml should <emphasis>not</emphasis> be hardcoded
70
 
into the build-dependency (this is a deviation from a practice which
71
 
used be recommended but is depreciated now). Of course, if it is
72
 
necessary to ensure that the version of OCaml has a certain value then
73
 
version constraints can be used. However, this should be justified by
74
 
the requirements of the compilation of the program.
75
 
</para>
76
 
 
77
 
<para>
78
 
    Bytecode programs which are compiled by <userinput>ocamlc -custom</userinput> must not be stripped. In particular, their package should be excluded from the <command>dh_strip</command> script. When compiled this way, an elf executable is generated containing the ocaml interpreter, and the bytecode of the program in a section which is removed when the program is stripped. For more information, see the bug <ulink url="http://bugs.debian.org/256900">256900</ulink>. An override for the lintian warning is considered as acceptable in this situation.
79
 
</para>
80
 
 
81
 
<para>
82
 
  Bytecode programs should not be compiled for debugging, i.e. they should not
83
 
  be compiled passing the <option>-g</option> option to
84
 
  <command>ocamlc</command> (or <command>ocamlc.opt</command>).
85
 
</para>
86
 
 
87
 
</section>
88
 
 
89
 
<section id="bytecode-native-prog">
90
 
    <title>Bytecode and native versions of programs</title>
91
 
    <para>
92
 
      As explained in <xref linkend='bytecode-native' />, native OCaml compilers are not available everywhere. For architectures missing native compiler, a bytecode version of the program should be provided.
93
 
    </para>
94
 
 
95
 
    <para>
96
 
        The package's <filename>debian/rules</filename> should build the native code executable if supported on the architecture it is built on, and fall back to building the bytecode version if no working native code compiler is available. Exceptions to this are the executables who are small or not time critical, which may be built only as bytecode. It is the decision of the individual maintainers to choose this, maybe guided by the practice of the upstream author.
97
 
    </para>
98
 
 
99
 
    <para>
100
 
      The availability of the native compiler can be tested in the <filename>debian/rules</filename> file by testing the possibility of executing <filename>/usr/bin/ocamlopt</filename>, and build the bytecode version or the native version of the program according to the result of the test. This is a sample snippet of <filename>debian/rules</filename> doing so:
101
 
      <programlisting>
102
 
        build-stamp:
103
 
                dh_testdir
104
 
 
105
 
                if [ -x /usr/bin/ocamlopt ]; then \
106
 
                        $(MAKE) opt; \
107
 
                else \
108
 
                        $(MAKE) all; \
109
 
                fi
110
 
      </programlisting>
111
 
    </para>
112
 
 
113
 
    <para>
114
 
        The bytecode versions are portable. In order to spare the buildds and the Debian archive, bytecode versions should be compiled once for all for big packages (which either take a lot of place on disks or take a lot of time to build). For example, the <filename>spamoracle</filename> package provides the <filename>spamoracle-byte</filename> package which is <varname>Architecture: all</varname> and contains the bytecode version of spamoracle, and the <filename>spamoracle</filename> package which contains the native version of spamoracle and is available only where a native OCaml compiler is available (<varname>Architecture: amd64 i386 kfreebsd-i386 powerpc sparc</varname>).
115
 
    </para>
116
 
 
117
 
    <para>
118
 
        Bytecode versions of the programs should depend on <filename>ocaml-base-nox-&ocaml-version;</filename> (or <filename>ocaml-base-&ocaml-version;</filename> the program either uses the <code>Graphics</code> or the <code>LablTk</code> module). In order for the package to be able to be rebuilt or even binNMUed without a change in the packaging, <emphasis>this version should not be hardcoded in the <filename>debian/control</filename> file.</emphasis> Instead, the package should depend on <varname>ocaml-base-nox-${F:OCamlABI}</varname> and use <code>OCAMLABI := $(shell ocamlc -version)</code> and <code>dh_gencontrol -- -VF:OCamlABI="$(OCAMLABI)"</code> in the <filename>debian/rules</filename> file.
119
 
    </para>
120
 
 
121
 
    <para>The following is a snippet of a sample <filename>debian/control</filename>:
122
 
      <programlisting>
123
 
        Package: spamoracle-byte
124
 
        Architecture: all
125
 
        Depends: ocaml-base-nox-${F:OCamlABI}
126
 
        Provides: spamoracle
127
 
        Conflicts: spamoracle
128
 
        Replaces: spamoracle
129
 
      </programlisting>
130
 
    </para>
131
 
    <para>The following its pairing <filename>debian/rules</filename> snippet:
132
 
      <programlisting>
133
 
        OCAMLABI := $(shell ocamlc -version)
134
 
        ...
135
 
        binary-indep: build install
136
 
        dh_gencontrol -i -- -VF:OCamlABI="$(OCAMLABI)"
137
 
      </programlisting>
138
 
  </para>
139
 
 
140
 
  <para>
141
 
      In the case where there is only one package, which provides either a native version where available or a bytecode version otherwise, the dependency on <varname>ocaml-base-nox-&ocaml-version;</varname> should be added only when the package is built in native mode. For example, the <filename>debian/control</filename> of <filename>approx</filename> contains:
142
 
      <programlisting>
143
 
        Package: approx
144
 
        Architecture: any
145
 
        Depends: ${shlibs:Depends}, ${F:OCamlRun}, adduser, bzip2, curl
146
 
      </programlisting>
147
 
      and the corresponding <filename>debian/rules</filename> contains:
148
 
      <programlisting>
149
 
        OCAMLABI = $(shell ocamlc -version)
150
 
        BYTECODE = $(shell [ -x /usr/bin/ocamlopt ] || echo yes)
151
 
        OCAMLRUN = $(if $(BYTECODE),ocaml-base-nox-$(OCAMLABI))
152
 
        ...
153
 
        binary-arch:
154
 
                ...
155
 
                dh_gencontrol -- -VF:OCamlRun="$(OCAMLRUN)"
156
 
      </programlisting>
157
 
  </para>
158
 
 
159
 
</section>