autotools.bbclass 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. inherit base
  2. def autotools_dep_prepend(d):
  3. import bb;
  4. if bb.data.getVar('INHIBIT_AUTOTOOLS_DEPS', d, 1):
  5. return ''
  6. pn = bb.data.getVar('PN', d, 1)
  7. deps = ''
  8. if pn in ['autoconf-native', 'automake-native']:
  9. return deps
  10. deps += 'autoconf-native automake-native '
  11. if not pn in ['libtool', 'libtool-native', 'libtool-cross']:
  12. deps += 'libtool-native '
  13. return deps + 'gnu-config-native '
  14. EXTRA_OEMAKE = ""
  15. DEPENDS_prepend = "${@autotools_dep_prepend(d)}"
  16. acpaths = "default"
  17. EXTRA_AUTORECONF = "--exclude=autopoint"
  18. def autotools_set_crosscompiling(d):
  19. import bb
  20. if not bb.data.inherits_class('native', d):
  21. return " cross_compiling=yes"
  22. return ""
  23. # EXTRA_OECONF_append = "${@autotools_set_crosscompiling(d)}"
  24. oe_runconf () {
  25. if [ -x ${S}/configure ] ; then
  26. cfgcmd="${S}/configure \
  27. --build=${BUILD_SYS} \
  28. --host=${HOST_SYS} \
  29. --target=${TARGET_SYS} \
  30. --prefix=${prefix} \
  31. --exec_prefix=${exec_prefix} \
  32. --bindir=${bindir} \
  33. --sbindir=${sbindir} \
  34. --libexecdir=${libexecdir} \
  35. --datadir=${datadir} \
  36. --sysconfdir=${sysconfdir} \
  37. --sharedstatedir=${sharedstatedir} \
  38. --localstatedir=${localstatedir} \
  39. --libdir=${libdir} \
  40. --includedir=${includedir} \
  41. --oldincludedir=${oldincludedir} \
  42. --infodir=${infodir} \
  43. --mandir=${mandir} \
  44. ${EXTRA_OECONF} \
  45. $@"
  46. oenote "Running $cfgcmd..."
  47. $cfgcmd || oefatal "oe_runconf failed"
  48. else
  49. oefatal "no configure script found"
  50. fi
  51. }
  52. autotools_do_configure() {
  53. case ${PN} in
  54. autoconf*)
  55. ;;
  56. automake*)
  57. ;;
  58. *)
  59. # WARNING: gross hack follows:
  60. # An autotools built package generally needs these scripts, however only
  61. # automake or libtoolize actually install the current versions of them.
  62. # This is a problem in builds that do not use libtool or automake, in the case
  63. # where we -need- the latest version of these scripts. e.g. running a build
  64. # for a package whose autotools are old, on an x86_64 machine, which the old
  65. # config.sub does not support. Work around this by installing them manually
  66. # regardless.
  67. ( for ac in `find ${S} -name configure.in -o -name configure.ac`; do
  68. rm -f `dirname $ac`/configure
  69. done )
  70. if [ -e ${S}/configure.in -o -e ${S}/configure.ac ]; then
  71. olddir=`pwd`
  72. cd ${S}
  73. if [ x"${acpaths}" = xdefault ]; then
  74. acpaths=
  75. for i in `find ${S} -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \
  76. grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
  77. acpaths="$acpaths -I $i"
  78. done
  79. else
  80. acpaths="${acpaths}"
  81. fi
  82. AUTOV=`automake --version |head -n 1 |sed "s/.* //;s/\.[0-9]\+$//"`
  83. automake --version
  84. echo "AUTOV is $AUTOV"
  85. install -d ${STAGING_DIR}/${HOST_SYS}/share/aclocal
  86. install -d ${STAGING_DIR}/${HOST_SYS}/share/aclocal-$AUTOV
  87. acpaths="$acpaths -I ${STAGING_DIR}/${HOST_SYS}/share/aclocal-$AUTOV -I ${STAGING_DIR}/${HOST_SYS}/share/aclocal"
  88. # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
  89. # like it was auto-generated. Work around this by blowing it away
  90. # by hand, unless the package specifically asked not to run aclocal.
  91. if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
  92. rm -f aclocal.m4
  93. fi
  94. if [ -e configure.in ]; then
  95. CONFIGURE_AC=configure.in
  96. else
  97. CONFIGURE_AC=configure.ac
  98. fi
  99. if grep "^AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
  100. if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then
  101. : do nothing -- we still have an old unmodified configure.ac
  102. else
  103. oenote Executing glib-gettextize --force --copy
  104. echo "no" | glib-gettextize --force --copy
  105. fi
  106. fi
  107. if grep "^AC_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then
  108. oenote Executing intltoolize --copy --force --automake
  109. intltoolize --copy --force --automake
  110. fi
  111. oenote Executing autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
  112. mkdir -p m4
  113. autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || oefatal "autoreconf execution failed."
  114. cd $olddir
  115. fi
  116. ;;
  117. esac
  118. if [ -e ${S}/configure ]; then
  119. oe_runconf
  120. else
  121. oenote "nothing to configure"
  122. fi
  123. }
  124. autotools_do_install() {
  125. oe_runmake 'DESTDIR=${D}' install
  126. }
  127. STAGE_TEMP="${WORKDIR}/temp-staging"
  128. autotools_stage_includes() {
  129. if [ "${INHIBIT_AUTO_STAGE_INCLUDES}" != "1" ]
  130. then
  131. rm -rf ${STAGE_TEMP}
  132. mkdir -p ${STAGE_TEMP}
  133. make DESTDIR="${STAGE_TEMP}" install
  134. cp -pPR ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR}
  135. rm -rf ${STAGE_TEMP}
  136. fi
  137. }
  138. autotools_stage_all() {
  139. if [ "${INHIBIT_AUTO_STAGE}" = "1" ]
  140. then
  141. return
  142. fi
  143. rm -rf ${STAGE_TEMP}
  144. mkdir -p ${STAGE_TEMP}
  145. oe_runmake DESTDIR="${STAGE_TEMP}" install
  146. if [ -d ${STAGE_TEMP}/${includedir} ]; then
  147. cp -fpPR ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR}
  148. fi
  149. if [ -d ${STAGE_TEMP}/${libdir} ]
  150. then
  151. for i in ${STAGE_TEMP}/${libdir}/*.la
  152. do
  153. if [ ! -f "$i" ]; then
  154. cp -fpPR ${STAGE_TEMP}/${libdir}/* ${STAGING_LIBDIR}
  155. break
  156. fi
  157. oe_libinstall -so $(basename $i .la) ${STAGING_LIBDIR}
  158. done
  159. fi
  160. if [ -d ${STAGE_TEMP}/${datadir}/aclocal ]; then
  161. install -d ${STAGING_DATADIR}/aclocal
  162. cp -fpPR ${STAGE_TEMP}/${datadir}/aclocal/* ${STAGING_DATADIR}/aclocal
  163. fi
  164. rm -rf ${STAGE_TEMP}
  165. }
  166. EXPORT_FUNCTIONS do_configure do_install