adding-packages-autotools.txt 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. // -*- mode:doc; -*-
  2. // vim: set syntax=asciidoc:
  3. Infrastructure for autotools-based packages
  4. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. [[autotools-package-tutorial]]
  6. +autotools-package+ tutorial
  7. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  8. First, let's see how to write a +.mk+ file for an autotools-based
  9. package, with an example :
  10. ------------------------
  11. 01: #############################################################
  12. 02: #
  13. 03: # libfoo
  14. 04: #
  15. 05: #############################################################
  16. 06: LIBFOO_VERSION = 1.0
  17. 07: LIBFOO_SOURCE = libfoo-$(LIBFOO_VERSION).tar.gz
  18. 08: LIBFOO_SITE = http://www.foosoftware.org/download
  19. 09: LIBFOO_INSTALL_STAGING = YES
  20. 10: LIBFOO_INSTALL_TARGET = NO
  21. 11: LIBFOO_CONF_OPT = --disable-shared
  22. 12: LIBFOO_DEPENDENCIES = libglib2 host-pkgconf
  23. 13:
  24. 14: $(eval $(autotools-package))
  25. ------------------------
  26. On line 6, we declare the version of the package.
  27. On line 7 and 8, we declare the name of the tarball and the location
  28. of the tarball on the Web. Buildroot will automatically download the
  29. tarball from this location.
  30. On line 9, we tell Buildroot to install the package to the staging
  31. directory. The staging directory, located in +output/staging/+
  32. is the directory where all the packages are installed, including their
  33. development files, etc. By default, packages are not installed to the
  34. staging directory, since usually, only libraries need to be installed in
  35. the staging directory: their development files are needed to compile
  36. other libraries or applications depending on them. Also by default, when
  37. staging installation is enabled, packages are installed in this location
  38. using the +make install+ command.
  39. On line 10, we tell Buildroot to not install the package to the
  40. target directory. This directory contains what will become the root
  41. filesystem running on the target. For purely static libraries, it is
  42. not necessary to install them in the target directory because they will
  43. not be used at runtime. By default, target installation is enabled; setting
  44. this variable to NO is almost never needed. Also by default, packages are
  45. installed in this location using the +make install+ command.
  46. On line 11, we tell Buildroot to pass a custom configure option, that
  47. will be passed to the +./configure+ script before configuring
  48. and building the package.
  49. On line 12, we declare our dependencies, so that they are built
  50. before the build process of our package starts.
  51. Finally, on line line 14, we invoke the +autotools-package+
  52. macro that generates all the Makefile rules that actually allows the
  53. package to be built.
  54. [[autotools-package-reference]]
  55. +autotools-package+ reference
  56. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  57. The main macro of the autotools package infrastructure is
  58. +autotools-package+. It is similar to the +generic-package+ macro. The ability to
  59. have target and host packages is also available, with the
  60. +host-autotools-package+ macro.
  61. Just like the generic infrastructure, the autotools infrastructure
  62. works by defining a number of variables before calling the
  63. +autotools-package+ macro.
  64. First, all the package metadata information variables that exist in the
  65. generic infrastructure also exist in the autotools infrastructure:
  66. +LIBFOO_VERSION+, +LIBFOO_SOURCE+,
  67. +LIBFOO_PATCH+, +LIBFOO_SITE+,
  68. +LIBFOO_SUBDIR+, +LIBFOO_DEPENDENCIES+,
  69. +LIBFOO_INSTALL_STAGING+, +LIBFOO_INSTALL_TARGET+.
  70. A few additional variables, specific to the autotools infrastructure,
  71. can also be defined. Many of them are only useful in very specific
  72. cases, typical packages will therefore only use a few of them.
  73. * +LIBFOO_SUBDIR+ may contain the name of a subdirectory
  74. inside the package that contains the configure script. This is useful,
  75. if for example, the main configure script is not at the root of the
  76. tree extracted by the tarball. If +HOST_LIBFOO_SUBDIR+ is
  77. not specified, it defaults to +LIBFOO_SUBDIR+.
  78. * +LIBFOO_CONF_ENV+, to specify additional environment
  79. variables to pass to the configure script. By default, empty.
  80. * +LIBFOO_CONF_OPT+, to specify additional configure
  81. options to pass to the configure script. By default, empty.
  82. * +LIBFOO_MAKE+, to specify an alternate +make+
  83. command. This is typically useful when parallel make is enabled in
  84. the configuration (using +BR2_JLEVEL+) but that this
  85. feature should be disabled for the given package, for one reason or
  86. another. By default, set to +$(MAKE)+. If parallel building
  87. is not supported by the package, then it should be set to
  88. +LIBFOO_MAKE=$(MAKE1)+.
  89. * +LIBFOO_MAKE_ENV+, to specify additional environment
  90. variables to pass to make in the build step. These are passed before
  91. the +make+ command. By default, empty.
  92. * +LIBFOO_MAKE_OPT+, to specify additional variables to
  93. pass to make in the build step. These are passed after the
  94. +make+ command. By default, empty.
  95. * +LIBFOO_AUTORECONF+, tells whether the package should
  96. be autoreconfigured or not (i.e, if the configure script and
  97. Makefile.in files should be re-generated by re-running autoconf,
  98. automake, libtool, etc.). Valid values are +YES+ and
  99. +NO+. By default, the value is +NO+
  100. * +LIBFOO_AUTORECONF_OPT+ to specify additional options
  101. passed to the 'autoreconf' program if
  102. +LIBFOO_AUTORECONF=YES+. By default, empty.
  103. * +LIBFOO_LIBTOOL_PATCH+ tells whether the Buildroot
  104. patch to fix libtool cross-compilation issues should be applied or
  105. not. Valid values are +YES+ and +NO+. By
  106. default, the value is +YES+
  107. * +LIBFOO_INSTALL_STAGING_OPT+ contains the make options
  108. used to install the package to the staging directory. By default, the
  109. value is +DESTDIR=$(STAGING_DIR) install+, which is
  110. correct for most autotools packages. It is still possible to override
  111. it.
  112. * +LIBFOO_INSTALL_TARGET_OPT+ contains the make options
  113. used to install the package to the target directory. By default, the
  114. value is +DESTDIR=$(TARGET_DIR) install+. The default
  115. value is correct for most autotools packages, but it is still possible
  116. to override it if needed.
  117. * +LIBFOO_CLEAN_OPT+ contains the make options used to
  118. clean the package. By default, the value is +clean+.
  119. * +LIBFOO_UNINSTALL_STAGING_OPT+, contains the make
  120. options used to uninstall the package from the staging directory. By
  121. default, the value is +DESTDIR=$$(STAGING_DIR) uninstall+.
  122. * +LIBFOO_UNINSTALL_TARGET_OPT+, contains the make
  123. options used to uninstall the package from the target directory. By
  124. default, the value is +DESTDIR=$$(TARGET_DIR) uninstall+.
  125. With the autotools infrastructure, all the steps required to build
  126. and install the packages are already defined, and they generally work
  127. well for most autotools-based packages. However, when required, it is
  128. still possible to customize what is done in any particular step:
  129. * By adding a post-operation hook (after extract, patch, configure,
  130. build or install). See the reference documentation of the generic
  131. infrastructure for details.
  132. * By overriding one of the steps. For example, even if the autotools
  133. infrastructure is used, if the package +.mk+ file defines its
  134. own +LIBFOO_CONFIGURE_CMDS+ variable, it will be used
  135. instead of the default autotools one. However, using this method
  136. should be restricted to very specific cases. Do not use it in the
  137. general case.