adding-packages-auto.txt 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // -*- mode:doc; -*-
  2. // vim: set syntax=asciidoc:
  3. Infrastructure for autotools-based packages
  4. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. [[auto-package-tutorial]]
  6. First, let's see how to write a +Makefile+ file for an autotools-based
  7. package, with an example:
  8. ------------------------
  9. 01: # This file is part of the OpenADK project. OpenADK is copyrighted
  10. 02: # material, please see the LICENCE file in the top-level directory.
  11. 03:
  12. 04: include ${TOPDIR}/rules.mk
  13. 05:
  14. 06: PKG_NAME:= libfoo
  15. 07: PKG_VERSION:= 1.0
  16. 08: PKG_RELEASE:= 1
  17. 09: PKG_MD5SUM:= ba526cd8f4403a5d351a9efaa8608fbc
  18. 10: PKG_DESCR:= foo library
  19. 11: PKG_SECTION:= libs
  20. 12: PKG_BUILDDEP:= openssl
  21. 13: PKG_DEPENDS:= libopenssl
  22. 14: PKG_URL:= http://www.libfoo.org/
  23. 15: PKG_SITES:= http://downloads.libfoo.org/
  24. 16:
  25. 17: include ${TOPDIR}/mk/package.mk
  26. 18:
  27. 19: $(eval $(call PKG_template,LIBFOO,libfoo,${PKG_VERSION}-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION}))
  28. 20:
  29. 21: libfoo-install:
  30. 22: ${INSTALL_DIR} ${IDIR_LIBFOO}/usr/lib
  31. 23: ${CP} ${WRKINST}/usr/lib/libfoo.so* ${IDIR_LIBFOO}/usr/lib
  32. 24:
  33. 25: include ${TOPDIR}/mk/pkg-bottom.mk
  34. ------------------------
  35. The Makefile begins with line 4 with the inclusion of the top level rules.mk
  36. file. After that the Makefile starts on line 6 to 15 with metadata
  37. information: the name of the package (+PKG_NAME+), the version of the package
  38. (+PKG_VERSION+), the release number of the package (+PKG_RELEASE+), which is
  39. used in OpenADK to mark any package updates, the md5 hash of the source archive
  40. (+PKG_MD5SUM+), the short one line description for the package (+PKG_DESCR+),
  41. the package section for the menu configuration system (+PKG_SECTION+), the
  42. package buildtime dependencies (+PKG_BUILDDEP+), the package runtime
  43. dependencies (+PKG_DEPENDS+), the package homepage (+PKG_URL+) and finally the
  44. internet locations at which the tarball can be downloaded from (+PKG_SITES+).
  45. Normally ${PKG_NAME}-${PKG_VERSION}.tar.gz will be downloaded. You can
  46. overwrite the default via the +DISTFILES+ variable. You can add more then one
  47. archive name in +DISTFILES+ via space separated. If you have no source archive
  48. at all, just use the boolean variable +NO_DISTFILES+ and set it to 1.
  49. On line 17 the +mk/package.mk+ file is included, which contains the PKG_template
  50. function, which is used in line 19.
  51. On line 21-23 we install the shared library into the package installation
  52. directory, which is used to create the resulting binary package or tar archive
  53. for the target.
  54. On line 25 we include +mk/pkg-bottom.mk+, which includes common functions used
  55. by the package fetching and building process.
  56. With the autotools infrastructure, all the steps required to build
  57. and install the packages are already defined, and they generally work
  58. well for most autotools-based packages. However, when required, it is
  59. still possible to customize what is done in any particular step.
  60. By adding a post-operation hook (after extract, patch, configure,
  61. build or install). See xref:hooks[] for details.