1// -*- mode:doc; -*- 2// vim: set syntax=asciidoc: 3 4[[hooks]] 5=== Hooks available in the various build steps 6 7The generic infrastructure (and as a result also the derived autotools 8and cmake infrastructures) allow packages to specify hooks. 9These define further actions to perform after existing steps. 10Most hooks aren't really useful for generic packages, since the +.mk+ 11file already has full control over the actions performed in each step 12of the package construction. 13 14The following hook points are available: 15 16* +LIBFOO_PRE_DOWNLOAD_HOOKS+ 17* +LIBFOO_POST_DOWNLOAD_HOOKS+ 18 19* +LIBFOO_PRE_EXTRACT_HOOKS+ 20* +LIBFOO_POST_EXTRACT_HOOKS+ 21 22* +LIBFOO_PRE_RSYNC_HOOKS+ 23* +LIBFOO_POST_RSYNC_HOOKS+ 24 25* +LIBFOO_PRE_PATCH_HOOKS+ 26* +LIBFOO_POST_PATCH_HOOKS+ 27 28* +LIBFOO_PRE_CONFIGURE_HOOKS+ 29* +LIBFOO_POST_CONFIGURE_HOOKS+ 30 31* +LIBFOO_PRE_BUILD_HOOKS+ 32* +LIBFOO_POST_BUILD_HOOKS+ 33 34* +LIBFOO_PRE_INSTALL_HOOKS+ (for host packages only) 35* +LIBFOO_POST_INSTALL_HOOKS+ (for host packages only) 36 37* +LIBFOO_PRE_INSTALL_STAGING_HOOKS+ (for target packages only) 38* +LIBFOO_POST_INSTALL_STAGING_HOOKS+ (for target packages only) 39 40* +LIBFOO_PRE_INSTALL_TARGET_HOOKS+ (for target packages only) 41* +LIBFOO_POST_INSTALL_TARGET_HOOKS+ (for target packages only) 42 43* +LIBFOO_PRE_INSTALL_IMAGES_HOOKS+ 44* +LIBFOO_POST_INSTALL_IMAGES_HOOKS+ 45 46* +LIBFOO_PRE_LEGAL_INFO_HOOKS+ 47* +LIBFOO_POST_LEGAL_INFO_HOOKS+ 48 49These variables are 'lists' of variable names containing actions to be 50performed at this hook point. This allows several hooks to be 51registered at a given hook point. Here is an example: 52 53---------------------- 54define LIBFOO_POST_PATCH_FIXUP 55 action1 56 action2 57endef 58 59LIBFOO_POST_PATCH_HOOKS += LIBFOO_POST_PATCH_FIXUP 60---------------------- 61 62[[hooks-rsync]] 63==== Using the +POST_RSYNC+ hook 64The +POST_RSYNC+ hook is run only for packages that use a local source, 65either through the +local+ site method or the +OVERRIDE_SRCDIR+ 66mechanism. In this case, package sources are copied using +rsync+ from 67the local location into the buildroot build directory. The +rsync+ 68command does not copy all files from the source directory, though. 69Files belonging to a version control system, like the directories 70+.git+, +.hg+, etc. are not copied. For most packages this is 71sufficient, but a given package can perform additional actions using 72the +POST_RSYNC+ hook. 73 74In principle, the hook can contain any command you want. One specific 75use case, though, is the intentional copying of the version control 76directory using +rsync+. The +rsync+ command you use in the hook can, among 77others, use the following variables: 78 79* +$(SRCDIR)+: the path to the overridden source directory 80* +$(@D)+: the path to the build directory 81 82==== Target-finalize hook 83 84Packages may also register hooks in +LIBFOO_TARGET_FINALIZE_HOOKS+. 85These hooks are run after all packages are built, but before the 86filesystem images are generated. They are seldom used, and your 87package probably do not need them. 88