uninstalled-env.in 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #!/bin/sh
  2. # Copyright (C) 2003, 2006, 2008, 2009, 2010, 2011, 2012, 2015, 2017, 2022, 2024 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. GUILE_DOCSTRINGS_PATH="@top_builddir_absolute@/libguile${GUILE_DOCSTRINGS_PATH:+:$GUILE_DOCSTRINGS_PATH}"
  41. export GUILE_DOCSTRINGS_PATH
  42. # When cross-compiling, let $GUILE_FOR_BUILD use its own .go files since
  43. # the ones that are being built may be incompatible ($GUILE_FOR_BUILD is
  44. # typically used to run `guild compile --target=$host'.) Likewise,
  45. # $GUILE_FOR_BUILD must use its own source files when booting; for
  46. # instance, $srcdir/module/ice-9/boot-9.scm must not be in its search
  47. # path, because it would then end up using its C evaluator to run the
  48. # compiler.
  49. if test "@cross_compiling@" = "no"
  50. then
  51. if [ x"$GUILE_LOAD_PATH" = x ]
  52. then
  53. GUILE_LOAD_PATH="${top_srcdir}/module:${top_srcdir}/guile-readline"
  54. if test "${top_srcdir}" != "${top_builddir}"; then
  55. GUILE_LOAD_PATH="$GUILE_LOAD_PATH:${top_builddir}/module:${top_builddir}/guile-readline"
  56. fi
  57. else
  58. for d in "/module" "/guile-readline"
  59. do
  60. # This hair prevents double inclusion.
  61. # The ":" prevents prefix aliasing.
  62. case x"$GUILE_LOAD_PATH" in
  63. x*${top_srcdir}${d}:*) ;;
  64. x*${top_srcdir}${d}) ;;
  65. *) GUILE_LOAD_PATH="${top_srcdir}${d}:$GUILE_LOAD_PATH" ;;
  66. esac
  67. case x"$GUILE_LOAD_PATH" in
  68. x*${top_builddir}${d}:*) ;;
  69. x*${top_builddir}${d}) ;;
  70. *) GUILE_LOAD_PATH="${top_builddir}${d}:$GUILE_LOAD_PATH" ;;
  71. esac
  72. done
  73. fi
  74. export GUILE_LOAD_PATH
  75. for d in "/prebuilt/@SCM_PREBUILT_BINARIES@" "/stage2" "/guile-readline"
  76. do
  77. # This hair prevents double inclusion.
  78. # The ":" prevents prefix aliasing.
  79. case x"$GUILE_LOAD_COMPILED_PATH" in
  80. x) GUILE_LOAD_COMPILED_PATH="${top_builddir}${d}" ;;
  81. x*${top_builddir}${d}:*) ;;
  82. x*${top_builddir}${d}) ;;
  83. *) GUILE_LOAD_COMPILED_PATH="${top_builddir}${d}:$GUILE_LOAD_COMPILED_PATH" ;;
  84. esac
  85. done
  86. export GUILE_LOAD_COMPILED_PATH
  87. # Don't look in installed dirs for guile modules
  88. if ( env | grep -v '^GUILE_SYSTEM_PATH=' > /dev/null ); then
  89. GUILE_SYSTEM_PATH=
  90. export GUILE_SYSTEM_PATH
  91. fi
  92. # Don't look in installed dirs for compiled guile modules
  93. if ( env | grep -v '^GUILE_SYSTEM_COMPILED_PATH=' > /dev/null ); then
  94. GUILE_SYSTEM_COMPILED_PATH=
  95. export GUILE_SYSTEM_COMPILED_PATH
  96. fi
  97. # Don't look in installed dirs for dlopen-able modules
  98. if ( env | grep -v '^GUILE_SYSTEM_EXTENSIONS_PATH=' > /dev/null ); then
  99. GUILE_SYSTEM_EXTENSIONS_PATH=
  100. export GUILE_SYSTEM_EXTENSIONS_PATH
  101. fi
  102. fi
  103. # handle LTDL_LIBRARY_PATH (no clobber)
  104. for dir in $subdirs_with_ltlibs ; do
  105. if test -z "$LTDL_LIBRARY_PATH"; then
  106. LTDL_LIBRARY_PATH="${top_builddir}/${dir}"
  107. else
  108. LTDL_LIBRARY_PATH="${top_builddir}/${dir}:${LTDL_LIBRARY_PATH}"
  109. fi
  110. if test -z "$DYLD_LIBRARY_PATH"; then
  111. DYLD_LIBRARY_PATH="${top_builddir}/${dir}/.libs"
  112. else
  113. DYLD_LIBRARY_PATH="${top_builddir}/${dir}/.libs:${DYLD_LIBRARY_PATH}"
  114. fi
  115. done
  116. export LTDL_LIBRARY_PATH
  117. export DYLD_LIBRARY_PATH
  118. if [ x"$PKG_CONFIG_PATH" = x ]
  119. then
  120. PKG_CONFIG_PATH="${top_builddir}/meta"
  121. else
  122. PKG_CONFIG_PATH="${top_builddir}/meta:$PKG_CONFIG_PATH"
  123. fi
  124. export PKG_CONFIG_PATH
  125. # handle PATH (no clobber)
  126. PATH="${top_builddir}/libguile:${PATH}"
  127. PATH="${top_srcdir}/meta:${PATH}"
  128. if test "x${top_srcdir}" != "x${top_builddir}"; then
  129. PATH="${top_builddir}/meta:${PATH}"
  130. fi
  131. export PATH
  132. # Define $GUILE, used by `guild'.
  133. GUILE="${top_builddir}/meta/guile"
  134. export GUILE
  135. exec "$@"