pre-inst-guile.in 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/bin/sh
  2. # Copyright (C) 2002, 2006, 2008 Free Software Foundation
  3. #
  4. # This file is part of GUILE.
  5. #
  6. # GUILE is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as
  8. # published by the Free Software Foundation; either version 2, or
  9. # (at your option) any later version.
  10. #
  11. # GUILE is distributed in the hope that it will be useful, but
  12. # WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public
  17. # License along with GUILE; see the file COPYING. If not, write
  18. # to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  19. # Floor, Boston, MA 02110-1301 USA
  20. # NOTE: at some point we might consider invoking this under
  21. # pre-inst-guile-env. If this will work, then most of the code below
  22. # can be removed.
  23. # NOTE: If you update this file, please update pre-inst-guile-env.in
  24. # as well, if appropriate.
  25. # Commentary:
  26. # Usage: pre-inst-guile [ARGS]
  27. #
  28. # This script arranges for the environment to support, and eventaully execs,
  29. # the uninstalled binary guile executable located somewhere under libguile/,
  30. # passing ARGS to it. In the process, env var GUILE is clobbered, and the
  31. # following env vars are modified (but not clobbered):
  32. # GUILE_LOAD_PATH
  33. # LTDL_LIBRARY_PATH
  34. #
  35. # This script can be used as a drop-in replacement for $bindir/guile;
  36. # if there is a discrepency in behavior, that's a bug.
  37. # Code:
  38. # config
  39. subdirs_with_ltlibs="srfi guile-readline" # maintain me
  40. # env (set by configure)
  41. top_srcdir="@top_srcdir_absolute@"
  42. top_builddir="@top_builddir_absolute@"
  43. [ x"$top_srcdir" = x -o ! -d "$top_srcdir" -o \
  44. x"$top_builddir" = x -o ! -d "$top_builddir" ] && {
  45. echo $0: bad environment
  46. echo top_srcdir=$top_srcdir
  47. echo top_builddir=$top_builddir
  48. exit 1
  49. }
  50. # handle GUILE_LOAD_PATH (no clobber)
  51. if [ x"$GUILE_LOAD_PATH" = x ]
  52. then
  53. GUILE_LOAD_PATH="${top_srcdir}/guile-readline:${top_srcdir}"
  54. else
  55. for d in "${top_srcdir}" "${top_srcdir}/guile-readline"
  56. do
  57. # This hair prevents double inclusion.
  58. # The ":" prevents prefix aliasing.
  59. case x"$GUILE_LOAD_PATH" in
  60. x*${d}:*) ;;
  61. *) GUILE_LOAD_PATH="${d}:$GUILE_LOAD_PATH" ;;
  62. esac
  63. done
  64. fi
  65. export GUILE_LOAD_PATH
  66. # handle LTDL_LIBRARY_PATH (no clobber)
  67. ltdl_prefix=""
  68. dyld_prefix=""
  69. for dir in $subdirs_with_ltlibs ; do
  70. ltdl_prefix="${top_builddir}/${dir}:${ltdl_prefix}"
  71. dyld_prefix="${top_builddir}/${dir}/.libs:${dyld_prefix}"
  72. done
  73. LTDL_LIBRARY_PATH="${ltdl_prefix}$LTDL_LIBRARY_PATH"
  74. export LTDL_LIBRARY_PATH
  75. DYLD_LIBRARY_PATH="${dyld_prefix}${top_builddir}/libguile/.libs:$DYLD_LIBRARY_PATH"
  76. export DYLD_LIBRARY_PATH
  77. # set GUILE (clobber)
  78. GUILE=${top_builddir}/libguile/guile
  79. export GUILE
  80. # do it
  81. exec $GUILE "$@"
  82. # never reached
  83. exit 1
  84. # pre-inst-guile ends here