This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
metaconfig unit changes for #19219.
[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 : see if ar generates random libraries by itself
42 echo " "
43 echo "Checking how to generate random libraries on your machine..." >&4
44 ?X: Some systems (like MIPS) complain when running ar... Others like Ultrix
45 ?X: need an explicit 'ar ts' to add the table of contents.
46 ?X: Still others like Linux run ar ts successfully, but still need ranlib.
47 ?X: This set of tests seems the minimum necessary to check out Linux.
48 ?X: We need to explicitly put the entries in out-of-order so that Sun's ld
49 ?X: will fail.  (Otherwise it complains, but gives an exit status of 0.)
50 echo 'int bar1() { return bar2(); }' > bar1.c
51 echo 'int bar2() { return 2; }' > bar2.c
52 $cat > foo.c <<EOP
53 #$i_stdlib I_STDLIB
54 #ifdef I_STDLIB
55 #include <stdlib.h>
56 #endif
57 int main() { printf("%d\n", bar1()); exit(0); }
58 EOP
59 $cc $ccflags -c bar1.c >/dev/null 2>&1
60 $cc $ccflags -c bar2.c >/dev/null 2>&1
61 $cc $ccflags -c foo.c >/dev/null 2>&1
62 $ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
63 if $cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
64         $run ./foobar >/dev/null 2>&1; then
65         echo "$ar appears to generate random libraries itself."
66         orderlib=false
67         ranlib=":"
68 elif $ar ts bar$_a >/dev/null 2>&1 &&
69         $cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
70         $run ./foobar >/dev/null 2>&1; then
71                 echo "a table of contents needs to be added with '$ar ts'."
72                 orderlib=false
73                 ranlib="$ar ts"
74 else
75 ?X: Allow hints to specify their own ranlib "script". For instance, on
76 ?X: some NeXT machines, the timestamp put by ranlib is not correct, and this
77 ?X: may raise tedious recompiles for nothing. Therefore, NeXT may add the
78 ?X: ranlib='sleep 5; /bin/ranlib' line in their hints to "fix" that.
79 ?X: (reported by Andreas Koenig <k@franz.ww.tu-berlin.de>)
80         case "$ranlib" in
81         :) ranlib='';;
82         '')
83                 ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
84                 $test -f $ranlib || ranlib=''
85                 ;;
86         esac
87         if $test -n "$ranlib"; then
88                 echo "your system has '$ranlib'; we'll use that."
89                 orderlib=false
90         else
91                 echo "your system doesn't seem to support random libraries"
92                 echo "so we'll use lorder and tsort to order the libraries."
93                 orderlib=true
94                 ranlib=":"
95         fi
96 fi
97 $rm -f foo* bar* 
98