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