setup.sh 4.44 KB
Newer Older
1
#!/bin/sh
Oliver Bock's avatar
Oliver Bock committed
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

### functions #######################################################

check_prerequisites()
{
	echo "Not yet implemented: check_prerequisites()"
	# wget
	# C compiler
	# lex or flex
	# yacc or bison or byacc
	# m4
}


prepare_generic()
{
	echo "Preparing source tree..." | tee -a setup.log
	mkdir -p 3rdparty/sdl >> setup.log
	mkdir -p 3rdparty/freetype2 >> setup.log
	mkdir -p 3rdparty/oglft >> setup.log
	mkdir -p 3rdparty/boinc >> setup.log
	
	echo "Preparing build tree..." | tee -a setup.log
	mkdir -p build/sdl >> setup.log
	mkdir -p build/freetype2 >> setup.log
	mkdir -p build/oglft >> setup.log
	mkdir -p build/boinc >> setup.log
	
	echo "Preparing install tree..." | tee -a setup.log
	mkdir -p install/bin >> setup.log
	mkdir -p install/include >> setup.log
	mkdir -p install/lib >> setup.log
	
	# prepare additional sources
	
	cd $ROOT
	cd 3rdparty/sdl
	if [ -d .svn ]; then
		echo "Updating SDL..." | tee -a ../../setup.log
		svn update >> ../../setup.log
	else
		echo "Retrieving SDL..." | tee -a ../../setup.log
		svn checkout http://svn.libsdl.org/branches/SDL-1.2 . >> ../../setup.log
	fi
	
	cd $ROOT
	cd 3rdparty/freetype2
	if [ -d CVS ]; then
		echo "Updating Freetype2..." | tee -a ../../setup.log
		cvs update >> ../../setup.log 2>&1
	else
		cd ..
		echo "Retrieving Freetype2..." | tee -a ../setup.log
		cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/freetype checkout -r VER-2-3-5-REAL freetype2 >> ../setup.log 2>&1
	fi
	
	cd $ROOT
	cd 3rdparty/oglft
	if [ -d .svn ]; then
		echo "Updating OGLFT..." | tee -a ../../setup.log
		svn update >> ../../setup.log
	else
		echo "Retrieving OGLFT..." | tee -a ../../setup.log
		svn checkout https://oglft.svn.sourceforge.net/svnroot/oglft/trunk . >> ../../setup.log
	fi
	
	cd $ROOT
	cd 3rdparty/boinc
	if [ -d .svn ]; then
		echo "Updating BOINC..." | tee -a ../../setup.log
		svn update >> ../../setup.log
	else
		echo "Retrieving BOINC..." | tee -a ../../setup.log
		svn checkout http://boinc.berkeley.edu/svn/trunk/boinc . >> ../../setup.log
	fi
}


prepare_win32()
{
	cd $ROOT
	mkdir -p 3rdparty/mingw/xscripts >> setup.log
	cd 3rdparty/mingw/xscripts

	if [ -d CVS ]; then
		echo "Updating MinGW build script..." | tee -a ../../../setup.log
		cvs update -C >> ../../../setup.log 2>&1
	else
		cd ..
		echo "Retrieving MinGW build script..." | tee -a ../../setup.log
		cvs -z3 -d:pserver:anonymous@mingw.cvs.sourceforge.net:/cvsroot/mingw checkout -P xscripts >> ../../setup.log 2>&1
	fi
	
	cd $ROOT
	cd 3rdparty/mingw/xscripts
	echo "Preparing MinGW build script..." | tee -a ../../../setup.log
	cp -f $ROOT/patches/x86-mingw32-build.sh.conf.patch . >> ../../../setup.log
	patch x86-mingw32-build.sh.conf < x86-mingw32-build.sh.conf.patch >> ../../../setup.log
	chmod +x x86-mingw32-build.sh >> ../../../setup.log
}


build_generic()
{
	echo "Not yet implemented: build_generic()"
}


build_linux()
{
	build_generic
	build_starsphere
}


build_mac()
{
	build_generic
	build_starsphere
}


build_win32()
{
	build_mingw
	build_generic
	build_starsphere
}


build_mingw()
{
	echo "Not yet implemented: build_mingw()"
}


build_starsphere()
{
	echo "Not yet implemented: build_starsphere()"
}


check_last_build()
{
	LASTBUILD=`cat .lastbuild`

	if [ "$LASTBUILD" != "$1" ]; then
		# TODO: clean build dirs when different target!
		echo "Not yet implemented: cleanup in check_lastbuild()"
	fi

	echo "$1" > .lastbuild
}

print_usage()
{
	cd $ROOT

	echo "*************************"
	echo "Usage: `basename $0` <target>"
	echo
	echo "Available targets:"
	echo "  --linux"
	echo "  --mac"
	echo "  --win32"
	echo "*************************"

	echo "Wrong usage. Stopping!" >> setup.log
}


### main control ####################################################

175
176
177
ROOT=`pwd`
DATE=`date`

Oliver Bock's avatar
Oliver Bock committed
178
179
180
181
182
TARGET=0
TARGET_LINUX=1
TARGET_MAC=2
TARGET_WIN32=3

183
184
185
186
187
echo "************************************" >> setup.log
echo "Starting new setup run!" >> setup.log
echo "$DATE" >> setup.log
echo "************************************" >> setup.log

Oliver Bock's avatar
Oliver Bock committed
188
# crude command line parsing :-)
189

Oliver Bock's avatar
Oliver Bock committed
190
191
192
if [ $# -ne 1 ]; then
  print_usage
  exit 1
193
194
fi

Oliver Bock's avatar
Oliver Bock committed
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
case "$1" in
	"--linux")
		TARGET=$TARGET_LINUX
		check_last_build "$1"
		echo "Building linux version:" | tee -a setup.log
		;;
	"--mac")
		TARGET=$TARGET_MAC
		check_last_build "$1"
		echo "Building mac version:" | tee -a setup.log
		;;
	"--win32")
			TARGET=$TARGET_WIN32
			check_last_build "$1"
			echo "Building win32 version:" | tee -a setup.log
			;;
	*)
			print_usage
			exit 1
			;;
esac
216

Oliver Bock's avatar
Oliver Bock committed
217
# here we go...
218

Oliver Bock's avatar
Oliver Bock committed
219
220
check_prerequisites
prepare_generic
221

Oliver Bock's avatar
Oliver Bock committed
222
exit 0