CONFIGURE_OPTS=${*}
# Reading system configuration informations, functions and package versions.
-source ../sysinfos
-source ../functions
-source ../packages-list
-
-# Applying patches (if any)
-apply_patches ${PACKAGE}
-
-cd ${LFS_TMP}/${PACKAGE}-build
-../${PACKAGE}/configure \
- --prefix=/cross-tools \
- ${CONFIGURE_OPTS}
-${HVMAKE}
-${HVMAKE} install
+source ${SCRDIR}/../sysinfos
+source ${SCRDIR}/../functions
+source ${SCRDIR}/../packages-list
+
+DEFAULT_CONFIGURE_PREFIX=/cross-tools
+
+# Default configure function
+hvconfigure()
+{
+ cd ${LFS_TMP}/${PACKAGE}-build
+
+ FINAL_CFG_OPTS="\
+ --prefix=${DEFAULT_CONFIGURE_PREFIX} \
+ ${CONFIGURE_OPTS}"
+
+ echo "Running configure with options:"
+ echo " <${FINAL_CFG_OPTS}>"
+
+ ../${PACKAGE}/configure ${FINAL_CFG_OPTS}
+}
+
+# Default build function
+hvbuild()
+{
+ ${HVMAKE}
+ ${HVMAKE} install
+}
+
+hvpatch()
+{
+ # Applying patches (if any)
+ apply_patches ${PACKAGE}
+}
+
+PACKAGE_DEF=${SCRDIR}/pkg/$(get_pkg_name ${PACKAGE})
+
+if [ -f ${PACKAGE_DEF} ]; then
+ echo "Load custom package functions and definitions"
+ source ${PACKAGE_DEF}
+fi
+
+hvpatch
+
+# Execute config-cache function if applicable
+if function_exists config_cache ; then
+ echo "Running configure cache script"
+ config_cache
+
+ CONFIGURE_OPTS="${CONFIGURE_OPTS} --cache-file=${LFS_TMP}/${PACKAGE}-build/config.cache"
+fi
+
+# Execute pre-configure function if applicable
+if function_exists configure_pre ; then
+ echo "Running configure pre-script"
+ configure_pre
+fi
+
+if [ -n "${HV_NO_CONFIGURE_SCRIPT}" ]; then
+ echo "Not calling configure because ${PACKAGE} has no configure script"
+else
+ hvconfigure
+fi
+
+# Execute post-configure function if applicable
+if function_exists configure_post ; then
+ echo "Running configure post-script"
+ configure_post
+fi
+
+hvbuild
exit $?