#!/usr/bin/env build build_make_compile_cleanup() { ret=$? if [ ${ret} -ne 0 ]; then echo "error: compile failed for ${CATEGORY}/${NAME}" >&2 echo "logfile: '${PKG_LOGFILE}'" >&2 exit ${ret} fi exit 0 } build_compile() { if [ -f "configure" ]; then ./configure --host="${CHOST}" \ --prefix=/usr \ --sysconfdir=/etc \ --mandir=/usr/share/man \ --docdir=/usr/share/doc \ --disable-dependency-tracking \ --with-sysroot="${SYSROOT}" \ --with-libtool-sysroot="${SYSROOT}" \ ${CONFIG_OPTS} fi make ${MAKE_OPTS} make DESTDIR="${D}" install } pkg_compile() { build_compile; } build_make_compile() {( trap build_make_compile_cleanup 0 load_rules "${1}" # Declare compilation variables before loading the rules as the package # may potentially overwrite this data, in particular the toolchain data # is usually rewritten within the toolchain/buildtools rule. echo "compiling: ${1}" eval "$(build-query --toolchain "${CHOST}")" mkenv "compile" PKG_LOGFILE="${L}/compile.log" build uninstall "${1}" >> "${PKG_LOGFILE}" # pkgconfig can be a right pita... PKG_CONFIG_LIBDIR="${SYSROOT}/usr/share/pkgconfig:${SYSROOT}/usr/lib/pkgconfig" PKG_CONFIG_SYSROOT_DIR="${SYSROOT}" export PKG_CONFIG_LIBDIR PKG_CONFIG_PATH export PKG_CONFIG_SYSROOT_DIR # Don't pass along the builder jobcontrol data to child processes unset MAKEFLAGS load_rules "${1}" ## Build the source and install it into the DESTDIR # Ironically this is the heart of what the build-engine does, and yet it has # been reduced to the simplest component of the entire system. cd "${S}" echo '## environ: pkg_compile()' >> "${PKG_LOGFILE}" env >> "${PKG_LOGFILE}" echo '## environ: end ' >> "${PKG_LOGFILE}" pkg_compile >> "${PKG_LOGFILE}" 2>&1 ## Save Space! # At this point everything important should be installed into ${D}, and # any form of reruning the build will remove ${W} before prepping it # for build, so we might as well gut it now. About the best option we # could do would be to avoid gutting this when being run in --debug # mode. if test "${BUILDER_DEBUG:-0}" -eq '0'; then find "${W}" -delete & fi ## # Generate the file index. This is done as a 0 delimited file stored # within the destination filesystem. This allows for easy checking of # the installed data as well as easy removal of individual binary # packages from the sysroot. mkdir -p "${D}/var/db/binpkgs/${CATEGORY}" binpkg_list="$(mktemp "${T}/binpkg.XXXXXXXX")" if [ ! -e "${binpkg_list}" ]; then die "failed to create package inventory" fi cd "${D}" for dir in man usr/man usr/share/man; do test -d "${dir}" || continue for file in `find "${dir}" -regex '.*[1-9]$'`; do if test -f "${file}"; then gzip -c -9 "${file}" > "${file}.gz" && rm "${file}" elif test -h "${file}"; then mv "${file}" "${file}.gz" fi done wait done wait find * -depth \( ! -type d \) -print0 > "${binpkg_list}" mv "${binpkg_list}" "${D}/var/db/binpkgs/${CATEGORY}/${NAME}" date >> "${BUILDER_TMPDIR}/${CATEGORY}/${NAME}/.compile" )} if test "${BUILDER_CALL_STACK}" = '__main__'; then simple_usage 'compile' '[all|[/]]' "$@" build_make_compile "${@}" fi # vim: filetype=sh