]> git.sesse.net Git - vlc/blob - contrib/src/README
Use a subfolder for the contribs prebuilt...
[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                 $(call download,$(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                 $(MOVE)
45
46         .foo: libfoo
47                 cd $< && $(HOSTVARS) ./configure $(HOSTCONF)
48                 cd $< && $(MAKE) install
49                 touch $@
50
51 Conditional builds
52 -------------------
53
54 As far as possible, build rules should determine automatically whether
55 a package is useful (for VLC media player) or not. Useful packages
56 should be listed in the PKGS special variable. See some examples:
57
58         # FFmpeg is always useful
59         PKGS += ffmpeg
60
61         # DirectX headers are useful only on Windows
62         ifdef HAVE_WIN32
63         PKGS += directx
64         endif
65
66         # x264 is only useful when stream output is enabled
67         ifdef BUILD_ENCODERS
68         PKGS += x264
69         endif
70
71 Some packages may be provided by the target system. This is especially
72 common when building natively on Linux or BSD. When this situation is
73 detected, the package name should be added to the PKGS_FOUND special
74 variable. The build system will then skip building this package:
75
76         # Asks pkg-config if foo version 1.2.3 or later is present:
77         ifeq ($(call need_pkg,'foo >= 1.2.3'),)
78         PKGS_FOUND += foo
79         endif
80
81 Note: The need_pkg function always return 1 during cross-compilation.
82 This is a bug.
83
84
85 Dependencies
86 -------------
87
88 If package bar depends on package foo, the special DEPS_bar variable
89 should be defined as follow:
90
91         DEPS_bar = foo $(DEPS_foo)
92
93 Note that dependency resolution is unfortunately _not_ recursive.
94 Therefore $(DEPS_foo) really should be specified explicitly as shown
95 above. (In practice, this will not make any difference insofar as there
96 are no pure second-level nested dependencies. For instance, libass
97 depends on FontConfig, which depends on FreeType, but libass depends
98 directly on FreeType anyway.)
99
100 Also note that DEPS_bar is set "recursively" with =, rather than
101 "immediately" with :=. This is so that $(DEPS_foo) is expanded
102 correctly, even if DEPS_foo it is defined after DEPS_bar.
103
104 Implementation note:
105
106         If you must know, the main.mak build hackery will automatically
107         emit a dependency from .bar onto .dep-foo:
108
109                 .bar: .dep-foo
110
111         ...whereby .dep-foo will depend on .foo:
112
113                 .dep-foo: .foo
114                         touch $@
115
116         ...unless foo was detected in the target distribution:
117
118                 .dep-foo:
119                         touch $@
120
121         So you really only need to set DEPS_bar.