I while ago it was discussed on IRC that WANT_AUTO{CONF,MAKE}=latest isn't 
such a great idea. If a package works with the currently latest version that 
doesn't mean it'll work with the next. Therefore it was suggested to replace 
WANT_AUTO{CONF,MAKE} by two arrays which lists slots that the package in 
question is known to work with.

I have produced a patch which uses the arrays SUPPORTED_AUTO{CONF,MAKE} for 
this when they are set. It also accepts SUPPORTED_AUTO{CONF,MAKE}=none when a 
package doesn't depend upon one or the other. To ensure correct ordering it 
uses version_sort() from versionator.exlib to sort the slots so the highest 
gets listed first as any-of dependency in || (   ), and gets used by the 
various autotools functions.

To retain backwards compatibility it still uses WANT_* when SUPPORTED_* is 
unset. Whenever this happens it prints an ewarn stating that WANT_* is 
deprecated, when the first of any of the functions in autotools.exlib is 
called. Until this code gets removed, latest is frozen at what is now the 
latest slots.

What I didn't do is fix auto{conf,make}-wrapper. They still use WANT_* and 
therefore the exlib still exports the first listed, available slot as WANT_*. 
For consistency's sake I think someone should fix this at some point and 
perhaps at the same time change it so it doesn't need an version bump 
whenever a new version of auto{conf,make} gets released. Currently it hard 
codes all available versions and their slots.

Patches are attached. Will be committed to arbor during the next 24 hours if 
noone objects. After that people are obviously encouraged to start converting 
exheres.

-- 
Bo Andresen
From 2eecc5a41ad037feeafe6dcd0bfb2f57fa235d41 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Bo=20=C3=98rsted=20Andresen?= <[EMAIL PROTECTED]>
Date: Sat, 6 Sep 2008 14:50:00 +0200
Subject: [PATCH] Reimplement version_sort() using `ever at_least`.

---
 exlibs/versionator.exlib |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/exlibs/versionator.exlib b/exlibs/versionator.exlib
index c5cfc6a..896d0f1 100644
--- a/exlibs/versionator.exlib
+++ b/exlibs/versionator.exlib
@@ -281,7 +281,23 @@ version_compare() {
     die "version_compare sucks, use ever at_least"
 }
 
+# Returns its parameters sorted, highest version last. We're using a quadratic
+# algorithm for simplicity, so don't call it with more than a few dozen items.
 version_sort() {
-    die "version_sort sucks, reimplement using ever at_least if you really need it"
+    local left=0 idx lowest_idx tmp items=()
+    items=( $@ )
+    while (( ${left} < [EMAIL PROTECTED] )); do
+        lowest_idx=${left}
+        (( idx = lowest_idx + 1 ))
+        while (( ${idx} < [EMAIL PROTECTED] )); do
+            ever at_least "${items[idx]}" "${items[lowest_idx]}" && lowest_idx=${idx}
+            (( idx += 1 ))
+        done
+        tmp=${items[lowest_idx]}
+        items[lowest_idx]=${items[left]}
+        items[left]=${tmp}
+        (( left+=1 ))
+    done
+    echo [EMAIL PROTECTED]
 }
 
-- 
1.6.0.1

From 6981f485e61eb5f1e30beb474017dcd28d7e0faa Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Bo=20=C3=98rsted=20Andresen?= <[EMAIL PROTECTED]>
Date: Sat, 6 Sep 2008 15:27:12 +0200
Subject: [PATCH] Add sorted_any_of_slot_dependencies().

---
 exlibs/versionator.exlib |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/exlibs/versionator.exlib b/exlibs/versionator.exlib
index 896d0f1..566af14 100644
--- a/exlibs/versionator.exlib
+++ b/exlibs/versionator.exlib
@@ -301,3 +301,17 @@ version_sort() {
     echo [EMAIL PROTECTED]
 }
 
