uninstalled-env.in 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #!/bin/sh
  2. # Copyright (C) 2003, 2006, 2008, 2009, 2010, 2011, 2012, 2015, 2017, 2022 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"
  52. if test "${top_srcdir}" != "${top_builddir}"; then
  53. GUILE_LOAD_PATH="$GUILE_LOAD_PATH:${top_builddir}/module:${top_builddir}/guile-readline"
  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. for d in "/prebuilt/@SCM_PREBUILT_BINARIES@" "/stage2" "/guile-readline"
  74. do
  75. # This hair prevents double inclusion.
  76. # The ":" prevents prefix aliasing.
  77. case x"$GUILE_LOAD_COMPILED_PATH" in
  78. x) GUILE_LOAD_COMPILED_PATH="${top_builddir}${d}" ;;
  79. x*${top_builddir}${d}:*) ;;
  80. x*${top_builddir}${d}) ;;
  81. *) GUILE_LOAD_COMPILED_PATH="${top_builddir}${d}:$GUILE_LOAD_COMPILED_PATH" ;;
  82. esac
  83. done
  84. export GUILE_LOAD_COMPILED_PATH
  85. # Don't look in installed dirs for guile modules
  86. if ( env | grep -v '^GUILE_SYSTEM_PATH=' > /dev/null ); then
  87. GUILE_SYSTEM_PATH=
  88. export GUILE_SYSTEM_PATH
  89. fi
  90. # Don't look in installed dirs for compiled guile modules
  91. if ( env | grep -v '^GUILE_SYSTEM_COMPILED_PATH=' > /dev/null ); then
  92. GUILE_SYSTEM_COMPILED_PATH=
  93. export GUILE_SYSTEM_COMPILED_PATH
  94. fi
  95. # Don't look in installed dirs for dlopen-able modules
  96. if ( env | grep -v '^GUILE_SYSTEM_EXTENSIONS_PATH=' > /dev/null ); then
  97. GUILE_SYSTEM_EXTENSIONS_PATH=
  98. export GUILE_SYSTEM_EXTENSIONS_PATH
  99. fi
  100. fi
  101. # handle LTDL_LIBRARY_PATH (no clobber)
  102. for dir in $subdirs_with_ltlibs ; do
  103. if test -z "$LTDL_LIBRARY_PATH"; then
  104. LTDL_LIBRARY_PATH="${top_builddir}/${dir}"
  105. else
  106. LTDL_LIBRARY_PATH="${top_builddir}/${dir}:${LTDL_LIBRARY_PATH}"
  107. fi
  108. if test -z "$DYLD_LIBRARY_PATH"; then
  109. DYLD_LIBRARY_PATH="${top_builddir}/${dir}/.libs"
  110. else
  111. DYLD_LIBRARY_PATH="${top_builddir}/${dir}/.libs:${DYLD_LIBRARY_PATH}"
  112. fi
  113. done
  114. export LTDL_LIBRARY_PATH
  115. export DYLD_LIBRARY_PATH
  116. if [ x"$PKG_CONFIG_PATH" = x ]
  117. then
  118. PKG_CONFIG_PATH="${top_builddir}/meta"
  119. else
  120. PKG_CONFIG_PATH="${top_builddir}/meta:$PKG_CONFIG_PATH"
  121. fi
  122. export PKG_CONFIG_PATH
  123. # handle PATH (no clobber)
  124. PATH="${top_builddir}/libguile:${PATH}"
  125. PATH="${top_srcdir}/meta:${PATH}"
  126. if test "x${top_srcdir}" != "x${top_builddir}"; then
  127. PATH="${top_builddir}/meta:${PATH}"
  128. fi
  129. export PATH
  130. # Define $GUILE, used by `guild'.
  131. GUILE="${top_builddir}/meta/guile"
  132. export GUILE
  133. exec "$@"