forked from rpi-ws281x/rpi-ws281x-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-swig-on-pi.sh
117 lines (105 loc) · 4.2 KB
/
install-swig-on-pi.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
#!/bin/bash
set -e
set -o pipefail
cd ~
sudo apt-get --yes --force-yes install build-essential libpcre2-dev libpcre3-dev
set +e
echo "check if java is already installed..."
java --version | grep jdk
if [ $? -ne 0 ]
then
set -e
echo "didn't detect install, will try..."
echo "check cpu architecture..."
cat /proc/cpuinfo | grep ARMv6
if [ $? -eq 0 ]
then
echo "DETECTED ARMv6, WILL TRY AND INSTALL ZULU JDK!"
mkdir -p /usr/lib/jvm
cd /usr/lib/jvm
sudo wget https://cdn.azul.com/zulu-embedded/bin/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf.tar.gz
sudo tar -xzvf zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf.tar.gz
sudo rm zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf.tar.gz
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/javac 1
else
echo "didn't detect ARMv6, will try and install default jdk..."
sudo apt-get --yes --force-yes install default-jdk-headless
fi
else
echo "detected java, skipping install"
fi
set -e
mkdir -p ~/rpi_ws281x_build/swigInstall
cd ~/rpi_ws281x_build/swigInstall
if [ -d "swig-4.1.1" ]; then
echo "found swig folder, skipping download..."
else
echo "attempting swig 4.1.1 download"
wget http://prdownloads.sourceforge.net/swig/swig-4.1.1.tar.gz
tar -xzvf swig-4.1.1.tar.gz
rm swig-4.1.1.tar.gz
fi
cd swig-4.1.1
echo "trying to figure out if --with-javainc arg needs/can to be passed to swig configure..."
echo "executing part of swig configure script to determine if it will find jni.h..."
JAVAINCDIR="/usr/j2sdk*/include /usr/local/j2sdk*/include /usr/jdk*/include /usr/local/jdk*/include /opt/j2sdk*/include /opt/jdk*/include /usr/java/include /usr/java/j2sdk*/include /usr/java/jdk*/include /usr/local/java/include /opt/java/include /usr/include/java /usr/local/include/java /usr/lib/java/include /usr/lib/jvm/java*/include /usr/lib64/jvm/java*/include /usr/include/kaffe /usr/local/include/kaffe /usr/include"
for d in $JAVAINCDIR ; do
if test -r "$d/jni.h" ; then
echo "yep, found something, setting flag"
FOUNDJNI="true"
break
fi
done
if [ "$FOUNDJNI" != "true" ]; then
echo "configure won't find anything, will try to get a path for JNI.h"
for d2 in /usr/lib/jvm/*/include ; do
if test -r "$d2/jni.h" ; then
echo "SUCCESS! found $d2"
echo "will pass to configure"
SELFJNI=$d2
break
fi
done
fi
if [ "$FOUNDJNI" = "true" ]; then
sudo ./configure
else
if [ -z ${SELFJNI+x} ]; then
echo "*********************[install-swig-on-pi.sh]*********************"
echo "NO JNI FOUND! NO POINT IN COMPILING SWIG ONLY FOR IT TO FAIL!"
echo "you could try running ./configure in $(pwd) yourself. If at the end it outputs:"
echo "'The SWIG test-suite and examples are configured for the following languages:'"
echo " java perl5"
echo "...then you're fine. You can then run the very time consuming command 'make' to compile swig."
echo "*****************************************************************"
exit 1
else
echo "passing include dir '$SELFJNI' to ./configure..."
sudo ./configure --with-javaincl=$SELFJNI
fi
fi
sudo make
echo "*********************[install-swig-on-pi.sh]*********************"
echo "COMPILATION DONE!!"
echo "*****************************************************************"
cd Examples/java/class && make check
echo "*********************[install-swig-on-pi.sh]*********************"
echo "CHECK DONE!!"
echo "*****************************************************************"
cd ../../../
sudo make install
set +e
source ~/.bashrc
/usr/local/bin/swig -version | grep "SWIG Version 4.1.1"
if [ $? -ne 0 ]; then
echo "*********************[install-swig-on-pi.sh]*********************"
echo "swig -version command didn't output expected info. Install probably failed 😣"
echo "*****************************************************************"
exit 1;
else
echo "*********************[install-swig-on-pi.sh]*********************"
echo "Install worked!!! 🔥🔥😀"
echo "*****************************************************************"
exit 0;
fi