]> git.sesse.net Git - vlc/blob - contrib/src/README
contribs: update documentation
[vlc] / contrib / src / README
1 Writing rules
2 ==============
3
4 At the bare minimum, a package in contrib must provide two Makefile
5 targets in src/foo/rules.mak:
6  - .foo to build and install the package, and
7  - .sum-foo to fetch or create a source tarball and verify it,
8 where foo the package name.
9
10
11 Tarball
12 --------
13
14 .sum-foo typically depends on a separate target that fetches the source
15 code. In that case, .sum-foo needs only verify that the tarball
16 is correct, e.g.:
17
18
19         $(TARBALLS)/libfoo-$(FOO_VERSION).tar.bz2:
20                 $(WGET) $(FOO_URL)
21
22         # This will use the default rule: check SHA-512
23         .sum-foo: libfoo-$(FOO_VERSION).tar.bz2
24
25 NOTE: contrary to the previous VLC contribs, this system always uses
26 a source tarball, even if the source code is downloaded from a VCS.
27 This serves two purposes:
28  - offline builds (or behind a firewall),
29  - source code requirements compliance.
30
31
32 Compilation
33 ------------
34
35 Similarly, .foo typically depends on the source code directory. In this
36 case, care must be taken that the directory name only exists if the
37 source code is fully ready. Otherwise Makefile dependencies will break
38 (this is not an issue for files, only directories).
39
40         libfoo: libfoo-$(FOO_VERSION).tar.bz2 .sum-foo
41                 $(UNPACK) # to libfoo-$(FOO_VERSION)
42                 ### apply patches here ###
43                 # last command: make the target directory
44                 mv libfoo-$(FOO_VERSION) libfoo
45
46         .foo: libfoo
47                 cd $< && $(HOSTVARS) ./configure $(HOSTCONF)
48                 cd $< && $(MAKE) install
49                 touch $@
50
51
52 Dependencies
53 -------------
54
55 If package bar depends on package foo, a Makefile dependency can ensure
56 that bar will be built after foo. It will also ensure that foo will be
57 built even if it was not selected explicitly in the $(PKGS) variable:
58
59         .bar: libbar .foo
60                 cd $< && $(HOSTVARS) ./configure $(HOSTCONF)
61                 cd $< && $(MAKE) install
62                 touch $@
63
64
65 Conditional builds
66 -------------------
67
68 Some packages may be provided by the target system. This is especially
69 common when building natively on Linux or BSD. A dummy build rule can
70 be used conditionally.
71
72         NEED_FOO := $(call need_pkg,'foo >= 1.2.3')
73
74         ifeq ($(NEED_FOO),)
75         .foo:
76         else
77         .foo: libfoo
78                 ### foo compilation rules here ###
79         endif
80                 touch $@
81
82 If pkg-config finds foo.pc with version 1.2.3 or larger, this will be
83 equivalent to:
84
85         .foo: ; touch .foo
86
87 Note: The need_pkg function always return 1 during cross-compilation.