* INSTALL: Document cross-compilation.
[grub.git] / INSTALL
1 -*- Text -*-
2
3 This is the GRUB.  Welcome.
4
5 This file contains instructions for compiling and installing the GRUB.
6
7 The Requirements
8 ================
9
10 GRUB depends on some software packages installed into your system. If
11 you don't have any of them, please obtain and install them before
12 configuring the GRUB.
13
14 * GCC 4.1.3 or later
15 * GNU Make
16 * GNU Bison 2.3 or later
17 * GNU gettext 0.17 or later
18 * GNU binutils 2.9.1.0.23 or later
19 * Flex 2.5.35 or later
20 * Other standard GNU/Unix tools
21
22 On GNU/Linux, you also need:
23
24 * libdevmapper 1.02.34 or later (recommended)
25
26 For optional grub-emu features, you need:
27
28 * SDL (recommended)
29 * libpciaccess (optional)
30 * libusb (optional)
31
32 To build GRUB's graphical terminal (gfxterm), you need:
33
34 * FreeType 2 or later
35 * GNU Unifont
36
37 If you use a development snapshot or want to hack on GRUB you may
38 need the following.
39
40 * Python 2.5.2 or later
41 * Autoconf 2.60 or later
42 * Automake 1.10.1 or later
43 * Autogen 5.10 or later
44
45 Prerequisites for make-check:
46
47 * qemu, specifically the binary 'qemu-system-i386'
48 * xorriso 1.2.9 or later, for grub-mkrescue and grub-shell
49
50 Configuring the GRUB
51 ====================
52
53 The `configure' shell script attempts to guess correct values for
54 various system-dependent variables used during compilation.  It uses
55 those values to create a `Makefile' in each directory of the package.
56 It may also create one or more `.h' files containing system-dependent
57 definitions.  Finally, it creates a shell script `config.status' that
58 you can run in the future to recreate the current configuration, a
59 file `config.cache' that saves the results of its tests to speed up
60 reconfiguring, and a file `config.log' containing compiler output
61 (useful mainly for debugging `configure').
62
63 If you need to do unusual things to compile the package, please try to
64 figure out how `configure' could check whether to do them, and mail
65 diffs or instructions to the address given in the `README' so they can
66 be considered for the next release.  If at some point `config.cache'
67 contains results you don't want to keep, you may remove or edit it.
68
69 The file `configure.ac' is used to create `configure' by a program
70 called `autoconf'.  You only need `configure.in' if you want to change
71 it or regenerate `configure' using a newer version of `autoconf'.
72
73
74 Building the GRUB
75 =================
76
77 The simplest way to compile this package is:
78
79   1. `cd' to the directory containing the package's source code.
80
81   2. Skip this and following step if you use release tarball and proceed to
82      step 4. If you want translations type `./linguas.sh'.
83   
84   3. Type `./autogen.sh'.
85
86   4. Type `./configure' to configure the package for your system.
87      If you're using `csh' on an old version of System V, you might
88      need to type `sh ./configure' instead to prevent `csh' from trying
89      to execute `configure' itself.
90
91      Running `configure' takes awhile.  While running, it prints some
92      messages telling which features it is checking for.
93
94   6. Type `make' to compile the package.
95
96   7. Optionally, type `make check' to run any self-tests that come with
97      the package.
98
99   8. Type `make install' to install the programs and any data files and
100      documentation.
101
102   9. You can remove the program binaries and object files from the
103      source code directory by typing `make clean'.  To also remove the
104      files that `configure' created (so you can compile the package for
105      a different kind of computer), type `make distclean'.  There is
106      also a `make maintainer-clean' target, but that is intended mainly
107      for the package's developers.  If you use it, you may have to get
108      all sorts of other programs in order to regenerate files that came
109      with the distribution.
110
111 Cross-compiling the GRUB
112 ========================
113
114 GRUB defines 3 platforms:
115
116   - "Build" is the one which build systems runs on.
117   - "Host" is where you execute GRUB utils.
118   - "Target" is where GRUB itself runs.
119
120 For grub-emu host and target must be the same but may differ from build.
121
122 If build and host are different make check isn't available.
123
124 As an example imagine you have a build system running on FreeBSD on sparc
125 which prepares packages for developpers running amd64 GNU/Linux laptop and
126 they need to make images for ARM board running U-boot. In this case:
127
128 build=sparc64-freebsd
129 host=amd64-linux-gnu
130 target=arm-uboot
131
132 For this example the configure line might look like (more details below)
133 (some options are optional and included here for completeness but some rarely
134 used options are omited):
135
136 ./configure BUILD_CC=gcc BUILD_FREETYPE=freetype-config --host=amd64-linux-gnu
137 CC=amd64-linux-gnu-gcc CFLAGS="-g -O2" FREETYPE=amd64-linux-gnu-freetype-config
138 --target=arm --with-platform=uboot TARGET_CC=arm-elf-gcc
139 TARGET_CFLAGS="-Os -march=armv6" TARGET_CCASFLAGS="-march=armv6"
140 TARGET_OBJCOPY="arm-elf-objcopy" TARGET_STRIP="arm-elf-strip"
141 TARGET_NM=arm-elf-nm LEX=gflex
142
143 You need to use following options to specify tools and platforms. For minimum
144 version look at prerequisites. All tools not mentioned in this section under
145 corresponding platform are not needed for the platform in question.
146
147   - For build
148     1. BUILD_CC= to gcc able to compile for build. This is used, for
149        example, to compile build-gentrigtables which is then run to
150        generate sin and cos tables.
151     2. BUILD_CFLAGS= for C options for build.
152     3. BUILD_CPPFLAGS= for C preprocessor options for build.
153     4. BUILD_FREETYPE= for freetype-config for build (optional).
154
155   - For host
156     1. --host= to autoconf name of host.
157     2. CC= for gcc able to compile for host
158     3. CFLAGS= for C options for host.
159     4. CPPFLAGS= for C preprocessor options for host.
160     5. LDFLAGS= for linker options for host.
161     6. FREETYPE= for freetype-config for host (optional).
162     7. Libdevmapper if any must be in standard linker folders (-ldevmapper) (optional).
163     8. Libfuse if any must be in standard linker folders (-lfuse) (optional).
164     9. Libzfs if any must be in standard linker folders (-lzfs) (optional).
165     10. Liblzma if any must be in standard linker folders (-llzma) (optional).
166
167   - For target
168     1. --target= to autoconf cpu name of target.
169     2. --with-platform to choose firmware.
170     3. TARGET_CC= for gcc able to compile for target
171     4. TARGET_CFLAGS= for C options for target.
172     5. TARGET_CPPFLAGS= for C preprocessor options for target.
173     6. TARGET_CCASFLAGS= for assembler options for target.
174     7. TARGET_LDFLAGS= for linker options for target.
175     8. TARGET_OBJCOPY= for objcopy for target.
176     9. TARGET_STRIP= for strip for target.
177     10. TARGET_NM= for nm for target.
178
179   - Additionally for emu, for host and target.
180     1. SDL is looked for in stadard linker directories (-lSDL) (optional)
181     2. libpciaccess is looked for in stadard linker directories (-lpciaccess) (optional)
182     3. libusb is looked for in stadard linker directories (-lusb) (optional)
183
184   - Platform-agnostic tools and data.
185     1. make is the tool you execute after ./configure.
186     2. Bison is specified in YACC= variable
187     3. Flex is specified in LEX= variable
188     4. GNU unifont and Djvu sans are looked for in standard directories.
189
190 Compiling For Multiple Architectures
191 ====================================
192
193 You can compile the package for more than one kind of computer at the
194 same time, by placing the object files for each architecture in their
195 own directory.  `cd' to the directory where you want the object files
196 and executables to go and run the `configure' script.  `configure'
197 automatically checks for the source code in the directory that
198 `configure' is in and in `..'.
199
200
201 Installation Names
202 ==================
203
204 By default, `make install' will install the package's files in
205 `/usr/local/bin', `/usr/local/man', etc.  You can specify an
206 installation prefix by giving `configure' the option `--prefix=PATH'.
207
208 You can specify separate installation prefixes for
209 architecture-specific files and architecture-independent files.  If
210 you give `configure' the option `--exec-prefix=PATH', the package will
211 use PATH as the prefix for installing programs and libraries.
212 Documentation and other data files will still use the regular prefix.
213
214 In addition, if you use an unusual directory layout you can give
215 options like `--bindir=PATH' to specify different values for
216 particular kinds of files.  Run `configure --help' for a list of the
217 directories you can set and what kinds of files go in them.
218
219 If the package supports it, you can cause programs to be installed
220 with an extra prefix or suffix on their names by giving `configure'
221 the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
222
223 Please note, however, that the GRUB knows where it is located in the
224 filesystem.  If you have installed it in an unusual location, the
225 system might not work properly, or at all.  The chief utility of these
226 options for the GRUB is to allow you to "install" in some alternate
227 location, and then copy these to the actual root filesystem later.
228
229
230 Sharing Defaults
231 ================
232
233 If you want to set default values for `configure' scripts to share,
234 you can create a site shell script called `config.site' that gives
235 default values for variables like `CC', `cache_file', and `prefix'.
236 `configure' looks for `PREFIX/share/config.site' if it exists, then
237 `PREFIX/etc/config.site' if it exists.  Or, you can set the
238 `CONFIG_SITE' environment variable to the location of the site script.
239 A warning: not all `configure' scripts look for a site script.
240
241
242 Operation Controls
243 ==================
244
245    `configure' recognizes the following options to control how it
246 operates.
247
248 `--cache-file=FILE'
249      Use and save the results of the tests in FILE instead of
250      `./config.cache'.  Set FILE to `/dev/null' to disable caching, for
251      debugging `configure'.
252
253 `--help'
254      Print a summary of the options to `configure', and exit.
255
256 `--quiet'
257 `--silent'
258 `-q'
259      Do not print messages saying which checks are being made.
260
261 `--srcdir=DIR'
262      Look for the package's source code in directory DIR.  Usually
263      `configure' can determine that directory automatically.
264
265 `--version'
266      Print the version of Autoconf used to generate the `configure'
267      script, and exit.