diff options
author | Mike Frysinger <vapier@gentoo.org> | 2005-01-18 01:58:18 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2005-01-18 01:58:18 +0000 |
commit | 5603c55b6f42e99e8ea012dc8b15c30e4a88b819 (patch) | |
tree | ff557011e9ceb06aab36c0acdaf45adc7c33761d /sys-devel/gcc | |
parent | clean up/simplify the gcc-config and fix_libtool_files logic (diff) | |
download | gentoo-2-5603c55b6f42e99e8ea012dc8b15c30e4a88b819.tar.gz gentoo-2-5603c55b6f42e99e8ea012dc8b15c30e4a88b819.tar.bz2 gentoo-2-5603c55b6f42e99e8ea012dc8b15c30e4a88b819.zip |
fix the libtool script to not destroy .la paths #73435
(Portage version: 2.0.51-r13)
Diffstat (limited to 'sys-devel/gcc')
-rw-r--r-- | sys-devel/gcc/files/awk/fixlafiles.awk | 148 | ||||
-rw-r--r-- | sys-devel/gcc/files/fix_libtool_files.sh | 33 |
2 files changed, 76 insertions, 105 deletions
diff --git a/sys-devel/gcc/files/awk/fixlafiles.awk b/sys-devel/gcc/files/awk/fixlafiles.awk index d7cdec041865..dd8ba2e6145e 100644 --- a/sys-devel/gcc/files/awk/fixlafiles.awk +++ b/sys-devel/gcc/files/awk/fixlafiles.awk @@ -1,55 +1,48 @@ -# Copyright 1999-2004 Gentoo Foundation +# Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# Author: Martin Schlemmer <azarah@gentoo.org> -# $Header: /var/cvsroot/gentoo-x86/sys-devel/gcc/files/awk/fixlafiles.awk,v 1.11 2004/07/15 00:59:02 agriffis Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-devel/gcc/files/awk/fixlafiles.awk,v 1.12 2005/01/18 01:58:18 vapier Exp $ -function printn(string) -{ +# +# Helper functions +# +function printn(string) { system("echo -n \"" string "\"") } - -function einfo(string) -{ +function einfo(string) { system("echo -e \" \\e[32;01m*\\e[0m " string "\"") } - -function einfon(string) -{ +function einfon(string) { system("echo -ne \" \\e[32;01m*\\e[0m " string "\"") } - -function ewarn(string) -{ +function ewarn(string) { system("echo -e \" \\e[33;01m*\\e[0m " string "\"") } - -function ewarnn(string) -{ +function ewarnn(string) { system("echo -ne \" \\e[33;01m*\\e[0m " string "\"") } - -function eerror(string) -{ +function eerror(string) { system("echo -e \" \\e[31;01m*\\e[0m " string "\"") } -# assert --- assert that a condition is true. Otherwise exit. -# This is from the gawk info manual. -function assert(condition, string) -{ +# +# assert(condition, errmsg) +# assert that a condition is true. Otherwise exit. +# +function assert(condition, string) { if (! condition) { printf("%s:%d: assertion failed: %s\n", - FILENAME, FNR, string) > "/dev/stderr" + FILENAME, FNR, string) > "/dev/stderr" _assert_exit = 1 exit 1 } } -# system() wrapper that normalize return codes ... -function dosystem(command, ret) -{ +# +# system(command, return) +# wrapper that normalizes return codes ... +# +function dosystem(command, ret) { ret = 0 - ret = system(command) if (ret == 0) return 1 @@ -57,10 +50,10 @@ function dosystem(command, ret) return 0 } - BEGIN { - + # # Get our variables from environment + # OLDVER = ENVIRON["OLDVER"] OLDCHOST = ENVIRON["OLDCHOST"] @@ -69,70 +62,64 @@ BEGIN { exit 1 } - LIBCOUNT = 0 + # Setup some sane defaults + LIBCOUNT = 2 HAVE_GCC34 = 0 - # Add the two default library paths DIRLIST[1] = "/lib" DIRLIST[2] = "/usr/lib" - # Walk /etc/ld.so.conf line for line and get any library paths + # + # Walk /etc/ld.so.conf to discover all our library paths + # pipe = "cat /etc/ld.so.conf | sort 2>/dev/null" while(((pipe) | getline ldsoconf_data) > 0) { - if (ldsoconf_data !~ /^[[:space:]]*#/) { - if (ldsoconf_data == "") continue # Remove any trailing comments sub(/#.*$/, "", ldsoconf_data) # Remove any trailing spaces sub(/[[:space:]]+$/, "", ldsoconf_data) - + + # If there's more than one path per line, split + # it up as if they were sep lines split(ldsoconf_data, nodes, /[:,[:space:]]/) # Now add the rest from ld.so.conf for (x in nodes) { - + # wtf does this line do ? sub(/=.*/, "", nodes[x]) + # Prune trailing / sub(/\/$/, "", nodes[x]) if (nodes[x] == "") continue - CHILD = 0 - + # # Drop the directory if its a child directory of # one that was already added ... + # For example, if we have: + # /usr/lib /usr/lib/mozilla /usr/lib/nss + # We really just want to save /usr/lib + # + CHILD = 0 for (y in DIRLIST) { - if (nodes[x] ~ "^" DIRLIST[y]) { - CHILD = 1 break } } - if (CHILD) continue - - DIRLIST[++LIBCOUNT + 2] = nodes[x] + + DIRLIST[++LIBCOUNT] = nodes[x] } } } - close(pipe) -# We have no guarantee that ld.so.conf have more library paths than -# the default, and its better to fix .la files only in /lib and -# /usr/lib than not at all ... -# if (LIBCOUNT == 0) { -# eerror("Could not read from /etc/ld.so.conf!") -# exit 1 -# } - - LIBCOUNT += 2 - + # # Get line from gcc's output containing CHOST + # pipe = "gcc -v 2>&1 | egrep '^Reading specs' 2>/dev/null" - if ((!((pipe) | getline TMP_CHOST)) || (TMP_CHOST == "")) { close(pipe) @@ -154,7 +141,6 @@ BEGIN { HAVE_GCC34 = 1 } } - close(pipe) if (CHOST == "") { @@ -168,14 +154,14 @@ BEGIN { GCCLIBPREFIX_OLD = "/usr/lib/gcc-lib/" GCCLIBPREFIX_NEW = "/usr/lib/gcc/" - + if (HAVE_GCC34) GCCLIBPREFIX = GCCLIBPREFIX_NEW else GCCLIBPREFIX = GCCLIBPREFIX_OLD - + GCCLIB = GCCLIBPREFIX CHOST - + if (OLDCHOST != "") { OLDGCCLIB1 = GCCLIBPREFIX_OLD OLDCHOST OLDGCCLIB2 = GCCLIBPREFIX_NEW OLDCHOST @@ -194,15 +180,17 @@ BEGIN { # Nothing to do ? if ((OLDVER == NEWVER) && (OLDCHOST == "")) exit 0 - - for (x = 1;x <= LIBCOUNT;x++) { + # + # Ok, now let's scan for the .la files and actually fix them up + # + for (x = 1; x <= LIBCOUNT; x++) { # Do nothing if the target dir is gcc's internal library path if (DIRLIST[x] ~ GCCLIBPREFIX_OLD || DIRLIST[x] ~ GCCLIBPREFIX_NEW) continue - einfo(" Scanning " DIRLIST[x] "...") + einfo(" [" x "/" LIBCOUNT "] Scanning " DIRLIST[x] " ...") pipe = "find " DIRLIST[x] "/ -name '*.la' 2>/dev/null" while (((pipe) | getline la_files) > 0) { @@ -217,36 +205,29 @@ BEGIN { # See if we need to fix the .la file while ((getline la_data < (la_files)) > 0) { - if (OLDCHOST != "") { - if ((gsub(OLDGCCLIB1 "[/[:space:]]+", GCCLIB, la_data) > 0) || (gsub(OLDGCCLIB2 "[/[:space:]]+", GCCLIB, la_data) > 0)) { - CHANGED = 1 CHOST_CHANGED = 1 } } - if (OLDVER != NEWVER) { - if ((gsub(GCCLIBPREFIX_OLD CHOST "/" OLDVER "[/[:space:]]*", GCCLIB "/" NEWVER, la_data) > 0) || (gsub(GCCLIBPREFIX_NEW CHOST "/" OLDVER "[/[:space:]]*", - GCCLIB "/" NEWVER, la_data) > 0)) + GCCLIB "/" NEWVER, la_data) > 0)) CHANGED = 1 } } - close(la_files) # Do the actual changes in a second loop, as we can then # verify that CHOST_CHANGED among things is correct ... if (CHANGED) { - - ewarnn(" FIXING: " la_files " ... ") + ewarnn(" FIXING: " la_files " ...") if (CHANGED) printn("[") @@ -256,21 +237,18 @@ BEGIN { dosystem("rm -f " la_files ".new") while ((getline la_data < (la_files)) > 0) { - if (OLDCHOST != "") { - tmpstr = gensub(OLDGCCLIB1 "([/[:space:]]+)", GCCLIB "\\1", "g", la_data) tmpstr = gensub(OLDGCCLIB2 "([/[:space:]]+)", GCCLIB "\\1", "g", tmpstr) - + if (la_data != tmpstr) { printn("c") la_data = tmpstr } if (CHOST_CHANGED > 0) { - # We try to be careful about CHOST changes outside # the gcc library path (meaning we cannot match it # via /GCCLIBPREFIX CHOST/) ... @@ -286,18 +264,20 @@ BEGIN { # dependency_libs=' -L/usr/lib/gcc-lib/CHOST/VER/../../../../CHOST/lib' # la_data = gensub("(" GCCLIB "/[^[:space:]]+)/" OLDCHOST "/", - "\\1/" CHOST "/", "g", la_data) + "\\1/" CHOST "/", "g", la_data) } } if (OLDVER != NEWVER) { - - tmpstr = gensub(GCCLIBPREFIX_OLD CHOST "/" OLDVER "([/[:space:]]*)", + # Catch: + # + # dependency_libs=' -L/usr/lib/gcc/CHOST/VER' + # + tmpstr = gensub(GCCLIBPREFIX_OLD CHOST "/" OLDVER "([/[:space:]]+)", GCCLIB "/" NEWVER "\\1", "g", la_data) - tmpstr = gensub(GCCLIBPREFIX_NEW CHOST "/" OLDVER "([/[:space:]]*)", + tmpstr = gensub(GCCLIBPREFIX_NEW CHOST "/" OLDVER "([/[:space:]]+)", GCCLIB "/" NEWVER "\\1", "g", tmpstr) - - + if (la_data != tmpstr) { # Catch: # @@ -308,7 +288,6 @@ BEGIN { GCCLIBPREFIX "\\1", "g", tmpstr) tmpstr = gensub(GCCLIBPREFIX_NEW "(../../" CHOST "/lib)", GCCLIBPREFIX "\\1", "g", tmpstr) - printn("v") la_data = tmpstr } @@ -332,5 +311,4 @@ BEGIN { } } - # vim:ts=4 diff --git a/sys-devel/gcc/files/fix_libtool_files.sh b/sys-devel/gcc/files/fix_libtool_files.sh index 6f6c612b648a..7aadf46a4a74 100644 --- a/sys-devel/gcc/files/fix_libtool_files.sh +++ b/sys-devel/gcc/files/fix_libtool_files.sh @@ -1,8 +1,7 @@ #!/bin/bash -# Copyright 1999-2004 Gentoo Foundation +# Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# Author: Martin Schlemmer <azarah@gentoo.org> -# $Header: /var/cvsroot/gentoo-x86/sys-devel/gcc/files/fix_libtool_files.sh,v 1.10 2004/07/15 00:59:02 agriffis Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-devel/gcc/files/fix_libtool_files.sh,v 1.11 2005/01/18 01:58:18 vapier Exp $ usage() { cat << "USAGE_END" @@ -25,52 +24,46 @@ Usage: fix_libtool_files.sh <old-gcc-version> [--oldarch <old-CHOST>] # fix_libtool_files.sh `gcc -dumpversion` --oldarch i586-pc-linux-gnu - USAGE_END - - exit 1 + exit 1 } -if [ "$2" != "--oldarch" -a "$#" -ne 1 ] || \ - [ "$2" = "--oldarch" -a "$#" -ne 3 ] +if [[ $2 != "--oldarch" && $# -ne 1 ]] || \ + [[ $2 == "--oldarch" && $# -ne 3 ]] then usage fi -ARGV1="$1" -ARGV2="$2" -ARGV3="$3" +ARGV1=$1 +ARGV2=$2 +ARGV3=$3 source /etc/profile source /sbin/functions.sh -if [ "`id -u`" -ne 0 ] -then +if [[ ${EUID} -ne 0 ]] ; then eerror "${0##*/}: Must be root." exit 1 fi -if [ "${ARGV2}" = "--oldarch" -a "x${ARGV3}" != "x" ] -then - OLDCHOST="${ARGV3}" +if [[ ${ARGV2} == "--oldarch" ]] && [[ -n ${ARGV3} ]] ; then + OLDCHOST=${ARGV3} else OLDCHOST= fi AWKDIR="/lib/rcscripts/awk" -if [ ! -r "${AWKDIR}/fixlafiles.awk" ] -then +if [[ ! -r ${AWKDIR}/fixlafiles.awk ]] ; then eerror "${0##*/}: ${AWKDIR}/fixlafiles.awk does not exist!" exit 1 fi -OLDVER="${ARGV1}" +OLDVER=${ARGV1} export OLDVER OLDCHOST einfo "Scanning libtool files for hardcoded gcc library paths..." /bin/gawk -f "${AWKDIR}/fixlafiles.awk" - # vim:ts=4 |