build-env.in 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #!/bin/sh
  2. # Copyright (C) 2003, 2006, 2008-2012, 2016, 2017, 2021, 2022 Free Software Foundation
  3. #
  4. # This file is part of GNU 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. # Usage: build-env [ARGS]
  21. # This script arranges for the environment to support running Guile from
  22. # the build tree. Unlike uninstalled-env, we clobber the environment so
  23. # as to avoid inheriting environment variables that could make Guile
  24. # load .scm, .go, or .so files from installed directories.
  25. # Example: build-env guile -c '(display "hello\n")'
  26. # Example: ../../build-env ./guile-test-foo
  27. top_srcdir="@top_srcdir_absolute@"
  28. top_builddir="@top_builddir_absolute@"
  29. [ x"$top_srcdir" = x -o ! -d "$top_srcdir" -o \
  30. x"$top_builddir" = x -o ! -d "$top_builddir" ] && {
  31. echo $0: bad environment
  32. echo top_srcdir=$top_srcdir
  33. echo top_builddir=$top_builddir
  34. exit 1
  35. }
  36. GUILE_AUTO_COMPILE=0
  37. export GUILE_AUTO_COMPILE
  38. # When cross-compiling, let $GUILE_FOR_BUILD use its own .go files since
  39. # the ones that are being built may be incompatible ($GUILE_FOR_BUILD is
  40. # typically used to run `guild compile --target=$host'.) Likewise,
  41. # $GUILE_FOR_BUILD must use its own source files when booting; for
  42. # instance, $srcdir/module/ice-9/boot-9.scm must not be in its search
  43. # path, because it would then end up using its C evaluator to run the
  44. # compiler.
  45. if test "@cross_compiling@" = "no"
  46. then
  47. GUILE_LOAD_PATH="${top_srcdir}/module:${top_srcdir}/guile-readline"
  48. if test "${top_srcdir}" != "${top_builddir}"; then
  49. GUILE_LOAD_PATH="$GUILE_LOAD_PATH:${top_builddir}/module:${top_builddir}/guile-readline"
  50. fi
  51. export GUILE_LOAD_PATH
  52. case "$GUILE_BOOTSTRAP_STAGE" in
  53. stage0) GUILE_LOAD_COMPILED_PATH="${top_builddir}/stage0:${top_srcdir}/prebuilt/@SCM_PREBUILT_BINARIES@" ;;
  54. stage1) GUILE_LOAD_COMPILED_PATH="${top_builddir}/stage1:${top_builddir}/stage0" ;;
  55. stage2) GUILE_LOAD_COMPILED_PATH="${top_builddir}/stage1" ;;
  56. *) GUILE_LOAD_COMPILED_PATH="${top_builddir}/stage2:${top_builddir}/guile-readline" ;;
  57. esac
  58. export GUILE_LOAD_COMPILED_PATH
  59. # Don't look in installed dirs for guile modules
  60. if ( env | grep -v '^GUILE_SYSTEM_PATH=' > /dev/null ); then
  61. GUILE_SYSTEM_PATH=
  62. export GUILE_SYSTEM_PATH
  63. fi
  64. # Don't look in installed dirs for compiled guile modules
  65. if ( env | grep -v '^GUILE_SYSTEM_COMPILED_PATH=' > /dev/null ); then
  66. GUILE_SYSTEM_COMPILED_PATH=
  67. export GUILE_SYSTEM_COMPILED_PATH
  68. fi
  69. # Don't look in installed dirs for dlopen-able modules
  70. if ( env | grep -v '^GUILE_SYSTEM_EXTENSIONS_PATH=' > /dev/null ); then
  71. GUILE_SYSTEM_EXTENSIONS_PATH=
  72. export GUILE_SYSTEM_EXTENSIONS_PATH
  73. fi
  74. fi
  75. # handle LTDL_LIBRARY_PATH (no clobber)
  76. for dir in guile-readline libguile ; do
  77. if test -z "$LTDL_LIBRARY_PATH"; then
  78. LTDL_LIBRARY_PATH="${top_builddir}/${dir}"
  79. else
  80. LTDL_LIBRARY_PATH="${top_builddir}/${dir}:${LTDL_LIBRARY_PATH}"
  81. fi
  82. if test -z "$DYLD_LIBRARY_PATH"; then
  83. DYLD_LIBRARY_PATH="${top_builddir}/${dir}/.libs"
  84. else
  85. DYLD_LIBRARY_PATH="${top_builddir}/${dir}/.libs:${DYLD_LIBRARY_PATH}"
  86. fi
  87. done
  88. export LTDL_LIBRARY_PATH
  89. export DYLD_LIBRARY_PATH
  90. if [ x"$PKG_CONFIG_PATH" = x ]
  91. then
  92. PKG_CONFIG_PATH="${top_builddir}/meta"
  93. else
  94. PKG_CONFIG_PATH="${top_builddir}/meta:$PKG_CONFIG_PATH"
  95. fi
  96. export PKG_CONFIG_PATH
  97. # handle PATH (no clobber)
  98. PATH="${top_builddir}/libguile:${PATH}"
  99. PATH="${top_srcdir}/meta:${PATH}"
  100. if test "x${top_srcdir}" != "x${top_builddir}"; then
  101. PATH="${top_builddir}/meta:${PATH}"
  102. fi
  103. export PATH
  104. # Define $GUILE, used by `guild'.
  105. if test "@cross_compiling@" = "no"
  106. then
  107. GUILE=${top_builddir}/libguile/guile@EXEEXT@
  108. else
  109. GUILE="@GUILE_FOR_BUILD@"
  110. fi
  111. export GUILE
  112. XDG_CACHE_HOME=${top_builddir}/cache
  113. export XDG_CACHE_HOME
  114. exec "$@"