uninstalled-env.in 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #!/bin/sh
  2. # Copyright (C) 2003, 2006, 2008, 2009, 2010, 2011 Free Software Foundation
  3. #
  4. # This file is part of GUILE.
  5. #
  6. # This script is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU Lesser General Public License as
  8. # published by the Free Software Foundation; either version 3 of the
  9. # License, or (at your option) any later version.
  10. #
  11. # This library is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. # Lesser General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Lesser General Public
  17. # License along with this library; if not, write to the Free Software
  18. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. # 02110-1301 USA
  20. # NOTE: If you update this file, please update uninstalled.in as
  21. # well, if appropriate.
  22. # Usage: uninstalled-env [ARGS]
  23. # This script arranges for the environment to support running Guile
  24. # from the build tree. The following env vars are modified (but not
  25. # clobbered): GUILE_LOAD_PATH, LTDL_LIBRARY_PATH, and PATH.
  26. # Example: uninstalled-env guile -c '(display "hello\n")'
  27. # Example: ../../uninstalled-env ./guile-test-foo
  28. # config
  29. subdirs_with_ltlibs="guile-readline libguile" # maintain me
  30. # env (set by configure)
  31. top_srcdir="@top_srcdir_absolute@"
  32. top_builddir="@top_builddir_absolute@"
  33. [ x"$top_srcdir" = x -o ! -d "$top_srcdir" -o \
  34. x"$top_builddir" = x -o ! -d "$top_builddir" ] && {
  35. echo $0: bad environment
  36. echo top_srcdir=$top_srcdir
  37. echo top_builddir=$top_builddir
  38. exit 1
  39. }
  40. # When cross-compiling, let $GUILE_FOR_BUILD use its own .go files since
  41. # the ones that are being built may be incompatible ($GUILE_FOR_BUILD is
  42. # typically used to run `guild compile --target=$host'.) Likewise,
  43. # $GUILE_FOR_BUILD must use its own source files when booting; for
  44. # instance, $srcdir/module/ice-9/boot-9.scm must not be in its search
  45. # path, because it would then end up using its C evaluator to run the
  46. # compiler.
  47. if test "@cross_compiling@" = "no"
  48. then
  49. if [ x"$GUILE_LOAD_PATH" = x ]
  50. then
  51. GUILE_LOAD_PATH="${top_srcdir}/module:${top_srcdir}/guile-readline:${top_srcdir}"
  52. if test "${top_srcdir}" != "${top_builddir}"; then
  53. GUILE_LOAD_PATH="$GUILE_LOAD_PATH:${top_builddir}/module:${top_builddir}/guile-readline:${top_builddir}"
  54. fi
  55. else
  56. for d in "/module" "/guile-readline" ""
  57. do
  58. # This hair prevents double inclusion.
  59. # The ":" prevents prefix aliasing.
  60. case x"$GUILE_LOAD_PATH" in
  61. x*${top_srcdir}${d}:*) ;;
  62. x*${top_srcdir}${d}) ;;
  63. *) GUILE_LOAD_PATH="${top_srcdir}${d}:$GUILE_LOAD_PATH" ;;
  64. esac
  65. case x"$GUILE_LOAD_PATH" in
  66. x*${top_builddir}${d}:*) ;;
  67. x*${top_builddir}${d}) ;;
  68. *) GUILE_LOAD_PATH="${top_builddir}${d}:$GUILE_LOAD_PATH" ;;
  69. esac
  70. done
  71. fi
  72. export GUILE_LOAD_PATH
  73. if test "x$GUILE_LOAD_COMPILED_PATH" = "x"
  74. then
  75. GUILE_LOAD_COMPILED_PATH="${top_builddir}/module:${top_builddir}/guile-readline:${top_builddir}"
  76. else
  77. for d in "/module" "/guile-readline" ""
  78. do
  79. # This hair prevents double inclusion.
  80. # The ":" prevents prefix aliasing.
  81. case x"$GUILE_LOAD_COMPILED_PATH" in
  82. x*${top_builddir}${d}:*) ;;
  83. x*${top_builddir}${d}) ;;
  84. *) GUILE_LOAD_COMPILED_PATH="${top_builddir}${d}:$GUILE_LOAD_COMPILED_PATH" ;;
  85. esac
  86. done
  87. fi
  88. export GUILE_LOAD_COMPILED_PATH
  89. # Don't look in installed dirs for guile modules
  90. if ( env | grep -v '^GUILE_SYSTEM_PATH=' > /dev/null ); then
  91. GUILE_SYSTEM_PATH=
  92. export GUILE_SYSTEM_PATH
  93. fi
  94. # Don't look in installed dirs for compiled guile modules
  95. if ( env | grep -v '^GUILE_SYSTEM_COMPILED_PATH=' > /dev/null ); then
  96. GUILE_SYSTEM_COMPILED_PATH=
  97. export GUILE_SYSTEM_COMPILED_PATH
  98. fi
  99. # Don't look in installed dirs for dlopen-able modules
  100. if ( env | grep -v '^GUILE_SYSTEM_EXTENSIONS_PATH=' > /dev/null ); then
  101. GUILE_SYSTEM_EXTENSIONS_PATH=
  102. export GUILE_SYSTEM_EXTENSIONS_PATH
  103. fi
  104. fi
  105. # handle LTDL_LIBRARY_PATH (no clobber)
  106. for dir in $subdirs_with_ltlibs ; do
  107. if test -z "$LTDL_LIBRARY_PATH"; then
  108. LTDL_LIBRARY_PATH="${top_builddir}/${dir}"
  109. else
  110. LTDL_LIBRARY_PATH="${top_builddir}/${dir}:${LTDL_LIBRARY_PATH}"
  111. fi
  112. if test -z "$DYLD_LIBRARY_PATH"; then
  113. DYLD_LIBRARY_PATH="${top_builddir}/${dir}/.libs"
  114. else
  115. DYLD_LIBRARY_PATH="${top_builddir}/${dir}/.libs:${DYLD_LIBRARY_PATH}"
  116. fi
  117. done
  118. export LTDL_LIBRARY_PATH
  119. export DYLD_LIBRARY_PATH
  120. if [ x"$PKG_CONFIG_PATH" = x ]
  121. then
  122. PKG_CONFIG_PATH="${top_builddir}/meta"
  123. else
  124. PKG_CONFIG_PATH="${top_builddir}/meta:$PKG_CONFIG_PATH"
  125. fi
  126. export PKG_CONFIG_PATH
  127. # handle PATH (no clobber)
  128. PATH="${top_builddir}/libguile:${PATH}"
  129. PATH="${top_srcdir}/meta:${PATH}"
  130. if test "x${top_srcdir}" != "x${top_builddir}"; then
  131. PATH="${top_builddir}/meta:${PATH}"
  132. fi
  133. export PATH
  134. # Define $GUILE, used by `guild'.
  135. GUILE="${top_builddir}/meta/guile"
  136. export GUILE
  137. exec "$@"