This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add the files from dist/meta to perl's repo
[metaconfig.git] / dist / U / orderlib.U
1 ?RCS: $Id: orderlib.U 1 2006-08-24 12:32:52Z rmanfredi $
2 ?RCS:
3 ?RCS: Copyright (c) 1991-1997, 2004-2006, 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 4.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 _a _o
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 int main() { printf("%d\n", bar1()); exit(0); }
55 EOP
56 $cc $ccflags -c bar1.c >/dev/null 2>&1
57 $cc $ccflags -c bar2.c >/dev/null 2>&1
58 $cc $ccflags -c foo.c >/dev/null 2>&1
59 $ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
60 if $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
61         ./foobar >/dev/null 2>&1; then
62         echo "ar appears to generate random libraries itself."
63         orderlib=false
64         ranlib=":"
65 elif $ar ts bar$_a >/dev/null 2>&1 &&
66         $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
67         ./foobar >/dev/null 2>&1; then
68                 echo "a table of contents needs to be added with 'ar ts'."
69                 orderlib=false
70                 ranlib="$ar ts"
71 else
72 ?X: Allow hints to specify their own ranlib "script". For instance, on
73 ?X: some NeXT machines, the timestamp put by ranlib is not correct, and this
74 ?X: may raise tedious recompiles for nothing. Therefore, NeXT may add the
75 ?X: ranlib='sleep 5; /bin/ranlib' line in their hints to "fix" that.
76 ?X: (reported by Andreas Koenig <k@franz.ww.tu-berlin.de>)
77         case "$ranlib" in
78         :) ranlib='';;
79         '')
80                 ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
81                 $test -f $ranlib || ranlib=''
82                 ;;
83         esac
84         if $test -n "$ranlib"; then
85                 echo "your system has '$ranlib'; we'll use that."
86                 orderlib=false
87         else
88                 echo "your system doesn't seem to support random libraries"
89                 echo "so we'll use lorder and tsort to order the libraries."
90                 orderlib=true
91                 ranlib=":"
92         fi
93 fi
94 $rm -f foo* bar* 
95