Fred Drake | d359022 | 2000-10-09 16:46:02 +0000 | [diff] [blame] | 1 | #!/bin/sh |
Guido van Rossum | 060f24c | 1998-12-18 15:37:14 +0000 | [diff] [blame] | 2 | # |
Fred Drake | d359022 | 2000-10-09 16:46:02 +0000 | [diff] [blame] | 3 | # Truly fake ar, using a directory to store object files. |
Guido van Rossum | 060f24c | 1998-12-18 15:37:14 +0000 | [diff] [blame] | 4 | # |
Fred Drake | d359022 | 2000-10-09 16:46:02 +0000 | [diff] [blame] | 5 | # Donn Cave, donn@oz.net |
Guido van Rossum | 060f24c | 1998-12-18 15:37:14 +0000 | [diff] [blame] | 6 | |
Fred Drake | d359022 | 2000-10-09 16:46:02 +0000 | [diff] [blame] | 7 | usage='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 Rossum | 060f24c | 1998-12-18 15:37:14 +0000 | [diff] [blame] | 10 | |
Fred Drake | d359022 | 2000-10-09 16:46:02 +0000 | [diff] [blame] | 11 | case $# in |
| 12 | 0|1|2) |
| 13 | echo "$usage" >&2 |
| 14 | exit 1 |
| 15 | ;; |
Guido van Rossum | 060f24c | 1998-12-18 15:37:14 +0000 | [diff] [blame] | 16 | esac |
| 17 | |
Fred Drake | d359022 | 2000-10-09 16:46:02 +0000 | [diff] [blame] | 18 | command=$1 |
| 19 | library=$2 |
| 20 | shift 2 |
| 21 | |
| 22 | case $command in |
| 23 | cr) |
| 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 | ;; |
| 39 | d) |
| 40 | if test -d $library |
| 41 | then |
| 42 | cd $library |
| 43 | rm -f $* |
| 44 | fi |
| 45 | ;; |
| 46 | so) |
| 47 | case $BE_HOST_CPU in |
| 48 | ppc) |
| 49 | mwld -xms -export pragma -nodup -o $1 $library/* |
| 50 | ;; |
| 51 | x86) |
| 52 | gcc -nostart -Wl,-soname=$(basename $1) -o $1 $library/* |
| 53 | ;; |
| 54 | esac |
| 55 | status=$? |
| 56 | cd $(dirname $1) |
| 57 | ln -sf $PWD lib |
| 58 | exit $status |
| 59 | ;; |
| 60 | *) |
| 61 | echo "$usage" >&2 |
| 62 | exit 1 |
| 63 | ;; |
| 64 | esac |