This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 3 of 4 v2] configure: pass the allowed lib extensions to check_for()


 configure |  75 ++++++++++++++++++++++++++++++++------------------------------
 1 files changed, 39 insertions(+), 36 deletions(-)


# HG changeset patch
# User "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
# Date 1309213742 -7200
# Node ID c1a75083d135ef092e9b5711a278fbca49d5b3c8
# Parent  1d66ee93a9a4cc963cad0ba2e245fa4a19e31af8
configure: pass the allowed lib extensions to check_for()

Rather than building all possible library names in the caller,
lets just do it once in check_for.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>

diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -104,6 +104,10 @@
 #     for each 'prog', test if $(prog --version) matches 'regexp'
 #     optional
 #       eg: ver='^GNU bash, version [34]\.'
+# $*: lib_exts=<extension[ extension...]>
+#     the list of allowed library extension
+#     mandatory
+#       eg: lib_exts="so dylib"     lib_exts="so dylib a"
 # $*: err=<error_message>
 #     the error message to print if tool is missing
 #     optional, defaults to: '${prog}: none found'
@@ -115,19 +119,21 @@
 #     optional, defaults to none
 #       eg: kconfig=has_libncurses
 check_for() {
+    local lib_exts
     local val
     local item
     local where
     local status
+    local ext
 
     # Note: prog/inc/lib and var/kconfig/ver/err are set here,
     # but declared by the caller (because it needs it)
     for item in "${@}"; do
         case "${item}" in
-            prog=*|inc=*|lib=*|var=*|ver=*|err=*|kconfig=*)
+            prog=*|inc=*|lib=*|var=*|ver=*|err=*|kconfig=*|lib_exts=*)
                 eval ${item%%=*}=\"${item#*=}\"
                 ;;
-            *)  do_error "check_for: incorrect parameters: '$@'";;
+            *)  do_error "check_for: incorrect parameters: '${item}'";;
         esac
     done
 
@@ -198,15 +204,20 @@
     fi
 
     if [ -n "${lib}" ]; then
+        if [ -z "${lib_exts}" ]; then
+            do_error "check_for: no library extension specified for '${lib}'"
+        fi
         for item in ${lib}; do
-            printf "Checking for '${item}'... "
-            where="$( gcc -print-file-name="${item}" )"
-            if [ "${where}" != "${item}" ]; then
-                where="$( readlink "${where}" )"
-                status=yes
-                break;
-            fi
-            printf "no\n"
+            for ext in ${lib_exts}; do
+                printf "Checking for '${item}.${ext}'... "
+                where="$( gcc -print-file-name="${item}.${ext}" )"
+                if [ "${where}" != "${item}.${ext}" ]; then
+                    where="$( readlink "${where}" )"
+                    status=yes
+                    break 2;
+                fi
+                printf "no\n"
+            done
         done
         if [ -z "${status}" ]; then
             return 1
@@ -478,38 +489,31 @@
 add_to_kconfig_list static_link_ok
 
 # Library checks
+libs_exts="so dylib a"
+
 ncurses_hdrs="ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h"
-ncurses_libs="$( for l in ncursesw ncurses curses; do   \
-                     for x in so a dylib; do            \
-                         printf "lib$l.$x ";            \
-                     done;                              \
-                 done                                   \
-               )"
+ncurses_libs="libncursesw libncurses libcurses"
 has_or_abort lib="${ncurses_libs}"                                          \
+             lib_exts="${libs_exts}"                                        \
              inc="${ncurses_hdrs}"                                          \
              err="The 'ncurses' library is needed fo the menuconfig frontend"
 
-stdcxx_libs="$( for x in so dylib a; do \
-                   printf "libstdc++.$x "; \
-               done \
-             )"
-has_or_abort lib="${stdcxx_libs}" \
+has_or_abort lib="libstdc++"            \
+             lib_exts="${libs_exts}"    \
              err="The 'libstdc++' library is needed to build gcc"
 
 # Yes, we may be checking twice for libstdc++.a
 # The first is because we need one instance of libstdc++ (shared or static)
 # because it is needed for PPL; the second is because the static version is
 # required for static-linking, and if missing, the option is removed.
-has_or_warn  lib="libstdc++.a" \
+has_or_warn  lib="libstdc++"    \
+             lib_exts="a"       \
              err="static 'libstdc++' is needed to statically link the toolchain's executables" \
              kconfig=has_static_libstdcxx
 
-expat_libs="$( for x in so dylib a; do \
-                   printf "libexpat.$x "; \
-               done \
-             )"
-has_or_warn  inc="expat.h" \
-             lib="${expat_libs}" \
+has_or_warn  inc="expat.h"              \
+             lib="libexpat"             \
+             lib_exts="${libs_exts}"    \
              err="The 'expat' header file and library are needed to link cross-gdb's executables" \
              kconfig=has_expat
 
@@ -517,19 +521,18 @@
 # The first is because we need one instance of libexpat (shared or static)
 # because it is needed for cross-gdb; the second is because the static version
 # is required for static-linking, and if missing, the option is removed.
-has_or_warn  lib="libexpat.a" \
+has_or_warn  lib="libexpat" \
+             lib_exts="a"   \
              err="static 'expat' is needed to statically link cross-gdb's executables" \
              kconfig=has_static_expat
 
 for v in 7 6 5 4; do
-    python_incs="${python_incs}$( printf "python2.$v/Python.h " )"
-    python_libs="${python_libs}$( for x in so dylib a; do \
-                                      printf "libpython2.$v.$x "; \
-                                  done \
-                                )"
+    python_incs="${python_incs} python2.${v}/Python.h"
+    python_libs="${python_libs} libpython2.${v}"
 done
-has_or_warn  inc="${python_incs}" \
-             lib="${python_libs}" \
+has_or_warn  inc="${python_incs}"       \
+             lib="${python_libs}"       \
+             lib_exts="${libs_exts}"    \
              err="The 'python' header file and library are needed for some features of cross-gdb"
 
 #---------------------------------------------------------------------

--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]