blob: e7efa7540131dceb64311f97c0ce1759f0845371 [file] [log] [blame]
Fred Draked3590222000-10-09 16:46:02 +00001#!/bin/sh
Guido van Rossum060f24c1998-12-18 15:37:14 +00002#
Fred Draked3590222000-10-09 16:46:02 +00003# Truly fake ar, using a directory to store object files.
Guido van Rossum060f24c1998-12-18 15:37:14 +00004#
Fred Draked3590222000-10-09 16:46:02 +00005# Donn Cave, donn@oz.net
Guido van Rossum060f24c1998-12-18 15:37:14 +00006
Fred Draked3590222000-10-09 16:46:02 +00007usage='Usage: ar-fake cr libpython.dir obj.o ...
8 ar-fake d libpython.dir obj.o ...
9 ar-fake so libpython.dir libpython.so'
Guido van Rossum060f24c1998-12-18 15:37:14 +000010
Fred Draked3590222000-10-09 16:46:02 +000011case $# in
120|1|2)
13 echo "$usage" >&2
14 exit 1
15 ;;
Guido van Rossum060f24c1998-12-18 15:37:14 +000016esac
17
Fred Draked3590222000-10-09 16:46:02 +000018command=$1
19library=$2
20shift 2
21
22case $command in
23cr)
24 if test -d $library
25 then :
26 else
27 mkdir $library
28 fi
29 if cp -p $* $library
30 then
31 # To force directory modify date, create or delete a file.
32 if test -e $library/.tch
33 then rm $library/.tch
34 else echo tch > $library/.tch
35 fi
36 exit 0
37 fi
38 ;;
39d)
40 if test -d $library
41 then
42 cd $library
43 rm -f $*
44 fi
45 ;;
46so)
47 case $BE_HOST_CPU in
48 ppc)
Guido van Rossum3fa560b2001-01-19 00:31:10 +000049 # In case your libpython.a refers to any exotic libraries,
50 # mwld needs to know that here. The following hack makes
51 # a couple of assumptions about Modules/Makefile. If it
52 # doesn't work, you may as well add the necessary libraries
53 # here explicitly instead.
54 extralibs=$(
55 (cd Modules; make -f Makefile -n link) |
56 sed -n 's/.*\.so \(.*\) -o python.*/\1/p'
57 )
58 mwld -xms -export pragma -nodup -o $1 $library/* $extralibs
Fred Draked3590222000-10-09 16:46:02 +000059 ;;
60 x86)
Guido van Rossum3fa560b2001-01-19 00:31:10 +000061 ld -shared -soname $(basename $1) -o $1 $library/*
Fred Draked3590222000-10-09 16:46:02 +000062 ;;
63 esac
64 status=$?
65 cd $(dirname $1)
66 ln -sf $PWD lib
67 exit $status
68 ;;
69*)
70 echo "$usage" >&2
71 exit 1
72 ;;
73esac