1 #
2 # chemsh master makefile
3 #
4 # This explicit list is to ensure the correct build order
5 # for the base libraries
6 #
7 LIBDIRS=util block objects fragment trmat field xtal matrix zmatrix cutils futils eispack nag blas lapack linpack eispack
9 UTILS=ccnvrt
10 EXAMPLES=examples
11 DOC=doc
12 SHELL=/bin/sh
13 LS=/bin/ls
14 #
15 # The program (also includes some subprograms as
16 # indicated above )
17 #
18 prog: checkpath
19 @for dir in $(UTILS); do ( cd src/$$dir; \
20 echo making in src/$$dir -----------------; make clean; make ) ; done;
21 @(cd src/chemsh; echo making chemsh.h -----------------; make include) ;
22 @for dir in $(LIBDIRS); do ( cd src/$$dir; \
23 echo making in src/$$dir -----------------; make ) ; done;
24 @make otherlibs MAKE_TARGET=all;
25 @(cd src/chemsh; \
26 echo Configuring chemsh Makefile -----------------; \
27 make config; \
28 echo making chemsh executables -----------------; \
29 make)
30 @make allsrc
31 @$(MAKE) index
32 #
33 # shell script to update a directory - ie replace any files
34 # that have changed
35 #
36 # to run this, first define $(DESTINATION);
37 #
38 update:
39 make updatedir SUBDIR=src/ccnvrt
40 (cd $(DESTINATION)/src/ccnvrt; make)
41 make updatefile FILE=Makefile
42 make updatefile FILE=README
43 make updatefile FILE=src/compilerflags.mk
44 make updatefile FILE=src/arch.mk
45 make updatedir SUBDIR=tcl
46 make updatedir SUBDIR=chemsh
47 make updatedir SUBDIR=scripts
48 (for dir in $(UTILS); do ( make updatedir SUBDIR=src/$$dir) ; done; \
49 for dir in $(LIBDIRS); do ( make updatedir SUBDIR=src/$$dir) ; done; \
50 for dir in $(PROGDIRS); do ( make updatedir SUBDIR=src/$$dir) ; done; )
51 #
52 # The file update procedure assumes that only Makefiles need ccnvrt
53 # processing (doing this before the diff helps avoid unnecessary
54 # re-builds when updating from the source from a different
55 # architecture.
56 #
57 updatefile:
58 @(if test -f $(DESTINATION)/$(FILE) ; then \
59 echo updating $(FILE) ; \
60 case $(FILE) in *Makefile) \
61 TMPFILE=ccnvrt.tmp; \
62 cp $(FILE) $$TMPFILE; \
63 ccnvrt -f $$TMPFILE `getarch` ;; \
64 *) TMPFILE=$(FILE) ;; \
65 esac; \
66 differ=`diff $$TMPFILE $(DESTINATION)/$(FILE) | wc -l` ;\
67 if test $$differ != 0 ; then \
68 echo ============= $(FILE) has been changed ============== ;\
69 diff $$TMPFILE $(DESTINATION)/$(FILE) | cat;\
70 mv $(DESTINATION)/$(FILE) $(DESTINATION)/$(FILE).bak ; \
71 fi ;\
72 else \
73 TMPFILE=$(FILE); \
74 echo "new file" $(DESTINATION)/$(FILE) ;\
75 fi ;\
76 cp $$TMPFILE $(DESTINATION)/$(FILE) ;\
77 case $(FILE) in *Makefile) rm -f $$TMPFILE ;; esac )
78 #
79 #
80 updatedir:
81 @(from=./$(SUBDIR) ; to=$(DESTINATION)/$(SUBDIR); \
82 if test -d $$from ; then \
83 if test ! -d $$to ; then \
84 echo "create subdirectory" $$to;\
85 mkdir $$to;\
86 fi ;\
87 fi ;\
88 from=`cd $$from; pwd`; to=`cd $$to; pwd` \
89 echo updating from $$from to $$to; date ;\
90 cd $$from ;\
91 list=`find . -print` ;\
92 for word in $$list ; do \
93 if test -d $$word ; then \
94 if test ! -d $$to/$$word ; then \
95 echo "create subdirectory" $$to/$$word ;\
96 mkdir $$to/$$word ;\
97 fi ;\
98 fi ;\
99 done ;\
100 for word in $$list ; do \
101 if test -f $$word ; then \
102 if test -f $$to/$$word ; then \
103 case $$word in \
104 *Makefile) \
105 CCNVRTDIR=$$from; export CCNVRTDIR; \
106 TMPFILE=ccnvrt.tmp; \
107 cp $$word $$TMPFILE; \
108 ccnvrt -f $$TMPFILE `getarch` ;; \
109 *) TMPFILE=$$word ;; \
110 esac; \
111 differ=`diff $$TMPFILE $$to/$$word | wc -l` ;\
112 if test $$differ != 0 ; then \
113 echo ============= $$word has been changed ============== ;\
114 diff $$TMPFILE $$to/$$word | cat;\
115 mv $$to/$$word $$to/$$word.bak ;\
116 cp $$TMPFILE $$to/$$word ;\
117 fi ;\
118 case $$word in *Makefile) rm -f $$TMPFILE ;; esac; \
119 else \
120 echo "new file" $$to/$$word ;\
121 cp $$word $$to/$$word ;\
122 fi ;\
123 fi ;\
124 done ;\
125 echo ======== the following extra files are present in $$to ====== ;\
126 cd $$to ;\
127 list=`find . -print` ;\
128 for word in $$list ; do \
129 if test ! -r $$from/$$word ; then echo $$to/$$word ; fi ;\
130 done ;\
131 echo '*********' update of $$to from $$from done '*********' )
132 #
133 #
134 delbak:
135 echo deleting .bak files......
136 find . -name \*.bak -print -exec rm -f {} \;
137 #
138 clean:
139 make allsrc MAKE_TARGET=clean
140 make interfaced MAKE_TARGET=clean
142 #
143 # this target uses a simple trick to check if the scripts directory
144 # below the cwd is ahead of the scripts directories of any previous
145 # chemsh installations.
146 #
147 # the file scripts/pathcheck is left behind to catch mistakes of this
148 # type in the future.
149 #
150 checkpath:
151 @echo checking your path -----------------------------------------------
152 @date > /tmp/datestamp
153 @echo echo `cat /tmp/datestamp` > scripts/pathcheck
154 @echo echo `cat /tmp/datestamp` > /tmp/pathcheck
155 @rm -rf /tmp/datestamp;
156 @chmod +x scripts/pathcheck
157 @chmod +x /tmp/pathcheck
158 @if pathcheck > /dev/null ; then \
159 echo scripts are in path, ok; else \
160 echo your path must include the `pwd`/scripts and `pwd`/bin directories; \
161 rm -rf /tmp/pathcheck; \
162 exit 1; fi
163 @if test "`/tmp/pathcheck`" = "`pathcheck`" ; then \
164 echo path is ok ; \
165 else \
166 echo you seem to have an old scripts directory in your path ; \
167 echo the date today is `/tmp/pathcheck`;\
168 echo the date associated with the pathcheck script in the current path is `pathcheck`;\
169 echo please check your path and try again;\
170 exit 1; \
171 fi;
172 rm -rf /tmp/pathcheck;
174 new:
175 @echo all deleting ARCH files
176 @find . -name ARCH -print -exec rm {}
177 @echo configuring chemsh -----------------; \
178 @(cd src/chemsh make config) ;\
179 @echo rebuilding
180 make
181 #
182 # this indexes the Tcl files - it requires chemsh to have been
183 # built first
184 #
185 index:
186 @(set noglob; cd src/chemsh; make index)
188 #
189 # this allows additional configurational
190 # flags to be added to all subdirctories
191 #
192 settings:
193 @(arch=`getarch`; \
194 echo "existing configuration for platform" $$arch "are" ; \
195 echo `cat src/settings.$$arch`;\
196 echo enter required options;\
197 echo and then hit return;\
198 x=1;\
199 while test $$x = 1 ;\
200 do \
201 read options; echo $$options ... ok? \(yes or no\) ; read confirm;\
202 if test $$confirm = yes ; then \
203 x=0;\
204 fi;\
205 done ;\
206 echo setting options for $$arch: $$options ;\
207 echo $$options > src/settings.$$arch)
208 #
209 # this target scans the src directory for libraries that need to be built
210 # before the chemsh executable can be linked
211 # It also compiles other directories that interface into chemshell without
212 # linking
213 #
214 otherlibs:
215 @(cd src; \
216 rm -f tmp-dirs;\
217 dirlist=`$(LS)`; \
218 for dir in $$dirlist ; do \
219 tester=0; \
220 if test -f $$dir/CHEMSH_INTERFACE -a \( -f $$dir/Makefile -o -f $$dir/Makefile.mk \) ; then \
221 tester=1;\
222 if test -f $$dir/CHEMSH_SWITCH ; then \
223 tester=0;\
224 cd $$dir;\
225 if ./CHEMSH_SWITCH ; then \
226 tester=1;\
227 fi ;\
228 cd ..;\
229 fi ;\
230 if test $$tester = 1; then \
231 pri=`cat $$dir/CHEMSH_INTERFACE | awk '/LIBRARY/ {print $$3}' | sort -n | head -1 ` ;\
232 if test X$$pri != X ;then \
233 echo $$pri $$dir >> tmp-dirs;\
234 else \
235 echo 99 $$dir >> tmp-dirs;\
236 fi;\
237 fi;\
238 fi;\
239 done; \
240 for dir in `sort -n < tmp-dirs | awk '{print $$2}' `; do \
241 (cd $$dir; echo making $(MAKE_TARGET) in src/$$dir; make $(MAKE_TARGET)) ;\
242 done;\
243 rm -f tmp-dirs)
244 #
245 # make target to loop over all src directories with Makefiles
246 # modified to exclude all those with CHEMSH_INTERFACE files, as
247 # these will have been dealt with by the previous target
248 #
249 allsrc:
250 @(cd src; \
251 dirlist=`$(LS)`; \
252 echo $$dirlist ; \
253 for dir in $$dirlist ; do \
254 if (test \( -f $$dir/Makefile -o -f $$dir/Makefile.mk \) -a ! -f $$dir/CHEMSH_INTERFACE ) ; then \
255 (cd $$dir; echo making $(MAKE_TARGET) in $$dir; make $(MAKE_TARGET) ) ;\
256 fi; \
257 done;)
258 #
259 # All source directories specified by a CHEMSH_INTERFACE file, ie complementary
260 # to the previous target. Used only by make clean at the moment.
261 #
262 interfaced:
263 @(cd src; \
264 dirlist=`$(LS)`; \
265 echo $$dirlist ; \
266 for dir in $$dirlist ; do \
267 if (test \( -f $$dir/Makefile -o -f $$dir/Makefile.mk \) -a -f $$dir/CHEMSH_INTERFACE ) ; then \
268 (cd $$dir; echo making $(MAKE_TARGET) in $$dir; make $(MAKE_TARGET) ) ;\
269 fi; \
270 done;)
272 unprotect:
273 @echo unprotecting executables
274 chmod go+rx .
275 chmod -R go+rx ./bin ./scripts
276 chmod go+x ./tcl
277 chmod -R go+r ./tcl
278 #
279 # this is just to check the directory structure before
280 # we start.
281 #
282 graphcheck:
283 #
284 # check for graphics
285 #
286 @( if (test `getarch` != iris -a -d src/graph ) ; then \
287 echo "warning - You have the src for the graph module but you are"; \
288 echo "not building on an SGI machine"; \
289 echo "unless you have Mesa please delete the src/graph directory and start again"; \
290 fi )
291 #
292 # check for NWChem
293 #
294 nwchemcheck:
295 @(if (test -d src/interface_nwchem ) ; then \
296 if ( (cd src/interface_nwchem; make libcheck) | grep NO > /dev/null ) ; then \
297 echo "You have the src for the nwchem interface included" ;\
298 echo "but NWChem seems to be missing" ;\
299 echo "You must either" ; \
300 echo " a build NWChem and set NWCHEM_TOP" ;\
301 echo " and NWCHEM_TARGET in src/compilerflags.mk" ;\
302 echo "or b delete the src/interface_nwchem directory";\
303 exit 999 ;\
304 fi; \
305 fi)
307 autodoc:
308 @(cd src; \
309 rm -f tmp-dirs;\
310 dirlist=`$(LS)`; \
311 for dir in $$dirlist ; do \
312 tester=0; \
313 if test -f $$dir/makedoc ; then \
314 tester=1;\
315 if test -f $$dir/CHEMSH_SWITCH ; then \
316 tester=0;\
317 cd $$dir;\
318 if ./CHEMSH_SWITCH ; then \
319 tester=1;\
320 fi ;\
321 cd ..;\
322 fi ;\
323 if test $$tester = 1; then \
324 pri=1; \
325 if test X$$pri != X ;then \
326 echo $$pri $$dir >> tmp-dirs;\
327 else \
328 echo 99 $$dir >> tmp-dirs;\
329 fi;\
330 fi;\
331 fi;\
332 done; \
333 for dir in `sort -n < tmp-dirs | awk '{print $$2}' `; do \
334 (cd $$dir; echo making doc in src/$$dir; make -f makedoc ) ;\
335 done;\
336 rm -f tmp-dirs)

