netsurf.eclass 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. # Copyright 1999-2015 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # @ECLASS: netsurf.eclass
  4. # @MAINTAINER:
  5. # Michael Weber <xmw@gentoo.org>
  6. # @BLURB: Handle buildsystem of www.netsurf-browser.org components
  7. # @DESCRIPTION:
  8. # Handle unpacking and usage of separate buildsystem tarball and manage
  9. # multilib build, static-libs generation and debug building.
  10. #
  11. # Supports PATCHES and DOCS as in base.eclass
  12. case ${EAPI:-0} in
  13. 0|1|2|3|4) die "this eclass doesn't support EAPI<5" ;;
  14. *) ;;
  15. esac
  16. inherit eutils toolchain-funcs multilib-minimal
  17. EXPORT_FUNCTIONS src_prepare src_configure src_compile src_install
  18. # @ECLASS-VARIABLE: NETSURF_BUILDSYSTEM
  19. # @DESCRIPTION:
  20. # Select version of buildsystem tarball to be used along the component
  21. # defaults to buildsystem-1.0
  22. NETSURF_BUILDSYSTEM="${NETSURF_BUILDSYSTEM:-buildsystem-1.0}"
  23. # @ECLASS-VARIABLE: NETSURF_BUILDSYSTEM_SRC_URI
  24. # @DESCRIPTION:
  25. # Download link for NETSURF_BUILDSYSTEM, add to SRC_URI iff set explicitly.
  26. NETSURF_BUILDSYSTEM_SRC_URI="http://download.netsurf-browser.org/libs/releases/${NETSURF_BUILDSYSTEM}.tar.gz -> netsurf-${NETSURF_BUILDSYSTEM}.tar.gz"
  27. # @ECLASS-VARIABLE: NETSURF_COMPONENT_TYPE
  28. # @DESCRIPTION:
  29. # Passed to buildsystem as COMPONENT_TYPE, valid values are
  30. # lib-shared, lib-static and binary. Defaults to "lib-static lib-shared"
  31. NETSURF_COMPONENT_TYPE="${NETSURF_COMPONENT_TYPE:-lib-static lib-shared}"
  32. # @ECLASS-VARIABLE: SRC_URI
  33. # @DESCRIPTION:
  34. # Defaults to http://download.netsurf-browser.org/libs/releases/${P}-src.tar.gz
  35. # and NETSURF_BUILDSYSTEM_SRC_URI.
  36. if [ -z "${SRC_URI}" ] ; then
  37. SRC_URI="http://download.netsurf-browser.org/libs/releases/${P}-src.tar.gz
  38. ${NETSURF_BUILDSYSTEM_SRC_URI}"
  39. fi
  40. IUSE="debug"
  41. if has lib-static ${NETSURF_COMPONENT_TYPE} ; then
  42. IUSE+=" static-libs"
  43. fi
  44. DEPEND="virtual/pkgconfig"
  45. # @FUNCTION: netsurf_src_prepare
  46. # @DESCRIPTION:
  47. # Apply and PATCHES and multilib_copy_sources for in-source build.
  48. netsurf_src_prepare() {
  49. [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
  50. debug-print "$FUNCNAME: applying user patches"
  51. epatch_user
  52. multilib_copy_sources
  53. }
  54. # @ECLASS-VARIABLE: netsurf_makeconf
  55. # @DESCRIPTION:
  56. # Configuration variable bash array to be passed to emake calls.
  57. # Defined at netsurf_src_configure and can be altered afterwards.
  58. # @FUNCTION: netsurf_src_configure
  59. # @DESCRIPTION:
  60. # Setup netsurf_makeconf and run multilib-minimal_src_configure.
  61. # A default multilib_src_configure is provided by this eclass.
  62. netsurf_src_configure() {
  63. netsurf_makeconf=(
  64. NSSHARED=${WORKDIR}/${NETSURF_BUILDSYSTEM}
  65. Q=
  66. HOST_CC="\$(CC)"
  67. CCOPT=
  68. CCNOOPT=
  69. CCDBG=
  70. LDDBG=
  71. AR="$(tc-getAR)"
  72. BUILD=$(usex debug debug release)
  73. PREFIX="${EROOT}"usr
  74. )
  75. multilib-minimal_src_configure
  76. }
  77. multilib_src_configure() {
  78. sed -e "/^INSTALL_ITEMS/s: /lib: /$(get_libdir):g" \
  79. -i Makefile || die
  80. if [ -f ${PN}.pc.in ] ; then
  81. sed -e "/^libdir/s:/lib:/$(get_libdir):g" \
  82. -i ${PN}.pc.in || die
  83. fi
  84. sed -e 's:/bin/which:which:' \
  85. -i ../${NETSURF_BUILDSYSTEM}/makefiles/Makefile.tools || die
  86. }
  87. # @FUNCTION: netsurf_make
  88. # @DESCRIPTION:
  89. # Calls emake with netsurf_makeconf and toolchain CC/LD
  90. # as arguments for every NETSURF_COMPONENT_TYPE if activated.
  91. netsurf_make() {
  92. for COMPONENT_TYPE in ${NETSURF_COMPONENT_TYPE} ; do
  93. if [ "${COMPONENT_TYPE}" == "lib-static" ] ; then
  94. if ! use static-libs ; then
  95. continue
  96. fi
  97. fi
  98. emake CC="$(tc-getCC)" LD="$(tc-getLD)" "${netsurf_makeconf[@]}" \
  99. COMPONENT_TYPE=${COMPONENT_TYPE} LIBDIR="$(get_libdir)" "$@"
  100. done
  101. }
  102. # @FUNCTION: netsurf_src_compile
  103. # @DESCRIPTION:
  104. # Calls multilib-minimal_src_compile and netsurf_make doc if USE=doc.
  105. # A default multilib_src_compile is provided by this eclass.
  106. netsurf_src_compile() {
  107. local problems=$(egrep -Hn -- ' (-O.?|-g)( |$)' \
  108. $(find . -type f -name 'Makefile*'))
  109. if [ -n "${problems}" ] ; then
  110. elog "found bad flags:
  111. ${problems}"
  112. fi
  113. multilib-minimal_src_compile "$@"
  114. if has doc ${USE} ; then
  115. netsurf_make "$@" docs
  116. fi
  117. }
  118. multilib_src_compile() {
  119. netsurf_make "$@"
  120. }
  121. # @FUNCTION: netsurf_src_test
  122. # @DESCRIPTION:
  123. # Calls multilib-minimal_src_test.
  124. # A default multilib_src_test is provided by this eclass.
  125. netsurf_src_test() {
  126. multilib-minimal_src_test "$@"
  127. }
  128. multilib_src_test() {
  129. netsurf_make test "$@"
  130. }
  131. # @FUNCTION: netsurf_src_install
  132. # @DESCRIPTION:
  133. # Calls multilib-minimal_src_install.
  134. # A default multilib_src_test is provided by this eclass.
  135. # A default multilib_src_install is provided by this eclass.
  136. netsurf_src_install() {
  137. multilib-minimal_src_install "$@"
  138. }
  139. multilib_src_install() {
  140. #DEFAULT_ABI may not be the last.
  141. #install to clean dir, rename binaries, move everything back
  142. if [ "${ABI}" == "${DEFAULT_ABI}" ] ; then
  143. netsurf_make DESTDIR="${D}" install "$@"
  144. else
  145. netsurf_make DESTDIR="${D}"${ABI} install "$@"
  146. if [ "${ABI}" != "${DEFAULT_ABI}" ] ; then
  147. find "${D}"${ABI}/usr/bin -type f -exec mv {} {}.${ABI} \;
  148. fi
  149. mv "${D}"${ABI}/* "${D}" || die
  150. rmdir "${D}"${ABI} || die
  151. fi
  152. }