You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
3.3 KiB

  1. #!/bin/sh
  2. #
  3. # +----------------------------------------------------------------------+
  4. # | PHP HTML Embedded Scripting Language Version 4.0 |
  5. # +----------------------------------------------------------------------+
  6. # | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
  7. # +----------------------------------------------------------------------+
  8. # | This program is free software; you can redistribute it and/or modify |
  9. # | it under the terms of one of the following licenses: |
  10. # | |
  11. # | A) the GNU General Public License as published by the Free Software |
  12. # | Foundation; either version 2 of the License, or (at your option) |
  13. # | any later version. |
  14. # | |
  15. # | B) the PHP License as published by the PHP Development Team and |
  16. # | included in the distribution in the file: LICENSE |
  17. # | |
  18. # | This program is distributed in the hope that it will be useful, |
  19. # | but WITHOUT ANY WARRANTY; without even the implied warranty of |
  20. # | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
  21. # | GNU General Public License for more details. |
  22. # | |
  23. # | You should have received a copy of both licenses referred to here. |
  24. # | If you did not, or have any questions about PHP licensing, please |
  25. # | contact core@php.net. |
  26. # +----------------------------------------------------------------------+
  27. # | Authors: Stig S�ther Bakken <ssb@fast.no> |
  28. # +----------------------------------------------------------------------+
  29. #
  30. # Archive merger. Usage: armerge libout.a dir1/libin1.a dir2/libin2.a ...
  31. # Creates the archive libout.a from the files in the rest of the
  32. # parameter list. If the input archives are in separate directories,
  33. # the names of the files inside them are prefixed before they are
  34. # merged into the output archive. The prefix used is the same as the
  35. # directory name with "/" replaced by "_" and a "_" at the end.
  36. #
  37. # $Id$
  38. #
  39. die() {
  40. echo $@
  41. exit 1
  42. }
  43. if test "$#" -lt "2"; then
  44. echo "Usage: "`basename $0`" <out-archive> <in-archives...>"
  45. exit 1
  46. fi
  47. out_archive=$1; shift
  48. in_archives=$@
  49. cwd=`pwd`
  50. tmpdir=/tmp/armerge$$
  51. rm -f $out_archive
  52. mkdir $tmpdir || die "can not create temporary directory $tmpdir"
  53. ( cd $tmpdir;
  54. for archive in $in_archives; do
  55. files=`ar t $cwd/$archive | sed -e 's/__\.SYMDEF SORTED//'`
  56. ar x $cwd/$archive
  57. dir=`dirname $archive`
  58. if test "$dir" = "."; then
  59. ext_files=$files
  60. else
  61. prefix=`echo $dir | sed -e 's#^\./##' -e 's#/#_#g'`_
  62. prefix=`echo $prefix | sed -e 's#^\.\._##g'`
  63. ext_files=""
  64. for file in $files; do
  65. if test "$file" != "$prefix$file"; then
  66. mv "$file" "$prefix$file"
  67. fi
  68. ext_files="$ext_files $prefix$file"
  69. done
  70. fi
  71. ar r out.a $ext_files
  72. done )
  73. cmp $tmpdir/out.a $out_archive >/dev/null 2>&1 || mv $tmpdir/out.a $out_archive || die "can not create $out_archive"
  74. rm -rf $tmpdir