This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
ee3262489edd38b30968e995a5b8a8fc4a41434b
[metaconfig.git] / U / compline / orderlib.U
1 ?RCS: $Id: orderlib.U,v 3.0.1.4 1997/02/28 16:18:18 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: orderlib.U,v $
12 ?RCS: Revision 3.0.1.4  1997/02/28  16:18:18  ram
13 ?RCS: patch61: replaced .a with $_a all over the place
14 ?RCS: patch61: likewise for .o replaced by $_o
15 ?RCS: patch61: now uses the ar located by Loc.U
16 ?RCS:
17 ?RCS: Revision 3.0.1.3  1995/01/11  15:33:04  ram
18 ?RCS: patch45: allows hint files to specify their own value for 'ranlib'
19 ?RCS:
20 ?RCS: Revision 3.0.1.2  1994/10/29  16:26:48  ram
21 ?RCS: patch36: now performs a real small compile for accurate checks (ADO)
22 ?RCS:
23 ?RCS: Revision 3.0.1.1  1994/08/29  16:31:17  ram
24 ?RCS: patch32: use cc variable instead of hardwired 'cc' in 1st compile
25 ?RCS:
26 ?RCS: Revision 3.0  1993/08/18  12:09:26  ram
27 ?RCS: Baseline for dist 3.0 netwide release.
28 ?RCS:
29 ?MAKE:orderlib ranlib: Loc ar cat test rm +cc +ccflags +ldflags +libs i_stdlib _a _o run
30 ?MAKE:  -pick add $@ %<
31 ?S:orderlib:
32 ?S:     This variable is "true" if the components of libraries must be ordered
33 ?S:     (with `lorder $* | tsort`) before placing them in an archive.  Set to
34 ?S:     "false" if ranlib or ar can generate random libraries.
35 ?S:.
36 ?S:ranlib:
37 ?S:     This variable is set to the pathname of the ranlib program, if it is
38 ?S:     needed to generate random libraries.  Set to ":" if ar can generate
39 ?S:     random libraries or if random libraries are not supported
40 ?S:.
41 ?F:!foobar
42 : see if ar generates random libraries by itself
43 echo " "
44 echo "Checking how to generate random libraries on your machine..." >&4
45 ?X: Some systems (like MIPS) complain when running ar... Others like Ultrix
46 ?X: need an explicit 'ar ts' to add the table of contents.
47 ?X: Still others like Linux run ar ts successfully, but still need ranlib.
48 ?X: This set of tests seems the minimum necessary to check out Linux.
49 ?X: We need to explicitly put the entries in out-of-order so that Sun's ld
50 ?X: will fail.  (Otherwise it complains, but gives an exit status of 0.)
51 echo 'int bar1() { return bar2(); }' > bar1.c
52 echo 'int bar2() { return 2; }' > bar2.c
53 $cat > foo.c <<EOP
54 #$i_stdlib I_STDLIB
55 #ifdef I_STDLIB
56 #include <stdlib.h>
57 #endif
58 int main() { printf("%d\n", bar1()); exit(0); }
59 EOP
60 $cc $ccflags -c bar1.c >/dev/null 2>&1
61 $cc $ccflags -c bar2.c >/dev/null 2>&1
62 $cc $ccflags -c foo.c >/dev/null 2>&1
63 $ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
64 if $cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
65         $run ./foobar >/dev/null 2>&1; then
66         echo "$ar appears to generate random libraries itself."
67         orderlib=false
68         if [ "X$ranlib" = "X" ]; then
69             ranlib=":"
70         fi
71 elif $ar s bar$_a >/dev/null 2>&1 &&
72         $cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
73         $run ./foobar >/dev/null 2>&1; then
74                 echo "a table of contents needs to be added with '$ar s'."
75                 orderlib=false
76                 ranlib="$ar s"
77 elif $ar ts bar$_a >/dev/null 2>&1 &&
78         $cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
79         $run ./foobar >/dev/null 2>&1; then
80                 echo "a table of contents needs to be added with '$ar ts'."
81                 orderlib=false
82                 ranlib="$ar ts"
83 else
84 ?X: Allow hints to specify their own ranlib "script". For instance, on
85 ?X: some NeXT machines, the timestamp put by ranlib is not correct, and this
86 ?X: may raise tedious recompiles for nothing. Therefore, NeXT may add the
87 ?X: ranlib='sleep 5; /bin/ranlib' line in their hints to "fix" that.
88 ?X: (reported by Andreas Koenig <k@franz.ww.tu-berlin.de>)
89         case "$ranlib" in
90         :) ranlib='';;
91         '')
92                 ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
93                 $test -f $ranlib || ranlib=''
94                 ;;
95         esac
96         if $test -n "$ranlib"; then
97                 echo "your system has '$ranlib'; we'll use that."
98                 orderlib=false
99         else
100                 echo "your system doesn't seem to support random libraries"
101                 echo "so we'll use lorder and tsort to order the libraries."
102                 orderlib=true
103                 ranlib=":"
104         fi
105 fi
106 $rm -f foo* bar*
107