1 |
#! /bin/csh -f |
2 |
|
3 |
# The system configuration for configure script |
4 |
set PERLBIN = "" |
5 |
set PYBIN = "python3" |
6 |
|
7 |
if ($PERLBIN == "") then |
8 |
if (-x /home/jsoc/bin/linux_x86_64/activeperl) then |
9 |
set PERLBIN = "/home/jsoc/bin/linux_x86_64/activeperl" |
10 |
else |
11 |
set PERLBIN = "perl" |
12 |
endif |
13 |
endif |
14 |
|
15 |
if ($PYBIN == "") then |
16 |
if (-x /home/jsoc/bin/linux_x86_64/activepython) then |
17 |
set PYBIN = "/home/jsoc/bin/linux_x86_64/activepython" |
18 |
else |
19 |
set PYBIN = "python3" |
20 |
endif |
21 |
endif |
22 |
|
23 |
# set up $JSOC_MACHINE |
24 |
set JSOC_MACHINE = `build/jsoc_machine.csh` |
25 |
if ($? != 0) then |
26 |
echo "Unable to determine machine type." |
27 |
exit 1 |
28 |
endif |
29 |
|
30 |
echo "Machine type is $JSOC_MACHINE" |
31 |
echo "" |
32 |
|
33 |
# Clean by default. |
34 |
set CLEAN = "yes" |
35 |
set PROJCONFIG = "" |
36 |
set CLEANCMD = "d" |
37 |
set CFGSERVER = "no" |
38 |
set CFGSERVERARG = "s" |
39 |
set CUSTOMDEFSFILE = "" |
40 |
|
41 |
foreach THEARG ($argv) |
42 |
set LITERALSTR = '{ my($argin) = "'${THEARG}'"; my($flagout); $flagout = ($argin =~ /^-(.+)/)[0]; print $flagout; }' |
43 |
set FLAG = `$PERLBIN -e "$LITERALSTR"` |
44 |
if ($? != 0) then |
45 |
echo "Unable to parse command-line arguments." |
46 |
exit 1 |
47 |
endif |
48 |
|
49 |
if ($FLAG == $CLEANCMD) then |
50 |
set CLEAN = "no" |
51 |
else if ($FLAG == $CFGSERVERARG) then |
52 |
set CFGSERVER = "yes" |
53 |
else if (-e $THEARG) then |
54 |
set PROJCONFIG = $THEARG |
55 |
endif |
56 |
end |
57 |
|
58 |
# Usage: |
59 |
# configure [ -d ] [ -s ] [ <project config file> ] |
60 |
|
61 |
# Backward compatibility - remove the links to the old make files in projconf |
62 |
if (-d proj) then |
63 |
cd proj |
64 |
if (-e configure) then |
65 |
rm configure |
66 |
endif |
67 |
if (-e make_basic.mk) then |
68 |
rm make_basic.mk |
69 |
endif |
70 |
if (-e Rules.mk) then |
71 |
rm Rules.mk |
72 |
endif |
73 |
if (-e target.mk) then |
74 |
rm target.mk |
75 |
endif |
76 |
cd .. |
77 |
endif |
78 |
|
79 |
# Always clean up links to man pages and re-create them. |
80 |
echo -n "Removing links to man pages..." |
81 |
if (-e man) then |
82 |
rm -rf man |
83 |
endif |
84 |
echo "done" |
85 |
|
86 |
if ($CLEAN == "yes") then |
87 |
echo -n "Removing links in base/include to headers..." |
88 |
# Links in base/include |
89 |
if (-d base/include) then |
90 |
cd base/include |
91 |
find . -name "*.h" -exec rm {} \; |
92 |
cd ../.. |
93 |
endif |
94 |
echo "done" |
95 |
|
96 |
# Special link from base/drms/apps/serverdefs.h to localization/drmsparams.h |
97 |
echo -n "Removing link to serverdefs.h..." |
98 |
if (-e base/drms/apps) then |
99 |
cd base/drms/apps |
100 |
rm serverdefs.h |
101 |
cd ../../.. |
102 |
endif |
103 |
echo "done" |
104 |
|
105 |
# Links in include |
106 |
echo -n "Removing links in include to headers..." |
107 |
if (-d include) then |
108 |
cd include |
109 |
find . -name "*.h" -exec rm {} \; |
110 |
find . -name "drmsparams*" -exec rm {} \; |
111 |
cd .. |
112 |
endif |
113 |
echo "done" |
114 |
|
115 |
echo -n "Removing links to scripts..." |
116 |
# Links in scripts |
117 |
if (-d scripts) then |
118 |
cd scripts |
119 |
if ($? == 0) then |
120 |
find . -type l -exec rm {} \; |
121 |
endif |
122 |
cd .. |
123 |
endif |
124 |
echo "done" |
125 |
# End clean flag |
126 |
endif |
127 |
|
128 |
# Always clean-up links to jsds and re-create them. |
129 |
echo -n "Removing links to jsds..." |
130 |
if (-d jsds) then |
131 |
cd jsds |
132 |
if ($? == 0) then |
133 |
find . -type l -exec rm {} \; |
134 |
endif |
135 |
cd .. |
136 |
endif |
137 |
echo "done" |
138 |
echo |
139 |
|
140 |
if ($CLEAN == "yes") then |
141 |
if (-x base/local/libs/dsds/scripts/rmlinks.csh) then |
142 |
base/local/libs/dsds/scripts/rmlinks.csh |
143 |
endif |
144 |
|
145 |
if (-x base/local/libs/soi/scripts/rmlinks.csh) then |
146 |
base/local/libs/soi/scripts/rmlinks.csh |
147 |
endif |
148 |
endif |
149 |
|
150 |
# Make include directories here, since they are used by multiple script blocks below |
151 |
if (!(-d base/include)) then |
152 |
mkdir -p base/include |
153 |
if ($? != 0) then |
154 |
echo "Unable to make base/include directory." |
155 |
exit 1 |
156 |
endif |
157 |
endif |
158 |
|
159 |
if (!(-d include)) then |
160 |
mkdir -p include |
161 |
if ($? != 0) then |
162 |
echo "Unable to make include directory." |
163 |
exit 1 |
164 |
endif |
165 |
|
166 |
|
167 |
endif |
168 |
|
169 |
echo "Setting links to man pages..." |
170 |
if (-d /home/jsoc/man) then |
171 |
if (!(-e man)) then |
172 |
ln -s /home/jsoc/man man |
173 |
endif |
174 |
endif |
175 |
echo "done" |
176 |
echo |
177 |
|
178 |
echo "Setting links to jsds..." |
179 |
if (!(-d jsds)) then |
180 |
mkdir jsds |
181 |
endif |
182 |
cd jsds |
183 |
find ../base \( -name \*.jsd -exec ln -s {} . \; -a -exec echo " " {} " OK" \; \) -o \( -name \*.jsd -exec echo " " {} " ERROR - couldn't create link" \; \) |
184 |
cd .. |
185 |
echo "done" |
186 |
echo |
187 |
|
188 |
# generate links for DSDS/SOI dynamic libraries - only do this if |
189 |
# user's environment has access to /home/soi/CM |
190 |
if (-d /home/soi/CM/include && -d /home/soi/CM/src) then |
191 |
if (-x base/local/libs/dsds/scripts/genlinks.csh) then |
192 |
base/local/libs/dsds/scripts/genlinks.csh |
193 |
endif |
194 |
|
195 |
if (-x base/local/libs/soi/scripts/genlinks.csh) then |
196 |
base/local/libs/soi/scripts/genlinks.csh |
197 |
endif |
198 |
endif |
199 |
|
200 |
echo "done" |
201 |
echo |
202 |
|
203 |
####################### |
204 |
## Site Localization ## |
205 |
####################### |
206 |
|
207 |
# Path to the configuration file - at some point, make this an argument to the configure script |
208 |
set LOCALIZATIONDIR = "" |
209 |
set RELLOCALIZATIONDIR = "" |
210 |
set conflocal = "config.local" |
211 |
|
212 |
if (-e $conflocal) then |
213 |
set RELLOCALIZATIONDIR = `perl -n -e 'if ($_ =~ /^LOCALIZATIONDIR\s+(.+)/) { print $1; }' $conflocal` |
214 |
endif |
215 |
|
216 |
if ($LOCALIZATIONDIR == "") then |
217 |
set RELLOCALIZATIONDIR = localization |
218 |
endif |
219 |
|
220 |
# Make the path absoluate |
221 |
set LOCALIZATIONDIR = ${PWD}/${RELLOCALIZATIONDIR} |
222 |
|
223 |
# Reset localization. |
224 |
if ($CLEAN == "yes") then |
225 |
# This script will need to read the config.local file to get the |
226 |
# localization directory. Otherwise, just use JSOC/localization as the default. |
227 |
if (!(-d ${LOCALIZATIONDIR})) then |
228 |
mkdir ${LOCALIZATIONDIR} |
229 |
if ($? != 0) then |
230 |
echo "Error creating localization directory." |
231 |
exit 1 |
232 |
endif |
233 |
endif |
234 |
|
235 |
if (-e ${LOCALIZATIONDIR}/drmsparams.h) then |
236 |
rm ${LOCALIZATIONDIR}/drmsparams.h |
237 |
endif |
238 |
|
239 |
if (-e ${LOCALIZATIONDIR}/drmsparams.mk) then |
240 |
rm ${LOCALIZATIONDIR}/drmsparams.mk |
241 |
endif |
242 |
|
243 |
if (-e ${LOCALIZATIONDIR}/drmsparams.pm) then |
244 |
rm ${LOCALIZATIONDIR}/drmsparams.pm |
245 |
endif |
246 |
|
247 |
if (-e ${LOCALIZATIONDIR}/drmsparams.py) then |
248 |
rm ${LOCALIZATIONDIR}/drmsparams.py |
249 |
endif |
250 |
|
251 |
if (!(-e configsdp.txt)) then |
252 |
# This is NetDRMS. |
253 |
if (!(-e config.local)) then |
254 |
echo "Error: config.local not found. If you have a saved version of this" |
255 |
echo " file from a previous installation, you should copy that into" |
256 |
echo " this directory and rerun configure. Otherwise, copy the file" |
257 |
echo " config.local.template to config.local and edit the config.local" |
258 |
echo " file to contain site-appropriate values." |
259 |
echo |
260 |
echo "*** IMPORTANT *** The edited config.local will contain site-specific" |
261 |
echo " values that should not be modified during subsequent updates to" |
262 |
echo " NetDRMS. Keep a safe copy of it somewhere outside of the DRMS" |
263 |
echo " directory tree, for example in /usr/local. After each NetDRMS" |
264 |
echo " update, ensure this file is in place." |
265 |
exit 1; |
266 |
endif |
267 |
endif |
268 |
|
269 |
# We now call localize.py for both Stanford and NetDRMS builds. |
270 |
if ($CFGSERVER == "yes") then |
271 |
set cmd = "$PYBIN ./localize.py -d ${LOCALIZATIONDIR} -b drmsparams -s" |
272 |
else |
273 |
set cmd = "$PYBIN ./localize.py -d ${LOCALIZATIONDIR} -b drmsparams" |
274 |
endif |
275 |
|
276 |
$cmd |
277 |
if ($? != 0) then |
278 |
echo "Failure running localize.py." |
279 |
exit 1 |
280 |
endif |
281 |
|
282 |
endif # End reset localization |
283 |
|
284 |
echo "Setting links to scripts..." |
285 |
if (!(-d scripts)) then |
286 |
mkdir scripts |
287 |
if ($? != 0) then |
288 |
echo "Unable to create scripts directory." |
289 |
exit 1 |
290 |
endif |
291 |
endif |
292 |
|
293 |
if ($CLEAN == "yes") then |
294 |
cd scripts |
295 |
|
296 |
# Sums scripts |
297 |
find ../base/sums/scripts -mindepth 1 -path \*CVS -prune -o -print | ${PERLBIN} -MFile::Basename -n -e 'my($bn) = basename($_); chomp($bn); my($path) = $_; chomp($path); if (!(-e $bn)) { `ln -s $_`; if ($? >> 8 == 0) { print " " . $path . " OK\n"; } else { print " " . $path . " ERROR - could not create link\n"; } }' |
298 |
|
299 |
# Util scripts |
300 |
find ../base/util/scripts -mindepth 1 -path \*CVS -prune -o -print | ${PERLBIN} -MFile::Basename -n -e 'my($bn) = basename($_); chomp($bn); my($path) = $_; chomp($path); if (!(-e $bn)) { `ln -s $_`; if ($? >> 8 == 0) { print " " . $path . " OK\n"; } else { print " " . $path . " ERROR - could not create link\n"; } }' |
301 |
|
302 |
# Export scripts |
303 |
find ../base/export/scripts -mindepth 1 -path \*CVS -prune -o -print | ${PERLBIN} -MFile::Basename -n -e 'my($bn) = basename($_); chomp($bn); my($path) = $_; chomp($path); if (!(-e $bn)) { `ln -s $_`; if ($? >> 8 == 0) { print " " . $path . " OK\n"; } else { print " " . $path . " ERROR - could not create link\n"; } }' |
304 |
|
305 |
# DRMS / IDL-interface scripts |
306 |
find ../base/drms/scripts -mindepth 1 -path \*CVS -prune -o -print | ${PERLBIN} -MFile::Basename -n -e 'my($bn) = basename($_); chomp($bn); my($path) = $_; chomp($path); if (!(-e $bn)) { `ln -s $_`; if ($? >> 8 == 0) { print " " . $path . " OK\n"; } else { print " " . $path . " ERROR - could not create link\n"; } }' |
307 |
|
308 |
# Project-specific scripts - these won't show up if you don't have the project source. |
309 |
if (-x ${LOCALIZATIONDIR}/configure) then |
310 |
${LOCALIZATIONDIR}/configure |
311 |
endif |
312 |
cd .. |
313 |
endif |
314 |
|
315 |
echo "done" |
316 |
echo |
317 |
|
318 |
echo "Setting links to headers..." |
319 |
|
320 |
# When localize.py was added, we removed the repository version of serverdefs.h, and we stopped generating JSOC/base/include/localization.h. |
321 |
# To support legacy code, we need to make a link from serverdefs.h to ${LOCALIZATIONDIR}/drmsparams.h (the replacement for serverdefs.h |
322 |
# at Stanford) and from JSOC/base/include/localization.h to ${LOCALIZATIONDIR}/drmsparams.h (the replacement for localization.h |
323 |
# for NetDRMs builds). However, some files are looking for JSOC/base/drms/apps/serverdefs.h (instead of JSOC/base/include, the correct path). |
324 |
# If we make a link from JSOC/base/drms/apps/serverdefs.h to ${LOCALIZATIONDIR}/drmsparams.h, then the script below will make links from |
325 |
# JSOC/base/include/serverdefs.h and JSOC/include/serverdefs.h to JSOC/base/drms/apps/serverdefs.h, which then links to ${LOCALIZATIONDIR}/drmsparams.h. |
326 |
if (!(-l base/drms/apps/serverdefs.h)) then |
327 |
cd base/drms/apps |
328 |
ln -s ../../../${RELLOCALIZATIONDIR}/drmsparams.h serverdefs.h |
329 |
if ($? != 0) then |
330 |
echo "Failure creating link to " |
331 |
exit 1 |
332 |
endif |
333 |
cd ../../.. |
334 |
endif |
335 |
|
336 |
if (!(-l base/include/localization.h)) then |
337 |
cd base/include |
338 |
ln -s ../../${RELLOCALIZATIONDIR}/drmsparams.h localization.h |
339 |
cd ../.. |
340 |
endif |
341 |
|
342 |
if ($CLEAN == "yes") then |
343 |
cd base/include |
344 |
find .. -path '../include' -prune -o -name \*.h -print | ${PERLBIN} -MFile::Basename -n -e 'my($bn) = basename($_); chomp($bn); my($path) = $_; chomp($path); if (!(-e $bn)) { `ln -s $_`; if ($? >> 8 == 0) { print " " . $path . " OK\n"; } else { print " " . $path . " ERROR - could not create link\n"; } }' |
345 |
cd ../.. |
346 |
|
347 |
cd include |
348 |
if (-d ../base/include) then |
349 |
find ../base/include -name \*.h -print | ${PERLBIN} -MFile::Basename -n -e 'my($bn) = basename($_); chomp($bn); my($path) = $_; chomp($path); if (!(-e $bn)) { `ln -s $_`; if ($? >> 8 == 0) { print " " . $path . " OK\n"; } else { print " " . $path . " ERROR - could not create link\n"; } }' |
350 |
endif |
351 |
cd .. |
352 |
endif |
353 |
|
354 |
cd include |
355 |
# ${LOCALIZATIONDIR} is an absolute path |
356 |
if (!(-l drmsparams.h)) then |
357 |
ln -s ../${RELLOCALIZATIONDIR}/drmsparams.h |
358 |
endif |
359 |
if (!(-l drmsparams.pm)) then |
360 |
ln -s ../${RELLOCALIZATIONDIR}/drmsparams.pm |
361 |
endif |
362 |
if (!(-l drmsparams.py)) then |
363 |
ln -s ../${RELLOCALIZATIONDIR}/drmsparams.py |
364 |
endif |
365 |
|
366 |
cd .. |
367 |
echo "done" |
368 |
echo |