This repository has been archived by the owner on Sep 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-epics.sh
executable file
·839 lines (785 loc) · 22.3 KB
/
install-epics.sh
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
#!/bin/sh
BASHRC=~/.bashrc
BASH_ALIAS_EPICS=~/.epics
#Where is the source code of EPICS
if test -z "$HOME_EPICS_APPS"; then
HOME_EPICS_APPS=$HOME/../epics/Apps
fi
echo HOME_EPICS_APPS=$HOME_EPICS_APPS
HOME_EPICS_APPS=$(echo $HOME_EPICS_APPS | sed -e "s%/[^/][^/]*/\.\./%/%")
echo HOME_EPICS_APPS=$HOME_EPICS_APPS
echo Do you want to install EPICS in $HOME_EPICS_APPS ? [y/N]
read yesno
case $yesno in
y|Y)
;;
*)
exit 0
esac
#Where are the binaries of EPICS
EPICS_ROOT=/usr/local/epics
EPICS_BASE=$EPICS_ROOT/base
EPICS_MODULES=$EPICS_ROOT/modules
#Version of base
EPICS_BASE_VER=3.14.12.3
#Version for synApps
SYNAPPSVER=synApps_5_6
#Version for ASYN
ASYNVER=asyn4-22
if test $SYNAPPSVER=synApps_5_6; then
MODSTOBEREMOVED="ALLEN_BRADLEY DAC128V IP330 IPUNIDIG LOVE IP VAC SOFTGLUE QUADEM DELAYGEN CAMAC VME AREA_DETECTOR DXP"
else
MODSTOBEREMOVED="ALLEN_BRADLEY AREA_DETECTOR AUTOSAVE CAMAC DAC128V DXP DELAYGEN IP IP330 IPUNIDIG LOVE MCA MEASCOMP OPTICS QUADEM SOFTGLUE STD SNCSEQ VAC VME"
fi
#extensions top
EPICS_EXTENSIONS_TOP_VER=extensionsTop_20120904
#msi
EPICS_MSI_VER=msi1-5
#StreamDevice, later version than synApps
#STREAMDEVICEVER=StreamDevice-2-6
export EPICS_ROOT EPICS_BASE EPICS_MODULES EPICS_BASE_VER HOME_EPICS_APPS
export EPICS_EXT=${EPICS_ROOT}/extensions
#########################
#apt or yum or port
if uname -a | egrep "CYGWIN|MING" >/dev/null; then
SUDO=
else
SUDO=sudo
fi
APTGET=/bin/false
if type apt-get >/dev/null 2>/dev/null; then
APTGET="$SUDO apt-get install"
fi
if type yum >/dev/null 2>/dev/null; then
APTGET="$SUDO /usr/bin/yum install"
fi
# port (Mac Ports)
if test -x /opt/local/bin/port; then
APTGET="$SUDO port install"
fi
export APTGET
#########################
create_soft_x_y() {
dir=$1
src=$2
dst=$3
(
cd "$dir" &&
linkdst=$(readlink $dst) || linkdst=""
if test "$linkdst" != "$src"; then
echo "$linkdst" != "$dst" &&
echo $SUDO rm $dst &&
$SUDO rm -f $dst &&
echo $SUDO ln -s $src $dst &&
$SUDO ln -s $src $dst || {
echo >&2 can not link $src $dst
exit 1
}
fi
)
}
########################
if ! test -d $HOME_EPICS_APPS; then
echo $SUDO mkdir -p $HOME_EPICS_APPS &&
$SUDO mkdir -p $HOME_EPICS_APPS || {
echo >&2 can not chown $HOME_EPICS_APPS
exit 1
}
fi
if ! test -w $HOME_EPICS_APPS; then
echo $SUDO chown "$USER" $HOME_EPICS_APPS &&
$SUDO chown "$USER" $HOME_EPICS_APPS || {
echo >&2 can not chown $HOME_EPICS_APPS
exit 1
}
fi
if ! test -d /usr/local; then
sudo mkdir /usr/local
fi &&
create_soft_x_y /usr/local $HOME_EPICS_APPS epics &&
create_soft_x_y $HOME_EPICS_APPS base-${EPICS_BASE_VER} base &&
wget_or_curl()
{
url=$1
file=$2
if type curl >/dev/null 2>/dev/null; then
curl "$url" >"$file.$$.tmp" &&
mv "$file.$$.tmp" "$file" || {
echo >&2 curl can not get $url
exit 1
}
else
# We need wget
if ! type wget >/dev/null 2>/dev/null; then
echo $APTGET wget
$APTGET wget
fi &&
wget "$url" -O "$file.$$.tmp" &&
mv "$file.$$.tmp" "$file" || {
echo >&2 wget can not get $url
exit 1
}
fi
}
install_re2c()
{
cd $HOME_EPICS_APPS &&
if ! test -d re2c-code-git; then
git clone git://git.code.sf.net/p/re2c/code-git re2c-code-git.$$.tmp &&
mv re2c-code-git.$$.tmp re2c-code-git
fi &&
(
cd re2c-code-git/re2c &&
./autogen.sh &&
./configure &&
make &&
echo PWD=$PWD $SUDO make install &&
$SUDO make install
)
}
run_make_in_dir()
{
dir=$1 &&
echo cd $dir &&
(
cd $dir &&
make
)
}
patch_motor_h()
{
(
cd "$1" &&
if grep "epicsEndian.h" motor.h >/dev/null; then
echo PWD=$PWD patch motor.h not needed &&
return
fi &&
echo PWD=$PWD patch motor.h &&
if ! test -e motor.h.original; then
cp motor.h motor.h.original
fi &&
cp motor.h.original motor.h &&
case $PWD in
*motor-6-7*)
cat <<EOF >motor.patch
diff --git a/motorApp/MotorSrc/motor.h b/motorApp/MotorSrc/motor.h
--- a/motorApp/MotorSrc/motor.h
+++ b/motorApp/MotorSrc/motor.h
63a64
> #include <epicsEndian.h>
140c141
< #elif (CPU == PPC604) || (CPU == PPC603) || (CPU==PPC85XX) || (CPU == MC68040) || (CPU == PPC32)
---
> #elif defined(CPU) && ((CPU == PPC604) || (CPU == PPC603) || (CPU == PPC85XX) || (CPU == MC68040) || (CPU == PPC32))
141a143,148
> #elif defined(__GNUC__)
> #if (EPICS_BYTE_ORDER == EPICS_ENDIAN_LITTLE)
> #define LSB_First (TRUE)
> #else
> #define MSB_First (TRUE)
> #endif
EOF
;;
*motor-6-8*)
cat <<EOF >motor.patch
diff --git a/motorApp/MotorSrc/motor.h b/motorApp/MotorSrc/motor.h
--- a/motorApp/MotorSrc/motor.h
+++ b/motorApp/MotorSrc/motor.h
63a64
> #include <epicsEndian.h>
140c141
< #elif (CPU == PPC604) || (CPU == PPC603) || (CPU == PPC85XX) || (CPU == MC68040) || (CPU == PPC32)
---
> #elif defined(CPU) && ((CPU == PPC604) || (CPU == PPC603) || (CPU == PPC85XX) || (CPU == MC68040) || (CPU == PPC32))
141a143,148
> #elif defined(__GNUC__)
> #if (EPICS_BYTE_ORDER == EPICS_ENDIAN_LITTLE)
> #define LSB_First (TRUE)
> #else
> #define MSB_First (TRUE)
> #endif
EOF
;;
*)
echo >&2 "Can not patch motor.h, only motor 6.7 or 6.8 is supported"
exit 1
esac &&
patch <motor.patch
)
}
install_motor()
{
cd $HOME_EPICS_APPS/modules &&
if test -e motor; then
echo rm -rf motor &&
rm -rf motor
fi &&
mkdir -p motor &&
cd motor &&
motordevver=$(echo ../../$SYNAPPSVER/support/motor-*) &&
echo motordevver=$motordevver &&
for f in src dbd Db lib include; do
if test -e $f; then
echo rm -rf $f &&
rm -rf $f
fi
done &&
(
mkdir dbd &&
cd dbd &&
rm -rf * &&
for mdbd in $(find ../../../$SYNAPPSVER/support/motor-* -name '*.dbd'); do
dbdbasename="${mdbd##*/}" &&
#echo mdbd=$mdbd dbdbasename=$dbdbasename &&
if ! test -f $dbdbasename; then
cp -fv $mdbd $dbdbasename
fi
done
) &&
(
mkdir Db &&
cd Db &&
rm -rf * &&
for mdbd in $(find ../../../$SYNAPPSVER/support/motor-* -name '*.db'); do
dbdbasename="${mdbd##*/}" &&
#echo mdbd=$mdbd dbdbasename=$dbdbasename &&
if ! test -f $dbdbasename; then
cp -fv $mdbd $dbdbasename
fi
done
) &&
(
motorlib=$(find ../../$SYNAPPSVER/support/motor-*/ -name lib | sed -e "s!//!/!g");
echo motorlib=$motorlib
ln -s "$motorlib" lib
) &&
(
motorinclude=$(find ../../$SYNAPPSVER/support/motor-*/ -name include | sed -e "s!//!/!g");
echo motorinclude=$motorinclude
ln -s "$motorinclude" include
)
}
install_streamdevice()
{
cd $HOME_EPICS_APPS/modules &&
if ! test -d streamdevice; then
mkdir -p streamdevice
fi &&
cd streamdevice &&
streamdevver=$(echo ../../$SYNAPPSVER/support/stream-*) &&
echo streamdevver=$streamdevver &&
if test -L src; then
echo rm src &&
rm src
fi &&
echo ln -s ../../$SYNAPPSVER/support/$streamdevver/streamDevice/src/ src &&
ln -s ../../$SYNAPPSVER/support/$streamdevver/streamDevice/src/ src || exit 1
for f in dbd lib include; do
if test -L $f; then
echo rm $f &&
rm $f
fi &&
ln -s ../../$SYNAPPSVER/support/$streamdevver/$f/ $f || exit 1
done
}
fix_epics_base()
{
file="$1" &&
if test -e "$file"; then
filebasename="${file%*.original}" &&
echo fix_epics_base PWD=$PWD file=$file filebasename=$filebasename &&
if ! test -f "$filebasename.original"; then
cp "$file" "$filebasename.original" || {
echo >&2 failed cp -v $file $filebasename.original in $PWD
exit 1
}
fi &&
sed <"$filebasename.original" >"$file.$$.tmp" \
-e "s!^SUPPORT=.*!SUPPORT=$EPICS_ROOT/$SYNAPPSVER/support!" \
-e "s!^EPICS_BASE=.*!EPICS_BASE=$EPICS_ROOT/base!" \
-e "s!^\(IPAC=.*\)!## rem by install-epics \1!" \
-e "s!^\(SNCSEQ=.*\)!## rem by install-epics \1!" \
-e "s!^BUSY=.*!BUSY=\$(SUPPORT)/busy-1-4!" &&
mv -fv "$file.$$.tmp" "$file" &&
if test "$ASYNVER"; then
sed <"$file" >"$file.$$.tmp" \
-e "s!^ASYN=.*!ASYN=$EPICS_MODULES/asyn!" &&
mv -fv "$file.$$.tmp" "$file"
fi
else
echo fix_epics_base PWD=$PWD file=$file does not exist, doing nothing
fi
}
remove_modules_from_RELEASE()
{
file="$1" &&
for mod in $MODSTOBEREMOVED; do
echo removing $mod in $PWD/$file &&
if grep $mod $file >/dev/null; then
sed -e "s/\($mod=.*\$\)/## xx \1/g" <$file >$file.$$.tmp &&
! diff $file $file.$$.tmp >/dev/null &&
mv -f $file.$$.tmp $file || {
echo >&2 failed removing $mod in $PWD
exit 1
}
fi
done
}
remove_modules_from_Makefile()
{
file="$1" &&
for mod in $MODSTOBEREMOVED; do
echo removing $mod in $PWD/$file &&
sed -e "s/ $mod / /g" -e "s/ $mod\$/ /g" <$file >$file.$$.tmp &&
! diff $file $file.$$.tmp >/dev/null &&
mv -f $file.$$.tmp $file || {
echo >&2 failed removing $mod in $PWD
exit 1
}
done
}
comment_out_in_file()
{
file=$1 &&
shift &&
for mod in "$@"; do
if grep "^#.*$mod" $file >/dev/null; then
echo already commented out $mod in $PWD/$file
else
echo commenting out $mod in $PWD/$file &&
filebasename="${file%*.original}" &&
echo file=$file filebasename=$filebasename &&
if ! test -f "$filebasename.original"; then
cp "$file" "$filebasename.original" || {
echo >&2 failed cp -v $file $filebasename.original in $PWD
exit 1
}
fi &&
sed -e "s/\(.*$mod.*\)/# rem by install-epics \1/g" <$filebasename.original >$file &&
! diff $filebasename.original $file >/dev/null
fi
done
}
(
cd $HOME_EPICS_APPS &&
if ! test -f baseR${EPICS_BASE_VER}.tar.gz; then
wget_or_curl http://www.aps.anl.gov/epics/download/base/baseR${EPICS_BASE_VER}.tar.gz baseR${EPICS_BASE_VER}.tar.gz
fi
if ! test -d base-$EPICS_BASE_VER; then
tar xzf baseR${EPICS_BASE_VER}.tar.gz || {
echo >&2 can not tar xzf baseR${EPICS_BASE_VER}.tar.gz
rm -rf base-$EPICS_BASE_VER
exit 1
}
fi
) || exit 1
#Need to set the softlink now
EPICS_HOST_ARCH=$($EPICS_ROOT/base/startup/EpicsHostArch) || {
echo >&2 EPICS_HOST_ARCH failed
exit 1
}
# here we know the EPICS_HOST_ARCH
export EPICS_HOST_ARCH
EPICS_BASE_BIN=${EPICS_BASE}/bin/$EPICS_HOST_ARCH
EPICS_EXT_BIN=${EPICS_EXT}/bin/$EPICS_HOST_ARCH
PATH=$PATH:$EPICS_BASE_BIN:$EPICS_EXT_BIN
EPICS_EXT_LIB=${EPICS_EXT}/lib/$EPICS_HOST_ARCH
if test "${LD_LIBRARY_PATH}"; then
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$EPICS_BASE_LIB
else
export LD_LIBRARY_PATH=$EPICS_EXT_LIB
fi
echo PATH=$PATH
export EPICS_BASE_BIN EPICS_EXT EPICS_EXT_LIB EPICS_EXT_BIN PATH LD_LIBRARY_PATH
############# Fix bashrc (or friends)
if ! grep "$BASH_ALIAS_EPICS" $BASHRC >/dev/null; then
echo updating $BASHRC
cat <<EOF >>$BASHRC
#install-epics.sh
if test -r ${BASH_ALIAS_EPICS}; then
. ${BASH_ALIAS_EPICS}
fi
EOF
fi
#update .epics
cat >${BASH_ALIAS_EPICS} <<EOF
export HOME_EPICS_APPS=$HOME_EPICS_APPS
export EPICS_ROOT=$EPICS_ROOT
export EPICS_BASE=\$EPICS_ROOT/base
export EPICS_EXT=\${EPICS_ROOT}/extensions
export EPICS_HOST_ARCH=$($EPICS_BASE/startup/EpicsHostArch)
export EPICS_EXT_BIN=${EPICS_EXT}/bin/\$EPICS_HOST_ARCH
export EPICS_EXT_LIB=${EPICS_EXT}/lib/\$EPICS_HOST_ARCH
export EPICS_MODULES=\$EPICS_ROOT/modules
export EPICS_BASE_BIN=\${EPICS_BASE}/bin/\$EPICS_HOST_ARCH
export EPICS_BASE_LIB=\${EPICS_BASE}/lib/\$EPICS_HOST_ARCH
export LD_LIBRARY_PATH=\${EPICS_BASE_LIB}:\$LD_LIBRARY_PATH
if test "\$LD_LIBRARY_PATH"; then
export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$EPICS_BASE_LIB
else
export LD_LIBRARY_PATH=\$EPICS_EXT_LIB
fi
export PATH=\$PATH:\$EPICS_BASE_BIN:\$EPICS_EXT_BIN
EOF
################
(
# We need gcc and g++: gcc-g++ under Scientifc Linux
if ! type g++ >/dev/null 2>/dev/null; then
echo $APTGET gcc-c++
$APTGET gcc-c++
fi
# We need g++
if ! type g++ >/dev/null 2>/dev/null; then
echo $APTGET g++
$APTGET g++
fi &&
#We need readline
# Mac OS: /usr/include/readline/readline.h
# Linux: /usr/include/readline.h
if ! test -r /usr/include/readline/readline.h; then
test -r /usr/include/readline.h ||
$APTGET readline-devel ||
$APTGET libreadline-dev ||
{
echo >&2 can not install readline-devel
exit 1
}
fi &&
run_make_in_dir $HOME_EPICS_APPS/base || {
echo >&2 failed in $PWD
exit 1
}
) &&
#Modules
(
cd $HOME_EPICS_APPS/ &&
if ! test -d modules; then
mkdir modules
fi
) || exit 1
#Streamdevice from PSI
if test -n "$STREAMDEVICEVER"; then
(
cd $HOME_EPICS_APPS &&
if ! test -f $STREAMDEVICEVER.tgz; then
wget_or_curl http://epics.web.psi.ch/software/streamdevice/$STREAMDEVICEVER.tgz $STREAMDEVICEVER.tgz.$$
fi
if ! test -d $STREAMDEVICEVER; then
tar xzvf $STREAMDEVICEVER.tgz
fi
if ! test -d $HOME_EPICS_APPS/$STREAMDEVICEVER/streamdevice-2.6/configure; then
mkdir -p $HOME_EPICS_APPS/$STREAMDEVICEVER/streamdevice-2.6/configure
fi
(
# Create the files (Obs: \EOF != EOF)
cd $HOME_EPICS_APPS/$STREAMDEVICEVER/streamdevice-2.6/configure &&
cat >CONFIG <<\EOF &&
#Generated by install-epics.sh
# CONFIG - Load build configuration data
#
# Do not make changes to this file!
# Allow user to override where the build rules come from
RULES = $(EPICS_BASE)
# RELEASE files point to other application tops
include $(TOP)/configure/RELEASE
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).Common
ifdef T_A
-include $(TOP)/configure/RELEASE.Common.$(T_A)
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A)
endif
CONFIG = $(RULES)/configure
include $(CONFIG)/CONFIG
# Override the Base definition:
INSTALL_LOCATION = $(TOP)
# CONFIG_SITE files contain other build configuration settings
include $(TOP)/configure/CONFIG_SITE
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).Common
ifdef T_A
-include $(TOP)/configure/CONFIG_SITE.Common.$(T_A)
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A)
endif
EOF
cat >CONFIG_SITE <<\EOF &&
#Generated by install-epics.sh
CHECK_RELEASE = YES
EOF
cat >Makefile <<\EOF &&
#Generated by install-epics.sh
TOP=..
include $(TOP)/configure/CONFIG
TARGETS = $(CONFIG_TARGETS)
CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS)))
include $(TOP)/configure/RULES
EOF
cat >RELEASE <<\EOF &&
#Generated by install-epics.sh
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
ASYN=${EPICS_ROOT}/modules/asyn
EPICS_BASE=${EPICS_ROOT}/base
EOF
cat >RULES <<\EOF &&
#Generated by install-epics.sh
# RULES
include $(CONFIG)/RULES
# Library should be rebuilt because LIBOBJS may have changed.
$(LIBNAME): ../Makefile
EOF
cat >RULES.ioc <<\EOF &&
#Generated by install-epics.sh
#RULES.ioc
include $(CONFIG)/RULES.ioc
EOF
cat >RULES_DIRS <<\EOF &&
#Generated by install-epics.sh
#RULES_DIRS
include $(CONFIG)/RULES_DIRS
EOF
cat >RULES_DIRS <<\EOF
#Generated by install-epics.sh
#RULES_TOP
include $(CONFIG)/RULES_TOP
EOF
)
)
fi
if test -n "$ASYNVER"; then
(
create_soft_x_y $HOME_EPICS_APPS/modules ../$ASYNVER/ asyn
(
cd $HOME_EPICS_APPS &&
if ! test -f $ASYNVER.tar.gz; then
wget_or_curl http://www.aps.anl.gov/epics/download/modules/$ASYNVER.tar.gz $ASYNVER.tar.gz
fi
if ! test -d $ASYNVER; then
tar xzvf $ASYNVER.tar.gz
fi
) &&
(
# Need to fix epics base for synapss already here,
# (if the dir already exists)
path=$HOME_EPICS_APPS/$SYNAPPSVER/support/configure &&
if test -d $path; then
echo cd $path &&
cd $path &&
(
fix_epics_base EPICS_BASE.$EPICS_HOST_ARCH &&
fix_epics_base SUPPORT.$EPICS_HOST_ARCH
)
fi
) &&
(
cd $HOME_EPICS_APPS/$ASYNVER/configure && {
for f in $(find . -name "RELEASE*" ); do
echo f=$f
fix_epics_base $f
done
}
) &&
(
run_make_in_dir $HOME_EPICS_APPS/$ASYNVER
) || {
echo >&2 failed $ASYNVER
exit 1
}
)
else
echo ASYNVER not defined, skipping asyn
install_asyn_ver ../$SYNAPPSVER/support/asyn-4-18
fi
#synApps
if test -n "$SYNAPPSVER"; then
(
cd $HOME_EPICS_APPS &&
if ! test -f $SYNAPPSVER.tar.gz; then
wget_or_curl http://www.aps.anl.gov/bcda/synApps/tar/$SYNAPPSVER.tar.gz $SYNAPPSVER.tar.gz
fi &&
if ! test -d $SYNAPPSVER; then
tar xzvf $SYNAPPSVER.tar.gz
fi
) || {
echo >&2 failed tar xzvf $SYNAPPSVER.tar.gz in $PWD
exit 1
} &&
(
if test -n "$STREAMDEVICEVER"; then
cd $HOME_EPICS_APPS/$SYNAPPSVER/support/stream* &&
(
#Move the directory out of its way
if ! test -d streamdevice.original; then
mv streamdevice streamdevice.original || {
echo >&2 can not mv streamdevice streamdevice.original PWD=$PWD
exit 1
}
#copy the later streamdevice
mkdir streamdevice &&
cp -R ../../../StreamDevice-2-6/ streamdevice/ || {
echo >&2 cp -R ../../../StreamDevice-2-6/ streamdevice/PWD=$PWD
exit 1
}
fi
)
fi
) &&
(
path=$HOME_EPICS_APPS/$SYNAPPSVER/support &&
echo cd $path &&
cd $path &&
for f in $(find . -name RELEASE); do
fix_epics_base $f
done &&
(
cd configure &&
mkdir -p orig || {
echo >&2 failed mkdir -p orig in $PWD
exit 1
}
for f in EPICS_BASE.cygwin* EPICS_BASE.linux-* EPICS_BASE.win32-* EPICS_BASE.windows-* SUPPORT.cygwin-* SUPPORT.linux-* SUPPORT.win32-* SUPPORT.windows-*; do
if test -f "$f"; then
mv -v "$f" $PWD/orig/ || {
echo >&2 failed mv "$f" orig/ in $PWD
exit 1
}
fi
done
) &&
(
echo cd $HOME_EPICS_APPS/$SYNAPPSVER/support/configure &&
cd $HOME_EPICS_APPS/$SYNAPPSVER/support/configure &&
if test "$SYNAPPSVER" = synApps_5_6; then
(
path=$HOME_EPICS_APPS/$SYNAPPSVER/support
echo cd $path &&
cd $path &&
if ! test -f makereleaseok; then
make release && touch makereleaseok || {
echo >&2 failed make release in $PWD
exit 1
}
else
echo The file $PWD/makereleaseok exist, skipping make release
fi
)
fi &&
fix_epics_base $PWD/RELEASE &&
remove_modules_from_RELEASE RELEASE &&
(
echo cd $HOME_EPICS_APPS/$SYNAPPSVER/support &&
cd $HOME_EPICS_APPS/$SYNAPPSVER/support &&
file=Makefile &&
if ! test -f $file.original; then
cp -v $file $file.original || exit 1
fi &&
cp $file.original $file &&
remove_modules_from_Makefile $file
) &&
file=Makefile &&
(
# Remove AREA_DETECTOR and IP from RELEASE
cd $HOME_EPICS_APPS/$SYNAPPSVER/support/xxx-5*/configure &&
if ! test -f RELEASE.original; then
cp -v RELEASE RELEASE.original || exit 1
fi &&
sed <RELEASE.original >RELEASE.$$.tmp \
-e "s!^AREA_DETECTOR!#AREA_DETECTOR!" \
-e "s!^IP=!#IP=!" \
-e "s!^SNCSEQ!#SNCSEQ!" &&
mv -fv RELEASE.$$.tmp RELEASE
) &&
(
# Remove AREA_DETECTOR and IP from dbd
cd $HOME_EPICS_APPS/$SYNAPPSVER/support/xxx-5*/xxxApp/src &&
if ! test -f xxxCommonInclude.dbd.original; then
cp -v xxxCommonInclude.dbd xxxCommonInclude.dbd.original || exit 1
fi &&
sed <xxxCommonInclude.dbd.original >xxxCommonInclude.dbd.$$.tmp \
-e "s!\(include.*ipSupport.dbd\)!#\1!" &&
mv -fv xxxCommonInclude.dbd.$$.tmp xxxCommonInclude.dbd
) &&
(
# Remove AREA_DETECTOR related modules from $file
cd $HOME_EPICS_APPS/$SYNAPPSVER/support/xxx-5*/xxxApp/src &&
if ! test -f $file.original; then
cp -v $file $file.original || exit 1
fi &&
cp $file.original $file &&
for mod in ADSupport NDPlugin simDetector netCDF dxp "xxx_Common_LIBS += ip"; do
echo removing $mod in $PWD/$file &&
sed -e "s/\(.*$mod.*\)/#XXX Removed by install-epics.sh XXX \1/g" <$file >$file.$$.tmp &&
! diff $file $file.$$.tmp >/dev/null &&
mv -f $PWD/$file.$$.tmp $PWD/$file ||{
echo >&2 failed removing $mod in $PWD
exit 1
}
done
)
) || {
echo >&2 failed in $PWD
exit 1
}
) || {
echo >&2 failed RELEASE in $PWD
exit 1
}
if test "$EPICS_EXTENSIONS_TOP_VER"; then
(
cd $HOME_EPICS_APPS &&
if ! test -f $EPICS_EXTENSIONS_TOP_VER.tar.gz; then
echo installing $EPICS_EXTENSIONS_TOP_VER &&
wget_or_curl http://www.aps.anl.gov/epics/download/extensions/$EPICS_EXTENSIONS_TOP_VER.tar.gz $EPICS_EXTENSIONS_TOP_VER.tar.gz
fi
if ! test -d ${EPICS_EXTENSIONS_TOP_VER}; then
tar xzf $EPICS_EXTENSIONS_TOP_VER.tar.gz
fi
)
fi &&
if ! type re2c >/dev/null 2>/dev/null; then
echo $APTGET re2c
$APTGET re2c || install_re2c
fi &&
if test "$EPICS_MSI_VER"; then
(
cd $HOME_EPICS_APPS &&
if ! test -f $EPICS_MSI_VER.tar.gz; then
echo installing $EPICS_MSI_VER &&
wget_or_curl http://www.aps.anl.gov/epics/download/extensions/$EPICS_MSI_VER.tar.gz $EPICS_MSI_VER.tar.gz
fi &&
(
mkdir -p extensions/src &&
cd extensions/src &&
tar xzf ../../$EPICS_MSI_VER.tar.gz &&
cd $EPICS_MSI_VER &&
run_make_in_dir . || {
echo >&2 make failed in $PWD
exit 1
}
) || {
echo >&2 msi failed in $PWD
exit 1
}
)
fi &&
if test -z "$ASYNVER"; then
#Need to compile asyn from synapps
run_make_in_dir $HOME_EPICS_APPS/$SYNAPPSVER/support/asyn-*/asyn
fi &&
run_make_in_dir $HOME_EPICS_APPS/$SYNAPPSVER/support/sscan* &&
run_make_in_dir $HOME_EPICS_APPS/$SYNAPPSVER/support/calc-* &&
run_make_in_dir $HOME_EPICS_APPS/$SYNAPPSVER/support/stream-* || {
echo >&2 failed $SYNAPPSVER PWD=$PWD PATH=$PATH
exit 1
}
patch_motor_h $HOME_EPICS_APPS/$SYNAPPSVER/support/motor-*/motorApp/MotorSrc &&
comment_out_in_file $HOME_EPICS_APPS/$SYNAPPSVER/support/motor-*/motorApp/Makefile HytecSrc &&
run_make_in_dir $HOME_EPICS_APPS/$SYNAPPSVER/support/motor-*/motorApp || {
echo >&2 failed $SYNAPPSVER PWD=$PWD PATH=$PATH
exit 1
}
install_motor &&
install_streamdevice &&
echo install motor streamdevice OK || {
echo >&2 failed install_streamdevice PWD=$PWD
exit 1
}
else
echo SYNAPPSVER not defined, skipping synApps
fi