summaryrefslogtreecommitdiffhomepage
path: root/subr
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2017-01-30 18:50:20 +0000
committerLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2017-01-30 23:09:41 +0000
commit570129106f694bef52e07a5fc08f6c63f7f54073 (patch)
tree3adbc4836865dd61a54ab60c3ce270d597d50a80 /subr
parent99690f1bad0f1a8621f5bbc706a8ef0ba033ee68 (diff)
downloadmidipix_build-570129106f694bef52e07a5fc08f6c63f7f54073.tar.bz2
midipix_build-570129106f694bef52e07a5fc08f6c63f7f54073.tar.xz
build.sh: 2nd refactoring pt. I.
build/{gcc,musl}.*.build: refactored into vars/{gcc,musl}.*.build. build/pkg.build: merged w/ build.sh (structurally) and refactored into subr/pkg_*.subr (implementations.) patches/gcc_native_x86_64_w64_mingw32.local.patch: fix wrong filename. subr/build.subr: merges source_scripts() into build.sh. subr/pkg.subr: accept either of ${PKG_..._{URL,VERSION}} when checking for missing entries in var/build.vars. vars/build.vars: adds vars for {gcc,musl}_*. vars/psxstub.vars: convert to pkg_..._all(); call pkg_fetch().
Diffstat (limited to 'subr')
-rw-r--r--subr/build.subr17
-rw-r--r--subr/pkg.subr3
-rw-r--r--subr/pkg_all.subr10
-rw-r--r--subr/pkg_autoconf.subr43
-rw-r--r--subr/pkg_build.subr30
-rw-r--r--subr/pkg_build_dir.subr16
-rw-r--r--subr/pkg_clean.subr11
-rw-r--r--subr/pkg_configure.subr19
-rw-r--r--subr/pkg_disabled.subr12
-rw-r--r--subr/pkg_extract.subr34
-rw-r--r--subr/pkg_fetch.subr18
-rw-r--r--subr/pkg_install.subr97
-rw-r--r--subr/pkg_patch.subr30
-rw-r--r--subr/pkg_patch_pre.subr23
-rw-r--r--subr/pkg_setup.subr33
15 files changed, 378 insertions, 18 deletions
diff --git a/subr/build.subr b/subr/build.subr
index 1f67257c..3020a002 100644
--- a/subr/build.subr
+++ b/subr/build.subr
@@ -121,23 +121,6 @@ init_build_vars() {
BUILD_TIMES_SECS=$(command date +%s);
};
-source_scripts() {
- _ss_pkg_name="${BUILD_PACKAGE_LC%.*}";
- _ss_arg1="${BUILD_PACKAGE_LC#*.}";
- _ss_arg1="${_ss_arg1%%.*}";
- _ss_arg2="${BUILD_PACKAGE_LC##*.}";
- set -- ${_ss_pkg_name} ${_ss_arg1} ${_ss_arg2};
- for SCRIPT_SOURCE in vars/${BUILD_PACKAGE_LC}.vars ${BUILD_SCRIPT_FNAME}; do
- if [ -f ${MIDIPIX_BUILD_PWD}/${SCRIPT_SOURCE} ]; then
- if [ ${ARG_DRYRUN:-0} -eq 1 ]; then
- echo . ${MIDIPIX_BUILD_PWD}/${SCRIPT_SOURCE};
- else
- . ${MIDIPIX_BUILD_PWD}/${SCRIPT_SOURCE};
- fi;
- fi;
- done;
-};
-
source_vars() {
for __ in ${HOME}/midipix_build.vars ../midipix_build.vars ./vars/build.vars; do
[ -e ${__} ] && . ${__};
diff --git a/subr/pkg.subr b/subr/pkg.subr
index 315bbfdd..da36f35e 100644
--- a/subr/pkg.subr
+++ b/subr/pkg.subr
@@ -92,7 +92,8 @@ log_env_vars() {
parse_with_pkg_name() {
PKG_NAME=${1}; shift;
_pwpn_pkg_name_uc=$(echo ${PKG_NAME} | tr a-z A-Z);
- if [ -z "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_URL)" ]; then
+ if [ -z "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_URL)" ]\
+ && [ -z "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_VERSION)" ]; then
unset _pwpn_pkg_name_uc;
log_msg failexit "Error: package \`${PKG_NAME}' missing in build.vars.";
else
diff --git a/subr/pkg_all.subr b/subr/pkg_all.subr
new file mode 100644
index 00000000..df96e00f
--- /dev/null
+++ b/subr/pkg_all.subr
@@ -0,0 +1,10 @@
+#
+# . ./build.vars and set -o errexit -o noglob are assumed.
+# See warning at the top of build.vars.
+#
+
+pkg_all() {
+ :;
+};
+
+# vim:filetype=sh
diff --git a/subr/pkg_autoconf.subr b/subr/pkg_autoconf.subr
new file mode 100644
index 00000000..1896fc1c
--- /dev/null
+++ b/subr/pkg_autoconf.subr
@@ -0,0 +1,43 @@
+#
+# . ./build.vars and set -o errexit -o noglob are assumed.
+# See warning at the top of build.vars.
+#
+
+pkg_autoconf() {
+ if [ -e ${PKG_SUBDIR}/configure -o \
+ -e ${PKG_SUBDIR}/configure.ac -o \
+ -e ${PKG_SUBDIR}/configure.in -o \
+ -e ${PKG_SUBDIR}/config.guess ]; then
+ find ${PKG_SUBDIR} -name config.sub \
+ -exec echo mv -- {} {}.orig \; \
+ -exec mv -- {} {}.orig \; \
+ -exec echo install -m 0700 ${MIDIPIX_BUILD_PWD}/etc/config.sub {} \; \
+ -exec install -m 0700 ${MIDIPIX_BUILD_PWD}/etc/config.sub {} \;;
+ if [ -e ${PKG_SUBDIR}/configure.ac -a \
+ ! -e ${PKG_SUBDIR}/configure ]; then
+ if [ -e ${PKG_SUBDIR}/autogen.sh ]; then
+ for __ in ${PKG_SUBDIR}/build-aux ${PKG_SUBDIR}; do
+ if [ -e ${__} ]; then
+ echo install -m 0700 \
+ ${MIDIPIX_BUILD_PWD}/etc/config.sub \
+ ${__}/config.sub;
+ install -m 0700 \
+ ${MIDIPIX_BUILD_PWD}/etc/config.sub \
+ ${__}/config.sub;
+ break;
+ fi;
+ done;
+ (cd ${PKG_SUBDIR} && ${SHELL} ./autogen.sh) || exit 1;
+ else
+ (cd ${PKG_SUBDIR} && autoconf) || exit 1;
+ fi;
+ fi;
+ for __ in ${PKG_BUILD_DIR} ${PKG_CONFIG_CACHE_EXTRA}; do
+ echo cp -- ${MIDIPIX_BUILD_PWD}/etc/config.cache ${__}/;
+ cp -- ${MIDIPIX_BUILD_PWD}/etc/config.cache ${__}/;
+ done;
+ fi;
+ set_build_script_done autoconf -patch;
+};
+
+# vim:filetype=sh
diff --git a/subr/pkg_build.subr b/subr/pkg_build.subr
new file mode 100644
index 00000000..d9b1e684
--- /dev/null
+++ b/subr/pkg_build.subr
@@ -0,0 +1,30 @@
+#
+# . ./build.vars and set -o errexit -o noglob are assumed.
+# See warning at the top of build.vars.
+#
+
+pkg_build() {
+ if [ -n "${PKG_BUILD_CMDLINE}" ]; then
+ ${PKG_BUILD_CMDLINE};
+ elif [ ${PKG_NO_MAKE_BUILD:-0} -eq 0 ]; then
+ if [ "${PKG_SLIBTOOL}" != "default" ]; then
+ export MAKE="make LIBTOOL=${PKG_SLIBTOOL:-slibtool}";
+ fi;
+ # 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}}" \
+ "${CFLAGS_FOR_BUILD:+CFLAGS_FOR_BUILD=${CFLAGS_FOR_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;
+};
+
+# vim:filetype=sh
diff --git a/subr/pkg_build_dir.subr b/subr/pkg_build_dir.subr
new file mode 100644
index 00000000..1e46323e
--- /dev/null
+++ b/subr/pkg_build_dir.subr
@@ -0,0 +1,16 @@
+#
+# . ./build.vars and set -o errexit -o noglob are assumed.
+# See warning at the top of build.vars.
+#
+
+pkg_build_dir() {
+ if [ -z "${PKG_BUILD_DIR}" ]; then
+ set_build_dir ${PKG_SUBDIR} ${PKG_BUILD_TYPE:-native};
+ fi;
+ [ "${PKG_SUBDIR}" != "${PKG_BUILD_DIR}" ] &&\
+ secure_rm ${PKG_BUILD_DIR};
+ insecure_mkdir ${PKG_BUILD_DIR};
+ set_build_script_done build_dir -patch_pre;
+};
+
+# vim:filetype=sh
diff --git a/subr/pkg_clean.subr b/subr/pkg_clean.subr
new file mode 100644
index 00000000..bd0e1d93
--- /dev/null
+++ b/subr/pkg_clean.subr
@@ -0,0 +1,11 @@
+#
+# . ./build.vars and set -o errexit -o noglob are assumed.
+# See warning at the top of build.vars.
+#
+
+pkg_clean() {
+ make clean;
+ set_build_script_done clean -build;
+};
+
+# vim:filetype=sh
diff --git a/subr/pkg_configure.subr b/subr/pkg_configure.subr
new file mode 100644
index 00000000..501ad710
--- /dev/null
+++ b/subr/pkg_configure.subr
@@ -0,0 +1,19 @@
+#
+# . ./build.vars and set -o errexit -o noglob are assumed.
+# See warning at the top of build.vars.
+#
+
+pkg_configure() {
+ if [ ${__no_autoconf:-0} -eq 0 ]; then
+ if test_cmd pkg_${PKG_NAME}_configure_pre; then
+ pkg_${PKG_NAME}_configure_pre;
+ fi;
+ 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_CONFIGURE} \
+ ${PKG_CONFIGURE_ARGS} ${PKG_CONFIGURE_ARGS_EXTRA} ${PKG_CONFIGURE_ARGS_EXTRA_DEBUG};
+ fi;
+ set_build_script_done configure clean -build;
+};
+
+# vim:filetype=sh
diff --git a/subr/pkg_disabled.subr b/subr/pkg_disabled.subr
new file mode 100644
index 00000000..9fb3f2f0
--- /dev/null
+++ b/subr/pkg_disabled.subr
@@ -0,0 +1,12 @@
+#
+# . ./build.vars and set -o errexit -o noglob are assumed.
+# See warning at the top of build.vars.
+#
+
+pkg_disabled() {
+ if [ ${PKG_DISABLED:-0} -eq 1 ]; then
+ exit 0;
+ fi;
+};
+
+# vim:filetype=sh
diff --git a/subr/pkg_extract.subr b/subr/pkg_extract.subr
new file mode 100644
index 00000000..1bee8835
--- /dev/null
+++ b/subr/pkg_extract.subr
@@ -0,0 +1,34 @@
+#
+# . ./build.vars and set -o errexit -o noglob are assumed.
+# See warning at the top of build.vars.
+#
+
+pkg_extract() {
+ if [ "${PKG_URL_TYPE:-wget}" = wget ]; then
+ secure_rm ${PKG_SUBDIR};
+ if [ ${PKG_SUBDIR_CREATE:-0} -eq 1 ]; then
+ insecure_mkdir ${PKG_SUBDIR};
+ fi;
+ if [ "${PKG_FNAME##*.tar.}" = "bz2" ]; then
+ bunzip2 -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
+ elif [ "${PKG_FNAME##*.tar.}" = "gz" ]; then
+ gunzip -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
+ elif [ "${PKG_FNAME##*.tar.}" = "xz" ]; then
+ xz -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
+ elif [ "${PKG_FNAME##*.t}" = "bz2" ]; then
+ bunzip2 -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
+ elif [ "${PKG_FNAME##*.t}" = "gz" ]; then
+ gunzip -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
+ elif [ "${PKG_FNAME##*.t}" = "xz" ]; then
+ xz -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
+ else
+ 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;
+ fi;
+ fi;
+ set_build_script_done extract -build_dir;
+};
+
+# vim:filetype=sh
diff --git a/subr/pkg_fetch.subr b/subr/pkg_fetch.subr
new file mode 100644
index 00000000..705e4936
--- /dev/null
+++ b/subr/pkg_fetch.subr
@@ -0,0 +1,18 @@
+#
+# . ./build.vars and set -o errexit -o noglob are assumed.
+# See warning at the top of build.vars.
+#
+
+pkg_fetch() {
+ if [ "${PKG_URL_TYPE:-wget}" = wget ]; then
+ fetch "${PKG_URL}" ${PKG_SHA256SUM};
+ else
+ fetch_git ${PKG_SUBDIR} ${PKG_URL} ${PKG_GIT_BRANCH};
+ fi;
+ if test_cmd pkg_${PKG_NAME}_fetch_post; then
+ pkg_${PKG_NAME}_fetch_post;
+ fi;
+ set_build_script_done fetch -extract;
+};
+
+# vim:filetype=sh
diff --git a/subr/pkg_install.subr b/subr/pkg_install.subr
new file mode 100644
index 00000000..67df0fd6
--- /dev/null
+++ b/subr/pkg_install.subr
@@ -0,0 +1,97 @@
+#
+# . ./build.vars and set -o errexit -o noglob are assumed.
+# See warning at the top of build.vars.
+#
+
+pkg_install() {
+ if test_cmd pkg_${PKG_NAME}_install; then
+ pkg_${PKG_NAME}_install;
+ else
+ if [ ${PKG_NO_MAKE_INSTALL:-0} -eq 0 ]; then
+ 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};
+ if [ -n "${PKG_PREFIX_EXTRA}" ]; then
+ 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_EXTRA:=install} \
+ DESTDIR=${PKG_PREFIX_EXTRA};
+ fi;
+ fi;
+ if test_cmd pkg_${PKG_NAME}_install_post; then
+ pkg_${PKG_NAME}_install_post;
+ fi;
+ fi;
+ if [ -d ${PKG_PREFIX}/lib ]; then
+ for __ in $(find ${PKG_PREFIX}/lib -type f -name \*.la); do
+ secure_rm ${__};
+ done;
+ 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#/=}";
+ insecure_mkdir ${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;
+ if [ "${PKG_BUILD_TYPE}" != "host" ] \
+ && test_cmd perk \
+ && test_cmd ${PKG_TARGET}-dlltool; then
+ for __so_fname in \
+ $(find \( -name "*.so" \
+ -or -name "*.so.[0-9]" \
+ -or -name "*.so.[0-9].[0-9]" \
+ -or -name "*.so.[0-9].[0-9].[0-9]" \) -printf '%P\n');
+ do
+ if [ \( -e ${__so_fname%.so}.lib.a \) -o \
+ \( ! -e ${PKG_PREFIX}/lib/$(basename ${__so_fname}) \) ];
+ 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;
+ fi;
+ set_build_script_done install -finish;
+};
+
+# vim:filetype=sh
diff --git a/subr/pkg_patch.subr b/subr/pkg_patch.subr
new file mode 100644
index 00000000..089c0c16
--- /dev/null
+++ b/subr/pkg_patch.subr
@@ -0,0 +1,30 @@
+#
+# . ./build.vars and set -o errexit -o noglob are assumed.
+# See warning at the top of build.vars.
+#
+
+pkg_patch() {
+ if [ -d ${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME} ]; then
+ set +o noglob;
+ for __patch_fname in ${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}/*.patch; do
+ patch -b -d ${PKG_SUBDIR} -p1 < ${__patch_fname};
+ done;
+ set -o noglob;
+ fi;
+ for __patch_fname in \
+ ${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}.local.patch \
+ ${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}.local@${BUILD_HNAME}.patch \
+ ${WORKDIR}/chainport/${PKG_SUBDIR}.midipix.patch \
+ ${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}.local.patch \
+ ${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}.local@${BUILD_HNAME}.patch; do
+ if [ -r "${__patch_fname}" ]; then
+ patch -b -d ${PKG_SUBDIR} -p1 < ${__patch_fname};
+ fi;
+ done; unset __patch_fname;
+ if test_cmd pkg_${PKG_NAME}_patch_post; then
+ pkg_${PKG_NAME}_patch_post;
+ fi;
+ set_build_script_done patch -setup;
+};
+
+# vim:filetype=sh
diff --git a/subr/pkg_patch_pre.subr b/subr/pkg_patch_pre.subr
new file mode 100644
index 00000000..2671d32c
--- /dev/null
+++ b/subr/pkg_patch_pre.subr
@@ -0,0 +1,23 @@
+#
+# . ./build.vars and set -o errexit -o noglob are assumed.
+# See warning at the top of build.vars.
+#
+
+pkg_patch_pre() {
+ for __ in \
+ ${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}_pre.local.patch \
+ ${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}_pre.local@${BUILD_HNAME}.patch \
+ ${WORKDIR}/chainport/${PKG_SUBDIR}_pre.midipix.patch \
+ ${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}_pre.local.patch \
+ ${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}_pre.local@${BUILD_HNAME}.patch; do
+ if [ -r "${__}" ]; then
+ patch -b -d ${PKG_SUBDIR} -p1 < ${__};
+ fi;
+ done; unset __;
+ if test_cmd pkg_${PKG_NAME}_patch_pre_post; then
+ pkg_${PKG_NAME}_patch_pre_post;
+ fi;
+ set_build_script_done patch_pre -autoconf;
+};
+
+# vim:filetype=sh
diff --git a/subr/pkg_setup.subr b/subr/pkg_setup.subr
new file mode 100644
index 00000000..242541ad
--- /dev/null
+++ b/subr/pkg_setup.subr
@@ -0,0 +1,33 @@
+#
+# . ./build.vars and set -o errexit -o noglob are assumed.
+# See warning at the top of build.vars.
+#
+
+pkg_setup() {
+ PKG_SUBDIR_PATH=${PWD}/${PKG_SUBDIR#/};
+ if [ -z "${PKG_CONFIGURE}" ]; then
+ PKG_CONFIGURE=${PKG_SUBDIR_PATH}/configure;
+ else
+ PKG_CONFIGURE=${PWD}/${PKG_CONFIGURE#/};
+ fi;
+ cd ${PKG_BUILD_DIR};
+ if [ "${PKG_BUILD_TYPE}" = "host" ]; then
+ export AR=ar;
+ export CC=gcc;
+ export CXX=g++;
+ export RANLIB=ranlib;
+ else
+ export AR=${PKG_TARGET}-ar;
+ export CC=${PKG_TARGET}-gcc;
+ export CXX=${PKG_TARGET}-g++;
+ export RANLIB=${PKG_TARGET}-ranlib;
+ fi;
+ if [ -x ${PKG_CONFIGURE} ]; then
+ export CFLAGS_FOR_BUILD="${HOST_TOOLCHAIN_CFLAGS_CONFIGURE_DEFAULT}";
+ else
+ __no_autoconf=1;
+ fi;
+ set_build_script_done setup -configure;
+};
+
+# vim:filetype=sh