Sun Mar 11 15:22:42 CET 2007 Jochen Eisinger <coffee@silcnet.org>
[silc.git] / libtoolfix
1 #!/bin/sh
2 #
3 # No Copyright 2002 Pekka Riikonen <priikone@silcnet.org>
4 #
5 # This script fixes the fundamental problem of libtool: it is not 
6 # configurable in run-time.  This changes the libtool so that it becomes
7 # more generic and configurable in run-time.
8 #
9 # New command line options to libtool:
10 #
11 # --libtool-enable-shared       Enable shared library compilation
12 # --libtool-enable-static       Enable static library compilation
13 # --libtool-disable-shared      Disable shared library compilation
14 # --libtool-disable-static      Disable static library compilation
15 #
16 # If options are omitted the default libtool configuration will apply.
17 #
18
19 # Sanity checks
20 if test '!' -f ./libtool; then
21   echo "./libtool does not exist"
22   exit 0
23 fi
24
25 # Take configuration from the ./libtool
26 sed '/^# ltmain\.sh/q' ./libtool >./libtool.tmp
27
28 # Put our wrapper to the new libtool.  This allows the run-time
29 # configuration of the libtool.
30 ltmain=`pwd`/ltmain.sh
31 cat << EOF >> ./libtool.tmp
32 args=\`echo \$*\`
33 cargs=\`echo \$* | sed -e '/--libtool-enable-shared/s///' -e '/--libtool-enable-static/s///' -e '/--libtool-disable-shared/s///' -e '/--libtool-disable-static/s///'\`
34 for i in \$args
35 do
36   if test "\$i" = "--libtool-enable-shared"; then
37     build_libtool_libs=yes
38     fast_install=yes
39     continue
40   fi
41   if test "\$i" = "--libtool-disable-shared"; then
42     build_libtool_libs=no
43     continue
44   fi
45   if test "\$i" = "--libtool-enable-static"; then
46     build_old_libs=yes
47     continue
48   fi
49   if test "\$i" = "--libtool-disable-static"; then
50     build_old_libs=no
51     continue
52   fi
53 done
54 if test "\$cargs" = ""; then
55   cargs="--silent"
56 fi
57 . $ltmain \$cargs
58 EOF
59
60 mv -f ./libtool.tmp ./libtool
61 chmod +x ./libtool
62
63 exit 1