bsdmk.eclass 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # Copyright 1999-2011 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # @ECLASS: bsdmk.eclass
  4. # @MAINTAINER:
  5. # maintainer-needed@gentoo.org
  6. # @BLURB: Some functions for BSDmake
  7. inherit toolchain-funcs portability flag-o-matic
  8. EXPORT_FUNCTIONS src_compile src_install
  9. RDEPEND=""
  10. # this should actually be BDEPEND, but this works.
  11. DEPEND="virtual/pmake"
  12. ESED="/usr/bin/sed"
  13. # @ECLASS-VARIABLE: mymakeopts
  14. # @DESCRIPTION:
  15. # Options for bsd-make
  16. # @FUNCTION: append-opt
  17. # @USAGE: < options >
  18. # @DESCRIPTION:
  19. # append options to enable or disable features
  20. append-opt() {
  21. mymakeopts="${mymakeopts} $@"
  22. }
  23. # @FUNCTION: mkmake
  24. # @USAGE: [ options ]
  25. # @DESCRIPTION:
  26. # calls bsd-make command with the given options, passing ${mymakeopts} to
  27. # enable ports to useflags bridge.
  28. mkmake() {
  29. [[ -z ${BMAKE} ]] && BMAKE="$(get_bmake)"
  30. tc-export CC CXX LD RANLIB
  31. ${BMAKE} ${MAKEOPTS} ${EXTRA_EMAKE} ${mymakeopts} NO_WERROR= STRIP= "$@"
  32. }
  33. # @FUNCTION: mkinstall
  34. # @USAGE: [ options ]
  35. # @DESCRIPTION:
  36. # Calls "bsd-make install" with the given options, passing ${mamakeopts} to
  37. # enable ports to useflags bridge
  38. mkinstall() {
  39. [[ -z ${BMAKE} ]] && BMAKE="$(get_bmake)"
  40. # STRIP= will replace the default value of -s, leaving to portage the
  41. # task of stripping executables.
  42. ${BMAKE} ${mymakeopts} NO_WERROR= STRIP= MANSUBDIR= DESTDIR="${D}" "$@" install
  43. }
  44. # @FUNCTION: dummy_mk
  45. # @USAGE: < dirnames >
  46. # @DESCRIPTION:
  47. # removes the specified subdirectories and creates a dummy makefile in them
  48. # useful to remove the need for "minimal" patches
  49. dummy_mk() {
  50. for dir in $@; do
  51. [ -d ${dir} ] || ewarn "dummy_mk called on a non-existing directory: $dir"
  52. [ -f ${dir}/Makefile ] || ewarn "dummy_mk called on a directory without Makefile: $dir"
  53. echo ".include <bsd.lib.mk>" > ${dir}/Makefile
  54. done
  55. }
  56. # @FUNCTION: bsdmk_src_compile
  57. # @DESCRIPTION:
  58. # The bsdmk src_compile function, which is exported
  59. bsdmk_src_compile() {
  60. mkmake "$@" || die "make failed"
  61. }
  62. # @FUNCTION: bsdmk_src_install
  63. # @DESCRIPTION:
  64. # The bsdmk src_install function, which is exported
  65. bsdmk_src_install() {
  66. mkinstall "$@" || die "install failed"
  67. }