Debian Codegraph @

configure

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