/Modules/ar_beos

http://unladen-swallow.googlecode.com/ · Shell · 73 lines · 58 code · 4 blank · 11 comment · 5 complexity · 467e7301472247c65579e4d5811e7f1a MD5 · raw file

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