INSTALL 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. -*- Text -*-
  2. This is the GRUB. Welcome.
  3. This file contains instructions for compiling and installing the GRUB.
  4. Where this document refers to packages names, they are named according to the
  5. Debian 11 package repositories. These packages can be found by searching
  6. https://packages.debian.org/.
  7. The Requirements
  8. ================
  9. GRUB depends on some software packages installed into your system. If
  10. you don't have any of them, please obtain and install them before
  11. configuring the GRUB.
  12. * GCC 5.1.0 or later
  13. Experimental support for clang 8.0.0 or later (results in much bigger binaries)
  14. for i386, x86_64, arm (including thumb), arm64, mips(el), powerpc, sparc64
  15. * GNU Make
  16. * GNU Bison 2.3 or later
  17. * GNU gettext
  18. * GNU binutils 2.9.1.0.23 or later
  19. * Flex 2.5.35 or later
  20. * pkg-config
  21. * GNU patch
  22. * Other standard GNU/Unix tools
  23. * a libc with large file support (e.g. glibc 2.1 or later)
  24. On GNU/Linux, you also need:
  25. * libdevmapper 1.02.34 or later (recommended)
  26. For optional grub-emu features, you need:
  27. * SDL (recommended)
  28. * libpciaccess (optional)
  29. To build GRUB's graphical terminal (gfxterm), you need:
  30. * FreeType 2.1.5 or later
  31. * GNU Unifont
  32. To build grub-mkfont the unicode fonts are required (xfonts-unifont package
  33. on Debian).
  34. If you use a development snapshot or want to hack on GRUB you may
  35. need the following.
  36. * Python 3 (NOTE: python 2.6 should still work, but it's not tested)
  37. * Autoconf 2.64 or later
  38. * Automake 1.14 or later
  39. Your distro may package cross-compiling toolchains such as the following
  40. incomplete list on Debian: gcc-aarch64-linux-gnu, gcc-arm-linux-gnueabihf,
  41. gcc-mips-linux-gnu, gcc-mipsel-linux-gnu, gcc-powerpc64-linux-gnu,
  42. gcc-riscv64-linux-gnu, gcc-sparc64-linux-gnu, mingw-w64 and mingw-w64-tools.
  43. More cross compiling toolchains can be found at the following trusted sites:
  44. * https://mirrors.kernel.org/pub/tools/crosstool/
  45. * https://toolchains.bootlin.com/
  46. Prerequisites for make-check:
  47. * qemu, specifically the binary "qemu-system-ARCH" where ARCH is the
  48. architecture GRUB has been built for; the "qemu-system" package on Debian
  49. will install all needed qemu architectures
  50. * OVMF, for EFI platforms (packages ovmf, ovmf-ia32, qemu-efi-arm, and
  51. qemu-efi-aarch64)
  52. * OpenBIOS, for ieee1275 platforms (packages openbios-ppc and openbios-sparc)
  53. * xorriso 1.2.9 or later, for grub-mkrescue and grub-shell
  54. * wamerican, for grub-fs-tester
  55. * mtools, FAT tools for EFI platforms
  56. * xfonts-unifont, for the functional tests
  57. * If running a Linux kernel the following modules must be loaded:
  58. - fuse, loop
  59. - btrfs, erofs, ext4, f2fs, fat, hfs, hfsplus, jfs, mac-roman, minix, nilfs2,
  60. reiserfs, udf, xfs
  61. - On newer kernels, the exfat kernel modules may be used instead of the
  62. exfat FUSE filesystem
  63. * The following are Debian named packages required mostly for the full
  64. suite of filesystem testing (but some are needed by other tests as well):
  65. - btrfs-progs, dosfstools, e2fsprogs, erofs-utils, exfatprogs, exfat-fuse,
  66. f2fs-tools, genromfs, hfsprogs, jfsutils, nilfs-tools, ntfs-3g,
  67. reiserfsprogs, squashfs-tools, reiserfsprogs, udftools, xfsprogs, zfs-fuse
  68. - exfat-fuse, if not using the exfat kernel module
  69. - gzip, lzop, xz-utils
  70. - attr, cpio, g++, gawk, parted, recode, tar, util-linux
  71. Note that `make check' will run and many tests may complete successfully
  72. with only a subset of these prerequisites. However, some tests may be
  73. skipped or fail due to missing prerequisites.
  74. To build the documentation you'll need:
  75. * texinfo, for the info and html documentation
  76. * texlive, for building the dvi and pdf documentation (optional)
  77. To use the gdb_grub GDB script you'll need:
  78. * readelf (binutils package)
  79. * objdump (binutils package)
  80. * GNU Debugger > 7, built with python support (gdb package)
  81. * Python >= 3.5 (python3 package)
  82. Configuring the GRUB
  83. ====================
  84. The `configure' shell script attempts to guess correct values for
  85. various system-dependent variables used during compilation. It uses
  86. those values to create a `Makefile' in each directory of the package.
  87. It may also create one or more `.h' files containing system-dependent
  88. definitions. Finally, it creates a shell script `config.status' that
  89. you can run in the future to recreate the current configuration, a
  90. file `config.cache' that saves the results of its tests to speed up
  91. reconfiguring, and a file `config.log' containing compiler output
  92. (useful mainly for debugging `configure').
  93. If you need to do unusual things to compile the package, please try to
  94. figure out how `configure' could check whether to do them, and mail
  95. diffs or instructions to the address given in the `README' so they can
  96. be considered for the next release. If at some point `config.cache'
  97. contains results you don't want to keep, you may remove or edit it.
  98. The file `configure.ac' is used to create `configure' by a program
  99. called `autoconf'. You only need `configure.in' if you want to change
  100. it or regenerate `configure' using a newer version of `autoconf'.
  101. Building the GRUB
  102. =================
  103. The simplest way to compile this package is:
  104. 1. `cd' to the directory containing the package's source code.
  105. 2. Skip this and following step if you use release tarball and proceed to
  106. step 4. If you want translations type `./linguas.sh'.
  107. 3. Type `./bootstrap'.
  108. The autogen.sh (called by bootstrap) uses python. By default autodetect
  109. it, but it can be overridden by setting the PYTHON variable.
  110. 4. Type `./configure' to configure the package for your system.
  111. If you're using `csh' on an old version of System V, you might
  112. need to type `sh ./configure' instead to prevent `csh' from trying
  113. to execute `configure' itself.
  114. Running `configure' takes awhile. While running, it prints some
  115. messages telling which features it is checking for.
  116. 6. Type `make' to compile the package.
  117. 7. Optionally, type `make check' to run any self-tests that come with
  118. the package. Note that many of the tests require root privileges in
  119. order to run.
  120. 8. Type `make install' to install the programs and any data files and
  121. documentation.
  122. 9. Type `make html' or `make pdf' to generate the html or pdf
  123. documentation. Note, these are not built by default.
  124. 10. You can remove the program binaries and object files from the
  125. source code directory by typing `make clean'. To also remove the
  126. files that `configure' created (so you can compile the package for
  127. a different kind of computer), type `make distclean'. There is
  128. also a `make maintainer-clean' target, but that is intended mainly
  129. for the package's developers. If you use it, you may have to get
  130. all sorts of other programs in order to regenerate files that came
  131. with the distribution.
  132. Cross-compiling the GRUB
  133. ========================
  134. GRUB defines 3 platforms:
  135. - "Build" is the one which build systems runs on.
  136. - "Host" is where you execute GRUB utils.
  137. - "Target" is where GRUB itself runs.
  138. For grub-emu host and target must be the same but may differ from build.
  139. If build and host are different make check isn't available.
  140. If build and host are different man pages are not generated.
  141. As an example imagine you have a build system running on FreeBSD on sparc
  142. which prepares packages for developers running amd64 GNU/Linux laptop and
  143. they need to make images for ARM board running U-boot. In this case:
  144. build=sparc64-freebsd
  145. host=amd64-linux-gnu
  146. target=arm-uboot
  147. For this example the configure line might look like (more details below)
  148. (some options are optional and included here for completeness but some rarely
  149. used options are omitted):
  150. ./configure --build=sparc64-freebsd --host=x86_64-linux-gnu \
  151. --target=arm-linux-gnueabihf --with-platform=efi \
  152. BUILD_CC=gcc BUILD_PKG_CONFIG=pkg-config \
  153. HOST_CC=x86_64-linux-gnu-gcc HOST_CFLAGS='-g -O2' \
  154. PKG_CONFIG=x86_64-linux-gnu-pkg-config TARGET_CC=arm-linux-gnueabihf-gcc \
  155. TARGET_CFLAGS='-Os -march=armv8.3-a' TARGET_CCASFLAGS='-march=armv8.3-a' \
  156. TARGET_OBJCOPY=arm-linux-gnueabihf-objcopy \
  157. TARGET_STRIP=arm-linux-gnueabihf-strip TARGET_NM=arm-linux-gnueabihf-nm \
  158. TARGET_RANLIB=arm-linux-gnueabihf-ranlib LEX=flex
  159. Note, that the autoconf 2.65 manual states that when using the --host argument
  160. to configure, the --build argument should be specified as well. Not sending
  161. --build, enters a compatibility mode that will be removed in the future.
  162. Normally, for building a GRUB on amd64 with tools to run on amd64 to
  163. generate images to run on ARM, using your Linux distribution's
  164. packaged cross compiler, the following would suffice:
  165. ./configure --target=arm-linux-gnueabihf --with-platform=efi
  166. You need to use following options to specify tools and platforms. For minimum
  167. version look at prerequisites. All tools not mentioned in this section under
  168. corresponding platform are not needed for the platform in question.
  169. - For build
  170. 1. --build= to autoconf name of build.
  171. 2. BUILD_CC= to gcc able to compile for build. This is used, for
  172. example, to compile build-gentrigtables which is then run to
  173. generate sin and cos tables.
  174. 3. BUILD_CFLAGS= for C options for build.
  175. 4. BUILD_CPPFLAGS= for C preprocessor options for build.
  176. 5. BUILD_LDFLAGS= for linker options for build.
  177. 6. BUILD_PKG_CONFIG= for pkg-config for build (optional).
  178. - For host
  179. 1. --host= to autoconf name of host.
  180. 2. CC= for gcc able to compile for host.
  181. 3. CFLAGS= for C options for host.
  182. 4. HOST_CC= for gcc able to compile for host.
  183. 5. HOST_CFLAGS= for C options for host.
  184. 6. HOST_CPPFLAGS= for C preprocessor options for host.
  185. 7. HOST_LDFLAGS= for linker options for host.
  186. 8. PKG_CONFIG= for pkg-config for host (optional).
  187. 9. Libdevmapper if any must be in standard linker folders (-ldevmapper) (optional).
  188. 10. Libfuse if any must be in standard linker folders (-lfuse) (optional).
  189. 11. Libzfs if any must be in standard linker folders (-lzfs) (optional).
  190. 12. Liblzma if any must be in standard linker folders (-llzma) (optional).
  191. Note: The HOST_* variables override not prefixed variables.
  192. - For target
  193. 1. --target= to autoconf cpu name of target.
  194. 2. --with-platform to choose firmware.
  195. 3. TARGET_CC= for gcc able to compile for target.
  196. 4. TARGET_CFLAGS= for C options for target.
  197. 5. TARGET_CPPFLAGS= for C preprocessor options for target.
  198. 6. TARGET_CCASFLAGS= for assembler options for target.
  199. 7. TARGET_LDFLAGS= for linker options for target.
  200. 8. TARGET_OBJCOPY= for objcopy for target.
  201. 9. TARGET_STRIP= for strip for target.
  202. 10. TARGET_NM= for nm for target.
  203. 11. TARGET_RANLIB= for ranlib for target.
  204. Note: If the TARGET_* variables are not specified then they will default
  205. to be the same as the host variables. If host variables are not
  206. specified then the TARGET_* variables will default to be the same
  207. as not prefixed variables.
  208. - Additionally for emu, for host and target.
  209. 1. SDL is looked for in standard linker directories (-lSDL) (optional)
  210. 2. libpciaccess is looked for in standard linker directories (-lpciaccess) (optional)
  211. - Platform-agnostic tools and data.
  212. 1. make is the tool you execute after ./configure.
  213. 2. Bison is specified in YACC= variable
  214. 3. Flex is specified in LEX= variable
  215. 4. GNU unifont and Djvu sans are looked for in standard directories.
  216. Compiling For Multiple Architectures
  217. ====================================
  218. You can compile the package for more than one kind of computer at the
  219. same time, by placing the object files for each architecture in their
  220. own directory. `cd' to the directory where you want the object files
  221. and executables to go and run the `configure' script. `configure'
  222. automatically checks for the source code in the directory that
  223. `configure' is in and in `..'.
  224. Installation Names
  225. ==================
  226. By default, `make install' will install the package's files in
  227. `/usr/local/bin', `/usr/local/man', etc. You can specify an
  228. installation prefix by giving `configure' the option `--prefix=PATH'.
  229. You can specify separate installation prefixes for
  230. architecture-specific files and architecture-independent files. If
  231. you give `configure' the option `--exec-prefix=PATH', the package will
  232. use PATH as the prefix for installing programs and libraries.
  233. Documentation and other data files will still use the regular prefix.
  234. In addition, if you use an unusual directory layout you can give
  235. options like `--bindir=PATH' to specify different values for
  236. particular kinds of files. Run `configure --help' for a list of the
  237. directories you can set and what kinds of files go in them.
  238. If the package supports it, you can cause programs to be installed
  239. with an extra prefix or suffix on their names by giving `configure'
  240. the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
  241. Please note, however, that the GRUB knows where it is located in the
  242. filesystem. If you have installed it in an unusual location, the
  243. system might not work properly, or at all. The chief utility of these
  244. options for the GRUB is to allow you to "install" in some alternate
  245. location, and then copy these to the actual root filesystem later.
  246. Sharing Defaults
  247. ================
  248. If you want to set default values for `configure' scripts to share,
  249. you can create a site shell script called `config.site' that gives
  250. default values for variables like `CC', `cache_file', and `prefix'.
  251. `configure' looks for `PREFIX/share/config.site' if it exists, then
  252. `PREFIX/etc/config.site' if it exists. Or, you can set the
  253. `CONFIG_SITE' environment variable to the location of the site script.
  254. A warning: not all `configure' scripts look for a site script.
  255. Operation Controls
  256. ==================
  257. `configure' recognizes the following options to control how it
  258. operates.
  259. `--cache-file=FILE'
  260. Use and save the results of the tests in FILE instead of
  261. `./config.cache'. Set FILE to `/dev/null' to disable caching, for
  262. debugging `configure'.
  263. `--help'
  264. Print a summary of the options to `configure', and exit.
  265. `--quiet'
  266. `--silent'
  267. `-q'
  268. Do not print messages saying which checks are being made.
  269. `--srcdir=DIR'
  270. Look for the package's source code in directory DIR. Usually
  271. `configure' can determine that directory automatically.
  272. `--version'
  273. Print the version of Autoconf used to generate the `configure'
  274. script, and exit.