+# First argument is a catogory/pn. The remaining arguments are slots. Sorts the
+# slots and outputs " || ( cpn:slot1 cpn:slot2 cpn:slot3 ) " etc, where slot1 is
+# highest. If there is only one slot it merely outputs " cpn:slot ".
+sorted_any_of_slot_dependencies() {
+    local i sorted_slots cpn=${1}
+    shift
+    (( ${#} > 1 )) && echo -n " || ( "
+    sorted_slots=( $(version_sort [EMAIL PROTECTED]) )
+    for(([EMAIL PROTECTED]; i>=0; --i)); do
+        echo -n " ${cpn}:${sorted_slots[i]} "
+    done
+    (( ${#} > 1 )) && echo -n ") "
+}
+
-- 
1.6.0.1

From a707230d94a1937a28dcb86dd005a6976f833d52 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Bo=20=C3=98rsted=20Andresen?= <[EMAIL PROTECTED]>
Date: Sat, 6 Sep 2008 15:29:08 +0200
Subject: [PATCH] Add support for SUPPORTED_AUTO{CONF,MAKE} arrays. Retain backwards compatibility with WANT_AUTO{CONF,MAKE} and set those for auto{conf,make}-wrapper.

---
 exlibs/autotools.exlib |   80 +++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 72 insertions(+), 8 deletions(-)

diff --git a/exlibs/autotools.exlib b/exlibs/autotools.exlib
index eb4e9ac..5ee30a8 100644
--- a/exlibs/autotools.exlib
+++ b/exlibs/autotools.exlib
@@ -8,19 +8,73 @@
 # This exlib is for handling autotooled software packages that
 # need to regenerate their build scripts.
 
+require versionator
+
 export_exlib_phases src_prepare
 
 DEPENDENCIES="build: sys-devel/libtool"
 
-[[ ${WANT_AUTOCONF:-latest} == latest ]] && WANT_AUTOCONF="2.5"
-[[ ${WANT_AUTOCONF} != none ]] \
-    && DEPENDENCIES+=" sys-devel/autoconf:${WANT_AUTOCONF}"
+autotools_dependencies() {
+    if [[ -n [EMAIL PROTECTED] ]]; then
+        if [[ [EMAIL PROTECTED] == none ]]; then
+            WANT_AUTOCONF=none
+        else
+            sorted_any_of_slot_dependencies \
+                sys-devel/autoconf \
+                "[EMAIL PROTECTED]"
+        fi
+    else
+        [[ ${WANT_AUTOCONF:-latest} == latest ]] && WANT_AUTOCONF="2.5"
+        [[ ${WANT_AUTOCONF} != none ]] \
+            && echo " sys-devel/autoconf:${WANT_AUTOCONF}"
+    fi
+
+    if [[ -n [EMAIL PROTECTED] ]]; then
+        if [[ [EMAIL PROTECTED] == none ]]; then
+            WANT_AUTOMAKE="none"
+        else
+            sorted_any_of_slot_dependencies \
+                sys-devel/automake \
+                "[EMAIL PROTECTED]"
+        fi
+    else
+        [[ ${WANT_AUTOMAKE:-latest} == latest ]] && WANT_AUTOMAKE="1.10"
+        [[ ${WANT_AUTOMAKE} != none ]] \
+            && echo " sys-devel/automake:${WANT_AUTOMAKE}"
+    fi
+}
 
-[[ ${WANT_AUTOMAKE:-latest} == latest ]] && WANT_AUTOMAKE="1.10"
-[[ ${WANT_AUTOMAKE} != none ]] \
-    && DEPENDENCIES+=" sys-devel/automake:${WANT_AUTOMAKE}"
+[[ -n ${WANT_AUTOCONF} ]] && AUTOCONF_DEPRECATED="${WANT_AUTOCONF}"
+[[ -n ${WANT_AUTOMAKE} ]] && AUTOMAKE_DEPRECATED="${WANT_AUTOMAKE}"
+DEPENDENCIES+="$(autotools_dependencies)"
 
-export WANT_AUTOCONF WANT_AUTOMAKE
+autotools_select_versions() {
+    local i sorted_slots=()
+    for i in AUTO{CONF,MAKE}_DEPRECATED; do
+        if [[ -n ${!i} ]]; then
+            ewarn "${i%_DEPRECATED} is deprecated. Please convert ${PN} to set SUPPORTED_${i%_DEPRECATED} instead."
+            export ${i}=""
+        fi
+    done
+    if [[ -z ${WANT_AUTOCONF} && [EMAIL PROTECTED] != none ]]; then
+        sorted_slots=( $(version_sort [EMAIL PROTECTED]) )
+        for(([EMAIL PROTECTED]; i>=0; --i)); do
+            has_version sys-devel/autoconf:${sorted_slots[i]} \
+                && export WANT_AUTOCONF="${sorted_slots[i]}" \
+                && break
+        done
+        [[ -z ${WANT_AUTOCONF} ]] && die "No autoconf installed"
+    fi
+    if [[ -z ${WANT_AUTOMAKE} && [EMAIL PROTECTED] != none ]]; then
+        sorted_slots=( $(version_sort [EMAIL PROTECTED]) )
+        for(([EMAIL PROTECTED]; i>=0; --i)); do
+            has_version sys-devel/automake:${sorted_slots[i]} \
+                && export WANT_AUTOMAKE="${sorted_slots[i]}" \
+                && break
+        done
+        [[ -z ${WANT_AUTOMAKE} ]] && die "No automake installed"
+    fi
+}
 
 # Variables:
 #
@@ -48,6 +102,7 @@ export WANT_AUTOCONF WANT_AUTOMAKE
 # This function mimes the behavior of autoreconf, but uses the different
 # eauto* functions to run the tools. It doesn't take any parameters.
 eautoreconf() {
+    autotools_select_versions
     local pwd=$(pwd) x auxdir
 
     if [[ -z ${AT_NO_RECURSIVE} ]]; then
@@ -77,6 +132,7 @@ eautoreconf() {
 # without e prefix.
 # They also force installing the support files for safety.
 eaclocal() {
+    autotools_select_versions
     local aclocal_opts
 
     if [[ -n ${AT_M4DIR} ]] ; then
@@ -98,6 +154,7 @@ eaclocal() {
 }
 
 _elibtoolize() {
+    autotools_select_versions
     local opts lttest
 
     # Check if we should run libtoolize (AM_PROG_LIBTOOL is an older macro,
@@ -115,12 +172,14 @@ _elibtoolize() {
 }
 
 eautoheader() {
+    autotools_select_versions
     # Check if we should run autoheader
     [[ -n $(autotools_check_macro "AC_CONFIG_HEADERS") ]] || return 0
     NO_FAIL=1 autotools_run_tool autoheader "$@"
 }
 
 eautoconf() {
+    autotools_select_versions
     if [[ ! -f configure.ac && ! -f configure.in ]] ; then
         echo
         eerror "No configure.{ac,in} present in ${PWD##*/}!"
@@ -132,6 +191,7 @@ eautoconf() {
 }
 
 eautomake() {
+    autotools_select_versions
     local extra_opts
 
     [[ -f Makefile.am ]] || return 0
@@ -160,6 +220,7 @@ eautomake() {
 
 # Internal function to run an autotools' tool
 autotools_run_tool() {
+    autotools_select_versions
     local ret=0
 
     echo "$@"
@@ -174,6 +235,7 @@ autotools_run_tool() {
 
 # Internal function to check for support
 autotools_check_macro() {
+    autotools_select_versions
     [[ -f configure.ac || -f configure.in ]] && \
         WANT_AUTOCONF="2.5" autoconf --trace=$1 2>/dev/null
     return 0
@@ -181,6 +243,7 @@ autotools_check_macro() {
 
 # Internal function to get additional subdirs to configure
 autotools_get_subdirs() {
+    autotools_select_versions
     local subdirs_scan_out
 
     subdirs_scan_out=$(autotools_check_macro "AC_CONFIG_SUBDIRS")
@@ -196,6 +259,7 @@ autotools_get_subdirs() {
 }
 
 autotools_get_auxdir() {
+    autotools_select_versions
     local auxdir_scan_out
 
     auxdir_scan_out=$(autotools_check_macro "AC_CONFIG_AUX_DIR")
@@ -211,7 +275,7 @@ autotools_get_auxdir() {
 }
 
 autotools_src_prepare() {
-    default_src_prepare
+    default
 
     eautoreconf
 }
-- 
1.6.0.1

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Exherbo-dev mailing list
[email protected]
http://lists.exherbo.org/mailman/listinfo/exherbo-dev

Reply via email to