Debian Codegraph @

contrib/depends/packages.md

raw symbols SCIP
1 Each recipe consists of 3 main parts: defining identifiers, setting build
2 variables, and defining build commands.
3
4 The package "mylib" will be used here as an example
5
6 General tips:
7 - mylib_foo is written as $(package)_foo in order to make recipes more similar.
8
9 ## Identifiers
10 Each package is required to define at least these variables:
11
12 ```
13 $(package)_version:
14 Version of the upstream library or program. If there is no version, a
15 placeholder such as 1.0 can be used.
16
17 $(package)_download_path:
18 Location of the upstream source, without the file-name. Usually http or
19 ftp.
20
21 $(package)_file_name:
22 The upstream source filename available at the download path.
23
24 $(package)_sha256_hash:
25 The sha256 hash of the upstream file
26 ```
27
28 These variables are optional:
29
30 ```
31 $(package)_build_subdir:
32 cd to this dir before running configure/build/stage commands.
33
34 $(package)_download_file:
35 The file-name of the upstream source if it differs from how it should be
36 stored locally. This can be used to avoid storing file-names with strange
37 characters.
38
39 $(package)_dependencies:
40 Names of any other packages that this one depends on.
41
42 $(package)_patches:
43 Filenames of any patches needed to build the package
44
45 $(package)_extra_sources:
46 Any extra files that will be fetched via $(package)_fetch_cmds. These are
47 specified so that they can be fetched and verified via 'make download'.
48 ```
49
50
51 ## Build Variables:
52 After defining the main identifiers, build variables may be added or customized
53 before running the build commands. They should be added to a function called
54 $(package)_set_vars. For example:
55
56 ```
57 define $(package)_set_vars
58 ...
59 endef
60 ```
61
62 Most variables can be prefixed with the host, architecture, or both, to make
63 the modifications specific to that case. For example:
64
65 ```
66 Universal: $(package)_cc=gcc
67 Linux only: $(package)_linux_cc=gcc
68 x86_64 only: $(package)_x86_64_cc = gcc
69 x86_64 linux only: $(package)_x86_64_linux_cc = gcc
70 ```
71
72 These variables may be set to override or append their default values.
73
74 ```
75 $(package)_cc
76 $(package)_cxx
77 $(package)_objc
78 $(package)_objcxx
79 $(package)_ar
80 $(package)_ranlib
81 $(package)_libtool
82 $(package)_nm
83 $(package)_cflags
84 $(package)_cxxflags
85 $(package)_ldflags
86 $(package)_cppflags
87 $(package)_config_env
88 $(package)_build_env
89 $(package)_stage_env
90 $(package)_build_opts
91 $(package)_config_opts
92 ```
93
94 The `*_env` variables are used to add environment variables to the respective
95 commands.
96
97 Many variables respect a debug/release suffix as well, in order to use them for
98 only the appropriate build config. For example:
99
100 ```
101 $(package)_cflags_release = -O3
102 $(package)_cflags_i686_debug = -g
103 $(package)_config_opts_release = --disable-debug
104 ```
105
106 These will be used in addition to the options that do not specify
107 debug/release. All builds are considered to be release unless DEBUG=1 is set by
108 the user. Other variables may be defined as needed.
109
110 ## Build commands:
111
112 For each build, a unique build dir and staging dir are created. For example,
113 `work/build/mylib/1.0-1adac830f6e` and `work/staging/mylib/1.0-1adac830f6e`.
114
115 The following build commands are available for each recipe:
116
117 ```
118 $(package)_fetch_cmds:
119 Runs from: build dir
120 Fetch the source file. If undefined, it will be fetched and verified
121 against its hash.
122
123 $(package)_extract_cmds:
124 Runs from: build dir
125 Verify the source file against its hash and extract it. If undefined, the
126 source is assumed to be a tarball.
127
128 $(package)_preprocess_cmds:
129 Runs from: build dir/$(package)_build_subdir
130 Preprocess the source as necessary. If undefined, does nothing.
131
132 $(package)_config_cmds:
133 Runs from: build dir/$(package)_build_subdir
134 Configure the source. If undefined, does nothing.
135
136 $(package)_build_cmds:
137 Runs from: build dir/$(package)_build_subdir
138 Build the source. If undefined, does nothing.
139
140 $(package)_stage_cmds:
141 Runs from: build dir/$(package)_build_subdir
142 Stage the build results. If undefined, does nothing.
143 ```
144
145 The following variables are available for each recipe:
146
147 ```
148 $(1)_staging_dir: package's destination sysroot path
149 $(1)_staging_prefix_dir: prefix path inside of the package's staging dir
150 $(1)_extract_dir: path to the package's extracted sources
151 $(1)_build_dir: path where configure/build/stage commands will be run
152 $(1)_patch_dir: path where the package's patches (if any) are found
153 ```
154
155 Notes on build commands:
156
157 For packages built with autotools, `$($(package)_autoconf)` can be used in the
158 configure step to (usually) correctly configure automatically. Any
159 `$($(package)_config_opts`) will be appended.
160
161 Most autotools projects can be properly staged using:
162
163 ```bash
164 $(MAKE) DESTDIR=$($(package)_staging_dir) install
165 ```