1 |
#! /bin/csh -f |
2 |
|
3 |
# system configuration for configure script |
4 |
set PERLBIN = "" |
5 |
|
6 |
if ($PERLBIN == "") then |
7 |
if (-e configsdp.txt) then |
8 |
# at stanford, use |
9 |
set PERLBIN = "/home/jsoc/bin/linux_x86_64/perl5.12.2" |
10 |
else |
11 |
set PERLBIN = "perl" |
12 |
endif |
13 |
endif |
14 |
|
15 |
# set up $JSOC_MACHINE |
16 |
set JSOC_MACHINE = `build/jsoc_machine.csh` |
17 |
echo "Machine type is $JSOC_MACHINE" |
18 |
echo "" |
19 |
|
20 |
set CLEAN = "no" |
21 |
set PROJCONFIG = "" |
22 |
set CLEANCMD = "d" |
23 |
|
24 |
set CUSTOMDEFSFILE = "" |
25 |
|
26 |
foreach THEARG ($argv) |
27 |
set LITERALSTR = '{ my($argin) = "'${THEARG}'"; my($flagout); $flagout = ($argin =~ /^-(.+)/)[0]; print $flagout; }' |
28 |
set FLAG = `$PERLBIN -e "$LITERALSTR"` |
29 |
|
30 |
if ($FLAG == $CLEANCMD) then |
31 |
set CLEAN = "yes" |
32 |
else if (-e $THEARG) then |
33 |
set PROJCONFIG = $THEARG |
34 |
endif |
35 |
end |
36 |
|
37 |
# Usage: |
38 |
# configure [ -c ] [ <project config file> ] |
39 |
|
40 |
# Backward compatibility - remove the links to the old make files in projconf |
41 |
if (-d proj) then |
42 |
cd proj |
43 |
if (-e configure) then |
44 |
rm configure |
45 |
endif |
46 |
if (-e make_basic.mk) then |
47 |
rm make_basic.mk |
48 |
endif |
49 |
if (-e Rules.mk) then |
50 |
rm Rules.mk |
51 |
endif |
52 |
if (-e target.mk) then |
53 |
rm target.mk |
54 |
endif |
55 |
cd .. |
56 |
endif |
57 |
|
58 |
echo -n "Remove links to man pages..." |
59 |
if (-e man) then |
60 |
rm -rf man |
61 |
endif |
62 |
echo "done" |
63 |
|
64 |
echo -n "Removing links to headers..." |
65 |
if (-d base/include) then |
66 |
cd base/include |
67 |
find . -name "*.h" -exec rm {} \; |
68 |
cd ../.. |
69 |
endif |
70 |
|
71 |
if (-d include) then |
72 |
cd include |
73 |
find . -name "*.h" -exec rm {} \; |
74 |
cd .. |
75 |
endif |
76 |
echo "done" |
77 |
|
78 |
echo -n "Removing links to scripts..." |
79 |
if (-d scripts) then |
80 |
cd scripts |
81 |
find . -name "*" -exec rm {} \; |
82 |
cd .. |
83 |
endif |
84 |
echo "done" |
85 |
|
86 |
echo -n "Removing links to jsds..." |
87 |
if (-d jsds) then |
88 |
cd jsds |
89 |
find . -name "*" -exec rm {} \; |
90 |
cd .. |
91 |
endif |
92 |
echo "done" |
93 |
|
94 |
echo |
95 |
|
96 |
if ($CLEAN == "yes") then |
97 |
if (-x base/local/libs/dsds/scripts/rmlinks.csh) then |
98 |
base/local/libs/dsds/scripts/rmlinks.csh |
99 |
endif |
100 |
|
101 |
if (-x base/local/libs/soi/scripts/rmlinks.csh) then |
102 |
base/local/libs/soi/scripts/rmlinks.csh |
103 |
endif |
104 |
else |
105 |
# Make include directories here, since they are used by multiple script blocks below |
106 |
if (!(-d base/include)) then |
107 |
mkdir -p base/include |
108 |
endif |
109 |
|
110 |
if (!(-d include)) then |
111 |
mkdir -p include |
112 |
endif |
113 |
|
114 |
echo "Setting links to man pages..." |
115 |
if (-d /home/jsoc/man) then |
116 |
if (!(-e man)) then |
117 |
ln -s /home/jsoc/man man |
118 |
endif |
119 |
endif |
120 |
echo "done" |
121 |
echo |
122 |
|
123 |
echo "Setting links to jsds..." |
124 |
if (!(-d jsds)) then |
125 |
mkdir jsds |
126 |
endif |
127 |
cd jsds |
128 |
find ../base \( -name \*.jsd -exec ln -s {} . \; -a -exec echo " " {} " OK" \; \) -o \( -name \*.jsd -exec echo " " {} " ERROR - couldn't create link" \; \) |
129 |
cd .. |
130 |
echo "done" |
131 |
echo |
132 |
|
133 |
# generate links for DSDS/SOI dynamic libraries - only do this if |
134 |
# user's environment has access to /home/soi/CM |
135 |
if (-d /home/soi/CM/include && -d /home/soi/CM/src) then |
136 |
if (-x base/local/libs/dsds/scripts/genlinks.csh) then |
137 |
base/local/libs/dsds/scripts/genlinks.csh |
138 |
endif |
139 |
|
140 |
if (-x base/local/libs/soi/scripts/genlinks.csh) then |
141 |
base/local/libs/soi/scripts/genlinks.csh |
142 |
endif |
143 |
endif |
144 |
|
145 |
echo "done" |
146 |
echo |
147 |
|
148 |
# Site Localization |
149 |
|
150 |
# Path to the configuration file - at some point, make this an argument to the configure script |
151 |
set LOCALIZATIONDIR = "" |
152 |
set conflocal = "config.local" |
153 |
|
154 |
if (-e $conflocal) then |
155 |
set LOCALIZATIONDIR = `perl -n -e 'if ($_ =~ /^LOCALIZATIONDIR\s+(.+)/) { print $1; }' $conflocal` |
156 |
endif |
157 |
|
158 |
if ($LOCALIZATIONDIR == "") then |
159 |
set LOCALIZATIONDIR = ${PWD}/localization |
160 |
endif |
161 |
|
162 |
# Eventually, dump all these generated files into a user-specified location. |
163 |
# This script will need to read the config.local file to get the |
164 |
# localization directory. Otherwise, just use JSOC/localization as the default. |
165 |
# We should put custom.mk in the localization directory too. |
166 |
if (!(-d ${LOCALIZATIONDIR})) then |
167 |
mkdir ${LOCALIZATIONDIR} |
168 |
if ($? != 0) then |
169 |
echo "Error creating localization directory." |
170 |
endif |
171 |
endif |
172 |
|
173 |
if (-e ${LOCALIZATIONDIR}/custom.mk) then |
174 |
rm ${LOCALIZATIONDIR}/custom.mk |
175 |
endif |
176 |
|
177 |
# Must create the scripts subdirectory before the call to gen_init.csh |
178 |
if (!(-d scripts)) then |
179 |
mkdir scripts |
180 |
endif |
181 |
|
182 |
if (!(-e configsdp.txt)) then |
183 |
# This is NetDRMS. |
184 |
if (!(-e config.local)) then |
185 |
echo "Error: config.local not found. If you have a saved version of this" |
186 |
echo " file from a previous installation, you should copy that into" |
187 |
echo " this directory and rerun configure. Otherwise, copy the file" |
188 |
echo " config.local.template to config.local and edit the config.local" |
189 |
echo " file to contain site-appropriate values." |
190 |
echo |
191 |
echo "*** IMPORTANT *** The edited config.local will contain site-specific" |
192 |
echo " values that should not be modified during subsequent updates to" |
193 |
echo " NetDRMS. Keep a safe copy of it somewhere outside of the DRMS" |
194 |
echo " directory tree, for example in /usr/local. After each NetDRMS" |
195 |
echo " update, ensure this file is in place." |
196 |
exit 1; |
197 |
else |
198 |
echo "CUSTOM_DEFINES = __LOCALIZED_DEFS__" >> ${LOCALIZATIONDIR}/custom.mk |
199 |
|
200 |
set CUSTOMDEFSFILE = "base/include/localization.h" |
201 |
echo "*** generating $CUSTOMDEFSFILE ***" |
202 |
cat /dev/null > $CUSTOMDEFSFILE |
203 |
echo '#ifndef __LOCALIZATION_H' >> $CUSTOMDEFSFILE |
204 |
echo '#define __LOCALIZATION_H' >> $CUSTOMDEFSFILE |
205 |
./gen_init.csh |
206 |
|
207 |
# Non-customizable parameters. There are certain features that are not |
208 |
# present in NetDRMS, but that are present in the SDP JSOC version of DRMS. |
209 |
# Set defines needed to accomplish this here. |
210 |
# NetDRMS sites do not have DSDS. |
211 |
echo '#define DSDS_SUPPORT (0)' >> $CUSTOMDEFSFILE |
212 |
echo '#endif' >> $CUSTOMDEFSFILE |
213 |
|
214 |
# run moreconfigure.pl - this script is written in perl because it is easier to do the compiler detection |
215 |
# in perl. It also reads configdsp.txt (if it exists) to set the default Stanford values for certain make variables |
216 |
$PERLBIN ./moreconfigure.pl -d${LOCALIZATIONDIR} -fcustom.mk -c${CUSTOMDEFSFILE} |
217 |
|
218 |
# must follow moreconfigure.pl, because moreconfigure.pl will possibly set the compiler make variables, |
219 |
# which are then referenced by lines in custom.mk generated by customizemake.pl. |
220 |
$PERLBIN ./customizemake.pl ./config.local ${LOCALIZATIONDIR} |
221 |
endif |
222 |
else if (-e config.local) then |
223 |
# This is Stanford. |
224 |
|
225 |
# config.local is optional at Stanford, but it won't necessarily contain the same information that |
226 |
# a NetDRMS config.local contains. The first section contains items that will override the |
227 |
# the items in serverdefs.h. The second section contains items used to populate custom.mk, |
228 |
# which causes make systems variables to be defined that override the default make behavior |
229 |
# (such as overriding the name of the directory to which binary data are written - linux_x86_64_n02 |
230 |
# instead of linux_x86_64, for example). |
231 |
|
232 |
# Override the defaults defined in serverdefs.h (don't use gen_init.csh as it does several things, |
233 |
# most of which are relevant only to non-SU NetDRMS sites). This script causes all |
234 |
# items included in config.local to override those defined in serverdefs.h, but not all |
235 |
# items need be specified in config.local. |
236 |
echo "CUSTOM_DEFINES = __CUSTOMIZED_DEFS__" >> ${LOCALIZATIONDIR}/custom.mk |
237 |
$PERLBIN ./customizedefs.pl |
238 |
|
239 |
set CUSTOMDEFSFILE = "base/include/customizeddefs.h" |
240 |
|
241 |
# run moreconfigure.pl - this script is written in perl because it is easier to do the compiler detection |
242 |
# in perl. It also reads configsdp.txt (if it exists) to set the default Stanford values for certain make variables |
243 |
$PERLBIN ./moreconfigure.pl -d${LOCALIZATIONDIR} -fcustom.mk -c${CUSTOMDEFSFILE} |
244 |
|
245 |
# update custom.mk with data from config.local |
246 |
# must follow moreconfigure.pl, because moreconfigure.pl will possibly set the compiler make variables, |
247 |
# which are then referenced by lines in custom.mk generated by customizemake.pl. |
248 |
$PERLBIN ./customizemake.pl ./config.local ${LOCALIZATIONDIR} |
249 |
else |
250 |
# run moreconfigure.pl - this script is written in perl because it is easier to do the compiler detection |
251 |
# in perl. It also reads configsdp.txt (if it exists) to set the default Stanford values for certain make variables |
252 |
$PERLBIN ./moreconfigure.pl -d${LOCALIZATIONDIR} -fcustom.mk |
253 |
endif |
254 |
|
255 |
# Figure out if this is a custom checkout |
256 |
set CUSTCO = "no" |
257 |
set LITERALSTR = '{ open(CFG, "<'${LOCALIZATIONDIR}'/dlset.txt") || die "BAD"; my $line = <CFG>; chomp($line); print $line; }' |
258 |
set CUSTCO = `$PERLBIN -e "$LITERALSTR"` |
259 |
|
260 |
if (${CUSTCO} == "BAD") then |
261 |
echo "Unable to open checkout state file ${LOCALIZATIONDIR}/dlset.txt" |
262 |
exit 1 |
263 |
else if (${CUSTCO} == "custom") then |
264 |
set CUSTCO = "yes" |
265 |
endif |
266 |
|
267 |
if (${PROJCONFIG} == "") then |
268 |
if (${CUSTCO} == "yes") then |
269 |
echo "Must provide configuration file as an argument to this configure script" |
270 |
exit 1; |
271 |
endif |
272 |
if (-e configsdp.txt) then |
273 |
set PROJCONFIG = configsdp.txt |
274 |
endif |
275 |
endif |
276 |
|
277 |
if (${PROJCONFIG} != "") then |
278 |
echo "Running project configuration [${PERLBIN} configproj.pl -c${PROJCONFIG} -d${LOCALIZATIONDIR}]." |
279 |
${PERLBIN} configproj.pl -c${PROJCONFIG} -d${LOCALIZATIONDIR} |
280 |
endif |
281 |
|
282 |
echo "Setting links to scripts..." |
283 |
cd scripts |
284 |
|
285 |
# Sums scripts |
286 |
find ../base/sums/scripts -mindepth 1 \( -path \*CVS -prune -o -exec ln -s {} . \; -a -exec echo " " {} " OK" \; \) -o -exec echo " " {} " ERROR - couldn't create link" \; |
287 |
|
288 |
# Util scripts |
289 |
find ../base/util/scripts -mindepth 1 \( -path \*CVS -prune -o -exec ln -s {} . \; -a -exec echo " " {} " OK" \; \) -o -exec echo " " {} " ERROR - couldn't create link" \; |
290 |
|
291 |
# Export scripts |
292 |
find ../base/export/scripts -mindepth 1 \( -path \*CVS -prune -o -exec ln -s {} . \; -a -exec echo " " {} " OK" \; \) -o -exec echo " " {} " ERROR - couldn't create link" \; |
293 |
|
294 |
# DRMS / IDL-interface scripts |
295 |
find ../base/drms/scripts -mindepth 1 \( -path \*CVS -prune -o -exec ln -s {} . \; -a -exec echo " " {} " OK" \; \) -o -exec echo " " {} " ERROR - couldn't create link" \; |
296 |
|
297 |
# Project-specific scripts - these won't show up if you don't have the project source. |
298 |
if (-x ${LOCALIZATIONDIR}/configure) then |
299 |
${LOCALIZATIONDIR}/configure |
300 |
endif |
301 |
|
302 |
cd .. |
303 |
echo "done" |
304 |
echo |
305 |
|
306 |
echo "Setting links to headers..." |
307 |
|
308 |
cd base/include |
309 |
find .. -path '../include' -prune -o -name \*.h \( \( -exec ln -s {} . \; -a -exec echo " " {} " OK" \; \) -o -exec echo " " {} " ERROR - couldn't create link" \; \) |
310 |
cd ../.. |
311 |
|
312 |
cd include |
313 |
if (-d ../base/include) then |
314 |
find ../base/include -name \*.h -exec ln -s {} . \; |
315 |
endif |
316 |
cd .. |
317 |
echo "done" |
318 |
echo |
319 |
|
320 |
# Custom make variable values - these will override the values set in moreconfigure.pl |
321 |
# echo "JSOC_COMPILER = gcc" >> custom.mk |
322 |
# echo "JSOC_FCOMPILER = gfortran" >> custom.mk |
323 |
# echo "DRMS_DEFAULT_RETENTION = -10" >> custom.mk |
324 |
|
325 |
endif |
326 |
|
327 |
|