File: autobuild

package info (click to toggle)
ball 1.4.3~beta1-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 318,984 kB
  • sloc: cpp: 346,579; ansic: 4,097; python: 2,664; yacc: 1,778; lex: 1,099; xml: 964; sh: 688; sql: 316; awk: 118; makefile: 108
file content (252 lines) | stat: -rwxr-xr-x 6,043 bytes parent folder | download | duplicates (6)
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
#!/bin/bash

#######################################
#### MODIFY THESE SETTINGS, IF DESIRED:
BUILD_VIEW=true
BUILD_PYTHON=true

#CDEBUG="Release"
CDEBUG="Debug"

CPYTHON="On"
#CPYTHON="Off"

CVIEW="On"
#CVIEW="Off"

CLPSOLVE="On"
#CLPSOLVE="Off"
#######################################

# ignore below

export BALL_PATH=`pwd | sed "s/source$//g"`
CDIR=""

export OS=`uname`

download()
{
	if [ -f /usr/bin/curl ]
	then 
		/usr/bin/curl $1 -o $2
	else
		wget $1
	fi
}

askContrib()
{
	cd $BALL_PATH
	echo 
	if [ "${BUILD_VIEW}" = "false" ]; then
		CONTRIB_PACKAGE="Contrib-noView"
		PREFIX="contrib-noview"
	else
		CONTRIB_PACKAGE="Contrib"
		PREFIX="contrib"
	fi
	echo This installer needs the Linux/Unix/MacOS $CONTRIB_PACKAGE package from the 
	echo BALL website: http://www.ballview.org/Downloads/Develop
	echo Have you already downloaded and installed this package?
	echo "(If a previous build of the contrib package failed, choose *No*)"
	OPTIONS="Yes No"
	select INST in $OPTIONS
	do
		if [ "$INST" = "Yes" ]; then
			echo Please enter the position of the contrib directory.
			echo "(Press Return for searching in "$BALL_PATH"/contrib)"
			read CDIR
			if [ "$CDIR" = "" ]; then
				export CDIR="$BALL_PATH/contrib"
			fi
			if [ -d "$CDIR" ]; then
				echo found package directory $CDIR ...
				export CDIR
				return 0
			else
				echo Could not find package directory!
				echo Aborting...
				exit 11
			fi
			else if [ "$INST" = "No" ]; then
				MAJOR_VERSION=`grep ^SET\(BALL_PACKAGE_VERSION_MAJOR "CMakeLists.txt" | sed 's/.*\"\([0-9]*\)\".*/\1/'`
				MINOR_VERSION=`grep ^SET\(BALL_PACKAGE_VERSION_MINOR "CMakeLists.txt" | sed 's/.*\"\([0-9]*\)\".*/\1/'`
				PATCH_VERSION=`grep ^SET\(BALL_PACKAGE_VERSION_PATCH "CMakeLists.txt" | sed 's/.*\"\([0-9]*\)\".*/\1/'`
				export VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}"

				echo Assuming version is: $VERSION ....
				if [ "$OS" != Darwin ]
				then
					PACKAGE=${PREFIX}"-"${VERSION}".tar.gz"
				else
					PACKAGE=${PREFIX}"-"${VERSION}"-darwin.tar.gz"
				fi
				echo Trying to download the current Contrib file: $PACKAGE
				URL=http://www.ballview.org/Downloads/Contrib/$PACKAGE
				echo from $URL ...
				echo
				rm -f $PACKAGE 
				download $URL $PACKAGE
				rm -rf contrib
				gunzip $PACKAGE 
				tar xf `basename $PACKAGE .gz`
				# rm $PACKAGE
				export CDIR="$BALL_PATH/contrib"
				cd $CDIR
				export BALL_BUILD_CONTRIB_CLEANUP="true"
				./build_contrib
				return $?
			fi
		fi
	done
}


automaticInstaller()
{
	echo 
	echo Running CMake ...
	cd $BALL_PATH
	mkdir build
	cd build
	touch config.lic
	if [ "${BUILD_VIEW}" = "true" ]; then
		CVIEW="On"
	else
		CVIEW="Off"
	fi

	cmake .. -DBALL_RELEASE_TYPE=$CDEBUG\
	         -DBALL_HAS_VIEW=$CVIEW\
	         -DBALL_PYTHON_SUPPOR=$CPYTHON\
	         -DUSE_LPSOLVE=$CLPSOLVE\
	         -DBALL_CONTRIB_PATH=$CDIR\
	         -DUSE_FIND_SIP_PY=Off\
	         -DSIP_EXECUTABLE="$CDIR/bin/sip"\
	         -DSIP_LIBRARY="$CDIR/lib/sip.so"\
	         -DSIP_INCLUDE_DIR="$CDIR/include" || exit
	make || exit
	cd $BALL_PATH

	LPATH="$BALL_PATH/build/lib/"

	LPATHN="LD_LIBRARY_PATH"
	if [ "$OS" == Darwin ] ; then
		LPATHN=DYLD_LIBRARY_PATH
	fi

	if test ${BUILD_VIEW} = true ; then
		SFILE="$BALL_PATH/build/bin/startBALLView"
		echo "#!/bin/bash" > $SFILE
		echo "PYTHONPATH=$LPATH:$CDIR/lib" >> $SFILE
		echo "export PYTHONPATH" >> $SFILE
		echo "BALL_DATA_PATH=$BALL_PATH/data" >> $SFILE
		echo "export BALL_DATA_PATH" >> $SFILE
		echo "$LPATHN=$LPATH" >> $SFILE
		echo "export $LPATHN" >> $SFILE
		echo "__GL_FSAA_MODE=6" >> $SFILE
		echo "export __GL_FSAA_MODE=6" >> $SFILE
		echo "export LANG=C" >> $SFILE
		echo "$BALL_PATH/build/bin/BALLView" >> $SFILE
		chmod +x $SFILE

		echo
		echo To start BALLView, just run $SFILE
		echo
	fi

	echo Build finished successfully!
}

customInstaller()
{
	cd $BALL_PATH
	echo
	echo Do you want to include visualization support in the library? This
	echo requires a functional OpenGL installation and will allow to build
	echo BALLView.
	echo
	OPTIONS="Yes No"
	select WITH_VIEW in $OPTIONS; do
		if [ "${WITH_VIEW}" = "Yes" ]; then
			export BUILD_VIEW=true
		elif [ "${WITH_VIEW}" = "No" ]; then
			export BUILD_VIEW=false
		fi
		break
	done
	echo ${BUILD_VIEW}
	askContrib 
	if test $? != 0; then
		echo "Autobuild aborted."
		exit
	fi
	BINDIR=$CDIR/bin
	INCDIR=$CDIR/include
	LIBDIR=$CDIR/lib
	automaticInstaller
}

if [ $# != 0 ] 
then
	if [ $1 == "--help" ]
	then
		echo Usage: either without any arguments or with the
		echo position of the contrib directory.
		exit 0
	fi

	CDIR=$1
	if [ ! -d $CDIR ]
	then 
		echo Could not find contrib directory $CDIR
		echo Aborting ...
		echo
		exit 22
	fi
	automaticInstaller
	exit $0
else
	echo
	echo This is the automatic BALL installer, using this script is
	echo only allowed if you have read and accepted the BALL licence
	echo file under BALL/source/.licence.
	echo 
	echo Please note that the build process of the contrib packages
	echo requires about 2Gb of disk space and can take several hours,
	echo depending on your machine. This is mostly due to compiling
	echo Qt. After compiling the contrib packages, you will be offered
	echo to clean object files and source directories, which will reduce
	echo the required disk space to ~250Mb.
	echo
	echo Furthermore, make sure that you have the following packages 
	echo installed on your machine:
	echo bison, flex, python, python-dev, libXmu-dev, libXi-dev, 
	echo libglu-dev, libx11-dev, autoconf, doxygen, tidy, dvipdf, latex, 
	echo wget *or* curl
	echo
	echo To proceed, please answer the following questions:
	echo "(Control-C will abort the installer.)"
	echo
	echo Which kind of installation do you want?
	OPTIONS="Automatic Custom"
	select INST in $OPTIONS; do
		if [ "$INST" = "Automatic" ]; then
			askContrib
			if test $? != 0; then
				echo "Autobuild aborted."
				exit
			fi
			BINDIR=$CDIR/bin
			INCDIR=$CDIR/include
			LIBDIR=$CDIR/lib
			automaticInstaller
		elif [ "$INST" = "Custom" ]; then
			customInstaller
		fi
		exit
	done
fi