diff options
Diffstat (limited to 'pkg.build')
-rw-r--r-- | pkg.build | 248 |
1 files changed, 146 insertions, 102 deletions
@@ -1,5 +1,5 @@ # -# . ./build.vars and set -o errexit are assumed. +# . ./build.vars and set -o errexit -o noglob are assumed. # parse_with_pkg_name ${SCRIPT_FNAME%[0-9][0-9]*} ${2} ${PKG_BUILD_NAMES}; @@ -21,22 +21,22 @@ elif [ "${PKG_URL_TYPE:-wget}" = wget ] &&\ ! is_build_script_done extract; then rm_if_exists ${PKG_SUBDIR}; if [ ${PKG_SUBDIR_CREATE:-0} -eq 1 ]; then - mkdir ${PKG_SUBDIR}; + mkdir -- ${PKG_SUBDIR}; fi; if [ "${PKG_FNAME##*.tar.}" = "bz2" ]; then - bunzip2 -d < ${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -; + bunzip2 -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -; elif [ "${PKG_FNAME##*.tar.}" = "gz" ]; then - gunzip -d < ${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -; + gunzip -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -; elif [ "${PKG_FNAME##*.tar.}" = "xz" ]; then - xz -d < ${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -; + xz -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -; elif [ "${PKG_FNAME##*.t}" = "bz2" ]; then - bunzip2 -d < ${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -; + bunzip2 -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -; elif [ "${PKG_FNAME##*.t}" = "gz" ]; then - gunzip -d < ${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -; + gunzip -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -; elif [ "${PKG_FNAME##*.t}" = "xz" ]; then - xz -d < ${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -; + xz -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -; else - tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf ${PKG_FNAME}; + tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf ${DLCACHEDIR}/${PKG_FNAME}; fi; if test_cmd pkg_${PKG_NAME}_extract_post; then pkg_${PKG_NAME}_extract_post; @@ -51,71 +51,87 @@ if ! is_build_script_done build_dir; then rm_if_exists -m ${PKG_BUILD_DIR}; set_build_script_done build_dir -patch; fi; -if ! is_build_script_done patch; then - if [ ${PKG_CONFIG_SUB_INSTALL:-0} -eq 1 ]; then - find ${PKG_SUBDIR} -name config.sub \ - -exec mv {} {}.orig \; \ - -exec install -m 0700 ${MIDIPIX_BUILD_PWD}/config.sub {} \;; - fi; - if [ ${PKG_AUTOGEN:-0} -eq 1 ]; then - if [ -d ${PKG_SUBDIR}/build-aux ]; then - install -m 0700 ${MIDIPIX_BUILD_PWD}/config.sub \ - ${PKG_SUBDIR}/build-aux; - fi; +if [ -e ${PKG_SUBDIR}/configure -o \ + -e ${PKG_SUBDIR}/configure.ac -o \ + -e ${PKG_SUBDIR}/configure.in -o \ + -e ${PKG_SUBDIR}/config.guess ] \ +&& ! is_build_script_done autoconf; then + find ${PKG_SUBDIR} -name config.sub \ + -exec echo mv -- {} {}.orig \; \ + -exec mv -- {} {}.orig \; \ + -exec echo install -m 0700 ${MIDIPIX_BUILD_PWD}/config.sub {} \; \ + -exec install -m 0700 ${MIDIPIX_BUILD_PWD}/config.sub {} \;; + if [ -e ${PKG_SUBDIR}/configure.ac -a \ + ! -e ${PKG_SUBDIR}/configure ]; then if [ -x ${PKG_SUBDIR}/autogen.sh ]; then + if [ ! -e ${PKG_SUBDIR}/build-aux/config.sub ]; then + echo install -m 0700 ${MIDIPIX_BUILD_PWD}/config.sub \ + ${PKG_SUBDIR}/build-aux/config.sub; + install -m 0700 ${MIDIPIX_BUILD_PWD}/config.sub \ + ${PKG_SUBDIR}/build-aux/config.sub; + fi; (cd ${PKG_SUBDIR} && ./autogen.sh) || exit 1; - fi; - elif [ ${PKG_AUTOCONF:-0} -eq 1 ]; then - if [ -d ${PKG_SUBDIR}/build-aux ]; then - install -m 0700 ${MIDIPIX_BUILD_PWD}/config.sub \ - ${PKG_SUBDIR}/build-aux; - fi; - if [ -r ${PKG_SUBDIR}/configure.ac ]; then + else (cd ${PKG_SUBDIR} && autoconf) || exit 1; fi; fi; - for PATCH_FNAME in \ + for __ in ${PKG_BUILD_DIR} ${PKG_CONFIG_CACHE_EXTRA}; do + echo cp -- ${MIDIPIX_BUILD_PWD}/config.cache ${__}/; + cp -- ${MIDIPIX_BUILD_PWD}/config.cache ${__}/; + done; + set_build_script_done autoconf -patch; +fi; +if ! is_build_script_done patch; then + for __patch_fname in \ ${MIDIPIX_BUILD_PWD}/${PKG_SUBDIR}.local.patch \ ${MIDIPIX_BUILD_PWD}/${PKG_SUBDIR}.local@${BUILD_HNAME}.patch \ ${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}.local.patch \ ${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}.local@${BUILD_HNAME}.patch; do - [ -r "${PATCH_FNAME}" ] &&\ - patch -b -d ${PKG_SUBDIR} -p1 < ${PATCH_FNAME}; - done; unset PATCH_FNAME; + if [ -r "${__patch_fname}" ]; then + patch -b -d ${PKG_SUBDIR} -p1 < ${__patch_fname}; + fi; + done; unset __patch_fname; if [ -n "${PKG_PATCHES_EXTRA_URL}" ]; then - apply_patches ${PKG_PATCHES_EXTRA_URL} ${PKG_SUBDIR}; + (rm_if_exists -m -c ${PKG_SUBDIR}-patches-extra; + wget -c -nd -np -r -R \*.htm\* -R \*.sig ${PKG_PATCHES_EXTRA_URL}; + for __patch_fname in \ + $(find . -type f -not -iname \*.sig | sort); do + patch -b -d ../${PKG_SUBDIR} -p0 < ${__patch_fname}; + done); if [ -n "${PKG_PATCHES_EXTRA_MANIFEST}" ]; then - compare_hash_manifest ${PKG_PATCHES_EXTRA_MANIFEST}; - fi; - fi; - [ -x ${PKG_SUBDIR}/configure ] && \ - cp ${MIDIPIX_BUILD_PWD}/config.cache ${PKG_BUILD_DIR}/; - if [ ${PKG_LIBTOOL_MIDIPIX:-0} -eq 1 ]; then - cp ${MIDIPIX_BUILD_PWD}/libtool.midipix ${PKG_SUBDIR}/; - sed -i.orig -e "/^libdir=/s/libdir='/libdir='\$PKG_PREFIX\//"\ - ${PKG_SUBDIR}/libtool.midipix; - if [ ${PKG_LIBTOOL_MIDIPIX_FIX:-0} -eq 1 ]; then - sed -i.orig.orig \ - -e '/^\s\+test \"\$inst_prefix_dir\" = \"\$destdir\" && \\$/{s/^/#/;n;s/^/#/}' \ - ${PKG_SUBDIR}/libtool.midipix; + (set -- ${PKG_PATCHES_EXTRA_MANIFEST}; + while [ ${#} -gt 0 ]; do + if ! compare_hash ${1} ${2}; then + log_msg failexit "Error: hash mismatch for patch file \`${1}'."; + fi; shift; + done); fi; fi; set_build_script_done patch -configure; fi; cd ${PKG_BUILD_DIR}; +if [ "${PKG_BUILD_TYPE}" = "host" ]; then + export AR=ar; + export CC=gcc; + export RANLIB=ranlib; +else + export AR=${PKG_TARGET}-ar; + export CC=${PKG_TARGET}-gcc; + export RANLIB=${PKG_TARGET}-ranlib; +fi; if [ -x ../${PKG_SUBDIR}/configure ]\ && ! is_build_script_done configure; then if test_cmd pkg_${PKG_NAME}_configure_pre; then pkg_${PKG_NAME}_configure_pre; fi; - AR="${PKG_AR_CONFIGURE}" CC="${PKG_CC_CONFIGURE}"\ CFLAGS="${PKG_CFLAGS_CONFIGURE}${PKG_CFLAGS_CONFIGURE_EXTRA:+ ${PKG_CFLAGS_CONFIGURE_EXTRA}}"\ LDFLAGS="${PKG_LDFLAGS_CONFIGURE}${PKG_LDFLAGS_CONFIGURE_EXTRA:+ ${PKG_LDFLAGS_CONFIGURE_EXTRA}}"\ - ../${PKG_SUBDIR}/configure \ + ../${PKG_SUBDIR}/configure \ ${PKG_CONFIGURE_ARGS} ${PKG_CONFIGURE_ARGS_EXTRA}; set_build_script_done configure clean -build; else - set_build_script_done clean; + __no_autoconf=1; + set_build_script_done clean -build; fi; if [ ${PKG_NO_CLEAN:-0} -eq 0 ]\ && ! is_build_script_done clean; then @@ -125,20 +141,24 @@ fi; if ! is_build_script_done build; then if test_cmd pkg_${PKG_NAME}_build; then pkg_${PKG_NAME}_build; + elif [ -n "${PKG_BUILD_CMDLINE}" ]; then + ${PKG_BUILD_CMDLINE}; else - if [ "${PKG_SLIBTOOL}" != "none" ]; then + if [ "${PKG_SLIBTOOL}" != "default" ]; then export MAKE="make LIBTOOL=${PKG_SLIBTOOL:-slibtool}"; fi; - run_cmd_unsplit make \ - ${PKG_MAKEFLAGS_BUILD} \ - ${PKG_MAKEFLAGS_BUILD_EXTRA} \ - "${PKG_AR_BUILD:+AR=${PKG_AR_BUILD}}" \ - "${PKG_CC_BUILD:+CC=${PKG_CC_BUILD}}" \ - "${PKG_CFLAGS_BUILD:+CFLAGS=${PKG_CFLAGS_BUILD}}"\ - "${PKG_CFLAGS_BUILD_EXTRA:+CFLAGS+=${PKG_CFLAGS_BUILD_EXTRA}}"\ - "${PKG_LDFLAGS_BUILD:+LDFLAGS=${PKG_LDFLAGS_BUILD}}"\ - "${PKG_LDFLAGS_BUILD_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_BUILD_EXTRA}}"\ - "${PKG_RANLIB_BUILD:+RANLIB=${PKG_RANLIB_BUILD}}"; + # N.B. We only specify CC= here if the current package does not use GNU + # autoconf as it often abuses it by appending -std={gnu99,...} to it + # instead of amending CFLAGS. + run_cmd_unsplit make \ + ${PKG_MAKEFLAGS_BUILD} \ + ${PKG_MAKEFLAGS_BUILD_EXTRA} \ + AR=${AR} ${__no_autoconf:+CC=${CC}} RANLIB=${RANLIB} \ + "${PKG_CFLAGS_BUILD:+CFLAGS=${PKG_CFLAGS_BUILD}}" \ + "${PKG_CFLAGS_BUILD_EXTRA:+CFLAGS+=${PKG_CFLAGS_BUILD_EXTRA}}" \ + "${PKG_LDFLAGS_BUILD:+LDFLAGS=${PKG_LDFLAGS_BUILD}}" \ + "${PKG_LDFLAGS_BUILD_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_BUILD_EXTRA}}"; + unset __no_autoconf; fi; set_build_script_done build -install; fi; @@ -146,54 +166,78 @@ if ! is_build_script_done install; then if test_cmd pkg_${PKG_NAME}_install; then pkg_${PKG_NAME}_install; else - run_cmd_unsplit make \ - ${PKG_MAKEFLAGS_INSTALL} \ - ${PKG_MAKEFLAGS_INSTALL_EXTRA} \ - "${PKG_AR_INSTALL:+AR=${PKG_AR_INSTALL}}"\ - "${PKG_CC_INSTALL:+CC=${PKG_CC_INSTALL}}"\ - "${PKG_CC_INSTALL:+CC=${PKG_CC_INSTALL}}"\ - "${PKG_CFLAGS_INSTALL:+CFLAGS=${PKG_CFLAGS_INSTALL}}"\ - "${PKG_CFLAGS_INSTALL_EXTRA:+CFLAGS+=${PKG_CFLAGS_INSTALL_EXTRA}}"\ - "${PKG_LDFLAGS_INSTALL:+LDFLAGS=${PKG_LDFLAGS_INSTALL}}"\ - "${PKG_LDFLAGS_INSTALL_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_INSTALL_EXTRA}}"\ - "${PKG_RANLIB_INSTALL:+RANLIB=${PKG_RANLIB_INSTALL}}"\ - ${PKG_INSTALL_TARGET:=install}; - if [ -n "${PKG_PREFIX_EXTRA}" ]; then - run_cmd_unsplit make \ - ${PKG_MAKEFLAGS_INSTALL} \ - ${PKG_MAKEFLAGS_INSTALL_EXTRA} \ - "${PKG_AR_INSTALL:+AR=${PKG_AR_INSTALL}}"\ - "${PKG_CC_INSTALL:+CC=${PKG_CC_INSTALL}}"\ - "${PKG_CC_INSTALL:+CC=${PKG_CC_INSTALL}}"\ - "${PKG_CFLAGS_INSTALL:+CFLAGS=${PKG_CFLAGS_INSTALL}}"\ - "${PKG_CFLAGS_INSTALL_EXTRA:+CFLAGS+=${PKG_CFLAGS_INSTALL_EXTRA}}"\ - "${PKG_LDFLAGS_INSTALL:+LDFLAGS=${PKG_LDFLAGS_INSTALL}}"\ - "${PKG_LDFLAGS_INSTALL_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_INSTALL_EXTRA}}"\ - "${PKG_RANLIB_INSTALL:+RANLIB=${PKG_RANLIB_INSTALL}}"\ - ${PKG_PREFIX_EXTRA} \ - ${PKG_INSTALL_TARGET:=install}; + if [ ${PKG_NO_MAKE_INSTALL:-0} -eq 0 ]; then + for __ in "" ${PKG_PREFIX_EXTRA}; do + run_cmd_unsplit make \ + ${PKG_MAKEFLAGS_INSTALL} \ + ${PKG_MAKEFLAGS_INSTALL_EXTRA} \ + AR=${AR} CC=${CC} RANLIB=${RANLIB} \ + "${PKG_CFLAGS_INSTALL:+CFLAGS=${PKG_CFLAGS_INSTALL}}" \ + "${PKG_CFLAGS_INSTALL_EXTRA:+CFLAGS+=${PKG_CFLAGS_INSTALL_EXTRA}}" \ + "${PKG_LDFLAGS_INSTALL:+LDFLAGS=${PKG_LDFLAGS_INSTALL}}" \ + "${PKG_LDFLAGS_INSTALL_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_INSTALL_EXTRA}}" \ + "${PKG_RANLIB_INSTALL:+RANLIB=${PKG_RANLIB_INSTALL}}" \ + ${PKG_INSTALL_TARGET:=install} \ + ${__}; + done; fi; if test_cmd pkg_${PKG_NAME}_install_post; then pkg_${PKG_NAME}_install_post; fi; fi; - find ${PKG_PREFIX}/lib -type f -name \*.la -exec rm -f {} \; - if [ ${PKG_LIBFILES_FIX:-0} -eq 1 ]; then - find . \( -name '*.so' -or -name '*.so.[0-9]' \ - -or -name '*.so.[0-9].[0-9]' -or \ - -name '*.so.[0-9].[0-9].[0-9]' \) \ - -exec sh -c ' \ - SO_PNAME={}; SO_PNAME=${SO_PNAME#./}; \ - if [ "${SO_PNAME##*.}" = "so" ]; then \ - SO_NAME=${SO_PNAME%%.*}; \ - else SO_NAME=${SO_PNAME}; fi; \ - echo perk -epdlltool ${SO_PNAME} \> ${SO_NAME}.def; \ - perk -epdlltool ${SO_PNAME} > ${SO_NAME}.def; \ - echo ${PKG_TARGET}-dlltool -l ${SO_NAME}.lib.a -D ${SO_PNAME} -d ${SO_NAME}.def; \ - ${PKG_TARGET}-dlltool -l ${SO_NAME}.lib.a -D ${SO_PNAME} -d ${SO_NAME}.def; \ - echo cp ${SO_NAME}.lib.a '"${PKG_PREFIX}/lib"'; \ - cp ${SO_NAME}.lib.a '"${PKG_PREFIX}/lib" \;; - + if [ -d ${PKG_PREFIX}/lib ]; then + find ${PKG_PREFIX}/lib -type f -name \*.la -exec rm -f -- {} \; + fi; + if test_cmd perk && test_cmd ${PKG_TARGET}-dlltool; then + set +o noglob; + for __so_fname in \ + *.so \ + *.so.[0-9] \ + *.so.[0-9].[0-9] \ + *.so.[0-9].[0-9].[0-9]; + do + if [ \( ! -e "${__so_fname}" \) -o \ + -e ${__so_fname%.so}.def ]; + then + continue; + else + __so_name="${__so_fname%.so}"; + echo perk -epdlltool ${__so_fname} \> ${__so_fname%.so}.def; + perk -epdlltool ${__so_fname} > ${__so_fname%.so}.def; + echo ${PKG_TARGET}-dlltool -l ${__so_fname%.so}.lib.a \ + -D ${__so_fname} -d ${__so_fname%.so}.def; + ${PKG_TARGET}-dlltool -l ${__so_fname%.so}.lib.a \ + -D ${__so_fname} -d ${__so_fname%.so}.def; + echo cp -- ${__so_fname%.so}.lib.a "${PKG_PREFIX}/lib"; + cp -- ${__so_fname%.so}.lib.a "${PKG_PREFIX}/lib"; + fi; + done; + set -o noglob; + fi; + if [ -n "${PKG_INSTALL_FILES}" ]; then + (set -- ${PKG_INSTALL_FILES}; + while [ ${#} -gt 0 ]; do + case "${1}" in + @*=*) + __ln_target="${1%=*}"; + __ln_target="${__ln_target#@}"; + __ln_fname="${1#*=}"; + echo ln -sf -- ${__ln_target} ${PKG_PREFIX}/${__ln_fname}; + ln -sf -- ${__ln_target} ${PKG_PREFIX}/${__ln_fname}; + ;; + /=*) + __mkdir_fname="${1#/=}"; + echo mkdir -p -- ${PKG_PREFIX}/${__mkdir_fname}; + mkdir -p -- ${PKG_PREFIX}/${__mkdir_fname}; + ;; + *) + __file_fname_src="${1%=*}"; + __file_fname_dst="${1#*=}"; + echo cp -pP -- ${__file_fname_src} ${PKG_PREFIX}/${__file_fname_dst}; + cp -pP -- ${__file_fname_src} ${PKG_PREFIX}/${__file_fname_dst}; + ;; + esac; shift; + done); fi; set_build_script_done install -finish; fi; |