-
Notifications
You must be signed in to change notification settings - Fork 78
/
mkdist
203 lines (184 loc) · 5.26 KB
/
mkdist
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
#!/bin/sh
# to locate JRI the following sequence is used:
# - ${JRI}
# - ${ORGPATH}/rosuda/JRI (if ORGPATH is set)
# - ../../../org/rosuda/JRI
if [ "$1" = "-h" ]; then
echo ''
echo " Usage: $0 [-c|-h]"
echo ''
echo ' Options: -c clean dist (remove all generated files first)'
echo ' -h this help screen'
echo ''
exit 0
fi
SWD=`pwd`
echo "Removing previous dist ..."
rm -rf /tmp/rJava
mkdir /tmp/rJava
echo "Copying package base ..."
cp -r . /tmp/rJava
if [ -e "${SWD}/jri/mkdist" ]; then
JRI="${SWD}/jri"
rm -rf /tmp/rJava/jri
echo "Embedded JRI: ${JRI}"
fi
rm /tmp/rJava/mkdist
rm -f /tmp/rJava/*~ /tmp/rJava/R/*~ /tmp/rJava/src/*~ /tmp/rJava/man/*~
rm -rf /tmp/rJava/aclo* /tmp/rJava/autom*
## remove GH README
rm -f /tmp/rJava/README.md
cd /tmp/rJava
if [ "$1" = "-c" ]; then
rm -f configure tools/install-sh jri/configure
fi
if [ -e /tmp/rJava/configure ]; then
echo "Note: autoreconf is *not* ran automatically if configure exists."
echo " Run it manually if necessary."
else
echo "Running autoreconf ..."
autoreconf
rm -rf autom4te* acloc*
fi
if [ ! -e tools/install-sh ]; then
echo "Fetching install-sh ..."
ams=/usr/share/automake/install-sh
if [ ! -e $ams ]; then
ams=`ls /usr/share/automake*/install*sh|tail -n 1`
fi
if [ -z "$ams" -o ! -e "$ams" ]; then
echo "*** ERROR: install-sh is not present and I can't find it in /usr/share"
exit 2
fi
cp $ams tools/install-sh
fi
if [ ! -e tools/getsp.class ]; then
echo "Compiling getsp.class"
(cd tools && javac -target 1.2 -source 1.2 getsp.java)
fi
echo "Removing CVS/SVN and backup files ..."
rm -rf `find . -name CVS -or -name .svn -or -name \*~`
## since we merged JRI and rJava trees we no longer support ORG builds
if [ ! -e jri/configure ]; then
if [ -e "${SWD}/jri/mkdist" ]; then
DEFAULTJRI="${SWD}/jri"
fi
: ${JRI=$DEFAULTJRI}
if [ ! -e "$JRI" ]; then
echo "*** ERROR: JRI dist is not in the jri subdirectory and JRI env var is not set!"
echo " Please set JRI to point to JRI sources or unpack JRI dist into the jri directory"
echo ""
echo " When using GIT, don't forget to use git clone --recursive"
exit 1
fi
if [ -e $JRI/mkdist ]; then
echo "Building JRI dist to include ..."
rm -rf /tmp/JRI_*
mywd=`pwd`
cd $JRI
sh mkdist
cd /tmp/rJava
jf=`ls /tmp/JRI_*|sed -n -e 1p`;
if [ -z "$jf" -o ! -e "$jf" ]; then
echo "*** ERROR: Cannot get JRI distro!"
exit 1
fi
rm -rf jri JRI ${SWD}/JRI_*
#mkdir jri 2> /dev/null > /dev/null
cd /tmp/rJava
tar fvxz $jf
else
tar fxz $JRI
fi
if [ -e jri/JRI ]; then
rm -rf 1
mv jri 1
mv 1/JRI jri
rm -rf 1
fi
if [ ! -e jri/Makefile.in ]; then
if [ -e JRI/Makefile.in ]; then
mv JRI jri
else
echo "*** ERROR: jri is not correctly set up."
exit 1
fi
fi
if [ -e jri/Makefile.in -a -e JRI/Makefile.in ]; then
# case-insensitive fs - but we need lower case *sigh*
mv JRI 1
mv 1 jri
fi
fi
DEFAULTRENG="${SWD}/jri/REngine"
if [ ! -e "$DEFAULTRENG/Makefile" ]; then
echo "*** WARNING *** cannot find REngine sources, the distribution will NOT include REngine!"
else
(cd "$DEFAULTRENG"; make clean; make)
if [ ! -e "$DEFAULTRENG/REngine.jar" ]; then
echo "*** ERROR *** cannot compile REngine API"
exit 1
fi
(cd "$DEFAULTRENG/JRI" && make)
if [ ! -e "$DEFAULTRENG/JRI/JRIEngine.jar" ]; then
echo "*** ERROR *** cannot compile JRI part of the REngine API"
exit 1
fi
## create JRIEngine that contains really just the JRIEngine and not JRI since that will be installed separately
(cd "$DEFAULTRENG/JRI" && jar fc JRIEngine.jar org/rosuda/REngine/JRI)
mkdir -p /tmp/rJava/inst/jri 2>/dev/null
cp "$DEFAULTRENG/REngine.jar" "$DEFAULTRENG/JRI/JRIEngine.jar" /tmp/rJava/inst/jri
(cd "$DEFAULTRENG/JRI" && make clean)
fi
#cd ..
#echo "Updating INDEX ..."
# R CMD Rdindex rJava > rJava/INDEX
#echo "library(tools)\nsink(\"rJava/INDEX\")\nRdindex(\"rJava/man\")\nsink()" | R --vanilla > /dev/null
echo "Compile Java classes ..."
cd /tmp/rJava
mkdir -p inst/java/boot
# compile all java classes
cd src/java
make clean
make compile
# do not generate javadoc (see #303)
#echo "Generate javadoc documentation"
#make javadoc
cd ../..
echo "Copy compiled Java classes ..."
# copy all complied Java classes and sources
cp src/java/*.class inst/java
cp src/java/*.java inst/java
# move RJavaClassLoader into boot area since it will be loaded by the system class loader
mv inst/java/RJavaClassLoader* inst/java/boot
# move javadoc directory
mv src/java/javadoc inst/javadoc
echo "Updating version ..."
cd /tmp/rJava
VER=`sed -n -e 's/.*rJava v\([0-9.-]\{1,\}\).*/\1/p' src/rJava.h`
echo "rJava version ${VER}"
cat DESCRIPTION| sed "s/Version:.*/Version: ${VER}/" > d
mv d DESCRIPTION
rm -rf tests
if test -n "${OPTIMIZED}"; then
echo "Creating optimized sources ..."
echo '#define ONEFILE 1' > src/all
for f in `ls src/*.c`; do
echo "#line 1 \"$f\"" >> src/all
cat $f >> src/all
echo '' >> src/all
done
rm src/*.c
mv src/all src/rJava.c
fi
echo "Creating package ..."
cd ..
rm -f `find rJava -name ._\*`
rm -rf rJava/.git* rJava/jri/REngine/.git*
rm -f rJava/version
R CMD build rJava
cd ${SWD}
cp /tmp/rJava_${VER}.tar.gz ..
rm -rf /tmp/rJava
echo "Done."
ls -l ../rJava_${VER}.tar.gz