Debian Codegraph @

configure

raw ◀ ▶
1 Debian patch touch this file
1 #!/usr/bin/env bash
2 #
3 # CONFIGURE, check requirements then set variables and create Makefiles
4 # Copyright (C) 2017-2025 Xavier Delaruelle
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program 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
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 ##########################################################################
20
21 progpath=$0
22 progdir=${progpath%/*}
23
24 # files to translate
25 targetlist="${progdir}/Makefile.inc ${progdir}/site.exp"
26
27 # argument list
28 arglist="TCLSH PYTHON SPHINXBUILD PS BASENAME RMDIR_IGN_NON_EMPTY SED_ERE \
29 VERSION RELEASE baseprefix prefix bindir libdir libexecdir etcdir initdir \
30 datarootdir mandir docdir vimdatadir modulefilesdir setmanpath appendmanpath \
31 setbinpath appendbinpath setmodulespath docinstall vimaddons \
32 examplemodulefiles builddoc usemanpath libtclenvmodules SHLIB_SUFFIX \
33 multilibsupport libdir64 libdir32 versioning silentshdbgsupport \
34 setshellstartup quarantinesupport autohandling availindepth implicitdefault \
35 extendeddefault moduleshome initconfin pager pageropts verbosity color \
•36 runstatedir buildtype includedir infodir sysconfdir localdstatedir versionpath \
37 darkbgcolors lightbgcolors termbg lockedconfigs icase unloadmatchorder \
38 searchmatch modulepath loadedmodules quarantinevars wa277 advversspec ml \
39 windowssupport nearlyforbiddendays implicitrequirement tagabbrev \
40 tagcolorname mcookieversioncheck availoutput availterseoutput listoutput \
41 listterseoutput editor variantshortcut bashcompletiondir fishcompletiondir \
42 zshcompletiondir tcllinter tcllinteropts nagelfardatadir nagelfaraddons \
43 stickypurge uniquenameloaded abortonerror sourcecache logger loggeropts \
44 loggedevents conflictunload spideroutput spiderterseoutput spiderindepth \
45 emacsdatadir emacsaddons requirevia"
46 libarglist=()
47
48 # flags to know if argument has been specified on command-line
49 defpageropts=1
50 defloggeropts=1
51
52 # set argument default values
53 prefix=/usr/local/Modules
54 setmanpath=y
55 appendmanpath=n
56 setbinpath=y
57 appendbinpath=n
58 setmodulespath=n
59 docinstall=y
60 vimaddons=y
61 emacsaddons=y
62 examplemodulefiles=y
63 libtclenvmodules=y
64 SHLIB_SUFFIX='.so'
65 multilibsupport=n
66 libdir64=undefined
67 libdir32=undefined
68 versioning=n
69 silentshdbgsupport=n
70 setshellstartup=n
71 quarantinesupport=n
72 autohandling=y
73 conflictunload=n
74 requirevia=n
75 implicitrequirement=y
76 availindepth=y
77 spiderindepth=y
78 implicitdefault=y
79 extendeddefault=y
80 advversspec=y
81 ml=y
82 wa277=n
83 loadedmodules=
84 quarantinevars=
85 binsearchpath=/usr/bin:/bin:/usr/local/bin
86 TCLSH=tclsh
87 PYTHON=python
88 SPHINXBUILD=sphinx-build
89 builddoc=y
90 usemanpath=y
91 PS='ps'
92 BASENAME='basename'
93 RMDIR_IGN_NON_EMPTY='rmdir'
94 SED_ERE='sed -E'
95 VERSION=
96 RELEASE=
97 # shellcheck disable=SC2034
98 initconfin=etcdir
99 loggedevents=
100 logger='logger'
101 loggeropts='-t modules'
102 pager=less
103 pageropts='-eFKRX'
104 verbosity=normal
105 color=y
106 darkbgcolors='hi=1:db=2:tr=2:se=2:er=91:wa=93:me=95:in=94:mp=1;94:di=94:al=96:va=93:sy=95:de=4:cm=92:aL=100:L=90;47:H=2:F=41:nF=31;43:S=46:sS=44:kL=30;48;5;109:W=30;43'
107 lightbgcolors='hi=1:db=2:tr=2:se=2:er=31:wa=33:me=35:in=34:mp=1;34:di=34:al=36:va=33:sy=35:de=4:cm=32:aL=107:L=47:H=2:F=101:nF=91;103:S=106:sS=104:kL=48;5;109:W=103'
108 termbg=dark
109 lockedconfigs=
110 uniquenameloaded=n
111 sourcecache=n
112 unloadmatchorder=returnlast
113 searchmatch=starts_with
114 icase=search
115 # these args are initialized here but as they depend on other argument value
116 # they will get their default value later (after command-line parse)
117 bindir=
118 libdir=
119 libexecdir=
120 etcdir=
121 initdir=
122 datarootdir=
123 mandir=
124 docdir=
125 vimdatadir=
126 emacsdatadir=
127 nagelfardatadir=
128 modulefilesdir=
129 moduleshome=
130 modulepath=
131 windowssupport=n
132 nearlyforbiddendays=14
133 tagabbrev='auto-loaded=aL:loaded=L:hidden=H:hidden-loaded=H:forbidden=F:nearly-forbidden=nF:sticky=S:super-sticky=sS:keep-loaded=kL:warning=W'
134 tagcolorname=
135 stickypurge=error
136 abortonerror='ml:reload:switch_unload'
137 mcookieversioncheck=y
138 availoutput='modulepath:alias:dirwsym:sym:tag:variantifspec:key'
139 availterseoutput='modulepath:alias:dirwsym:sym:tag:variantifspec'
140 listoutput='header:idx:variant:sym:tag:key'
141 listterseoutput='header'
142 spideroutput='modulepath:alias:dirwsym:sym:tag:variantifspec:via:key'
143 spiderterseoutput=$availterseoutput
144 editor='vi'
145 variantshortcut=
146 bashcompletiondir=
147 fishcompletiondir=
148 zshcompletiondir=
149 tcllinter='nagelfar.tcl'
150 tcllinteropts=
151 nagelfaraddons=y
152
153
154 # check if output/error channels are attached to terminal
155 for i in 1 2; do
156 if [ -t $i ]; then
157 fdisterm[i]=1
158 else
159 fdisterm[i]=0
160 fi
161 done
162
163 # apply SGR code to message if output channel is attached to terminal
164 sgr() {
165 local fd=$1
166 local code=$2
167 local msg=$3
168 if [ "${fdisterm[fd]}" -eq 1 ]; then
169 local out="\033[${code}m${msg}\033[0m"
170 else
171 local out=$msg
172 fi
173 echo "$out"
174 }
175
176 # print message on stderr then exit
177 echo_error() {
178 local firstln=1
179 while [ $# -gt 0 ]; do
180 if [ $firstln -eq 1 ]; then
181 local msg
182 msg="$(sgr 2 31 ERROR): $1"
183 firstln=0
184 elif [ "$1" = 'tryhelp' ]; then
185 msg="${msg}\n Try \`$progpath --help' for more information"
186 else
187 msg="${msg}\n $1"
188 fi
189 shift
190 done
191 echo -e "${msg}" >&2
192 exit 1
193 }
194
195 # print message on stderr then exit
196 echo_warning() {
197 echo -e "$(sgr 1 33 WARNING): $1"
198 }
199
200
201 # print usage message
202 echo_usage() {
203 # shellcheck disable=SC2028
204 echo "Usage: $progpath [OPTION]...
205 Check requirements then set variables and create Makefiles.
206
207 Defaults for the options are specified in square brackets.
208
209 Configuration:
210 -h, --help display this help and exit
211
212 Installation directories:
213 --prefix=PREFIX install files in PREFIX [$prefix]
214
215 By default, \`make install' will install all the files in
216 \`$prefix/bin', \`$prefix/libexec', etc. You
217 can specify an installation prefix other than \`$prefix'
218 using \`--prefix', for instance \`--prefix=\$HOME'.
219
220 For better control, use the options below.
221
222 Fine tuning of the installation directories:
223 --bindir=DIR user executables [PREFIX/bin]
224 --libdir=DIR object code libraries [PREFIX/lib]
225 --libexecdir=DIR program executables [PREFIX/libexec]
226 --etcdir=DIR program configurations [PREFIX/etc]
227 --initdir=DIR environment initialization scripts [PREFIX/init]
228 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
229 --mandir=DIR man documentation [DATAROOTDIR/man]
230 --docdir=DIR documentation root [DATAROOTDIR/doc]
231 --vimdatadir=DIR Vim addons directory [DATAROOTDIR/vim/vimfiles]
232 --emacsdatadir=DIR Emacs addons directory [DATAROOTDIR/emacs/lisp]
233 --nagelfardatadir=DIR Nagelfar addons directory [DATAROOTDIR/nagelfar]
234 --modulefilesdir=DIR system modulefiles [PREFIX/modulefiles]
235
236 Optional Features:
237 --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
238 --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
239 --enable-set-manpath set mandir to MANPATH in init scripts [yes]
240 --enable-append-manpath append rather prepend mandir to MANPATH [no]
241 --enable-set-binpath set bindir to PATH in init scripts [yes]
242 --enable-append-binpath append rather prepend bindir to PATH [no]
243 --enable-modulespath, --enable-dotmodulespath
244 configure modules path in modulespath file rather
245 than initrc file (or respectively in .modulespath
246 file rather modulerc file if \`--with-initconf-in'
247 is set to 'initdir') [no]
248 --enable-doc-install install documentation files in the documentation
249 directory defined with \'docdir' (no impact on
250 man pages installation) [yes]
251 --enable-vim-addons install Vim addon files in the directory defined
252 with \'vimdatadir' [yes]
253 --enable-emacs-addons install Emacs addon files in the directory defined
254 with \'emacsdatadir' [yes]
255 --enable-nagelfar-addons
256 install Nagelfar addon files in the directory
257 defined with \'nagelfardatadir' [yes]
258 --enable-example-modulefiles
259 install in 'modulefilesdir' some modulefiles
260 provided as examples [yes]
261 --enable-libtclenvmodules
262 build and install the Modules Tcl extension library
263 and enable its load in modulecmd.tcl [yes]
264 --enable-multilib-support
265 support multilib systems by looking at an alternative
266 location where to find the Modules Tcl extension lib
267 depending on current machine architecture. [no]
268 --enable-versioning append modules version to installation prefix and
269 deploy a \`versions' modulepath, shared between all
270 versioning enabled Modules installation, containing
271 modulefiles that enable to switch from one Modules
272 version to another [no]
273 --enable-silent-shell-debug-support
274 generate code in module function definition to add
275 support for silencing shell debugging properties [no]
276 --enable-set-shell-startup
277 set when module function is defined the shell
278 startup file to ensure that the module function is
279 still defined in sub-shells [no]
280 --enable-quarantine-support
281 generate code in module function definition to add
282 support for the environment variable quarantine
283 mechanism [no]
284 --enable-auto-handling set modulecmd.tcl to automatically apply automated
285 modulefiles handling actions, like loading the
286 pre-requisites of a modulefile when loading this
287 modulefile [yes]
288 --enable-conflict-unload
289 set modulecmd.tcl to automatically unload modules
290 that conflict with modules to load and the dependent
291 of these conflicting modules [no]
292 --enable-require-via set modulecmd.tcl to consider that a module enabling
293 a modulepath is a requirement for the loaded modules
294 stored in this modulepath [no]
295 --enable-implicit-requirement
296 implicitly define a requirement toward modules
297 specified on ``module load`` or ``module unload``
298 commands in modulefile [yes]
299 --enable-avail-indepth control whether \`avail' search results should
300 recursively include or not modulefiles from
301 directories matching search query [yes]
302 --enable-spider-indepth control whether \`spider' search results should
303 recursively include or not modulefiles from
304 directories matching search query [yes]
305 --enable-implicit-default
306 implicitly set a default version for modules with
307 none defined [yes]
308 --enable-extended-default
309 allow partial module version specification [yes]
310 --enable-advanced-version-spec
311 activate the advanced module version specificers to
312 specify finer constraints on module version. [yes]
313 --enable-unique-name-loaded
314 only allow one module loaded per module name. [no]
315 --enable-source-cache cache files evaluated through \`source' Tcl command.
316 [no]
317 --enable-ml define \`ml' command when Modules initializes [yes]
318 --enable-color control colored output. \`yes' equals to the \`auto'
319 color mode. \`no' equals to the \`never' color mode
320 [yes]
321 --enable-wa-277 activate workaround for Tcsh history issue [no]
322 --enable-windows-support
323 install all required files for Windows platform [no]
324 --enable-new-features enable all new features that are disabled by default
325 due to substantial behavior changes they imply on
326 Modules 5 [no]
327 --enable-mcookie-version-check
328 enable check of the version specified right after
329 Modules magic cookie in modulefiles, which defines
330 the minimal version of the Modules tool to use to
331 evaluate the modulefile [yes]
332
333 Optional Packages:
334 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
335 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
336 --with-bin-search-path=PATHLIST
337 list of paths to look at when searching the location
338 of tools required to build and configure Modules
339 [$binsearchpath]
340 --with-moduleshome location of the main Modules package file
341 directory [$prefix]
342 --with-initconf-in=VALUE
343 location where to install Modules initialization
344 configuration files. Either \`initdir' or \`etcdir'
345 [etcdir]
346 --with-tclsh=BIN name or full path of Tcl interpreter shell [tclsh]
347 --with-logger=BIN name or full path of default logger program to use
348 to log some evaluation information (can be super-
349 seeded at run-time by environment variable) [$logger]
350 --with-logger-opts=OPTLIST
351 settings to apply to default logger program
352 [$loggeropts]
353 --with-logged-events=EVENTLIST
354 events to log. accepted event names in EVENTLIST are
355 \`auto_eval', \`requested_eval' and \`requested_cmd'
356 (each event name in EVENTLIST should be separated by
357 \`:') [$loggedevents]
358 --with-pager=BIN name or full path of default pager program to use to
359 paginate informational message output (can be super-
360 seeded at run-time by environment variable) [$pager]
361 --with-pager-opts=OPTLIST
362 settings to apply to default pager program [$pageropts]
363 --with-verbosity=VALUE specify default message verbosity. accepted values
364 are \`silent', \`concise', \`normal', \`verbose',
365 \`verbose2', \`trace', \`debug' and \`debug2'
366 [$verbosity]
367 --with-dark-background-colors=SGRLIST
368 default color set to apply if terminal background
369 color is defined to \`dark'. Each element in SGRLIST
370 is an output item associated to a Select Graphic
371 Rendition (SGR) code (elements in SGRLIST are
372 separated by \`:')
373 [$darkbgcolors]
374 --with-light-background-colors=SGRLIST
375 default color set to apply if terminal background
376 color is defined to \`light'. Expect the same syntax
377 than described for \`--with-dark-background-colors'
378 [$lightbgcolors]
379 --with-terminal-background=VALUE
380 terminal background color which determines the color
381 set to apply by default between the \`dark' background
382 colors or the \`light' background colors [$termbg]
383 --with-locked-configs=CONFIGLIST
384 ignore environment variable superseding value for
385 listed configuration options. accepted option names
386 in CONFIGLIST are \`extra_siteconfig',
387 \`implicit_default', \`logged_events' and \`logger'
388 (each option name in CONFIGLIST should be separated
389 by \` ') [$lockedconfigs]
390 --with-unload-match-order=VALUE
391 when unloading a module if multiple loaded modules
392 match the request, unload module loaded first
393 (\`returnfirst') or module loaded last (\`returnlast')
394 [$unloadmatchorder]
395 --with-search-match=VALUE
396 when searching for a module, query string should
397 match the beginning of module name (\`starts_with')
398 or any part of module name (\`contains')
399 [$searchmatch]
400 --with-icase=VALUE apply a case insensitive match to module
401 specification on search-like sub-commands
402 (\`search'), on all sub-commands and modulefile Tcl
403 commands (\`always') or disable case insensitive
404 match (\`never') [$icase]
405 --with-nearly-forbidden-days=VALUE
406 define the number of days a module is considered
407 nearly forbidden prior reaching its expiry date [$nearlyforbiddendays]
408 --with-tag-abbrev=ABBRVLIST
409 define the abbreviation to use when reporting each
410 module tag. Each element in ABBRVLIST is a tag name
411 associated to an abbreviation string (elements in
412 ABBRVLIST are separated by \`:')
413 [$tagabbrev]
414 --with-tag-color-name=TAGLIST
415 define the tags whose graphical rendering should be
416 applied over their name instead of over the name of
417 the module they are attached to. Each element in
418 TAGLIST is a tag name or abbreviation (elements in
419 TAGLIST are separated by \`:') [$tagcolorname]
420 --with-sticky-purge=VALUE
421 define the kind of error to render when unloading
422 a sticky or super-sticky module during a purge.
423 Raise an \`error' or report a \`warning' or be
424 \`silent'. [$stickypurge]
425 --with-abort-on-error=LIST
426 list of sub-commands that should abort when a module
427 evaluation fails instead of continuing their
428 evaluation sequence. sub-commands accepted in LIST
429 are: \`load', \`ml', \`mod-to-sh', \`purge',
430 \`reload', \`switch', \`switch_unload', \`try-load'
431 and \`unload' (elements in LIST are separated by
432 \`:') [$abortonerror]
433 --with-avail-output=LIST
434 specify content to report on avail sub-command
435 regular output. elements accepted in LIST are:
436 \`modulepath', \`alias', \`provided-alias',
437 \`dirwsym', \`indesym', \`sym', \`tag', \`key',
438 \`hidden', \`variant', \`variantifspec' and \`via'
439 (elements in LIST are separated by \`:')
440 [$availoutput]
441 --with-avail-terse-output=LIST
442 specify content to report on avail sub-command
443 terse output. elements accepted in LIST are:
444 \`modulepath', \`alias', \`provided-alias',
445 \`dirwsym', \`indesym', \`sym', \`tag', \`key',
446 \`hidden', \`variant' and \`variantifspec' (elements
447 in LIST are separated by \`:')
448 [$availterseoutput]
449 --with-list-output=LIST
450 specify content to report on list sub-command
451 regular output. elements accepted in LIST are:
452 \`header', \`idx', \`variant', \`alias', \`indesym',
453 \`sym', \`tag', \`hidden' and \`key' (elements in
454 LIST are separated by \`:') [$listoutput]
455 --with-list-terse-output=LIST
456 specify content to report on list sub-command terse
457 output. elements accepted in LIST are: \`header',
458 \`idx', \`variant', \`alias', \`indesym', \`sym',
459 \`tag', \`hidden' and \`key' (elements in LIST are
460 separated by \`:') [$listterseoutput]
461 --with-spider-output=LIST
462 specify content to report on spider sub-command
463 regular output. elements accepted in LIST are:
464 \`modulepath', \`alias', \`provided-alias',
465 \`dirwsym', \`indesym', \`sym', \`tag', \`key',
466 \`hidden', \`variant', \`variantifspec' and \`via'
467 (elements in LIST are separated by \`:')
468 [$spideroutput]
469 --with-spider-terse-output=LIST
470 specify content to report on spider sub-command
471 terse output. elements accepted in LIST are:
472 \`modulepath', \`alias', \`provided-alias',
473 \`dirwsym', \`indesym', \`sym', \`tag', \`key',
474 \`hidden', \`variant' and \`variantifspec' (elements
475 in LIST are separated by \`:')
476 [$spiderterseoutput]
477 --with-variant-shortcut=SHORTCUTLIST
478 define shortcut characters to specify variant names.
479 Each element in SHORTCUTLIST is a variant name
480 associated to a shortcut character (elements in
481 SHORTCUTLIST are separated by \`:') [$variantshortcut]
482 --with-editor=BIN name or full path of default editor program to use to
483 edit modulefiles [$editor]
484 --with-modulepath=PATHLIST
485 default modulepaths to set in default configuration
486 file to be enabled (each path in PATHLIST should
487 be separated by \`:') [PREFIX/modulefiles or
488 BASEPREFIX/\$MODULE_VERSION/modulefiles if versioning
489 installation mode enabled]
490 --with-loadedmodules=MODLIST
491 default modulefiles to set in default configuration
492 file to be loaded (each modulefile name in MODLIST
493 should be separated by \`:') []
494 --with-quarantine-vars='VARNAME[=VALUE] ...'
495 environment variables to put in quarantine when
496 running the module command to ensure it a sane
497 execution environment (each variable should be
498 separated by \` '). a value can eventually be set to
499 a quarantine variable instead of emptying it. []
500 --with-tcl directory containing the Tcl configuration script
501 tclConfig.sh.
502 --with-tclinclude directory containing the Tcl header files.
503 --with-python=BIN name or full path of Python interpreter command to
504 use as shebang for helper scripts [$PYTHON]
505 --with-bashcompletiondir=DIR
506 Bash completions directory []
507 --with-fishcompletiondir=DIR
508 Fish completions directory []
509 --with-zshcompletiondir=DIR
510 Zsh completions directory []
511 --with-tcl-linter=BIN name of full path of program to use to lint Tcl
512 modulefiles [$tcllinter]
513 --with-tcl-linter-opts=OPTLIST
514 settings to apply to tcl linter program [$tcllinteropts]
515
516 Depending on the above configuration options the files are approximately
517 placed in the following directory structure:
518 PREFIX/
519 bin/
520 etc/
521 init/
522 lib/
523 libexec/
524 share/
525 doc/
526 emacs/
527 lisp/
528 man/
529 man1/
530 man5/
531 nagelfar/
532 vim/
533 vimfiles/
534 modulefiles/"
535 }
536
537 # check requirement availability
538 check_requirement() {
539 typeset req=$1
540 typeset optmesg=$2
541 typeset cmdenv=$3
542
543 if [ $# -gt 3 ]; then
544 shift 3
545 else
546 shift $#
547 fi
548
549 for cmd in $req "${@}"; do
550 if [ -n "$cmd" ]; then
551 echo -n "checking for ${cmd}... "
552 if [ -n "$cmdenv" ]; then
553 cmdsearch="$cmdenv command -v $cmd"
554 else
555 cmdsearch="command -v $cmd"
556 fi
557 reqpath=$(eval "$cmdsearch")
558 if [ -n "$reqpath" ]; then
559 echo "$reqpath"
560 break
561 else
562 echo "not found"
•563 fi
564 fi
565 done
566
567 if [ -z "$reqpath" ]; then
568 if [ -z "$optmesg" ]; then
569 echo_error "$req could not be found"
570 # no message output if message set to '-'
571 elif [ "$optmesg" != '-' ]; then
572 echo_warning "$optmesg"
573 fi
574 fi
575 }
576
577 # parse optional argument to find if feature is enabled or disabled
578 get_feature_value() {
579 typeset val="${1#*=}"
580
581 if [ "${1//--enable/}" != "$1" ]; then
582 if [ "$val" = 'no' ]; then
583 echo 'n'
584 else
585 echo 'y'
586 fi
587 else
588 echo 'n'
589 fi
590 }
591
592 # parse optional argument to extract package's option
593 get_package_option() {
594 typeset option="${1%=*}"
595 echo "${option/#--without/--with}"
596 }
597
598 # parse optional argument to find package is set or disabled
599 get_package_value() {
600 typeset val_raw="${1#*=}"
601 typeset dfl_without_val="$2"
602
603 if [ "${1/#--with-/}" = "$1" ] || [ "$val_raw" = 'no' ]; then
604 value="$dfl_without_val"
605 else
606 value="$val_raw"
607 fi
608
609 echo "$value"
610 }
611
612 check_and_get_package_value() {
613 typeset arg_raw="$2"
614 typeset allowed_values="$3"
615 typeset dfl_without_val="$4"
616
617 option=$(get_package_option "$arg_raw")
618 value=$(get_package_value "$arg_raw" "$dfl_without_val")
619 if [ "${allowed_values// $value /}" = "$allowed_values" ]; then
620 echo_error "Bad value for option \`$option'"\
621 "Allowed values are:$allowed_values"
622 fi
623
624 typeset -g "$1"="$value"
625 }
626
627 check_and_get_package_value_list() {
628 typeset arg_raw="$2"
629 typeset allowed_values="$3"
•630 typeset dfl_without_val="$4"
631
632 option=$(get_package_option "$arg_raw")
633 value=$(get_package_value "$arg_raw" "$dfl_without_val")
634 ORIG_IFS=$IFS
635 IFS=:
636 for val in $value; do
637 if [ "${allowed_values// $val /}" = "$allowed_values" ]; then
638 echo_error "Bad value '$val' set in option \`$option'"\
639 "Values allowed in list are:$allowed_values"
640 fi
641 done
642 IFS=$ORIG_IFS
643
644 typeset -g "$1"="$value"
645 }
646
647 # parse arguments
648 for arg in "$@"; do
649 # set argument value defined with "--arg val" form
650 if [ -n "${nextargisval+x}" ]; then
651 declare "$nextargisval"="$arg"
652 unset nextargisval
653 continue
654 # set lib argument value defined with "--arg val" form
655 elif [ -n "${nextargislibarg+x}" ]; then
656 libarglist+=("$arg");
657 unset nextargislibarg
658 continue
659 # current arg should be skipped
660 elif [ -n "${nextargisign+x}" ]; then
661 unset nextargisign
662 continue
663 fi
664
665 case "$arg" in
666 --prefix=*)
667 prefix="${arg#*=}" ;;
668 --prefix)
669 nextargisval=prefix ;;
670 --bindir=*)
671 bindir="${arg#*=}" ;;
672 --bindir)
673 nextargisval=bindir ;;
674 --libdir=*)
675 libdir="${arg#*=}" ;;
676 --libdir)
677 nextargisval=libdir ;;
678 --libexecdir=*)
679 libexecdir="${arg#*=}" ;;
680 --libexecdir)
681 nextargisval=libexecdir ;;
682 --runstatedir=*)
683 runstatedir="${arg#*=}" ;;
684 --runstatedir)
685 nextargisval=runstatedir ;;
686 --includedir=*)
687 includedir="${arg#*=}" ;;
688 --includedir)
689 nextargisval=includedir ;;
690 --infodir=*)
691 infodir="${arg#*=}" ;;
692 --infodir)
693 nextargisval=infodir ;;
694 --infodir)
695 nextargisval=infodir ;;
696 --sysconfdir=*)
697 sysconfdir="${arg#*=}" ;;
698 --sysconfdir)
699 nextargisval=sysconfdir ;;
700 --localstatedir=*)
701 localstatedir="${arg#*=}" ;;
702 --localstatedir)
703 nextargisval=localstatedirdir ;;
704 --build=*)
705 buildtype="${arg#*=}" ;;
706 --build)
707 nextargisval=buildtype ;;
708 --etcdir=*)
709 etcdir="${arg#*=}" ;;
710 --etcdir)
711 nextargisval=etcdir ;;
712 --initdir=*)
713 initdir="${arg#*=}" ;;
714 --initdir)
715 nextargisval=initdir ;;
716 --datarootdir=*)
717 datarootdir="${arg#*=}" ;;
718 --datarootdir)
719 nextargisval=datarootdir ;;
720 --mandir=*)
721 mandir="${arg#*=}" ;;
722 --mandir)
723 nextargisval=mandir ;;
724 --docdir=*)
725 docdir="${arg#*=}" ;;
726 --docdir)
727 nextargisval=docdir ;;
728 --vimdatadir=*)
729 vimdatadir="${arg#*=}" ;;
730 --vimdatadir)
731 nextargisval=vimdatadir ;;
732 --emacsdatadir=*)
733 emacsdatadir="${arg#*=}" ;;
734 --emacsdatadir)
735 nextargisval=emacsdatadir ;;
736 --nagelfardatadir=*)
737 nagelfardatadir="${arg#*=}" ;;
738 --nagelfardatadir)
739 nextargisval=nagelfardatadir ;;
740 --modulefilesdir=*)
741 modulefilesdir="${arg#*=}" ;;
742 --modulefilesdir)
743 nextargisval=modulefilesdir ;;
744 --enable-set-manpath*|--disable-set-manpath)
745 # shellcheck disable=SC2034
746 setmanpath=$(get_feature_value "$arg") ;;
747 --enable-append-manpath*|--disable-append-manpath)
748 # shellcheck disable=SC2034
749 appendmanpath=$(get_feature_value "$arg") ;;
750 --enable-set-binpath*|--disable-set-binpath)
751 # shellcheck disable=SC2034
752 setbinpath=$(get_feature_value "$arg") ;;
753 --enable-option-checking*|--disable-option-checking)
754 setbinpath=$(get_feature_value "$arg") ;;
755 --enable-silent-rules*|--disable-silent-rules)
756 setbinpath=$(get_feature_value "$arg") ;;
757 --enable-maintainer-mode*|--disable-maintainer-mode)
758 setbinpath=$(get_feature_value "$arg") ;;
759 --enable-logging*|--disable-logging)
760 setbinpath=$(get_feature_value "$arg") ;;
761 --enable-dependency-tracking*|--disable-dependency-tracking)
762 setbinpath=$(get_feature_value "$arg") ;;
763 --enable-append-binpath*|--disable-append-binpath)
764 # shellcheck disable=SC2034
765 appendbinpath=$(get_feature_value "$arg") ;;
766 --enable-dotmodulespath*|--disable-dotmodulespath|--enable-modulespath*|--disable-modulespath)
767 setmodulespath=$(get_feature_value "$arg") ;;
768 --enable-doc-install*|--disable-doc-install)
769 # shellcheck disable=SC2034
770 docinstall=$(get_feature_value "$arg") ;;
771 --enable-vim-addons*|--disable-vim-addons)
772 # shellcheck disable=SC2034
773 vimaddons=$(get_feature_value "$arg") ;;
774 --enable-emacs-addons*|--disable-emacs-addons)
775 # shellcheck disable=SC2034
776 emacsaddons=$(get_feature_value "$arg") ;;
777 --enable-nagelfar-addons*|--disable-nagelfar-addons)
778 # shellcheck disable=SC2034
779 nagelfaraddons=$(get_feature_value "$arg") ;;
780 --enable-example-modulefiles*|--disable-example-modulefiles)
781 # shellcheck disable=SC2034
782 examplemodulefiles=$(get_feature_value "$arg") ;;
783 --enable-libtclenvmodules*|--disable-libtclenvmodules)
784 libtclenvmodules=$(get_feature_value "$arg") ;;
785 --enable-multilib-support*|--disable-multilib-support)
786 multilibsupport=$(get_feature_value "$arg") ;;
787 --enable-versioning*|--disable-versioning)
788 versioning=$(get_feature_value "$arg") ;;
789 --enable-silent-shell-debug-support*|--disable-silent-shell-debug-support)
790 # shellcheck disable=SC2034
791 silentshdbgsupport=$(get_feature_value "$arg") ;;
792 --enable-set-shell-startup*|--disable-set-shell-startup)
793 # shellcheck disable=SC2034
794 setshellstartup=$(get_feature_value "$arg") ;;
795 --enable-quarantine-support*|--disable-quarantine-support)
796 # shellcheck disable=SC2034
797 quarantinesupport=$(get_feature_value "$arg") ;;
798 --enable-auto-handling*|--disable-auto-handling)
799 # shellcheck disable=SC2034
800 autohandling=$(get_feature_value "$arg") ;;
801 --enable-conflict-unload*|--disable-conflict-unload)
802 # shellcheck disable=SC2034
803 conflictunload=$(get_feature_value "$arg") ;;
804 --enable-require-via*|--disable-require-via)
805 # shellcheck disable=SC2034
806 requirevia=$(get_feature_value "$arg") ;;
807 --enable-implicit-requirement*|--disable-implicit-requirement)
808 # shellcheck disable=SC2034
809 implicitrequirement=$(get_feature_value "$arg") ;;
810 --enable-avail-indepth*|--disable-avail-indepth)
811 # shellcheck disable=SC2034
812 availindepth=$(get_feature_value "$arg") ;;
813 --enable-spider-indepth*|--disable-spider-indepth)
814 # shellcheck disable=SC2034
815 spiderindepth=$(get_feature_value "$arg") ;;
816 --enable-implicit-default*|--disable-implicit-default)
817 # shellcheck disable=SC2034
818 implicitdefault=$(get_feature_value "$arg") ;;
819 --enable-extended-default*|--disable-extended-default)
820 # shellcheck disable=SC2034
821 extendeddefault=$(get_feature_value "$arg") ;;
822 --enable-advanced-version-spec*|--disable-advanced-version-spec)
823 # shellcheck disable=SC2034
824 advversspec=$(get_feature_value "$arg") ;;
825 --enable-unique-name-loaded*|--disable-unique-name-loaded)
826 # shellcheck disable=SC2034
827 uniquenameloaded=$(get_feature_value "$arg") ;;
828 --enable-source-cache*|--disable-source-cache)
829 # shellcheck disable=SC2034
830 sourcecache=$(get_feature_value "$arg") ;;
831 --enable-ml*|--disable-ml)
832 # shellcheck disable=SC2034
833 ml=$(get_feature_value "$arg") ;;
834 --enable-wa-277*|--disable-wa-277)
835 # shellcheck disable=SC2034
836 wa277=$(get_feature_value "$arg") ;;
837 --enable-windows-support*|--disable-windows-support)
838 # shellcheck disable=SC2034
839 windowssupport=$(get_feature_value "$arg") ;;
840 --enable-mcookie-version-check*|--disable-mcookie-version-check)
841 # shellcheck disable=SC2034
842 mcookieversioncheck=$(get_feature_value "$arg") ;;
843 --with-bin-search-path=*|--without-bin-search-path)
844 binsearchpath=$(get_package_value "$arg") ;;
845 --with-moduleshome=*|--without-moduleshome)
846 moduleshome=$(get_package_value "$arg") ;;
847 --with-initconf-in=*|--without-initconf-in)
848 allowedval=" initdir etcdir " ;
849 check_and_get_package_value "initconfin" "$arg" "$allowedval" ;;
850 --with-tclsh=*|--without-tclsh)
851 tclshbin=$(get_package_value "$arg") ;;
852 --with-logger=*|--without-logger)
853 logger=$(get_package_value "$arg" "") ;;
854 --with-logger-opts=*|--without-logger-opts)
855 loggeropts=$(get_package_value "$arg" "")
856 defloggeropts=0 ;;
857 --with-logged-events=*|--without-logged-events)
858 allowedval=" auto_eval requested_eval requested_cmd " ;
859 check_and_get_package_value_list "loggedevents" "$arg" "$allowedval" "" ;;
860 --with-pager=*|--without-pager)
861 pager=$(get_package_value "$arg" "") ;;
862 --with-pager-opts=*|--without-pager-opts)
•863 pageropts=$(get_package_value "$arg" "")
864 defpageropts=0 ;;
865 --with-verbosity=*|--without-verbosity)
866 allowedval=" silent concise normal verbose trace debug debug2 " ;
867 check_and_get_package_value "verbosity" "$arg" "$allowedval" ;;
868 --enable-color*|--disable-color)
869 # shellcheck disable=SC2034
870 color=$(get_feature_value "$arg") ;;
871 --enable-new-features*|--disable-new-features)
872 val=$(get_feature_value "$arg") ;
873 if [ "$val" = 'y' ]; then
874 abortonerror='load:ml:reload:switch' ;
875 # shellcheck disable=SC2034
876 conflictunload=y ;
877 # shellcheck disable=SC2034
878 requirevia=y ;
879 fi ;;
880 --with-dark-background-colors=*|--without-dark-background-colors)
881 darkbgcolors=$(get_package_value "$arg" "") ;;
882 --with-light-background-colors=*|--without-light-background-colors)
883 lightbgcolors=$(get_package_value "$arg" "") ;;
884 --with-terminal-background=*|--without-terminal-background)
885 allowedval=" dark light " ;
886 check_and_get_package_value "termbg" "$arg" "$allowedval" ;;
887 --with-locked-configs=*|--disable-locked-configs)
888 lockedconfigs=$(get_package_value "$arg" "") ;
889 allowedval=" extra_siteconfig implicit_default logged_events logger " ;
890 for val in $lockedconfigs; do
891 if [ "${allowedval// $val /}" = "$allowedval" ]; then
892 echo_error "Bad value for option \`--with-locked-configs'"\
893 "Allowed values are:$allowedval"
894 fi ;
895 done ;;
896 --with-unload-match-order=*|--without-unload-match-order)
897 allowedval=" returnlast returnfirst " ;
898 check_and_get_package_value "unloadmatchorder" "$arg" "$allowedval" ;;
899 --with-search-match=*|--without-search-match)
900 allowedval=" starts_with contains " ;
901 check_and_get_package_value "searchmatch" "$arg" "$allowedval" ;;
902 --with-icase=*|--without-icase)
903 allowedval=" never search always " ;
904 check_and_get_package_value "icase" "$arg" "$allowedval" "never";;
905 --with-nearly-forbidden-days=*|--without-nearly-forbidden-days)
906 nearlyforbiddendays=$(get_package_value "$arg") ;
907 if [ -z "$nearlyforbiddendays" ] || ! [ "$nearlyforbiddendays" -eq "$nearlyforbiddendays" ] 2>/dev/null\
908 || ! [ "$nearlyforbiddendays" -ge 0 ] || ! [ "$nearlyforbiddendays" -le 365 ]; then
909 echo_error "Bad value for option \`--with-nearly-forbidden-days'"\
910 "Value should be an integer comprised between 0 and 365"
911 fi ;;
912 --with-tag-abbrev=*|--without-tag-abbrev)
913 tagabbrev=$(get_package_value "$arg" "") ;;
914 --with-tag-color-name=*|--without-tag-color-name)
915 tagcolorname=$(get_package_value "$arg" "") ;;
916 --with-sticky-purge=*|--without-sticky-purge)
917 allowedval=" error warning silent " ;
918 check_and_get_package_value "stickypurge" "$arg" "$allowedval" ;;
919 --with-abort-on-error=*|--without-abort-on-error)
920 allowedval=" load ml mod-to-sh purge reload switch switch_unload try-load unload " ;
921 check_and_get_package_value_list "abortonerror" "$arg" "$allowedval" "" ;;
922 --with-avail-output=*|--without-avail-output)
923 allowedval=" modulepath alias provided-alias dirwsym indesym sym tag key hidden variant variantifspec via " ;
924 check_and_get_package_value_list "availoutput" "$arg" "$allowedval" "" ;;
925 --with-avail-terse-output=*|--without-avail-terse-output)
926 allowedval=" modulepath alias provided-alias dirwsym indesym sym tag key hidden variant variantifspec " ;
927 check_and_get_package_value_list "availterseoutput" "$arg" "$allowedval" "" ;;
928 --with-list-output=*|--without-list-output)
929 allowedval=" header idx variant alias indesym sym tag hidden key " ;
930 check_and_get_package_value_list listoutput "$arg" "$allowedval" "" ;;
931 --with-list-terse-output=*|--without-list-terse-output)
932 allowedval=" header idx variant alias indesym sym tag hidden key " ;
933 check_and_get_package_value_list "listterseoutput" "$arg" "$allowedval" "" ;;
934 --with-spider-output=*|--without-spider-output)
935 allowedval=" modulepath alias provided-alias dirwsym indesym sym tag key hidden variant variantifspec via " ;
936 check_and_get_package_value_list "spideroutput" "$arg" "$allowedval" "" ;;
937 --with-spider-terse-output=*|--without-spider-terse-output)
938 allowedval=" modulepath alias provided-alias dirwsym indesym sym tag key hidden variant variantifspec " ;
939 check_and_get_package_value_list "spiderterseoutput" "$arg" "$allowedval" "" ;;
940 --with-variant-shortcut=*|--without-variant-shortcut)
941 variantshortcut=$(get_package_value "$arg" "") ;;
942 --with-editor=*|--without-editor)
943 editor=$(get_package_value "$arg") ;;
944 --with-modulepath=*|--without-modulepath)
945 modulepath=$(get_package_value "$arg" "") ;;
946 --with-loadedmodules=*|--without-loadedmodules)
947 loadedmodules=$(get_package_value "$arg" "") ;;
948 --with-quarantine-vars=*|--without-quarantine-vars)
949 # shellcheck disable=SC2034
950 quarantinevars=$(get_package_value "$arg" "") ;;
951 --with-bashcompletiondir=*|--without-bashcompletiondir)
952 # shellcheck disable=SC2034
953 bashcompletiondir=$(get_package_value "$arg" "") ;;
954 --with-fishcompletiondir=*|--without-fishcompletiondir)
955 # shellcheck disable=SC2034
956 fishcompletiondir=$(get_package_value "$arg" "") ;;
957 --with-zshcompletiondir=*|--without-zshcompletiondir)
958 # shellcheck disable=SC2034
959 zshcompletiondir=$(get_package_value "$arg" "") ;;
960 --with-tcl-linter=*|--without-tcl-linter)
961 tcllinter=$(get_package_value "$arg" "") ;;
962 --with-tcl-linter-opts=*|--without-tcl-linter-opts)
963 # shellcheck disable=SC2034
964 tcllinteropts=$(get_package_value "$arg" "") ;;
965 --with-tcl=*|--without-tcl|--with-tclinclude=*|--without-tclinclude)
966 libarglist+=("$arg") ;;
967 --with-python=*|--without-python)
968 pythonbin=$(get_package_value "$arg") ;;
969 --with-version-path=*)
970 dummy=$(get_package_value "$arg") ;;
971 --with-module-path=*)
972 dummy=$(get_package_value "$arg") ;;
973 --with-module-path=*)
974 echo_warning "Option \`--with-module-path' ignored, use \`--modulepath' instead" ;;
975 -h|--help)
976 echo_usage
977 exit 0
978 ;;
979 --build|--host|--target)
980 # pass argument supported by lib to its ./configure script
981 libarglist+=("$arg") ;
982 # and set next arg should also be send to lib script
983 nextargislibarg=y ;;
984 --build=*|--host=*|--target=*)
985 # pass argument supported by lib to its ./configure script
986 libarglist+=("$arg") ;;
987 --program-prefix|--program-suffix|--program-transform-name|--exec-prefix|\
988 --sbindir|--sysconfdir|--datadir|--includedir|--localstatedir|\
989 --sharedstatedir|--infodir|--runstatedir|--oldincludedir|--localedir|\
990 --htmldir|--dvidir|--pdfdir|--psdir)
991 # ignore standard configure option and value which has no meaning here
992 echo_warning "Option \`$arg' ignored" ;
993 nextargisign=y ;;
994 --program-prefix=*|--program-suffix=*|--program-transform-name=*|\
995 --exec-prefix=*|--sbindir=*|--sysconfdir=*|--datadir=*|--includedir=*|\
996 --localstatedir=*|--sharedstatedir=*|--infodir=*|--runstatedir=*|\
997 --oldincludedir=*|--localedir=*|--htmldir=*|--dvidir=*|--pdfdir=*|\
998 --psdir=*)
999 # ignore standard configure option which has no meaning here
1000 echo_warning "Option \`$arg' ignored" ;;
1001 --enable-*|--disable-*|--with-*|--without-*)
1002 # ignore --enable-*/--with-* options not supported here to comply with
1003 # GNU Configuration specification
1004 # (https://www.gnu.org/prep/standards/html_node/Configuration.html)
1005 echo_warning "Option \`$arg' ignored" ;;
1006 -*)
1007 echo_error "Unrecognized option \`$arg'" tryhelp;;
1008 *=*)
1009 echo -e "Export \`$arg' in environment" ;
1010 export "${arg?}" ;;
1011 *)
1012 # type of system to build the program for (not needed here but useful
1013 # for true autoconf configure script below
1014 libarglist+=("$arg") ;;
1015 esac
1016 done
1017
1018 # test requirements availability
1019 check_requirement uname
1020 kernelname=$(uname -s)
1021
1022 # Makefile for this project are GNU Makefile so we must ensure correct make
1023 # command is available, on Linux/Darwin systems the 'make' bin refers to GNU
1024 # Make whereas on other system it is not the default make flavor, so 'gmake'
1025 # should be checked
1026 case "$kernelname" in
1027 Linux|Darwin|CYGWIN*|MINGW*|MSYS_NT*) make='make' ;;
1028 *) make='gmake'
1029 esac
1030 check_requirement $make
1031 check_requirement sed
1032 check_requirement runtest "Install \`dejagnu' if you want to run the \
1033 testsuite"
1034 check_requirement manpath 'Will rely on MANPATH to get enabled man directories'
1035 # shellcheck disable=SC2034
1036 [ -z "$reqpath" ] && usemanpath=n
1037
1038 # rmdir option may not be available, use || true in any case
1039 # shellcheck disable=SC2034
1040 if [ "$kernelname" = 'Linux' ]; then
1041 RMDIR_IGN_NON_EMPTY='rmdir --ignore-fail-on-non-empty'
1042 else
1043 RMDIR_IGN_NON_EMPTY='rmdir'
1044 fi
1045
1046 # sed -E option may not be available, use -r option otherwise
1047 if [ "$(echo foo | $SED_ERE 's|foo|bar|' 2>/dev/null)" != 'bar' ]; then
1048 SED_ERE='sed -r'
1049 fi
1050
1051 export GIT_DIR="${progdir}/.git"
1052 export GIT_WORK_TREE="${progdir}"
1053
1054 test -e "${GIT_DIR}"
1055 work_from_git_repo=$?
1056
1057 # if we install from git repository, must have git to fetch current release number
1058 if [ $work_from_git_repo -eq 0 ]; then
1059 check_requirement git
1060 fi
1061
1062 # if pre-built docs are available (but not from a previous make run), no doc
1063 # build but install pre-built files
1064 builddocdir="${progdir}/doc/build"
1065 oldbuilddoc=$(sed -n '/^builddoc/{s/.*:= //p;q;}' Makefile.inc 2>/dev/null)
1066 if [ -e "${builddocdir}/changes.txt" ] && [ -e "${builddocdir}/MIGRATING.txt" ] \
1067 && [ -e "${builddocdir}/INSTALL.txt" ] && [ -e "${builddocdir}/INSTALL-win.txt" ] \
1068 && [ -e "${builddocdir}/NEWS.txt" ] && [ -e "${builddocdir}/CONTRIBUTING.txt" ] \
1069 && [ -e "${builddocdir}/module.1.in" ] && [ -e "${builddocdir}/ml.1" ] \
1070 && [ -e "${builddocdir}/envml.1" ] && [ -e "${builddocdir}/modulefile.5" ] \
1071 && [ "$oldbuilddoc" != 'y' ]; then
1072 builddoc=p
1073 # test sphinx availability otherwise
1074 else
1075 # pass even if sphinx not there but no doc will be built
1076 check_requirement sphinx-build "Install \`sphinx-build' if you want to \
1077 build the documentation" '' 'sphinx-1.0-build'
1078 # shellcheck disable=SC2034
1079 SPHINXBUILD=$reqpath
1080 # shellcheck disable=SC2034
1081 [ -z "$reqpath" ] && builddoc=n
1082 fi
1083
1084 # get tclsh location from standard PATHs or /usr/local/bin
1085 # or validate location passed as argument
1086 if [ -n "$tclshbin" ]; then
1087 check_requirement "$tclshbin" '' "PATH=$binsearchpath"
1088 else
1089 # also check version-specific names in case no generic tclsh binary exists
1090 check_requirement $TCLSH '' "PATH=$binsearchpath" 'tclsh8.6' 'tclsh8.5' 'tclsh8.4'
1091 fi
1092 TCLSH=$reqpath
1093
1094 # python is mandatory if installing from git repository to build ChangeLog
1095 if [ $work_from_git_repo -eq 0 ]; then
1096 missmsg=''
1097 elif [ -n "$pythonbin" ]; then
1098 missmsg="Specified Python command \`$pythonbin' cannot be found"
1099 else
1100 missmsg='-'
1101 fi
1102 # only look at --with-python specification if set
1103 if [ -n "$pythonbin" ]; then
1104 check_requirement "$pythonbin" "$missmsg" "PATH=$binsearchpath"
1105 else
1106 check_requirement $PYTHON "$missmsg" "PATH=$binsearchpath" 'python3' 'python2'
1107 fi
1108 # define a generic launching name if command not found at build time
1109 if [ -z "$reqpath" ]; then
1110 # use --with-python specification if set
1111 if [ "${pythonbin:0:1}" = '/' ]; then
1112 PYTHON="$pythonbin"
1113 elif [ -n "$pythonbin" ]; then
1114 PYTHON="/usr/bin/env $pythonbin"
1115 else
1116 PYTHON="/usr/bin/env $PYTHON"
1117 fi
1118 else
1119 PYTHON=$reqpath
1120 fi
1121
1122 # gzip is mandatory if installing from git repository to build ChangeLog.gz
1123 if [ $work_from_git_repo -eq 0 ]; then
1124 check_requirement gzip
1125 fi
1126
1127 # get location of commands used 'fullpath' in init scripts
1128 check_requirement 'ps' '' "PATH=$binsearchpath"
1129 # shellcheck disable=SC2034
1130 PS=$reqpath
1131 check_requirement 'basename' '' "PATH=$binsearchpath"
1132 # shellcheck disable=SC2034
1133 BASENAME=$reqpath
1134
1135 # get logger program location from standard PATHs or /usr/local/bin
1136 # or validate location passed as argument
1137 if [ -n "$logger" ]; then
1138 check_requirement "$logger" '' "PATH=$binsearchpath"
1139 logger=$reqpath
1140 fi
1141 # adapt logger program settings dependings of specified args
1142 if [ $defloggeropts -eq 1 ] && [ "${logger##*/}" != 'logger' ]; then
1143 loggeropts=''
1144 echo_warning "As chosen logger is not \`logger', default logger options are cleared"
1145 fi
1146
1147 # get pager program location from standard PATHs or /usr/local/bin
1148 # or validate location passed as argument
1149 if [ -n "$pager" ]; then
1150 check_requirement "$pager" '' "PATH=$binsearchpath"
1151 pager=$reqpath
1152 fi
1153 # adapt pager program settings dependings of specified args
1154 if [ $defpageropts -eq 1 ] && [ "${pager##*/}" != 'less' ]; then
1155 pageropts=''
1156 echo_warning "As chosen pager is not \`less', default pager options are cleared"
1157 fi
1158
1159 if [ -n "$tcllinter" ]; then
1160 check_requirement "$tcllinter" "$tcllinter could not be found" "PATH=$binsearchpath"
1161 if [ -n "$reqpath" ]; then
1162 tcllinter=$reqpath
1163 fi
1164 fi
1165
1166 # fetch modules version from version.inc.in file (which may be raw data to
1167 # refine or exact values if dist has been built by `git archive`)
1168 if [ -r "${progdir}/version.inc.in" ]; then
1169 release=$(sed -n '/^MODULES_RELEASE/{s/.*= //p;q;}' \
1170 "${progdir}/version.inc.in")
1171 build_hash=$(sed -n '/^MODULES_BUILD_HASH/{s/.*= //p;q;}' \
1172 "${progdir}/version.inc.in")
1173 build_refs=$(sed -n '/^MODULES_BUILD_REFS/{s/.*= //p;q;}' \
1174 "${progdir}/version.inc.in")
1175 build_refs=${build_refs//,}
1176 build_refs=${build_refs//origin\/}
1177 else
1178 echo_error "${progdir}/version.inc.in is missing"
1179 fi
1180
1181 # refine build number if working from git repository
1182 # shellcheck disable=SC2016
1183 if [ $work_from_git_repo -eq 0 ]; then
1184 gitcurtag=$(git describe --tags --abbrev=0)
1185 gitcurdesc=$(git describe --tags)
1186 gitcurbranch=$(git rev-parse --abbrev-ref HEAD)
1187 if [ "$gitcurtag" = "$gitcurdesc" ]; then
1188 build=''
1189 elif [ "$gitcurbranch" = 'main' ]; then
1190 build="+${gitcurdesc#"${gitcurtag}"-}"
1191 else
1192 build="+${gitcurbranch}${gitcurdesc#"${gitcurtag}"}"
1193 fi
1194 # set a recognizable build number if one found in version.inc.in is raw data
1195 elif [ "$build_hash" = '$Format:%h' ]; then
1196 build='+XX-gffffffff'
1197 # or compute it from these information as if working from git repository
1198 elif [[ " $build_refs " == *" v$release "* ]]; then
1199 build=''
1200 elif [[ " $build_refs " == *" main "* ]]; then
1201 build="+XX-g$build_hash"
1202 # %D placeholder may not be known by old version of git
1203 elif [ "$build_refs" = "%D" ]; then
1204 build="+XX-g$build_hash"
1205 else
1206 build="+${build_refs##* }-XX-g$build_hash"
1207 fi
1208 VERSION=$release$build
1209 # shellcheck disable=SC2034
1210 RELEASE=$release
1211
1212 if [ -z "$VERSION" ]; then
1213 echo_error "Cannot fetch modules version"
1214 fi
1215
1216 # refer to binary exes and libs to build with the appropriate extension
1217 # shellcheck disable=SC2034
1218 case "$kernelname" in
1219 CYGWIN*) SHLIB_SUFFIX='.dll' ;;
1220 MINGW*|MSYS_NT*) SHLIB_SUFFIX='.dll' ;;
1221 Darwin) SHLIB_SUFFIX='.dylib' ;;
1222 esac
1223
1224 # adapt prefix if versioning enabled
1225 baseprefix=$prefix
1226 if [ "$versioning" = 'y' ]; then
1227 # append modules version to installation prefix
1228 prefix=$prefix/$VERSION
1229 fi
1230
1231 # set argument default values for those depending of other argument
1232 [ -z "$bindir" ] && bindir=$prefix/bin
1233 [ -z "$libdir" ] && libdir=$prefix/lib
1234 [ -z "$libexecdir" ] && libexecdir=$prefix/libexec
1235 [ -z "$etcdir" ] && etcdir=$prefix/etc
1236 [ -z "$initdir" ] && initdir=$prefix/init
1237 [ -z "$datarootdir" ] && datarootdir=$prefix/share
1238 [ -z "$mandir" ] && mandir=$datarootdir/man
1239 [ -z "$docdir" ] && docdir=$datarootdir/doc
1240 [ -z "$vimdatadir" ] && vimdatadir=$datarootdir/vim/vimfiles
1241 [ -z "$emacsdatadir" ] && emacsdatadir=$datarootdir/emacs/lisp
1242 [ -z "$nagelfardatadir" ] && nagelfardatadir=$datarootdir/nagelfar
1243 [ -z "$modulefilesdir" ] && modulefilesdir=$prefix/modulefiles
1244 [ -z "$moduleshome" ] && moduleshome=$prefix
1245 # default modulepath based on MODULE_VERSION if versioning enabled
1246 [ -z "$modulepath" ] && [ "$versioning" = 'y' ] && modulepath=${modulefilesdir/#$prefix/$baseprefix\/\$MODULE_VERSION}
1247 [ -z "$modulepath" ] && modulepath=$modulefilesdir
1248
1249 # define libdir64 and libdir32 based on libdir if multilib support enabled
1250 if [ "$multilibsupport" = 'y' ]; then
1251 # shellcheck disable=SC2034
1252 case "$libdir" in
1253 *64*)
1254 libdir64=$libdir ;
1255 libdir32=${libdir/64} ;;
1256 *)
1257 libdir64=${libdir/lib/lib64} ;
1258 libdir32=$libdir ;;
1259 esac
1260 fi
1261
1262 # check feature requirements are met
1263 if [ "$setmodulespath" = 'y' ] && [ -n "$loadedmodules" ]; then
1264 featmesg="As \`setmodulespath' is enabled beware that \`loadedmodules' may be ignored by init scripts"
1265 echo_warning "$featmesg"
1266 fi
1267 if [ -n "$loadedmodules" ] && [ -z "$modulepath" ]; then
1268 featmesg="A value is set for \`loadedmodules' whereas \`modulepath' is not defined"
1269 echo_warning "$featmesg"
1270 fi
1271
1272 # prepare extension library sources if not yet done whether libtclenvmodules
1273 # is enabled or not to create consistent dist in any cases.
1274 if [ ! -e "${progdir}/lib/configure" ]; then
1275 check_requirement autoreconf
1276 echo "--- preparing extension library sources ----------"
1277 pushd "${progdir}/lib" || exit 1
1278 autoreconf -i || exit 1
1279 popd || exit 1
1280 echo "--------------------------------------------------"
1281 fi
1282
1283 # display configuration set
1284 # and build Makefile translation expression
1285 translation_regexp=()
1286 for arg in ${arglist}; do
1287 echo "$arg = ${!arg}"
1288 translation_regexp+=('-e' "s|@${arg}@|${!arg}|g")
1289 done
1290
1291 # configure extension library sources
1292 if [ "$libtclenvmodules" = 'y' ]; then
1293 echo "--- configuring extension library sources --------"
1294 echo "libarglist = ${libarglist[*]}"
1295 pushd "${progdir}/lib" || exit 1
1296 ./configure "${libarglist[@]}" || exit 1
1297 popd || exit 1
1298 echo "--------------------------------------------------"
1299 fi
1300
1301 # generate Makefiles
1302 for target in ${targetlist}; do
1303 # escape any '$' in value for Makefile or testsuite interpretation
1304 if [ "${target/Makefile}" = "${target}" ]; then
1305 extra_regexp=()
1306 else
1307 extra_regexp=('-e' 's|\$|\$\$|g')
1308 fi
1309 echo "creating $target"
1310 sed "${translation_regexp[@]}" "${extra_regexp[@]}" "${target}.in" >"$target"
1311 done
1312
1313 exit 0
1314
1315 # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: