forked from TACC/Lmod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.in
327 lines (269 loc) · 14.3 KB
/
Makefile.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
LMOD_FULL_SETTARG_SUPPORT := $(shell echo "@SETTARG@" | tr '[:upper:]' '[:lower:]')
USE_DOT_FILES := $(shell echo "@USE_DOT_FILES@" | tr '[:upper:]' '[:lower:]')
PREPEND_BLOCK := $(shell echo "@PREPEND_BLOCK@" | tr '[:upper:]' '[:lower:]')
COLORIZE := $(shell echo "@COLORIZE@" | tr '[:upper:]' '[:lower:]')
ZSH_SITE_FUNCTIONS_DIR := @ZSH_SITE_FUNCTIONS_DIR@
SPIDER_CACHE_DESCRIPT_FN := @SPIDER_CACHE_DESCRIPT_FN@
ANCIENT := @ANCIENT@
ALLOW_TCL_MFILES := @ALLOW_TCL_MFILES@
MPATH_AVAIL := @MPATH_AVAIL@
DUPLICATE_PATHS := @DUPLICATE_PATHS@
SHORT_TIME := @SHORT_TIME@
SPIDER_CACHE_DIRS := @SPIDER_CACHE_DIRS@
PATH_TO_HASHSUM := @PATH_TO_HASHSUM@
PATH_TO_LUA := @PATH_TO_LUA@
PATH_TO_PAGER := @PATH_TO_PAGER@
MODULEPATH_ROOT := @MODULEPATH_ROOT@
VERSION_SRC := src/Version.lua
LUA_INCLUDE := @LUA_INCLUDE@
UPDATE_SYSTEM_FN := @UPDATE_SYSTEM_FN@
GIT_PROG := @PATH_TO_GIT@
GIT_VERSION := $(shell if [ -n "$(GIT_PROG)" -a -d .git ]; then lmodV=`git describe --always`; echo "($$lmodV)"; else echo "@git@"; fi)
prefix := @prefix@
package := lmod
version := $(shell cd ./src; $(PATH_TO_LUA)/lua -e "V=require('Version'); print(V.tag())")
PKGV := $(prefix)/$(package)/$(version)
PKG := $(prefix)/$(package)/$(package)
LIB := $(prefix)/$(package)/$(version)/lib
LIBEXEC := $(prefix)/$(package)/$(version)/libexec
SHELLS := $(prefix)/$(package)/$(version)/shells
TOOLS := $(prefix)/$(package)/$(version)/tools
SETTARG := $(prefix)/$(package)/$(version)/settarg
INIT := $(prefix)/$(package)/$(version)/init
LMOD_MF := $(prefix)/$(package)/$(version)/modulefiles/Core
LMOD_MF_SOURCE := MF/*.version.lua
SETTARG_SOURCE := settarg/*.lua settarg/.settarg.lua settarg/targ.in
DIRLIST := $(DESTDIR)$(LIBEXEC) $(DESTDIR)$(TOOLS) $(DESTDIR)$(SETTARG) \
$(DESTDIR)$(SHELLS) \
$(DESTDIR)$(INIT) $(DESTDIR)$(LIB) $(DESTDIR)$(LMOD_MF)
STANDALONE_PRGM := src/lmod.in.lua src/addto.in.lua src/getmt.in.lua src/processMT.in.lua \
src/spider.in.lua src/processModuleUsage.in.lua src/reportUsers.in.lua \
src/clearMT_cmd.in.lua src/ml_cmd.in.lua src/spiderCacheSupport.in.lua \
src/sh_to_modulefile.in.lua
SHELL_INIT := bash.in csh.in ksh.in tcsh.in zsh.in sh.in perl.in \
env_modules_python.py.in lmod_bash_completions .lmodrc.lua
SHELL_INIT := $(patsubst %, init/%, $(SHELL_INIT))
ZSH_FUNCS := init/zsh/_ml init/zsh/_module
STARTUP := profile.in cshrc.in
STARTUP := $(patsubst %, init/%, $(STARTUP))
MAIN_DIR := Makefile.in INSTALL configure README_lua_modulefiles.txt README README.old
CONTRIB_DIRS := \
bash_patch \
BuildSystemCacheFile \
converting_shell_to_module_files \
hook \
parseVersions \
settarg \
SitePackage \
TACC \
tricky_modulefiles
CONTRIB := $(patsubst %, contrib/%, $(CONTRIB_DIRS))
lua_code := $(filter-out %.in.lua, $(wildcard src/*.lua)) \
$(wildcard src/*.tcl)
VDATE := $(shell date +'%F %H:%M')
ComputeHashSum := src/computeHashSum.in.lua
spiderCacheSupportCMD := lua src/spiderCacheSupport.in.lua
.PHONY: test pkgs
all:
@echo done
pre-install: $(DIRLIST) shell_init startup spiderCacheSupport libexec \
Inst_Tools Inst_Shells Inst_Settarg Inst_Lmod_MF pkgs other_tools
install: pre-install zsh_tab_funcs
$(RM) $(DESTDIR)$(PKG)
ln -s $(version) $(DESTDIR)$(PKG)
echo:
@echo Version: $(version)
$(DIRLIST) :
mkdir -p $@
__installMe:
-for i in $(FILELIST); do \
bareN=$${i##*/}; \
fn=$${bareN%%.in*}; \
ext=$${bareN#*.}; \
: echo "DIRLOC/fn: $(DIRLOC)/$$fn"; \
sed -e 's|@PREFIX@|$(prefix)|g' \
-e 's|@path_to_lua@|$(PATH_TO_LUA)|g' \
-e 's|@path_to_hashsum@|$(PATH_TO_HASHSUM)|g' \
-e 's|@path_to_pager@|$(PATH_TO_PAGER)|g' \
-e 's|@lmod_full_settarg_support@|$(LMOD_FULL_SETTARG_SUPPORT)|g' \
-e 's|@use_dot_files@|$(USE_DOT_FILES)|g' \
-e 's|@git@|$(GIT_VERSION)|g' \
-e 's|@ancient@|$(ANCIENT)|g' \
-e 's|@prepend_block@|$(PREPEND_BLOCK)|g' \
-e 's|@colorize@|$(COLORIZE)|g' \
-e 's|@duplicate_paths@|$(DUPLICATE_PATHS)|g' \
-e 's|@allow_tcl_mfiles@|$(ALLOW_TCL_MFILES)|g' \
-e 's|@mpath_avail@|$(MPATH_AVAIL)|g' \
-e 's|@short_time@|$(SHORT_TIME)|g' \
-e 's|@cacheDirs@|$(SPIDER_CACHE_DIRS)|g' \
-e 's|@updateSystemFn@|$(UPDATE_SYSTEM_FN)|g' \
-e 's|@modulepath_root@|$(MODULEPATH_ROOT)|g' \
-e 's|@PKGV@|$(PKGV)|g' \
-e 's|@PKG@|$(PKG)|g' < $$i > $(DIRLOC)/$$fn; \
[ "$$ext" = "in.lua" -o "$$ext" = "tcl" -o "$$ext" = "in" ] && \
chmod +x $(DIRLOC)/$$fn; \
if [ "$$ext" = "version.lua" ]; then \
mname=$${bareN%%.*}; \
: echo "DIRLOC: $(DIRLOC)/$$mname"; \
mkdir -p $(DIRLOC)/$$mname; \
mv $(DIRLOC)/$$fn $(DIRLOC)/$$mname/$(version).lua; \
fi; \
done
shell_init: $(SHELL_INIT)
$(MAKE) FILELIST="$^" DIRLOC=$(DESTDIR)$(INIT) __installMe
startup: $(STARTUP)
$(MAKE) FILELIST="$^" DIRLOC=$(DESTDIR)$(INIT) __installMe
other_tools: $(ComputeHashSum) $(STANDALONE_PRGM)
$(MAKE) FILELIST="$^" DIRLOC=$(DESTDIR)$(LIBEXEC) __installMe
spiderCacheSupport:
$(spiderCacheSupportCMD) --cacheDirs "$(SPIDER_CACHE_DIRS)" \
--updateFn "$(UPDATE_SYSTEM_FN)" \
--descriptFn "$(SPIDER_CACHE_DESCRIPT_FN)" \
>> $(DESTDIR)$(INIT)/.lmodrc.lua;
src/computeHashSum: $(ComputeHashSum)
$(MAKE) FILELIST="$^" DIRLOC="src" __installMe
chmod +x $@
pkgs:
cd pkgs; \
$(MAKE) LUA_INC=$(LUA_INCLUDE) LIB=$(DESTDIR)$(LIB) \
SHARE=$(DESTDIR)$(LIBEXEC) install
zsh_tab_funcs: $(ZSH_FUNCS)
-if [ -n "$(ZSH_SITE_FUNCTIONS_DIR)" ]; then \
cp $^ $(DESTDIR)$(ZSH_SITE_FUNCTIONS_DIR); \
fi
makefile: Makefile.in config.status
./config.status $@
config.status:
./config.status --recheck
dist:
$(MAKE) DistD=DIST _dist
_dist: _distMkDir _distMainDir _distSrc _distSetup _distSetupZsh \
_distVersion _distPkgs _distMF _distContrib _distTar
_distMkDir:
$(RM) -r $(DistD)
mkdir $(DistD)
_distContrib:
mkdir $(DistD)/contrib
cp -r $(CONTRIB) $(DistD)/contrib
_distSrc:
mkdir $(DistD)/src $(DistD)/tools $(DistD)/settarg $(DistD)/shells
cp $(lua_code) $(ComputeHashSum) $(STANDALONE_PRGM) $(DistD)/src
cp tools/*.lua $(DistD)/tools
cp $(SETTARG_SOURCE) $(DistD)/settarg
cp shells/*.lua $(DistD)/shells
_distVersion:
perl -p -i -e 's/\@git\@/$(GIT_VERSION)/g' $(DistD)/src/Version.lua
_distPkgs:
mkdir $(DistD)/pkgs
cp -r pkgs/* $(DistD)/pkgs
_distSetup:
mkdir $(DistD)/init
cp $(SHELL_INIT) $(STARTUP) $(DistD)/init
_distSetupZsh:
mkdir $(DistD)/init/zsh
cp $(ZSH_FUNCS) $(DistD)/init/zsh
_distMainDir:
cp $(MAIN_DIR) $(DistD)
_distMF:
mkdir $(DistD)/MF
cp -r MF $(DistD)/
_distTar:
echo "Lmod"-$(version) > .fname; \
$(RM) -r `cat .fname` `cat .fname`.tar*; \
mv ${DistD} `cat .fname`; \
tar chf `cat .fname`.tar `cat .fname`; \
bzip2 `cat .fname`.tar; \
rm -rf `cat .fname` .fname;
test:
cd rt; unset TMFuncPATH; tm .
tags:
find . \( -regex '.*~$$\|.*/\.git\|.*/\.git/' -prune \) \
-o -type f > file_list.1
sed -e 's|.*/.git.*||g' \
-e 's|.*/rt/.*/t1/.*||g' \
-e 's|./TAGS||g' \
-e 's|./makefile||g' \
-e 's|./configure$$||g' \
-e 's|/.DS_Store$$||g' \
-e 's|.*\.tgz$$||g' \
-e 's|.*\.tar\.gz$$||g' \
-e 's|.*\.tar\.bz2$$||g' \
-e 's|.*\.csv$$||g' \
-e 's|.*\.aux$$||g' \
-e 's|.*\.fdb_latexmk$$||g' \
-e 's|.*\.fls$$||g' \
-e 's|.*\.nav$$||g' \
-e 's|.*\.out$$||g' \
-e 's|.*\.pdf$$||g' \
-e 's|.*\.snm$$||g' \
-e 's|.*\.toc$$||g' \
-e 's|.*\.vrb$$||g' \
-e 's|^#.*||g' \
-e 's|/#.*||g' \
-e 's|\.#.*||g' \
-e 's|.*\.pdf$$||g' \
-e 's|.*\.used$$||g' \
-e 's|./.*\.log$$||g' \
-e 's|./testreports/.*||g' \
-e 's|./config\.status$$||g' \
-e 's|.*\~$$||g' \
-e 's|./file_list\..*||g' \
-e '/^\s*$$/d' \
< file_list.1 > file_list.2
etags `cat file_list.2`
$(RM) file_list.*
libexec: $(lua_code)
$(MAKE) FILELIST="$^" DIRLOC=$(DESTDIR)$(LIBEXEC) __installMe
Inst_Tools: tools/*.lua
$(MAKE) FILELIST="$^" DIRLOC=$(DESTDIR)$(TOOLS) __installMe
Inst_Shells: shells/*.lua
$(MAKE) FILELIST="$^" DIRLOC=$(DESTDIR)$(SHELLS) __installMe
Inst_Settarg: $(SETTARG_SOURCE)
$(MAKE) FILELIST="$^" DIRLOC=$(DESTDIR)$(SETTARG) __installMe
Inst_Lmod_MF: $(LMOD_MF_SOURCE)
$(MAKE) FILELIST="$^" DIRLOC=$(DESTDIR)$(LMOD_MF) __installMe
clean:
$(RM) config.log
cd pkgs; $(MAKE) LIB=$(DESTDIR)$(LIB) SHARE=$(DESTDIR)$(LIBEXEC) clean
clobber: clean
distclean: clobber
$(RM) makefile config.status
world_update:
@git status -s > /tmp/lmod$$$$; \
if [ -s /tmp/lmod$$$$ ]; then \
echo "All files not checked in => try again"; \
else \
git push github; \
git push --tags github; \
git push sf; \
git push --tags sf; \
fi; \
rm -f /tmp/lmod$$$$
gittag:
ifneq ($(TAG),)
@git status -s > /tmp/lmod$$$$; \
if [ -s /tmp/lmod$$$$ ]; then \
echo "All files not checked in => try again"; \
else \
$(RM) $(VERSION_SRC); \
echo "--module('Version')" > $(VERSION_SRC); \
echo 'local M={}' >> $(VERSION_SRC); \
echo 'function M.tag() return "$(TAG)" end' >> $(VERSION_SRC); \
echo 'function M.git() return "@git@" end' >> $(VERSION_SRC); \
echo 'function M.date() return "$(VDATE)" end' >> $(VERSION_SRC); \
echo 'function M.name()' >> $(VERSION_SRC); \
echo ' local a = {}' >> $(VERSION_SRC); \
echo ' a[#a+1] = M.tag()' >> $(VERSION_SRC); \
echo ' a[#a+1] = M.git()' >> $(VERSION_SRC); \
echo ' a[#a+1] = M.date()' >> $(VERSION_SRC); \
echo ' return table.concat(a," ")' >> $(VERSION_SRC); \
echo 'end' >> $(VERSION_SRC); \
echo 'return M' >> $(VERSION_SRC); \
git commit -m "moving to TAG_VERSION $(TAG)" $(VERSION_SRC); \
git tag -a $(TAG) -m 'Setting TAG_VERSION to $(TAG)' ; \
git push --tags ; \
fi; \
rm -f /tmp/lmod$$$$
else
@echo "To git tag do: make gittag TAG=?"
endif