No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / build-aux / install-reloc
blobad4b0ebdd6a140d1d9af47d8df4ed67aeae5c137
1 #!/bin/sh
2 # install-reloc - install a program including a relocating wrapper
3 # Copyright (C) 2003 Free Software Foundation, Inc.
4 # Written by Bruno Haible <bruno@clisp.org>, 2003.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 # Usage:
21 # install-reloc library_path_var library_path_value prefix compile_command srcdir config_h_dir install_command... destprog
22 # where
23 # - library_path_var is the platform dependent runtime library path variable
24 # - library_path_value is a colon separated list of directories that contain
25 # the libraries at installation time (use this instead of -rpath)
26 # - prefix is the base directory at installation time
27 # - compile_command is a C compiler compilation and linking command
28 # - srcdir is the directory where to find relocwrapper.c and its dependencies
29 # - builddir is the directory where to find built dependencies (namely,
30 # alloca.h and stdbool.h)
31 # - config_h_dir is the directory where to find config.h
32 # - install-command is the install command line, excluding the final destprog
33 # - destprog is the destination program name
34 # install-reloc renames destprog to destprog.bin and installs a relocating
35 # wrapper in the place of destprog.
37 progname=$0
39 if test $# -eq 2; then
40 # Get arguments from environment variables.
41 library_path_var=$RELOC_LIBRARY_PATH_VAR
42 library_path_value=$RELOC_LIBRARY_PATH_VALUE
43 prefix=$RELOC_PREFIX
44 compile_command=$RELOC_COMPILE_COMMAND
45 srcdir=$RELOC_SRCDIR
46 builddir=$RELOC_BUILDDIR
47 config_h_dir=$RELOC_CONFIG_H_DIR
48 install_prog=$RELOC_INSTALL_PROG # including the "-c" option
49 else
50 if test $# -ge 9; then
51 # Get fixed position arguments.
52 library_path_var=$1
53 library_path_value=$2
54 prefix=$3
55 compile_command=$4
56 srcdir=$5
57 builddir=$6
58 config_h_dir=$7
59 install_prog=$8 # maybe not including the "-c" option
60 shift
61 shift
62 shift
63 shift
64 shift
65 shift
66 shift
67 shift
68 else
69 echo "Usage: $0 library_path_var library_path_value prefix compile_command srcdir builddir config_h_dir install_command... destprog" 1>&2
70 exit 1
74 # Get destprog, last argument.
75 destprog=
76 for arg
78 destprog=$arg
79 done
81 # Outputs a command and runs it.
82 func_verbose ()
84 echo "$@"
85 "$@"
88 # Run install_command.
89 func_verbose $install_prog "$@" || exit $?
91 # If the platform doesn't support LD_LIBRARY_PATH or similar, we cannot build
92 # a wrapper.
93 test -n "$library_path_var" || exit 0
95 libdirs=
96 save_IFS="$IFS"; IFS=":"
97 for dir in $library_path_value; do
98 IFS="$save_IFS"
99 if test -n "$dir"; then
100 case "$libdirs" in
101 *"\"$dir\""*) ;; # remove duplicate
102 *) libdirs="$libdirs\"$dir\"," ;;
103 esac
105 done
106 IFS="$save_IFS"
107 # If there are no library directories to add at runtime, we don't need a
108 # wrapper.
109 test -n "$libdirs" || exit 0
111 # Compile wrapper.
112 installdir=`echo "$destprog" | sed -e 's,/[^/]*$,,'`
113 func_verbose $compile_command -I"$builddir" -I"$srcdir" -I"$config_h_dir" -DHAVE_CONFIG_H -DNO_XMALLOC -D"INSTALLPREFIX=\"$prefix\"" -D"INSTALLDIR=\"$installdir\"" -D"LIBPATHVAR=\"$library_path_var\"" -D"LIBDIRS=$libdirs" "$srcdir"/relocwrapper.c "$srcdir"/progname.c "$srcdir"/progreloc.c "$srcdir"/xreadlink.c "$srcdir"/readlink.c "$srcdir"/canonicalize.c "$srcdir"/allocsa.c "$srcdir"/relocatable.c "$srcdir"/setenv.c "$srcdir"/strerror.c -o $destprog.wrapper || exit $?
115 # Rename $destprog.wrapper -> $destprog -> $destprog.bin.
116 ln -f $destprog $destprog.bin || exit 1
117 mv $destprog.wrapper $destprog || exit 1
119 exit 0