This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
71a989122b2390a8c4fcebce395080db184f8d81
[metaconfig.git] / U / modified / libs.U
1 ?RCS: $Id: libs.U,v 3.0.1.6 1997/02/28 16:09:11 ram Exp $
2 ?RCS:
3 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
4 ?RCS: 
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 3.0.
10 ?RCS:
11 ?RCS: $Log: libs.U,v $
12 ?RCS: Revision 3.0.1.6  1997/02/28  16:09:11  ram
13 ?RCS: patch61: replaced .a with $_a all over the place
14 ?RCS:
15 ?RCS: Revision 3.0.1.5  1995/07/25  14:12:05  ram
16 ?RCS: patch56: now knows about OS/2 platforms
17 ?RCS:
18 ?RCS: Revision 3.0.1.4  1994/10/29  16:24:22  ram
19 ?RCS: patch36: removed old broken thislib/thatlib processing (ADO)
20 ?RCS:
21 ?RCS: Revision 3.0.1.3  1994/06/20  07:05:44  ram
22 ?RCS: patch30: code cleanup with if/elif by ADO and RAM
23 ?RCS: patch30: undone patch23 for libswanted default setting
24 ?RCS:
25 ?RCS: Revision 3.0.1.2  1994/05/06  15:08:45  ram
26 ?RCS: patch23: now includes ordered default libswanted variable (ADO)
27 ?RCS: patch23: major cleanup for library lookups (ADO)
28 ?RCS:
29 ?RCS: Revision 3.0.1.1  1993/08/25  14:02:31  ram
30 ?RCS: patch6: added default for libs
31 ?RCS:
32 ?RCS: Revision 3.0  1993/08/18  12:09:03  ram
33 ?RCS: Baseline for dist 3.0 netwide release.
34 ?RCS:
35 ?MAKE:libs ignore_versioned_solibs libsfound libsfiles libsdirs: \
36         test cat Myread Oldconfig Loc libpth package xlibpth so _a \
37         usesocks ccflags
38 ?MAKE:  -pick add $@ %<
39 ?S:libs:
40 ?S:     This variable holds the additional libraries we want to use.
41 ?S:     It is up to the Makefile to deal with it.
42 ?S:.
43 ?S:libsfound:
44 ?S:     This variable holds the full pathnames of the libraries
45 ?S:     we found and accepted.
46 ?S:.
47 ?S:libsfiles:
48 ?S:     This variable holds the filenames aka basenames of the libraries
49 ?S:     we found and accepted.
50 ?S:.
51 ?S:libsdirs:
52 ?S:     This variable holds the directory names aka dirnames of the libraries
53 ?S:     we found and accepted, duplicates are removed.
54 ?S:.
55 ?S:ignore_versioned_solibs:
56 ?S:     This variable should be non-empty if non-versioned shared
57 ?S:     libraries (libfoo.so.x.y) are to be ignored (because they
58 ?S:     cannot be linked against).
59 ?S:.
60 ?T:xxx yyy thislib libswanted libstyle libname
61 ?D:libs=''
62 ?X:
63 ?X: This order is chosen so that libraries  -lndir, -ldir, -lucb, -lbsd,
64 ?X: -lBSD, -lPW, and -lx only get used if there are unresolved
65 ?X: routines at link time.  Usually, these are backwards compatability
66 ?X: libraries, and may not be as reliable as the standard c library.
67 ?X:
68 ?X: The -lsocket -linet -lnsl order has been reported to be necessary
69 ?X: for at least one SVR4 implementation.
70 ?X: -lc must proceed -lucb or -lbsd for most Solaris applications.
71 ?X: -lc_s proceeds -lc so we pick up the shared library version, if
72 ?X: it is available.
73 ?X:
74 ?X: The ordering of c, posix, and cposix is a guess and almost
75 ?X: certainly wrong on about half of all systems.
76 ?X:
77 ?X: Set proper libswanted in your private Myinit.U if needed.
78 ?X:
79 ?X:: default ordered library list
80 ?X:libswanted='net socket inet nsl nm sdbm gdbm ndbm dbm malloc dl'
81 ?X:libswanted="$libswanted dld sun m c_s c posix cposix ndir dir ucb"
82 ?X:libswanted="$libswanted bsd BSD PW x iconv"
83 ?X:
84 ?INIT:: default library list
85 ?INIT:libswanted=''
86 ?INIT:: some systems want to use only the non-versioned libso:s
87 ?INIT:ignore_versioned_solibs=''
88 : Looking for optional libraries
89 echo " "
90 echo "Checking for optional libraries..." >&4
91 case "$libs" in
92 ' '|'') dflt='';;
93 *) dflt="$libs";;
94 esac
95 case "$libswanted" in
96 '') libswanted='c_s';;
97 esac
98 ?X: libsocks has nasty naming.
99 case "$usesocks" in
100 $define)
101         libswanted="$libswanted socks5 socks5_sh"
102         ;;
103 esac
104 for thislib in $libswanted; do
105 ?X:
106 ?X: Comparisons via case statement use the string " $dflt " to ensure that
107 ?X: each library is separated by a space. That way, by looking to something
108 ?X: like *"-l$thislib "*, we ensure we find -lm and not -lmalloc (which was
109 ?X: the case with the old looking pattern *-l$thislib*.
110 ?X:
111         for thisdir in $libpth; do
112             xxx=''
113             if $test ! -f "$xxx" -a "X$ignore_versioned_solibs" = "X"; then
114                 xxx=`ls $thisdir/lib$thislib.$so.[0-9] 2>/dev/null|tail -1`
115                 $test -f "$xxx" && eval $libscheck
116                 $test -f "$xxx" && libstyle=shared
117             fi
118             if test ! -f "$xxx"; then
119                 xxx=$thisdir/lib$thislib.$so
120                 $test -f "$xxx" && eval $libscheck
121                 $test -f "$xxx" && libstyle=shared
122             fi  
123             if test ! -f "$xxx"; then
124                 xxx=$thisdir/lib$thislib$_a
125                 $test -f "$xxx" && eval $libscheck
126                 $test -f "$xxx" && libstyle=static
127             fi
128             if test ! -f "$xxx"; then
129                 xxx=$thisdir/$thislib$_a
130                 $test -f "$xxx" && eval $libscheck
131                 $test -f "$xxx" && libstyle=static
132             fi
133             if test ! -f "$xxx"; then
134                 xxx=$thisdir/lib${thislib}_s$_a
135                 $test -f "$xxx" && eval $libscheck
136                 $test -f "$xxx" && libstyle=static
137             fi
138             if test ! -f "$xxx"; then
139                 xxx=$thisdir/Slib$thislib$_a
140                 $test -f "$xxx" && eval $libscheck
141                 $test -f "$xxx" && libstyle=static
142             fi
143             if $test -f "$xxx"; then
144                 case "$libstyle" in
145                 shared) echo "Found -l$thislib (shared)." ;;
146                 static) echo "Found -l$thislib." ;;
147                 *)      echo "Found -l$thislib ($libstyle)." ;;
148                 esac
149                 case " $dflt " in
150                 *"-l$thislib "*);;
151                 *) dflt="$dflt -l$thislib"
152                    libsfound="$libsfound $xxx"
153                    yyy=`basename $xxx`
154                    libsfiles="$libsfiles $yyy"
155                    yyy=`echo $xxx|sed "s@/$yyy\\$@@"`
156                    case " $libsdirs " in
157                    *" $yyy "*) ;;
158                    *) libsdirs="$libsdirs $yyy" ;;
159                    esac
160                    ;;
161                 esac
162                 break
163             fi  
164         done
165         if $test ! -f "$xxx"; then
166             echo "No -l$thislib."
167         fi
168 done
169 set X $dflt
170 shift
171 dflt="$*"
172 case "$libs" in
173 '') dflt="$dflt";;
174 *) dflt="$libs";;
175 esac
176 case "$dflt" in
177 ' '|'') dflt='none';;
178 esac
179
180 $cat <<EOM
181
182 In order to compile $package on your machine, a number of libraries
183 are usually needed.  Include any other special libraries here as well.
184 Say "none" for none.  The default list is almost always right.
185 EOM
186
187 echo " "
188 rp="What libraries to use?"
189 . ./myread
190 case "$ans" in
191 none) libs=' ';;
192 *) libs="$ans";;
193 esac
194