Annotation of embedaddon/libiconv/build-aux/reloc-ldflags, revision 1.1.1.3

1.1       misho       1: #! /bin/sh
                      2: # Output a system dependent linker command for putting a relocatable library
                      3: # search path into an executable.
                      4: #
1.1.1.3 ! misho       5: #   Copyright 2003-2019 Free Software Foundation, Inc.
1.1       misho       6: #   Written by Bruno Haible <bruno@clisp.org>, 2003.
                      7: #
                      8: #   This program is free software: you can redistribute it and/or modify
                      9: #   it under the terms of the GNU General Public License as published by
                     10: #   the Free Software Foundation; either version 3 of the License, or
                     11: #   (at your option) any later version.
                     12: #
                     13: #   This program is distributed in the hope that it will be useful,
                     14: #   but WITHOUT ANY WARRANTY; without even the implied warranty of
                     15: #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     16: #   GNU General Public License for more details.
                     17: #
                     18: #   You should have received a copy of the GNU General Public License
1.1.1.3 ! misho      19: #   along with this program.  If not, see <https://www.gnu.org/licenses/>.
1.1       misho      20: #
                     21: #   As a special exception to the GNU General Public License, if you
                     22: #   distribute this file as part of a program that contains a
                     23: #   configuration script generated by Autoconf, you may include it under
                     24: #   the same distribution terms that you use for the rest of that program.
                     25: #
                     26: # The first argument passed to this file is the canonical host specification,
                     27: #    CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
                     28: # or
                     29: #    CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
                     30: # The environment variable LD should be set by the caller.
                     31: #
                     32: # The second argument is a colon separated list of directories that contain
                     33: # the libraries at installation time.
                     34: #
                     35: # The third argument is the directory into which the executable is going to be
                     36: # installed.
                     37: 
                     38: host="$1"
                     39: host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
                     40: host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
                     41: host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
                     42: 
                     43: library_path_value=$2
                     44: 
                     45: installdir=$3
                     46: 
                     47: # Verify that installdir is absolute.
                     48: case "$installdir" in
                     49:   /*) ;;
                     50:   *)
                     51:     echo "installdir is not absolute: $installdir" 1>&2
                     52:     exit 1
                     53:     ;;
                     54: esac
                     55: 
1.1.1.3 ! misho      56: origin_token=
1.1       misho      57: case "$host_os" in
1.1.1.3 ! misho      58:   linux* | gnu* | kfreebsd* | \
        !            59:   freebsd* | dragonfly* | \
        !            60:   netbsd* | \
        !            61:   openbsd* | \
        !            62:   solaris* | \
        !            63:   haiku*)
        !            64:     origin_token='$ORIGIN'
1.1       misho      65:     ;;
1.1.1.3 ! misho      66:   darwin*)
        !            67:     origin_token='@loader_path'
1.1       misho      68:     ;;
                     69: esac
1.1.1.3 ! misho      70: if test -n "$origin_token"; then
        !            71:   rpath=
        !            72:   save_IFS="$IFS"; IFS=":"
        !            73:   for dir in $library_path_value; do
        !            74:     IFS="$save_IFS"
        !            75:     case "$dir" in
        !            76:       /*)
        !            77:         # Make dir relative to installdir. (Works only if dir is absolute.)
        !            78:         idir="$installdir"
        !            79:         while true; do
        !            80:           dfirst=`echo "$dir" | sed -n -e 's,^//*\([^/]*\).*$,/\1,p'`
        !            81:           ifirst=`echo "$idir" | sed -n -e 's,^//*\([^/]*\).*$,/\1,p'`
        !            82:           if test -z "$dfirst" || test -z "$ifirst"; then
        !            83:             break
        !            84:           fi
        !            85:           if test "$dfirst" != "$ifirst"; then
        !            86:             break
        !            87:           fi
        !            88:           dir=`echo "$dir" | sed -e 's,^//*[^/]*,,'`
        !            89:           idir=`echo "$idir" | sed -e 's,^//*[^/]*,,'`
        !            90:         done
        !            91:         dir="$origin_token"`echo "$idir" | sed -e 's,//*[^/]*,/..,g'`"$dir"
        !            92:         # Add dir to rpath.
        !            93:         rpath="${rpath}${rpath:+ }$dir"
        !            94:         ;;
        !            95:       *)
        !            96:         if test -n "$dir"; then
        !            97:           echo "libdir is not absolute: $dir" 1>&2
        !            98:         fi
        !            99:         ;;
        !           100:     esac
        !           101:   done
        !           102:   IFS="$save_IFS"
        !           103:   # Output it.
        !           104:   if test -n "$rpath"; then
        !           105:     case "$host_os" in
        !           106:       # At least some versions of FreeBSD, DragonFly, and OpenBSD need the
        !           107:       # linker option "-z origin". See <https://lekensteyn.nl/rpath.html>.
        !           108:       freebsd* | dragonfly* | openbsd*)
        !           109:         echo "-Wl,-z,origin -Wl,-rpath,$rpath" ;;
        !           110:       *)
        !           111:         echo "-Wl,-rpath,$rpath" ;;
        !           112:     esac
        !           113:   fi
        !           114: else
        !           115:   echo "relocation via rpath not supported on this system: $host" 1>&2
        !           116:   exit 1
        !           117: fi
1.1       misho     118: 
                    119: exit 0

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>