Skip to content

Commit 4eab0e2

Browse files
committed
install: allow running configure script outside source dir
Fixes #558
1 parent fde153f commit 4eab0e2

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

NEWS.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Modules 5.6.0 (not yet released)
1919
* Doc: improve Authors and Acknowledgments sections in README
2020
* Doc: add :ref:`create-new-release` guide
2121
* Update repository URL to https://github.com/envmodules/modules.
22+
* Install: update :file:`configure` script to allow running it from a current
23+
working directory different than where this file is stored. (fix issue #558)
2224

2325
.. _Security policy: https://github.com/envmodules/modules/blob/main/SECURITY.md
2426

configure

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -950,19 +950,26 @@ if [ "$(echo foo | $SED_ERE 's|foo|bar|' 2>/dev/null)" != 'bar' ]; then
950950
SED_ERE='sed -r'
951951
fi
952952

953+
export GIT_DIR="${progdir}/.git"
954+
export GIT_WORK_TREE="${progdir}"
955+
956+
test -e "${GIT_DIR}"
957+
work_from_git_repo=$?
958+
953959
# if we install from git repository, must have git to fetch current release number
954-
if [ -e '.git' ]; then
960+
if [ $work_from_git_repo -eq 0 ]; then
955961
check_requirement git
956962
fi
957963

958964
# if pre-built docs are available (but not from a previous make run), no doc
959965
# build but install pre-built files
966+
builddocdir="${progdir}/doc/build"
960967
oldbuilddoc=$(sed -n '/^builddoc/{s/.*:= //p;q;}' Makefile.inc 2>/dev/null)
961-
if [ -e 'doc/build/changes.txt' ] && [ -e 'doc/build/MIGRATING.txt' ] \
962-
&& [ -e 'doc/build/INSTALL.txt' ] && [ -e 'doc/build/INSTALL-win.txt' ] \
963-
&& [ -e 'doc/build/NEWS.txt' ] && [ -e 'doc/build/CONTRIBUTING.txt' ] \
964-
&& [ -e 'doc/build/module.1.in' ] && [ -e 'doc/build/ml.1' ] \
965-
&& [ -e 'doc/build/modulefile.5' ] && [ "$oldbuilddoc" != 'y' ]; then
968+
if [ -e "${builddocdir}/changes.txt" ] && [ -e "${builddocdir}/MIGRATING.txt" ] \
969+
&& [ -e "${builddocdir}/INSTALL.txt" ] && [ -e "${builddocdir}/INSTALL-win.txt" ] \
970+
&& [ -e "${builddocdir}/NEWS.txt" ] && [ -e "${builddocdir}/CONTRIBUTING.txt" ] \
971+
&& [ -e "${builddocdir}/module.1.in" ] && [ -e "${builddocdir}/ml.1" ] \
972+
&& [ -e "${builddocdir}/modulefile.5" ] && [ "$oldbuilddoc" != 'y' ]; then
966973
builddoc=p
967974
# test sphinx availability otherwise
968975
else
@@ -986,7 +993,7 @@ fi
986993
TCLSH=$reqpath
987994

988995
# python is mandatory if installing from git repository to build ChangeLog
989-
if [ -e '.git' ]; then
996+
if [ $work_from_git_repo -eq 0 ]; then
990997
missmsg=''
991998
elif [ -n "$pythonbin" ]; then
992999
missmsg="Specified Python command \`$pythonbin' cannot be found"
@@ -1014,7 +1021,7 @@ else
10141021
fi
10151022

10161023
# gzip is mandatory if installing from git repository to build ChangeLog.gz
1017-
if [ -e '.git' ]; then
1024+
if [ $work_from_git_repo -eq 0 ]; then
10181025
check_requirement gzip
10191026
fi
10201027

@@ -1074,7 +1081,7 @@ fi
10741081

10751082
# refine build number if working from git repository
10761083
# shellcheck disable=SC2016
1077-
if [ -e '.git' ]; then
1084+
if [ $work_from_git_repo -eq 0 ]; then
10781085
gitcurtag=$(git describe --tags --abbrev=0)
10791086
gitcurdesc=$(git describe --tags)
10801087
gitcurbranch=$(git rev-parse --abbrev-ref HEAD)
@@ -1164,10 +1171,10 @@ fi
11641171

11651172
# prepare extension library sources if not yet done whether libtclenvmodules
11661173
# is enabled or not to create consistent dist in any cases.
1167-
if [ ! -e 'lib/configure' ]; then
1174+
if [ ! -e "${progdir}/lib/configure" ]; then
11681175
check_requirement autoreconf
11691176
echo "--- preparing extension library sources ----------"
1170-
pushd lib || exit 1
1177+
pushd "${progdir}/lib" || exit 1
11711178
autoreconf -i || exit 1
11721179
popd || exit 1
11731180
echo "--------------------------------------------------"
@@ -1185,7 +1192,7 @@ done
11851192
if [ "$libtclenvmodules" = 'y' ]; then
11861193
echo "--- configuring extension library sources --------"
11871194
echo "libarglist = ${libarglist[*]}"
1188-
pushd lib || exit 1
1195+
pushd "${progdir}/lib" || exit 1
11891196
./configure "${libarglist[@]}" || exit 1
11901197
popd || exit 1
11911198
echo "--------------------------------------------------"

0 commit comments

Comments
 (0)