Debian Codegraph @

Makefile

raw
1 .PHONY: doc pkgdoc initdir install install-testsiteconfig \
2 install-testsiteconfig-1 install-testmodulerc install-testinitrc-1 \
3 install-testinitrc install-testetcrc install-testmodspath \
4 install-testmodspath-empty install-testmodspath-wild \
5 install-testmoguicmd uninstall-testconfig uninstall dist dist-tar \
6 dist-gzip dist-bzip2 dist-win srpm rpm clean distclean test-deps test \
7 testinstall testlint
8
9 # commands to install files
10 INSTALL = install
11 INSTALL_DIR = $(INSTALL) -d -m 755
12 INSTALL_DATA = $(INSTALL) -m 644
13 INSTALL_PROGRAM = $(INSTALL) -m 755
14
15 # download command and its options
16 CURL := curl --location --remote-name --retry 3 --retry-connrefused \
17 --retry-delay 20 --max-time 20
18
19 # definitions for code coverage
20 NAGELFAR_DLSRC1 := http://downloads.sourceforge.net/nagelfar/
21 NAGELFAR_RELEASE := nagelfar135
22 NAGELFAR_DIST := $(NAGELFAR_RELEASE).tar.gz
23 NAGELFAR_DISTSUM := 0305ae1617a365626f45fc08909c6f58
24 NAGELFAR := $(NAGELFAR_RELEASE)/nagelfar.tcl
25
26 # definition for old Tcl interpreter for coverage testing
27 TCL_DLSRC := http://downloads.sourceforge.net/tcl/
28 TCL_RELEASE83 := tcl8.3.5
29 TCL_DIST83 := $(TCL_RELEASE83)-src.tar.gz
30 TCL_DISTSUM83 := 5cb79f8b90cf1322cb1286b9fe67f7a2
31 TCLSH83 := $(TCL_RELEASE83)/unix/tclsh
32
33 # third-party definitions for source-sh testing
34 SPACK_REPOURL := https://github.com/spack/spack.git
35 MINICONDA_DLSRC := https://repo.anaconda.com/miniconda/
36 MINICONDA_DIST := Miniconda3-py38_4.11.0-Linux-x86_64.sh
37 MINICONDA_DISTSUM := 252d3b0c863333639f99fbc465ee1d61
38 OPENFOAM_REPOURL := https://github.com/OpenFOAM/OpenFOAM-dev.git
39
40 # specific modulecmd script for test
41 MODULECMDTEST := modulecmd-test.tcl
42 # if coverage enabled, run tests on instrumented file to create coverage log
43 ifeq ($(COVERAGE),y)
44 MODULECMD := $(MODULECMDTEST)_i
45 else
46 MODULECMD := $(MODULECMDTEST)
47 endif
48
49 # definitions for enhanced diff tool (to review test results)
50 ICDIFF_DLSRC := https://raw.githubusercontent.com/jeffkaufman/icdiff/release-2.0.4/
51 ICDIFF_CHECKSUM := 597bd4cda393803e5991c43b78cab3b3
52
53 # source definitions shared across the Makefiles of this project
54 ifneq ($(wildcard Makefile.inc),Makefile.inc)
55 $(error Makefile.inc is missing, please run './configure')
56 endif
57 include Makefile.inc
58
59 INSTALL_PREREQ := modulecmd.tcl ChangeLog.gz README script/add.modules \
60 script/modulecmd
61 TEST_PREREQ := $(MODULECMD)
62 ifeq ($(COVERAGE),y)
63 TEST_PREREQ += $(NAGELFAR)
64 endif
65
66 ifeq ($(libtclenvmodules),y)
67 INSTALL_PREREQ += lib/libtclenvmodules$(SHLIB_SUFFIX)
68 TEST_PREREQ += lib/libtclenvmodules$(SHLIB_SUFFIX)
69 ifeq ($(COVERAGE),y)
70 TEST_PREREQ += lib/libtestutil-closedir$(SHLIB_SUFFIX) \
71 lib/libtestutil-getpwuid$(SHLIB_SUFFIX) \
72 lib/libtestutil-getgroups$(SHLIB_SUFFIX) \
73 lib/libtestutil-0getgroups$(SHLIB_SUFFIX) \
74 lib/libtestutil-dupgetgroups$(SHLIB_SUFFIX) \
75 lib/libtestutil-getgrgid$(SHLIB_SUFFIX) \
76 lib/libtestutil-time$(SHLIB_SUFFIX) \
77 lib/libtestutil-mktime$(SHLIB_SUFFIX)
78 endif
79 endif
80
81 # install old Tcl interpreters to test coverage
82 ifeq ($(COVERAGE_OLDTCL),y)
83 TEST_PREREQ += tclsh83
84 endif
85
86 # install extra software to test source-sh against their scripts
87 ifeq ($(EXTRATEST_SOURCESH),y)
88 TEST_PREREQ += spack miniconda3 OpenFOAM-dev
89 endif
90
91 # define rule prereq when target need to be rebuilt when git repository change
92 ifeq ($(wildcard .git),.git)
93 GIT_REFRESH_PREREQ := .git/objects
94
95 # determine if version.inc needs to get updated as git repository has changed
96 ifeq ($(wildcard version.inc), version.inc)
97 MTIME_VERSION := $(shell date -r version.inc +%s)
98 MTIME_GIT_REPO := $(shell date -r $(GIT_REFRESH_PREREQ) +%s)
99 REFRESH_VERSION_INC := $(shell if [ $(MTIME_GIT_REPO) -gt $(MTIME_VERSION) ]; \
100 then echo y; else echo n; fi)
101 else
102 REFRESH_VERSION_INC := y
103 endif
104
105 else
106 GIT_REFRESH_PREREQ :=
107 REFRESH_VERSION_INC := n
108 endif
109
110 # setup summary echo rules unless silent mode set
111 ifneq ($(findstring s,$(MAKEFLAGS)),s)
112 ECHO_GEN = @echo ' ' GEN $@;
113 ECHO_GEN2 = @echo ' ' GEN
114 else
115 # disable echo rules followed by a string
116 ECHO_GEN2 = \#
117 endif
118
119 all: initdir $(INSTALL_PREREQ)
120
121 # skip doc build if no sphinx-build
122 ifneq ($(builddoc),n)
123 all: pkgdoc
124 endif
125
126 initdir:
127 $(MAKE) --no-print-directory -C init all
128
129 pkgdoc: version.inc
130 $(MAKE) --no-print-directory -C doc man txt
131
132 doc: version.inc
133 $(MAKE) --no-print-directory -C doc all
134
135 # source version definitions if built and no need to get refreshed
136 # skip calls to git command if this file is available
137 ifeq ($(wildcard version.inc) $(REFRESH_VERSION_INC), version.inc n)
138 -include version.inc
139 else
140 # build version.inc shared definitions from git repository info
141 ifeq ($(wildcard .git) $(wildcard version.inc.in),.git version.inc.in)
142 GIT_CURRENT_TAG := $(shell git describe --tags --abbrev=0 2>/dev/null)
143 GIT_CURRENT_DESC := $(shell git describe --tags 2>/dev/null)
144 GIT_CURRENT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
145
146 MODULES_RELEASE := $(subst v,,$(GIT_CURRENT_TAG))
147 ifeq ($(MODULES_RELEASE),)
148 # load raw version information to get MODULES_RELEASE as git repository does
149 # not contain enough info (checked out repository depth too short)
150 include version.inc.in
151 GIT_CURRENT_COMMIT := $(shell git rev-parse --short=8 HEAD)
152 ifeq ($(GIT_CURRENT_BRANCH),main)
153 MODULES_BUILD := +XX-g$(GIT_CURRENT_COMMIT)
154 else
155 MODULES_BUILD := +$(GIT_CURRENT_BRANCH)-XX-g$(GIT_CURRENT_COMMIT)
156 endif
157 else ifeq ($(GIT_CURRENT_TAG),$(GIT_CURRENT_DESC))
158 MODULES_BUILD :=
159 else ifeq ($(GIT_CURRENT_BRANCH),main)
160 MODULES_BUILD := +$(subst $(GIT_CURRENT_TAG)-,,$(GIT_CURRENT_DESC))
161 else
162 MODULES_BUILD := +$(GIT_CURRENT_BRANCH)$(subst $(GIT_CURRENT_TAG),,$(GIT_CURRENT_DESC))
163 endif
164 MODULES_BUILD_DATE := $(shell git log -1 --format=%cd --date=short)
165
166 else
167 # load raw version information
168 include version.inc.in
169
170 # build short date from full date found in raw data
171 ifeq ($(MODULES_BUILD_FDATE),$$Format:%ci$$)
172 MODULES_BUILD_DATE := $(shell date '+%Y-%m-%d')
173 else
174 MODULES_BUILD_DATE := $(firstword $(MODULES_BUILD_FDATE))
175 endif
176
177 # set a recognizable build number if one found in version.inc.in is raw data
178 ifeq ($(MODULES_BUILD_HASH),$$Format:%h$$)
179 MODULES_BUILD := +XX-gffffffff
180 # or compute it from these information as if working from git repository
181 else
182 comma := ,
183 MODULES_BUILD_REFS := $(subst $(comma),,$(MODULES_BUILD_REFS))
184
185 ifeq ($(filter v$(MODULES_RELEASE),$(MODULES_BUILD_REFS)),v$(MODULES_RELEASE))
186 MODULES_BUILD :=
187 else ifeq ($(filter main,$(MODULES_BUILD_REFS)),main)
188 MODULES_BUILD := +XX-g$(MODULES_BUILD_HASH)
189 else ifeq ($(MODULES_BUILD_REFS),%D)
190 MODULES_BUILD := +XX-g$(MODULES_BUILD_HASH)
191 else
192 MODULES_BUILD := +$(notdir $(lastword $(MODULES_BUILD_REFS)))-XX-g$(MODULES_BUILD_HASH)
193 endif
194 endif
195 endif
196 # no need to include generated version.inc file as the MODULES_* variables
197 # have just been computed
198 endif
199
200 # determine RPM release
201 # use last release if we currently sat on tag, append build number to it elsewhere
202 MODULES_LAST_RPM_VERSREL := $(shell sed -n '/^%changelog/ {n;s/^\*.* - //p;q;}' \
203 share/rpm/environment-modules.spec.in)
204 MODULES_LAST_RPM_RELEASE := $(lastword $(subst -, ,$(MODULES_LAST_RPM_VERSREL)))
205 MODULES_RPM_RELEASE := $(MODULES_LAST_RPM_RELEASE)$(subst +,.,$(subst -,.,$(MODULES_BUILD)))
206
207 # define init configs location
208 ifeq ($(initconfin),etcdir)
209 modulespath := $(etcdir)/modulespath
210 initrc := $(etcdir)/initrc
211 else
212 modulespath := $(initdir)/.modulespath
213 initrc := $(initdir)/modulerc
214 endif
215
216 # comment entries if feature not enabled
217 ifeq ($(versioning),y)
218 setversioning :=
219 setnotversioning := \#
220 else
221 setversioning := \#
222 setnotversioning :=
223 endif
224 ifeq ($(setbinpath),y)
225 setsetbinpath :=
226 else
227 setsetbinpath := \#
228 endif
229 ifeq ($(appendbinpath),y)
230 setappendbinpath := append
231 else
232 setappendbinpath := prepend
233 endif
234 ifeq ($(setmanpath),y)
235 setsetmanpath :=
236 else
237 setsetmanpath := \#
238 endif
239 ifeq ($(appendmanpath),y)
240 setappendmanpath := append
241 else
242 setappendmanpath := prepend
243 endif
244 ifeq ($(usemanpath),y)
245 setusemanpath :=
246 setnotusemanpath := \#
247 else
248 setusemanpath := \#
249 setnotusemanpath :=
250 endif
251
252 # build list of shell whose completion script has to be sourced during
253 # autoinit initialization
254 shellcompsource := tcsh
255 ifeq ($(bashcompletiondir),)
256 shellcompsource += bash
257 endif
258 ifeq ($(fishcompletiondir),)
259 shellcompsource += fish
260 endif
261
262 ifeq ($(silentshdbgsupport),y)
263 setsilentshdbgsupport := 1
264 else
265 setsilentshdbgsupport := 0
266 endif
267
268 ifeq ($(quarantinesupport),y)
269 setquarantinesupport := 1
270 else
271 setquarantinesupport := 0
272 endif
273
274 ifeq ($(libtclenvmodules),y)
275 setlibtclenvmodules :=
276 else
277 setlibtclenvmodules := \#
278 endif
279
280 ifeq ($(multilibsupport),y)
281 setmultilibsupport :=
282 setnotmultilibsupport := \#
283 sedexprlibdir := -e 's|@libdir64@|$(libdir64)|g' -e 's|@libdir32@|$(libdir32)|g'
284 else
285 setmultilibsupport := \#
286 setnotmultilibsupport :=
287 sedexprlibdir := -e 's|@libdir@|$(libdir)|g'
288 endif
289
290 ifneq ($(pageropts),)
291 pagercmd := $(pager) $(pageropts)
292 else
293 pagercmd := $(pager)
294 endif
295
296 ifneq ($(loggeropts),)
297 loggercmd := $(logger) $(loggeropts)
298 else
299 loggercmd := $(logger)
300 endif
301
302 ifeq ($(color),y)
303 setcolor := auto
304 else
305 setcolor := never
306 endif
307
308 ifeq ($(autohandling),y)
309 setautohandling := 1
310 else
311 setautohandling := 0
312 endif
313
314 ifeq ($(conflictunload),y)
315 setconflictunload := 1
316 else
317 setconflictunload := 0
318 endif
319
320 ifeq ($(requirevia),y)
321 setrequirevia := 1
322 else
323 setrequirevia := 0
324 endif
325
326 ifeq ($(implicitrequirement),y)
327 setimplicitrequirement := 1
328 else
329 setimplicitrequirement := 0
330 endif
331
332 ifeq ($(availindepth),y)
333 setavailindepth := 1
334 else
335 setavailindepth := 0
336 endif
337
338 ifeq ($(spiderindepth),y)
339 setspiderindepth := 1
340 else
341 setspiderindepth := 0
342 endif
343
344 ifeq ($(implicitdefault),y)
345 setimplicitdefault := 1
346 else
347 setimplicitdefault := 0
348 endif
349
350 ifeq ($(extendeddefault),y)
351 setextendeddefault := 1
352 else
353 setextendeddefault := 0
354 endif
355
356 ifeq ($(advversspec),y)
357 setadvversspec := 1
358 else
359 setadvversspec := 0
360 endif
361
362 ifeq ($(uniquenameloaded),y)
363 setuniquenameloaded := 1
364 else
365 setuniquenameloaded := 0
366 endif
367
368 ifeq ($(sourcecache),y)
369 setsourcecache := 1
370 else
371 setsourcecache := 0
372 endif
373
374 ifeq ($(ml),y)
375 setml := 1
376 else
377 setml := 0
378 endif
379
380 ifeq ($(setshellstartup),y)
381 setsetshellstartup := 1
382 else
383 setsetshellstartup := 0
384 endif
385
386 ifeq ($(mcookieversioncheck),y)
387 setmcookieversioncheck := 1
388 else
389 setmcookieversioncheck := 0
390 endif
391
392 ifeq ($(wa277),y)
393 setwa277 := 1
394 else
395 setwa277 := 0
396 endif
397
398 ifneq ($(tcllinteropts),)
399 tcllintercmd := $(tcllinter) $(tcllinteropts)
400 else
401 tcllintercmd := $(tcllinter)
402 endif
403
404 ifeq ($(nagelfaraddons),y)
405 setnagelfaraddons :=
406 else
407 setnagelfaraddons := \#
408 endif
409
410 define translate-in-script
411 $(ECHO_GEN)
412 sed -e 's|@prefix@|$(prefix)|g' \
413 -e 's|@baseprefix@|$(baseprefix)|g' \
414 $(sedexprlibdir) \
415 -e 's|@libexecdir@|$(libexecdir)|g' \
416 -e 's|@initdir@|$(initdir)|g' \
417 -e 's|@etcdir@|$(etcdir)|g' \
418 -e 's|@modulefilesdir@|$(modulefilesdir)|g' \
419 -e 's|@bindir@|$(bindir)|g' \
420 -e 's|@mandir@|$(mandir)|g' \
421 -e 's|@nagelfardatadir@|$(nagelfardatadir)|g' \
422 -e 's|@moduleshome@|$(moduleshome)|g' \
423 -e 's|@initrc@|$(initrc)|g' \
424 -e 's|@modulespath@|$(modulespath)|g' \
425 -e 's|@VERSION@|$(VERSION)|g' \
426 -e 's|@TCLSHDIR@/tclsh|$(TCLSH)|g' \
427 -e 's|@TCLSH@|$(TCLSH)|g' \
428 -e 's|@PYTHON@|$(PYTHON)|g' \
429 -e 's|@loggedevents@|$(loggedevents)|g' \
430 -e 's|@loggercmd@|$(loggercmd)|g' \
431 -e 's|@pagercmd@|$(pagercmd)|g' \
432 -e 's|@verbosity@|$(verbosity)|g' \
433 -e 's|@color@|$(setcolor)|g' \
434 -e 's|@darkbgcolors@|$(darkbgcolors)|g' \
435 -e 's|@lightbgcolors@|$(lightbgcolors)|g' \
436 -e 's|@termbg@|$(termbg)|g' \
437 -e 's|@lockedconfigs@|$(lockedconfigs)|g' \
438 -e 's|@unloadmatchorder@|$(unloadmatchorder)|g' \
439 -e 's|@implicitdefault@|$(setimplicitdefault)|g' \
440 -e 's|@extendeddefault@|$(setextendeddefault)|g' \
441 -e 's|@advversspec@|$(setadvversspec)|g' \
442 -e 's|@uniquenameloaded@|$(setuniquenameloaded)|g' \
443 -e 's|@sourcecache@|$(setsourcecache)|g' \
444 -e 's|@searchmatch@|$(searchmatch)|g' \
445 -e 's|@wa277@|$(setwa277)|g' \
446 -e 's|@icase@|$(icase)|g' \
447 -e 's|@nearlyforbiddendays@|$(nearlyforbiddendays)|g' \
448 -e 's|@tagabbrev@|$(tagabbrev)|g' \
449 -e 's|@tagcolorname@|$(tagcolorname)|g' \
450 -e 's|@stickypurge@|$(stickypurge)|g' \
451 -e 's|@abortonerror@|$(abortonerror)|g' \
452 -e 's|@availoutput@|$(availoutput)|g' \
453 -e 's|@availterseoutput@|$(availterseoutput)|g' \
454 -e 's|@listoutput@|$(listoutput)|g' \
455 -e 's|@listterseoutput@|$(listterseoutput)|g' \
456 -e 's|@spideroutput@|$(spideroutput)|g' \
457 -e 's|@spiderterseoutput@|$(spiderterseoutput)|g' \
458 -e 's|@variantshortcut@|$(variantshortcut)|g' \
459 -e 's|@editor@|$(editor)|g' \
460 -e 's|@autohandling@|$(setautohandling)|g' \
461 -e 's|@conflictunload@|$(setconflictunload)|g' \
462 -e 's|@requirevia@|$(setrequirevia)|g' \
463 -e 's|@implicitrequirement@|$(setimplicitrequirement)|g' \
464 -e 's|@availindepth@|$(setavailindepth)|g' \
465 -e 's|@spiderindepth@|$(setspiderindepth)|g' \
466 -e 's|@silentshdbgsupport@|$(setsilentshdbgsupport)|g' \
467 -e 's|@ml@|$(setml)|g' \
468 -e 's|@setshellstartup@|$(setsetshellstartup)|g' \
469 -e 's|@mcookieversioncheck@|$(setmcookieversioncheck)|g' \
470 -e 's|@quarantinesupport@|$(setquarantinesupport)|g' \
471 -e 's|@libtclenvmodules@|$(setlibtclenvmodules)|g' \
472 -e 's|@SHLIB_SUFFIX@|$(SHLIB_SUFFIX)|g' \
473 -e 's|@multilibsupport@|$(setmultilibsupport)|g' \
474 -e 's|@notmultilibsupport@|$(setnotmultilibsupport)|g' \
475 -e 's|@VERSIONING@|$(setversioning)|g' \
476 -e 's|@NOTVERSIONING@|$(setnotversioning)|g' \
477 -e 's|@setbinpath@|$(setsetbinpath)|g' \
478 -e 's|@appendbinpath@|$(setappendbinpath)|g' \
479 -e 's|@setmanpath@|$(setsetmanpath)|g' \
480 -e 's|@appendmanpath@|$(setappendmanpath)|g' \
481 -e 's|@usemanpath@|$(setusemanpath)|g' \
482 -e 's|@notusemanpath@|$(setnotusemanpath)|g' \
483 -e 's|@shellcompsource@|$(shellcompsource)|g' \
484 -e 's|@tcllintercmd@|$(tcllintercmd)|g' \
485 -e 's|@nagelfaraddons@|$(setnagelfaraddons)|g' \
486 -e 's|@MODULES_RELEASE@|$(MODULES_RELEASE)|g' \
487 -e 's|@MODULES_BUILD@|$(MODULES_BUILD)|g' \
488 -e 's|@MODULES_RPM_RELEASE@|$(MODULES_RPM_RELEASE)|g' \
489 -e 's|@MODULES_BUILD_DATE@|$(MODULES_BUILD_DATE)|g' $< > $@
490 endef
491
492 DIST_PREFIX := modules-$(MODULES_RELEASE)$(MODULES_BUILD)
493 DIST_WIN_PREFIX := $(DIST_PREFIX)-win
494
495 # avoid shared definitions to be rebuilt by make
496 Makefile.inc: ;
497
498 version.inc: version.inc.in $(GIT_REFRESH_PREREQ)
499 $(translate-in-script)
500
501 share/rpm/environment-modules.spec: share/rpm/environment-modules.spec.in $(GIT_REFRESH_PREREQ)
502 $(translate-in-script)
503
504 tcl/cache.tcl: tcl/cache.tcl.in version.inc
505 $(translate-in-script)
506
507 tcl/coll.tcl: tcl/coll.tcl.in version.inc
508 $(translate-in-script)
509
510 tcl/envmngt.tcl: tcl/envmngt.tcl.in version.inc
511 $(translate-in-script)
512
513 tcl/init.tcl: tcl/init.tcl.in version.inc
514 $(translate-in-script)
515
516 tcl/main.tcl: tcl/main.tcl.in version.inc
517 $(translate-in-script)
518
519 tcl/interp.tcl: tcl/interp.tcl.in version.inc
520 $(translate-in-script)
521
522 tcl/modfind.tcl: tcl/modfind.tcl.in version.inc
523 $(translate-in-script)
524
525 tcl/report.tcl: tcl/report.tcl.in version.inc
526 $(translate-in-script)
527
528 tcl/subcmd.tcl: tcl/subcmd.tcl.in version.inc
529 $(translate-in-script)
530
531 tcl/init.tcl_i: tcl/init.tcl $(NAGELFAR)
532 $(ECHO_GEN)
533 rm -f $<_log
534 $(NAGELFAR) -instrument $<
535 ifeq ($(multilibsupport),y)
536 ifeq ($(COVERAGE_MULTILIB),y)
537 sed -i -e 's|$(libdir64)|lib64|' -e 's|$(libdir32)|lib|' $@
538 else
539 sed -i -e 's|$(libdir64)|lib|' -e 's|$(libdir32)|lib|' $@
540 endif
541 else
542 sed -i -e 's|$(libdir)|lib|' $@
543 endif
544
545 tcl/subcmd.tcl_i: tcl/subcmd.tcl $(NAGELFAR)
546 $(ECHO_GEN)
547 rm -f $<_log
548 $(NAGELFAR) -instrument $<
549 sed -i -e 's|$(nagelfardatadir)|share/nagelfar|g' $@
550
551 # join all tcl/*.tcl files to build modulecmd.tcl
552 modulecmd.tcl: tcl/cache.tcl tcl/coll.tcl tcl/envmngt.tcl tcl/init.tcl \
553 tcl/interp.tcl tcl/main.tcl tcl/mfcmd.tcl tcl/modeval.tcl \
554 tcl/modfind.tcl tcl/modscan.tcl tcl/modspec.tcl tcl/report.tcl \
555 tcl/subcmd.tcl tcl/util.tcl version.inc
556 $(ECHO_GEN)
557 echo "#!$(TCLSH)" > $@
558 sed -e '3s/.*/# MODULECMD.TCL, a pure TCL implementation of the module command/' \
559 -e '1d' -e '/^# vim:/d' -e '/^# ;;;/d' tcl/init.tcl >> $@
560 sed -e '1,22d' -e '/^# vim:/d' -e '/^# ;;;/d' tcl/util.tcl >> $@
561 sed -e '1,22d' -e '/^# vim:/d' -e '/^# ;;;/d' tcl/envmngt.tcl >> $@
562 sed -e '1,22d' -e '/^# vim:/d' -e '/^# ;;;/d' tcl/report.tcl >> $@
563 sed -e '1,22d' -e '/^# vim:/d' -e '/^# ;;;/d' tcl/interp.tcl >> $@
564 sed -e '1,22d' -e '/^# vim:/d' -e '/^# ;;;/d' tcl/mfcmd.tcl >> $@
565 sed -e '1,20d' -e '/^# vim:/d' -e '/^# ;;;/d' tcl/modscan.tcl >> $@
566 sed -e '1,22d' -e '/^# vim:/d' -e '/^# ;;;/d' tcl/modfind.tcl >> $@
567 sed -e '1,22d' -e '/^# vim:/d' -e '/^# ;;;/d' tcl/modeval.tcl >> $@
568 sed -e '1,20d' -e '/^# vim:/d' -e '/^# ;;;/d' tcl/modspec.tcl >> $@
569 sed -e '1,20d' -e '/^# vim:/d' -e '/^# ;;;/d' tcl/cache.tcl >> $@
570 sed -e '1,20d' -e '/^# vim:/d' -e '/^# ;;;/d' tcl/coll.tcl >> $@
571 sed -e '1,22d' -e '/^# vim:/d' -e '/^# ;;;/d' tcl/subcmd.tcl >> $@
572 sed -e '1,22d' -e '/^# vim:/d' -e '/^# ;;;/d' tcl/main.tcl >> $@
573 chmod +x $@
574
575 # generate an empty changelog file if not working from git repository
576 ifeq ($(wildcard .git),.git)
577 ChangeLog.gz: script/gitlog2changelog.py
578 $(ECHO_GEN)
579 script/gitlog2changelog.py
580 gzip -f -9 ChangeLog
581 else
582 ChangeLog.gz:
583 $(ECHO_GEN)
584 echo "Please refer to the NEWS document to learn about main changes" >ChangeLog
585 gzip -f -9 ChangeLog
586 endif
587
588 README:
589 $(ECHO_GEN)
590 sed -e '181,187d' -e '1,10d' -e 's|\[\(.*\?\)\]\[[0-9]\]|\1|' [email protected] > $@
591
592 script/add.modules: script/add.modules.in
593 $(translate-in-script)
594 chmod +x $@
595
596 script/gitlog2changelog.py: script/gitlog2changelog.py.in
597 $(translate-in-script)
598 chmod +x $@
599
600 script/modulecmd: script/modulecmd.in
601 $(translate-in-script)
602 chmod +x $@
603
604 # Tcl extension library-related rules
605 lib/libtclenvmodules$(SHLIB_SUFFIX):
606 $(MAKE) --no-print-directory -C lib $(@F)
607
608 lib/libtestutil-closedir$(SHLIB_SUFFIX):
609 $(MAKE) --no-print-directory -C lib $(@F)
610
611 lib/libtestutil-getpwuid$(SHLIB_SUFFIX):
612 $(MAKE) --no-print-directory -C lib $(@F)
613
614 lib/libtestutil-getgroups$(SHLIB_SUFFIX):
615 $(MAKE) --no-print-directory -C lib $(@F)
616
617 lib/libtestutil-0getgroups$(SHLIB_SUFFIX):
618 $(MAKE) --no-print-directory -C lib $(@F)
619
620 lib/libtestutil-dupgetgroups$(SHLIB_SUFFIX):
621 $(MAKE) --no-print-directory -C lib $(@F)
622
623 lib/libtestutil-getgrgid$(SHLIB_SUFFIX):
624 $(MAKE) --no-print-directory -C lib $(@F)
625
626 lib/libtestutil-time$(SHLIB_SUFFIX):
627 $(MAKE) --no-print-directory -C lib $(@F)
628
629 lib/libtestutil-mktime$(SHLIB_SUFFIX):
630 $(MAKE) --no-print-directory -C lib $(@F)
631
632 # example configs for test rules
633 testsuite/example/.modulespath: testsuite/example/.modulespath.in
634 $(translate-in-script)
635
636 testsuite/example/modulespath-wild: testsuite/example/modulespath-wild.in
637 $(translate-in-script)
638
639 testsuite/example/modulerc: testsuite/example/modulerc.in
640 $(translate-in-script)
641
642 testsuite/example/initrc-1: testsuite/example/initrc-1.in
643 $(translate-in-script)
644
645 testsuite/example/initrc: testsuite/example/initrc.in
646 $(translate-in-script)
647
648 install-testsiteconfig: testsuite/example/siteconfig.tcl
649 $(MAKE) -C init install-testconfig DESTDIR='$(DESTDIR)'
650 $(INSTALL_DATA) $^ '$(DESTDIR)$(etcdir)/'
651
652 install-testsiteconfig-1: testsuite/example/siteconfig.tcl-1
653 $(MAKE) -C init install-testconfig DESTDIR='$(DESTDIR)'
654 $(INSTALL_DATA) $^ '$(DESTDIR)$(etcdir)/siteconfig.tcl'
655
656 install-testmodulerc: testsuite/example/modulerc
657 $(MAKE) -C init install-testconfig DESTDIR='$(DESTDIR)'
658 $(INSTALL_DATA) $^ '$(DESTDIR)$(initrc)'
659
660 install-testinitrc-1: testsuite/example/initrc-1
661 $(MAKE) -C init install-testconfig DESTDIR='$(DESTDIR)'
662 $(INSTALL_DATA) $^ '$(DESTDIR)$(initrc)'
663
664 install-testinitrc: testsuite/example/initrc
665 $(MAKE) -C init install-testconfig DESTDIR='$(DESTDIR)'
666 $(INSTALL_DATA) $^ '$(DESTDIR)$(initrc)'
667
668 install-testetcrc: testsuite/etc/empty
669 $(MAKE) -C init install-testconfig DESTDIR='$(DESTDIR)'
670 $(INSTALL_DATA) $^ '$(DESTDIR)$(etcdir)/rc'
671
672 install-testmodspath: testsuite/example/.modulespath
673 $(MAKE) -C init install-testconfig DESTDIR='$(DESTDIR)'
674 $(INSTALL_DATA) $^ '$(DESTDIR)$(modulespath)'
675
676 install-testmodspath-empty: testsuite/example/modulespath-empty
677 $(MAKE) -C init install-testconfig DESTDIR='$(DESTDIR)'
678 $(INSTALL_DATA) $^ '$(DESTDIR)$(modulespath)'
679
680 install-testmodspath-wild: testsuite/example/modulespath-wild
681 $(MAKE) -C init install-testconfig DESTDIR='$(DESTDIR)'
682 $(INSTALL_DATA) $^ '$(DESTDIR)$(modulespath)'
683
684 install-testmoguicmd:
685 $(INSTALL_DIR) '$(HOME)/.local/bin'
686 $(INSTALL_PROGRAM) script/envml '$(HOME)/.local/bin/mogui-cmd'
687
688 uninstall-testconfig:
689 rm -f '$(DESTDIR)$(etcdir)/rc'
690 rm -f '$(DESTDIR)$(etcdir)/siteconfig.tcl'
691 rm -f '$(DESTDIR)$(initrc)'
692 rm -f '$(DESTDIR)$(modulespath)'
693 rm -f '$(HOME)/.local/bin/mogui-cmd'
694 $(MAKE) -C init uninstall-testconfig DESTDIR='$(DESTDIR)'
695
696 # define space character as a variable to reference it in functions
697 space := $(subst ,, )
698
699 install: $(INSTALL_PREREQ)
700 $(INSTALL_DIR) '$(DESTDIR)$(libexecdir)'
701 $(INSTALL_DIR) '$(DESTDIR)$(bindir)'
702 $(INSTALL_DIR) '$(DESTDIR)$(etcdir)'
703 $(INSTALL_PROGRAM) modulecmd.tcl '$(DESTDIR)$(libexecdir)/'
704 ifeq ($(libtclenvmodules),y)
705 $(INSTALL_DIR) '$(DESTDIR)$(libdir)'
706 $(INSTALL_PROGRAM) lib/libtclenvmodules$(SHLIB_SUFFIX) '$(DESTDIR)$(libdir)/'
707 endif
708 $(INSTALL_PROGRAM) script/envml '$(DESTDIR)$(bindir)/'
709 $(INSTALL_PROGRAM) script/add.modules '$(DESTDIR)$(bindir)/'
710 $(INSTALL_PROGRAM) script/modulecmd '$(DESTDIR)$(bindir)/'
711 $(INSTALL_PROGRAM) script/mkroot '$(DESTDIR)$(bindir)/'
712 ifeq ($(windowssupport),y)
713 $(INSTALL_PROGRAM) script/module.cmd '$(DESTDIR)$(bindir)/'
714 $(INSTALL_PROGRAM) script/ml.cmd '$(DESTDIR)$(bindir)/'
715 $(INSTALL_PROGRAM) script/envml.cmd '$(DESTDIR)$(bindir)/'
716 endif
717 ifneq ($(wildcard $(subst $(space),\$(space),$(DESTDIR)$(etcdir)/siteconfig.tcl)),$(DESTDIR)$(etcdir)/siteconfig.tcl)
718 $(INSTALL_DATA) siteconfig.tcl '$(DESTDIR)$(etcdir)/'
719 endif
720 ifeq ($(docinstall),y)
721 $(INSTALL_DIR) '$(DESTDIR)$(docdir)'
722 $(INSTALL_DATA) COPYING.GPLv2 '$(DESTDIR)$(docdir)/'
723 $(INSTALL_DATA) ChangeLog.gz '$(DESTDIR)$(docdir)/'
724 $(INSTALL_DATA) README '$(DESTDIR)$(docdir)/'
725 endif
726 ifeq ($(vimaddons),y)
727 $(INSTALL_DIR) '$(DESTDIR)$(vimdatadir)/ftdetect'
728 $(INSTALL_DIR) '$(DESTDIR)$(vimdatadir)/ftplugin'
729 $(INSTALL_DIR) '$(DESTDIR)$(vimdatadir)/syntax'
730 $(INSTALL_DATA) share/vim/ftdetect/modulefile.vim '$(DESTDIR)$(vimdatadir)/ftdetect'
731 $(INSTALL_DATA) share/vim/ftplugin/modulefile.vim '$(DESTDIR)$(vimdatadir)/ftplugin'
732 $(INSTALL_DATA) share/vim/syntax/modulefile.vim '$(DESTDIR)$(vimdatadir)/syntax'
733 endif
734 ifeq ($(emacsaddons),y)
735 $(INSTALL_DIR) '$(DESTDIR)$(emacsdatadir)'
736 $(INSTALL_DATA) share/emacs/lisp/modulefile-mode.el* '$(DESTDIR)$(emacsdatadir)'
737 endif
738 ifeq ($(nagelfaraddons),y)
739 $(INSTALL_DIR) '$(DESTDIR)$(nagelfardatadir)'
740 $(INSTALL_DATA) share/nagelfar/plugin_modulecache.tcl '$(DESTDIR)$(nagelfardatadir)/'
741 $(INSTALL_DATA) share/nagelfar/plugin_modulefile.tcl '$(DESTDIR)$(nagelfardatadir)/'
742 $(INSTALL_DATA) share/nagelfar/plugin_modulerc.tcl '$(DESTDIR)$(nagelfardatadir)/'
743 $(INSTALL_DATA) share/nagelfar/plugin_globalrc.tcl '$(DESTDIR)$(nagelfardatadir)/'
744 $(INSTALL_DATA) share/nagelfar/syntaxdb_modulecache.tcl '$(DESTDIR)$(nagelfardatadir)/'
745 $(INSTALL_DATA) share/nagelfar/syntaxdb_modulefile.tcl '$(DESTDIR)$(nagelfardatadir)/'
746 $(INSTALL_DATA) share/nagelfar/syntaxdb_modulerc.tcl '$(DESTDIR)$(nagelfardatadir)/'
747 endif
748 $(MAKE) -C init install DESTDIR='$(DESTDIR)'
749 ifneq ($(builddoc),n)
750 $(MAKE) -C doc install DESTDIR='$(DESTDIR)'
751 else
752 @echo
753 @echo "WARNING: Documentation not built nor installed" >&2
754 endif
755 @echo
756 @echo "NOTICE: Modules installation is complete." >&2
757 @echo " Please read the 'Configuration' section in INSTALL guide to learn" >&2
758 @echo " how to adapt your installation and make it fit your needs." >&2
759 @echo
760
761 uninstall:
762 rm -f '$(DESTDIR)$(libexecdir)/modulecmd.tcl'
763 ifeq ($(libtclenvmodules),y)
764 rm -f '$(DESTDIR)$(libdir)/libtclenvmodules$(SHLIB_SUFFIX)'
765 endif
766 rm -f '$(DESTDIR)$(bindir)/envml'
767 rm -f '$(DESTDIR)$(bindir)/add.modules'
768 rm -f '$(DESTDIR)$(bindir)/modulecmd'
769 rm -f '$(DESTDIR)$(bindir)/mkroot'
770 ifeq ($(windowssupport),y)
771 rm -f '$(DESTDIR)$(bindir)/module.cmd'
772 rm -f '$(DESTDIR)$(bindir)/ml.cmd'
773 rm -f '$(DESTDIR)$(bindir)/envml.cmd'
774 endif
775 ifeq ($(vimaddons),y)
776 rm -f '$(DESTDIR)$(vimdatadir)/ftdetect/modulefile.vim'
777 rm -f '$(DESTDIR)$(vimdatadir)/ftplugin/modulefile.vim'
778 rm -f '$(DESTDIR)$(vimdatadir)/syntax/modulefile.vim'
779 -rmdir '$(DESTDIR)$(vimdatadir)/ftdetect'
780 -rmdir '$(DESTDIR)$(vimdatadir)/ftplugin'
781 -rmdir '$(DESTDIR)$(vimdatadir)/syntax'
782 -rmdir -p '$(DESTDIR)$(vimdatadir)'
783 endif
784 ifeq ($(emacsaddons),y)
785 rm -f '$(DESTDIR)$(emacsdatadir)/modulefile-mode.el'
786 rm -f '$(DESTDIR)$(emacsdatadir)/modulefile-mode.elc'
787 -rmdir -p '$(DESTDIR)$(emacsdatadir)'
788 endif
789 ifeq ($(nagelfaraddons),y)
790 rm -f '$(DESTDIR)$(nagelfardatadir)/plugin_modulecache.tcl'
791 rm -f '$(DESTDIR)$(nagelfardatadir)/plugin_modulefile.tcl'
792 rm -f '$(DESTDIR)$(nagelfardatadir)/plugin_modulerc.tcl'
793 rm -f '$(DESTDIR)$(nagelfardatadir)/plugin_globalrc.tcl'
794 rm -f '$(DESTDIR)$(nagelfardatadir)/syntaxdb_modulecache.tcl'
795 rm -f '$(DESTDIR)$(nagelfardatadir)/syntaxdb_modulefile.tcl'
796 rm -f '$(DESTDIR)$(nagelfardatadir)/syntaxdb_modulerc.tcl'
797 -rmdir -p '$(DESTDIR)$(nagelfardatadir)'
798 endif
799 ifeq ($(docinstall),y)
800 rm -f $(foreach docfile,ChangeLog.gz README COPYING.GPLv2,'$(DESTDIR)$(docdir)/$(docfile)')
801 ifeq ($(builddoc),n)
802 rmdir '$(DESTDIR)$(docdir)'
803 endif
804 endif
805 $(MAKE) -C init uninstall DESTDIR='$(DESTDIR)'
806 ifneq ($(builddoc),n)
807 $(MAKE) -C doc uninstall DESTDIR='$(DESTDIR)'
808 endif
809 rmdir '$(DESTDIR)$(libexecdir)'
810 ifeq ($(libtclenvmodules),y)
811 rmdir '$(DESTDIR)$(libdir)'
812 endif
813 rmdir '$(DESTDIR)$(bindir)'
814 rmdir '$(DESTDIR)$(datarootdir)'
815 $(RMDIR_IGN_NON_EMPTY) '$(DESTDIR)$(prefix)' || true
816
817 # include config.{guess,sub} scripts in dist if generated by autoreconf
818 ifeq ($(wildcard lib/config.guess),lib/config.guess)
819 DIST_AUTORECONF_EXTRA += lib/config.guess
820 endif
821 ifeq ($(wildcard lib/config.sub),lib/config.sub)
822 DIST_AUTORECONF_EXTRA += lib/config.sub
823 endif
824
825 # include pre-generated documents not to require documentation build
826 # tools when installing from dist tarball
827 dist-tar: ChangeLog.gz share/rpm/environment-modules.spec pkgdoc
828 $(ECHO_GEN2) $(DIST_PREFIX).tar
829 git archive --prefix=$(DIST_PREFIX)/ --worktree-attributes \
830 -o $(DIST_PREFIX).tar HEAD
831 tar -rf $(DIST_PREFIX).tar --transform 's,^,$(DIST_PREFIX)/,' \
832 lib/configure lib/config.h.in $(DIST_AUTORECONF_EXTRA) ChangeLog.gz \
833 doc/build/MIGRATING.txt doc/build/changes.txt doc/build/INSTALL.txt \
834 doc/build/INSTALL-win.txt doc/build/NEWS.txt doc/build/CONTRIBUTING.txt \
835 doc/build/module.1.in doc/build/ml.1 doc/build/envml.1 \
836 doc/build/modulefile.5 share/rpm/environment-modules.spec
837
838 dist-gzip: dist-tar
839 $(ECHO_GEN2) $(DIST_PREFIX).tar.gz
840 gzip -f -9 $(DIST_PREFIX).tar
841
842 dist-bzip2: dist-tar
843 $(ECHO_GEN2) $(DIST_PREFIX).tar.bz2
844 bzip2 -f $(DIST_PREFIX).tar
845
846 dist: dist-gzip
847
848 # dist zip ball for Windows platform with all pre-generated relevant files
849 dist-win: modulecmd.tcl ChangeLog.gz README pkgdoc
850 $(ECHO_GEN2) $(DIST_WIN_PREFIX).zip
851 $(INSTALL_DIR) $(DIST_WIN_PREFIX)
852 $(INSTALL_DIR) $(DIST_WIN_PREFIX)/libexec
853 $(INSTALL_PROGRAM) modulecmd.tcl $(DIST_WIN_PREFIX)/libexec/
854 $(INSTALL_DIR) $(DIST_WIN_PREFIX)/bin
855 $(INSTALL_PROGRAM) script/module.cmd $(DIST_WIN_PREFIX)/bin/
856 $(INSTALL_PROGRAM) script/ml.cmd $(DIST_WIN_PREFIX)/bin/
857 $(INSTALL_PROGRAM) script/envml.cmd $(DIST_WIN_PREFIX)/bin/
858 $(INSTALL_DIR) $(DIST_WIN_PREFIX)/doc
859 $(INSTALL_DATA) COPYING.GPLv2 $(DIST_WIN_PREFIX)/doc/
860 $(INSTALL_DATA) ChangeLog.gz $(DIST_WIN_PREFIX)/doc/
861 $(INSTALL_DATA) README $(DIST_WIN_PREFIX)/doc/
862 $(INSTALL_DATA) doc/build/MIGRATING.txt $(DIST_WIN_PREFIX)/doc/
863 $(INSTALL_DATA) doc/build/INSTALL-win.txt $(DIST_WIN_PREFIX)/doc/
864 $(INSTALL_DATA) doc/build/NEWS.txt $(DIST_WIN_PREFIX)/doc/
865 $(INSTALL_DATA) doc/build/CONTRIBUTING.txt $(DIST_WIN_PREFIX)/doc/
866 $(INSTALL_DATA) doc/build/module.txt $(DIST_WIN_PREFIX)/doc/
867 $(INSTALL_DATA) doc/build/ml.txt $(DIST_WIN_PREFIX)/doc/
868 $(INSTALL_DATA) doc/build/envml.txt $(DIST_WIN_PREFIX)/doc/
869 $(INSTALL_DATA) doc/build/modulefile.txt $(DIST_WIN_PREFIX)/doc/
870 $(MAKE) --no-print-directory -C init dist-win DIST_WIN_PREFIX=../$(DIST_WIN_PREFIX)
871 $(INSTALL_PROGRAM) script/INSTALL.bat $(DIST_WIN_PREFIX)/
872 $(INSTALL_PROGRAM) script/UNINSTALL.bat $(DIST_WIN_PREFIX)/
873 $(INSTALL_PROGRAM) script/TESTINSTALL.bat $(DIST_WIN_PREFIX)/
874 $(INSTALL_PROGRAM) script/INSTALL_PWSH.bat $(DIST_WIN_PREFIX)/
875 $(INSTALL_PROGRAM) script/TESTINSTALL_PWSH.ps1 $(DIST_WIN_PREFIX)/
876 zip -r $(DIST_WIN_PREFIX).zip $(DIST_WIN_PREFIX)
877 rm -rf $(DIST_WIN_PREFIX)
878
879 srpm: dist-bzip2
880 rpmbuild -ts $(DIST_PREFIX).tar.bz2
881
882 rpm: dist-bzip2
883 rpmbuild -tb $(DIST_PREFIX).tar.bz2
884
885 clean:
886 rm -f *.log *.sum
887 rm -f tcl/*.tcl_i tcl/*.tcl_log tcl/*.tcl_m
888 rm -rf coverage
889 # do not clean generated docs if not in git repository
890 ifeq ($(wildcard .git),.git)
891 rm -f ChangeLog.gz
892 endif
893 rm -f README
894 rm -f modulecmd.tcl
895 rm -f $(MODULECMDTEST) $(MODULECMDTEST)_i
896 rm -f tcl/cache.tcl
897 rm -f tcl/coll.tcl
898 rm -f tcl/envmngt.tcl
899 rm -f tcl/init.tcl
900 rm -f tcl/interp.tcl
901 rm -f tcl/main.tcl
902 rm -f tcl/modfind.tcl
903 rm -f tcl/report.tcl
904 rm -f tcl/subcmd.tcl
905 rm -f script/add.modules
906 rm -f script/gitlog2changelog.py
907 rm -f script/modulecmd
908 rm -f testsuite/example/.modulespath testsuite/example/modulespath-wild testsuite/example/modulerc testsuite/example/initrc-1 testsuite/example/initrc
909 rm -f modules-*.tar modules-*.tar.gz modules-*.tar.bz2
910 rm -rf modules-*-win/
911 rm -f modules-*-win.zip
912 rm -f environment-modules-*.srpm environment-modules-*.rpm
913 $(MAKE) -C init clean
914 ifneq ($(builddoc),n)
915 $(MAKE) -C doc clean
916 endif
917 rm -f version.inc
918 rm -f share/rpm/environment-modules.spec
919 ifneq ($(wildcard lib/Makefile),)
920 $(MAKE) -C lib clean
921 endif
922
923 distclean: clean
924 rm -f Makefile.inc
925 rm -f site.exp
926 rm -f icdiff .noicdiff
927 rm -rf $(NAGELFAR_RELEASE)
928 rm -rf $(TCL_RELEASE83)
929 rm -f tclsh83
930 rm -rf spack
931 rm -rf miniconda3
932 rm -rf OpenFOAM-dev
933 rm -f tcl/tags
934 rm -f tcl/GTAGS tcl/GRTAGS tcl/GPATH tcl/gtags.file
935 rm -f tcl/syntaxdb_modulecmd.tcl
936 ifneq ($(wildcard lib/Makefile),)
937 $(MAKE) -C lib distclean
938 endif
939
940 # make specific modulecmd script for test to check built extension lib
941 # if coverage asked, instrument script and clear previous coverage log
942 $(MODULECMDTEST): modulecmd.tcl
943 $(ECHO_GEN)
944 ifeq ($(multilibsupport),y)
945 sed -e 's|$(libdir64)|lib|' -e 's|$(libdir32)|lib|' $< > $@
946 else
947 sed -e 's|$(libdir)|lib|' $< > $@
948 endif
949 sed -i -e 's|$(nagelfardatadir)|share/nagelfar|g' $@
950
951 tcl/%.tcl_i: tcl/%.tcl $(NAGELFAR)
952 $(ECHO_GEN)
953 rm -f $<_log
954 $(NAGELFAR) -instrument $<
955
956 # for coverage check, run tests on instrumented file to create coverage log
957 # over split tcl source files
958 $(MODULECMDTEST)_i: tcl/cache.tcl_i tcl/coll.tcl_i tcl/envmngt.tcl_i \
959 tcl/init.tcl_i tcl/interp.tcl_i tcl/main.tcl_i tcl/mfcmd.tcl_i \
960 tcl/modeval.tcl_i tcl/modfind.tcl_i tcl/modscan.tcl_i tcl/modspec.tcl_i \
961 tcl/report.tcl_i tcl/subcmd.tcl_i tcl/util.tcl_i version.inc
962 $(ECHO_GEN)
963 echo "#!$(TCLSH)" > $@
964 echo 'source tcl/init.tcl_i' >> $@
965 echo 'source tcl/util.tcl_i' >> $@
966 echo 'source tcl/envmngt.tcl_i' >> $@
967 echo 'source tcl/report.tcl_i' >> $@
968 echo 'source tcl/interp.tcl_i' >> $@
969 echo 'source tcl/mfcmd.tcl_i' >> $@
970 echo 'source tcl/modscan.tcl_i' >> $@
971 echo 'source tcl/modfind.tcl_i' >> $@
972 echo 'source tcl/modeval.tcl_i' >> $@
973 echo 'source tcl/modspec.tcl_i' >> $@
974 echo 'source tcl/cache.tcl_i' >> $@
975 echo 'source tcl/coll.tcl_i' >> $@
976 echo 'source tcl/subcmd.tcl_i' >> $@
977 echo 'source tcl/main.tcl_i' >> $@
978 chmod +x $@
979
980 # specific target to build test dependencies
981 test-deps: $(TEST_PREREQ)
982
983 # if coverage enabled create markup file for better read coverage result
984 test: $(TEST_PREREQ)
985 TCLSH=$(TCLSH); export TCLSH; \
986 MODULECMD=$(MODULECMD); export MODULECMD; \
987 OBJDIR=`pwd -P`; export OBJDIR; \
988 TESTSUITEDIR=`cd testsuite;pwd -P`; export TESTSUITEDIR; \
989 runtest --srcdir $$TESTSUITEDIR --objdir $$OBJDIR $(RUNTESTFLAGS) --tool modules $(RUNTESTFILES)
990 ifeq ($(COVERAGE),y)
991 $(NAGELFAR) -markup tcl/cache.tcl
992 $(NAGELFAR) -markup tcl/coll.tcl
993 $(NAGELFAR) -markup tcl/envmngt.tcl
994 $(NAGELFAR) -markup tcl/init.tcl
995 $(NAGELFAR) -markup tcl/interp.tcl
996 $(NAGELFAR) -markup tcl/main.tcl
997 $(NAGELFAR) -markup tcl/mfcmd.tcl
998 $(NAGELFAR) -markup tcl/modeval.tcl
999 $(NAGELFAR) -markup tcl/modscan.tcl
1000 $(NAGELFAR) -markup tcl/modfind.tcl
1001 $(NAGELFAR) -markup tcl/modspec.tcl
1002 $(NAGELFAR) -markup tcl/report.tcl
1003 $(NAGELFAR) -markup tcl/subcmd.tcl
1004 $(NAGELFAR) -markup tcl/util.tcl
1005 endif
1006
1007 testinstall:
1008 OBJDIR=`pwd -P`; export OBJDIR; \
1009 TESTSUITEDIR=`cd testsuite;pwd -P`; export TESTSUITEDIR; \
1010 runtest --srcdir $$TESTSUITEDIR --objdir $$OBJDIR $(RUNTESTFLAGS) --tool install $(RUNTESTFILES)
1011
1012 testlint: initdir modulecmd.tcl $(NAGELFAR) script/add.modules script/modulecmd
1013 NAGELFAR=$(NAGELFAR); export NAGELFAR; \
1014 OBJDIR=`pwd -P`; export OBJDIR; \
1015 TESTSUITEDIR=`cd testsuite;pwd -P`; export TESTSUITEDIR; \
1016 runtest --srcdir $$TESTSUITEDIR --objdir $$OBJDIR $(RUNTESTFLAGS) --tool lint $(RUNTESTFILES)
1017
1018
1019 # install enhanced diff tool (to review test results)
1020 icdiff:
1021 $(CURL) $(ICDIFF_DLSRC)$@
1022 echo "$(ICDIFF_CHECKSUM) $@" | md5sum --status -c - || \
1023 md5 -c $(ICDIFF_CHECKSUM) $@
1024 chmod +x $@
1025
1026 # install old Tcl interpreter (for code coverage purpose)
1027 tclsh83:
1028 $(CURL) $(TCL_DLSRC)$(TCL_DIST83)
1029 echo "$(TCL_DISTSUM83) $(TCL_DIST83)" | md5sum --status -c - || \
1030 md5 -c $(TCL_DISTSUM83) $@ || (rm -f $(TCL_DIST83) && false)
1031 tar xzf $(TCL_DIST83)
1032 cd $(TCL_RELEASE83)/unix && bash configure --disable-shared && make
1033 echo '#!/bin/bash' >$@
1034 echo 'exec $(TCLSH83) $${@}' >>$@
1035 chmod +x $@
1036 rm $(TCL_DIST83)
1037
1038 # fetch spack repository and initialize it (for source-sh test purpose)
1039 spack:
1040 git clone --depth 1 $(SPACK_REPOURL)
1041 cd spack && ./bin/spack bootstrap now
1042
1043 # install Conda (for source-sh test purpose)
1044 miniconda3:
1045 $(CURL) $(MINICONDA_DLSRC)$(MINICONDA_DIST)
1046 echo "$(MINICONDA_DISTSUM) $(MINICONDA_DIST)" | md5sum --status -c - || \
1047 md5 -c $(MINICONDA_DISTSUM) $@ || (rm -f $(MINICONDA_DIST) && false)
1048 bash $(MINICONDA_DIST) -b -s -p ./miniconda3
1049 rm $(MINICONDA_DIST)
1050
1051 # fetch OpenFOAM repository (for source-sh test purpose)
1052 OpenFOAM-dev:
1053 git clone --branch 20240520 --depth 1 $(OPENFOAM_REPOURL)
1054
1055 # install code coverage tool
1056 # download from alt. source if correct tarball not retrieved from primary location
1057 $(NAGELFAR):
1058 $(CURL) $(NAGELFAR_DLSRC1)$(NAGELFAR_DIST)
1059 echo "$(NAGELFAR_DISTSUM) $(NAGELFAR_DIST)" | md5sum --status -c - || \
1060 (rm -f $(NAGELFAR_DIST) && false)
1061 tar xzf $(NAGELFAR_DIST)
1062 rm $(NAGELFAR_DIST)
1063
1064 # build Ctags index
1065 tcl/tags: tcl/cache.tcl.in tcl/coll.tcl.in tcl/envmngt.tcl.in tcl/init.tcl.in \
1066 tcl/interp.tcl.in tcl/main.tcl.in tcl/mfcmd.tcl tcl/modeval.tcl \
1067 tcl/modfind.tcl.in tcl/modscan.tcl tcl/modspec.tcl tcl/report.tcl.in \
1068 tcl/subcmd.tcl.in tcl/util.tcl
1069 ctags --tag-relative -f $@ --langmap=tcl:.tcl.in tcl/cache.tcl.in \
1070 tcl/coll.tcl.in tcl/envmngt.tcl.in tcl/init.tcl.in tcl/interp.tcl.in \
1071 tcl/main.tcl.in tcl/mfcmd.tcl tcl/modeval.tcl tcl/modfind.tcl.in \
1072 tcl/modscan.tcl tcl/modspec.tcl tcl/report.tcl.in tcl/subcmd.tcl.in \
1073 tcl/util.tcl
1074
1075 # build Gtags target files
1076 tcl/gtags.file:
1077 echo cache.tcl.in > $@
1078 echo coll.tcl.in >> $@
1079 echo envmngt.tcl.in >> $@
1080 echo init.tcl.in >> $@
1081 echo interp.tcl.in >> $@
1082 echo main.tcl.in >> $@
1083 echo mfcmd.tcl >> $@
1084 echo modeval.tcl >> $@
1085 echo modscan.tcl >> $@
1086 echo modfind.tcl.in >> $@
1087 echo modspec.tcl >> $@
1088 echo report.tcl.in >> $@
1089 echo subcmd.tcl.in >> $@
1090 echo util.tcl >> $@
1091
1092 # build Gtags tag file
1093 tcl/GTAGS: tcl/cache.tcl.in tcl/coll.tcl.in tcl/envmngt.tcl.in tcl/init.tcl.in \
1094 tcl/interp.tcl.in tcl/main.tcl.in tcl/mfcmd.tcl tcl/modeval.tcl \
1095 tcl/modfind.tcl.in tcl/modscan.tcl tcl/modspec.tcl tcl/report.tcl.in \
1096 tcl/subcmd.tcl.in tcl/util.tcl tcl/gtags.file
1097 gtags -C tcl --gtagsconf ../.globalrc
1098
1099 tcl/syntaxdb.tcl: modulecmd.tcl $(NAGELFAR)
1100 echo "set argv {sh -V};\
1101 rename exit __exit;\
1102 proc exit {args} {};\
1103 source modulecmd.tcl;\
1104 defineModStartNbProc 1;\
1105 defineGetEqArrayKeyProc 1 1 1;\
1106 defineDoesModMatchAtDepthProc 1 1 equal;\
1107 defineModVersCmpProc 1 1;\
1108 defineModEqStaticProc 1 1 mod;\
1109 defineModEqProc 1 1;\
1110 defineParseModuleSpecificationProc 1;\
1111 set tcl_interactive 1;\
1112 source $(NAGELFAR_RELEASE)/syntaxbuild.tcl;\
1113 set ::syntax(appendNoDupToList) {n x*};\
1114 set ::syntax(lprepend) {n x*};\
1115 set ::syntax(execute-modulefile) {x x n x x x? x? x?};\
1116 set ::syntax(scanExtraMatchSearch) {x x n};\
1117 set ::syntax(insertProvidedAliases) {x n};\
1118 set ::syntax(filterExtraMatchSearch) {x x n n};\
1119 set ::syntax(findModulesFromDirsAndFiles) {x x x x n n? n? n? n?};\
1120 set ::syntax(getArrayKey) {n x x};\
1121 set ::syntax(getDiffBetweenArray) {n n x? x?};\
1122 buildFile $@;" | $(TCLSH)
1123
1124
1125 # quiet build targets unless verbose mode set
1126 ifeq ($(VERBOSE),1)
1127 V = 1
1128 endif
1129 # let verbose by default the install/clean/test and other specific non-build targets
1130 $(V).SILENT: initdir pkgdoc doc version.inc share/rpm/environment-modules.spec \
1131 modulecmd.tcl tcl/cache.tcl tcl/coll.tcl tcl/envmngt.tcl tcl/init.tcl \
1132 tcl/interp.tcl tcl/main.tcl tcl/modfind.tcl tcl/report.tcl tcl/subcmd.tcl \
1133 tcl/cache.tcl_i tcl/coll.tcl_i tcl/envmngt.tcl_i tcl/init.tcl_i tcl/interp.tcl_i \
1134 tcl/main.tcl_i tcl/mfcmd.tcl_i tcl/modfind.tcl_i tcl/modeval.tcl_i \
1135 tcl/modscan.tcl_i tcl/modspec.tcl_i tcl/report.tcl_i tcl/subcmd.tcl_i \
1136 tcl/util.tcl_i ChangeLog.gz README script/add.modules \
1137 script/gitlog2changelog.py script/modulecmd \
1138 lib/libtclenvmodules$(SHLIB_SUFFIX) lib/libtestutil-closedir$(SHLIB_SUFFIX) \
1139 lib/libtestutil-getpwuid$(SHLIB_SUFFIX) lib/libtestutil-getgroups$(SHLIB_SUFFIX) \
1140 lib/libtestutil-0getgroups$(SHLIB_SUFFIX) \
1141 lib/libtestutil-dupgetgroups$(SHLIB_SUFFIX) lib/libtestutil-getgrgid$(SHLIB_SUFFIX) \
1142 lib/libtestutil-time$(SHLIB_SUFFIX) lib/libtestutil-mktime$(SHLIB_SUFFIX) \
1143 testsuite/example/.modulespath testsuite/example/modulespath-wild \
1144 testsuite/example/modulerc testsuite/example/initrc-1 testsuite/example/initrc \
1145 dist-tar dist-gzip dist-bzip2 dist-win $(MODULECMDTEST) $(MODULECMDTEST)_i