-
Notifications
You must be signed in to change notification settings - Fork 109
/
build.sh
executable file
·164 lines (153 loc) · 4.35 KB
/
build.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
#!/bin/bash
echo Building OpenPLC environment:
echo [MATIEC COMPILER]
cd matiec_src
autoreconf -i
./configure
make
echo [LADDER]
cd ..
cp ./matiec_src/iec2c ./
./iec2c ./st_files/blank_program.st
mv -f POUS.c POUS.h LOCATED_VARIABLES.h VARIABLES.csv Config0.c Config0.h Res0.c ./core/
echo [ST OPTIMIZER]
cd st_optimizer_src
g++ st_optimizer.cpp -o st_optimizer
cd ..
cp ./st_optimizer_src/st_optimizer ./
echo [GLUE GENERATOR]
cd glue_generator_src
g++ glue_generator.cpp -o glue_generator
cd ..
cp ./glue_generator_src/glue_generator ./core/glue_generator
clear
echo OpenPLC can talk Modbus/TCP and DNP3 SCADA protocols. Modbus/TCP is already
echo added to the system. Do you want to add support for DNP3 as well \(Y/N\)?
read DNP3_SUPPORT
if [ "$DNP3_SUPPORT" = "Y" -o "$DNP3_SUPPORT" = "y" -o "$DNP3_SUPPORT" = "yes" ]; then
echo Installing DNP3 on the system...
#moving files to the right place
mv ./core/dnp3.disabled ./core/dnp3.cpp 2> /dev/null
mv ./core/dnp3_dummy.cpp ./core/dnp3_dummy.disabled 2> /dev/null
cp -f ./core/core_builders/dnp3_enabled/*.* ./core/core_builders/
#make sure cmake is installed
sudo apt-get install cmake
#download opendnp3
#git clone --recursive https://github.com/automatak/dnp3.git
cd dnp3
#create swapfile to prevent out of memory errors
echo creating swapfile...
sudo dd if=/dev/zero of=swapfile bs=1M count=1000
sudo mkswap swapfile
sudo swapon swapfile
#build opendnp3
cmake ../dnp3
make
sudo make install
sudo ldconfig
#remove swapfile
sudo swapoff swapfile
sudo rm -f ./swapfile
cd ..
else
echo Skipping DNP3 installation
mv ./core/dnp3.cpp ./core/dnp3.disabled 2> /dev/null
mv ./core/dnp3_dummy.disabled ./core/dnp3_dummy.cpp 2> /dev/null
cp -f ./core/core_builders/dnp3_disabled/*.* ./core/core_builders/
fi
cd core
rm -f ./hardware_layer.cpp
rm -f ../build_core.sh
echo The OpenPLC needs a driver to be able to control physical or virtual hardware.
echo Please select the driver you would like to use:
OPTIONS="Blank Modbus Fischertechnik RaspberryPi UniPi PiXtend PiXtend_2S Arduino ESP8266 Arduino+RaspberryPi Simulink "
select opt in $OPTIONS; do
if [ "$opt" = "Blank" ]; then
cp ./hardware_layers/blank.cpp ./hardware_layer.cpp
cp ./core_builders/build_normal.sh ../build_core.sh
echo [OPENPLC]
cd ..
./build_core.sh
exit
elif [ "$opt" = "Modbus" ]; then
cp ./hardware_layers/modbus_master.cpp ./hardware_layer.cpp
cp ./core_builders/build_modbus.sh ../build_core.sh
echo [LIBMODBUS]
cd ..
cd libmodbus_src
./autogen.sh
./configure
sudo make install
sudo ldconfig
echo [OPENPLC]
cd ..
./build_core.sh
exit
elif [ "$opt" = "Fischertechnik" ]; then
cp ./hardware_layers/fischertechnik.cpp ./hardware_layer.cpp
cp ./core_builders/build_rpi.sh ../build_core.sh
echo [OPENPLC]
cd ..
./build_core.sh
exit
elif [ "$opt" = "RaspberryPi" ]; then
cp ./hardware_layers/raspberrypi.cpp ./hardware_layer.cpp
cp ./core_builders/build_rpi.sh ../build_core.sh
echo [OPENPLC]
cd ..
./build_core.sh
exit
elif [ "$opt" = "UniPi" ]; then
cp ./hardware_layers/unipi.cpp ./hardware_layer.cpp
cp ./core_builders/build_rpi.sh ../build_core.sh
echo [OPENPLC]
cd ..
./build_core.sh
exit
elif [ "$opt" = "PiXtend" ]; then
cp ./hardware_layers/pixtend.cpp ./hardware_layer.cpp
cp ./core_builders/build_rpi.sh ../build_core.sh
echo [OPENPLC]
cd ..
./build_core.sh
exit
elif [ "$opt" = "PiXtend_2S" ]; then
cp ./hardware_layers/pixtend2s.cpp ./hardware_layer.cpp
cp ./core_builders/build_rpi.sh ../build_core.sh
echo [OPENPLC]
cd ..
./build_core.sh
exit
elif [ "$opt" = "Arduino" ]; then
cp ./hardware_layers/arduino.cpp ./hardware_layer.cpp
cp ./core_builders/build_normal.sh ../build_core.sh
echo [OPENPLC]
cd ..
./build_core.sh
exit
elif [ "$opt" = "ESP8266" ]; then
cp ./hardware_layers/esp8266.cpp ./hardware_layer.cpp
cp ./core_builders/build_normal.sh ../build_core.sh
echo [OPENPLC]
cd ..
./build_core.sh
exit
elif [ "$opt" = "Arduino+RaspberryPi" ]; then
cp ./hardware_layers/arduino.cpp ./hardware_layer.cpp
cp ./core_builders/build_rpi.sh ../build_core.sh
echo [OPENPLC]
cd ..
./build_core.sh
exit
elif [ "$opt" = "Simulink" ]; then
cp ./hardware_layers/simulink.cpp ./hardware_layer.cpp
cp ./core_builders/build_normal.sh ../build_core.sh
echo [OPENPLC]
cd ..
./build_core.sh
exit
else
#clear
echo bad option
fi
done