scummvm random work
[patches.git] / scummvm-cross-compile.patch
CommitLineData
6d7b707a
MF
1--- vanilla-20071026/configure 2007-10-26 01:46:59.000000000 -0400
2+++ scummvm-20071026/configure 2007-10-27 02:08:06.000000000 -0400
3@@ -240,34 +240,25 @@
4 #
5 find_type_with_size ()
6 {
7+for datatype in int short char long unknown; do
8 cat <<EOF >tmp_find_type_with_size.cpp
9-#include <stdio.h>
10-int main(int argc, char **argv)
11-{
12- int size = argv[1][0] - '0';
13- if (size == sizeof(int))
14- printf("int\n");
15- else if (size == sizeof(short))
16- printf("short\n");
17- else if (size == sizeof(char))
18- printf("char\n");
19- else if (size == sizeof(long))
20- printf("long\n");
21- else {
22- printf("unknown\n");
23- return 1;
24- }
25-
26+typedef $datatype ac__type_sizeof_;
27+int main() {
28+ static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) == $1)];
29+ test_array [0] = 0;
30 return 0;
31 }
32 EOF
33-if eval "$CXX $CXXFLAGS -o tmp_find_type_with_size$EXEEXT tmp_find_type_with_size.cpp"; then
34- datatype=`./tmp_find_type_with_size $1`
35+if ! $CXX $CXXFLAGS -o tmp_find_type_with_size$EXEEXT tmp_find_type_with_size.cpp 2>/dev/null; then
36 if test "$datatype" = "unknown"; then
37 echo "couldn't find data type with $1 bytes"
38 exit 1
39 fi
40+ continue
41+else
42+ break
43 fi
44+done
45 rm -f tmp_find_type_with_size$EXEEXT tmp_find_type_with_size.cpp
46 echo $datatype
47 }
48@@ -577,10 +568,14 @@
49 _host_cpu=i586
50 ;;
51 *)
52- guessed_host=`$_srcdir/config.guess`
53- _host_cpu=`echo $guessed_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
54- _host_os=`echo $guessed_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
55- _host_vendor=`echo $guessed_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
56+ if test -z "$_host"; then
57+ _host=`$_srcdir/config.guess`
58+ else
59+ _host=`$_srcdir/config.sub $_host`
60+ fi
61+ _host_cpu=`echo $_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
62+ _host_os=`echo $_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
63+ _host_vendor=`echo $_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
64 ;;
65 esac
66
67@@ -619,7 +614,7 @@
68 #
69 echo_n "Looking for C++ compiler... "
70 if test -n "$_host"; then
71- compilers="$CXX $_host_cpu-$_host_os-g++ $_host_cpu-$_host_os-c++"
72+ compilers="$CXX $_host_cpu-$_host_os-g++ $_host_cpu-$_host_os-c++ $_host-g++ $_host-c++"
73 else
74 compilers="$CXX g++ c++"
75 fi
76@@ -737,6 +732,108 @@
77 add_to_config_mk_if_no $_build_hq_scalers 'DISABLE_HQ_SCALERS = 1'
78 add_to_config_mk_if_no $_build_scalers 'DISABLE_SCALERS = 1'
79
80+#
81+# Check for endianness
82+#
83+echo_n "Checking endianness... "
84+cat <<EOF >tmp_endianness_check.cpp
85+short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
86+short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
87+void _ascii() { char* s = (char*) ascii_mm; s = (char*) ascii_ii; }
88+short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
89+short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
90+void _ebcdic() { char* s = (char*) ebcdic_mm; s = (char*) ebcdic_ii; }
91+int main() { _ascii (); _ebcdic (); return 0; }
92+EOF
93+$CXX $CXXFLAGS -c -o tmp_endianness_check.o tmp_endianness_check.cpp
94+if grep BIGenDianSyS tmp_endianness_check.o >/dev/null; then
95+ _endian=big
96+else
97+ _endian=little
98+fi
99+echo $_endian;
100+rm -f tmp_endianness_check.o tmp_endianness_check.cpp
101+
102+#
103+# Determine data type sizes
104+# TODO: proper error checking
105+# TODO: Actually, we should check individually for both signed & unsigned
106+# data types - there are systems on which the size of an unsigned int
107+# differs from that of a signed int!
108+# However, so far we haven't encountered one of those, so we can live with
109+# the limited check for now.
110+#
111+echo_n "Type with 1 byte... "
112+type_1_byte=`find_type_with_size 1`
113+echo "$type_1_byte"
114+
115+echo_n "Type with 2 bytes... "
116+type_2_byte=`find_type_with_size 2`
117+echo "$type_2_byte"
118+
119+echo_n "Type with 4 bytes... "
120+type_4_byte=`find_type_with_size 4`
121+echo "$type_4_byte"
122+
123+#
124+# Check whether we can use x86 asm routines
125+#
126+echo_n "Running on x86... "
127+case $_host_cpu in
128+ i386|i486|i586|i686)
129+ _have_x86=yes
130+ ;;
131+ *)
132+ _have_x86=no
133+ ;;
134+esac
135+echo "$_have_x86"
136+
137+#
138+# Determine build settings
139+#
140+# TODO - also add an command line option to override this?!?
141+echo_n "Checking hosttype... "
142+echo $_host_os
143+case $_host_os in
144+ linux* | uclinux* | openbsd* | freebsd* | netbsd* | bsd* | sunos* | hpux* | beos*)
145+ DEFINES="$DEFINES -DUNIX"
146+ ;;
147+ solaris*)
148+ DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
149+ ;;
150+ irix*)
151+ DEFINES="$DEFINES -DUNIX -DIRIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
152+ LIBS="$LIBS -lmd "
153+ _ranlib=:
154+ ;;
155+ darwin*)
156+ DEFINES="$DEFINES -DUNIX -DMACOSX"
157+ LIBS="$LIBS -framework QuickTime -framework AudioUnit -framework AudioToolbox -framework Carbon -framework CoreMIDI"
158+ ;;
159+ mingw*)
160+ DEFINES="$DEFINES -DWIN32"
161+ LIBS="$LIBS -lmingw32 -lwinmm"
162+ OBJS="$OBJS scummvmico.o"
163+ ;;
164+ cygwin*)
165+ DEFINES="$DEFINES -mno-cygwin -DWIN32"
166+ LIBS="$LIBS -mno-cygwin -lmingw32 -lwinmm"
167+ OBJS="$OBJS scummvmico.o"
168+ ;;
169+ os2-emx*)
170+ DEFINES="$DEFINES -DUNIX"
171+ ;;
172+ mint*)
173+ DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
174+ ;;
175+ # given this is a shell script assume some type of unix
176+ *)
177+ echo "WARNING: could not establish system type, assuming unix like"
178+ DEFINES="$DEFINES -DUNIX"
179+ ;;
180+esac
181+
182 if test -n "$_host"; then
183 # Cross-compiling mode - add your target here if needed
184 case "$_host" in
185@@ -762,6 +859,9 @@
186 add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1'
187 add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1'
188 ;;
189+ bfin*)
190+ _need_memalign=yes
191+ ;;
192 gp2x)
193 echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
194 DEFINES="$DEFINES -DUNIX -DGP2X -DUSE_ARM_SOUND_ASM -DUSE_ARM_SMUSH_ASM"
195@@ -813,97 +913,12 @@
196 OBJS="$OBJS scummvmico.o"
197 ;;
198 *)
199- echo "Cross-compiling to unknown target $_host, please add your target to configure."
200- exit 1
201+ echo "Continuing with auto-detected values ... if you have problems, please add your target to configure."
202 ;;
203 esac
204
205 else
206 #
207- # Determine build settings
208- #
209- # TODO - also add an command line option to override this?!?
210- echo_n "Checking hosttype... "
211- echo $_host_os
212- case $_host_os in
213- linux* | openbsd* | freebsd* | netbsd* | bsd* | sunos* | hpux* | beos*)
214- DEFINES="$DEFINES -DUNIX"
215- ;;
216- solaris*)
217- DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
218- ;;
219- irix*)
220- DEFINES="$DEFINES -DUNIX -DIRIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
221- LIBS="$LIBS -lmd "
222- _ranlib=:
223- ;;
224- darwin*)
225- DEFINES="$DEFINES -DUNIX -DMACOSX"
226- LIBS="$LIBS -framework QuickTime -framework AudioUnit -framework AudioToolbox -framework Carbon -framework CoreMIDI"
227- ;;
228- mingw*)
229- DEFINES="$DEFINES -DWIN32"
230- LIBS="$LIBS -lmingw32 -lwinmm"
231- OBJS="$OBJS scummvmico.o"
232- ;;
233- cygwin*)
234- DEFINES="$DEFINES -mno-cygwin -DWIN32"
235- LIBS="$LIBS -mno-cygwin -lmingw32 -lwinmm"
236- OBJS="$OBJS scummvmico.o"
237- ;;
238- os2-emx*)
239- DEFINES="$DEFINES -DUNIX"
240- ;;
241- mint*)
242- DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
243- ;;
244- # given this is a shell script assume some type of unix
245- *)
246- echo "WARNING: could not establish system type, assuming unix like"
247- DEFINES="$DEFINES -DUNIX"
248- ;;
249- esac
250-
251- #
252- # Check for endianness
253- #
254- echo_n "Checking endianness... "
255- cat <<EOF >tmp_endianness_check.cpp
256-#include <stdio.h>
257-#include <stdlib.h>
258-int main(int argc, char **argv)
259-{
260- unsigned int data = 0x01234567;
261- char *ptr = (char *)&data;
262- if (ptr[0] == 0x01 && ptr[1] == 0x23 && ptr[2] == 0x45 && ptr[3] == 0x67)
263- printf("big\n");
264- else if (ptr[3] == 0x01 && ptr[2] == 0x23 && ptr[1] == 0x45 && ptr[0] == 0x67)
265- printf("little\n");
266- else
267- printf("unknown\n");
268- return 0;
269-}
270-EOF
271- $CXX $CXXFLAGS -o tmp_endianness_check$EXEEXT tmp_endianness_check.cpp
272- _endian=`./tmp_endianness_check`
273- echo $_endian;
274- rm -f tmp_endianness_check$EXEEXT tmp_endianness_check.cpp
275-
276- #
277- # Check whether we can use x86 asm routines
278- #
279- echo_n "Running on x86... "
280- case $_host_cpu in
281- i386|i486|i586|i686)
282- _have_x86=yes
283- ;;
284- *)
285- _have_x86=no
286- ;;
287- esac
288- echo "$_have_x86"
289-
290- #
291 # Check whether memory alignment is required
292 #
293 echo_n "Alignment required... "
294@@ -949,28 +964,6 @@
295 ;;
296 esac
297 echo "$_need_memalign"
298-
299- #
300- # Determine data type sizes
301- # TODO: proper error checking
302- # TODO: Actually, we should check individually for both signed & unsigned
303- # data types - there are systems on which the size of an unsigned int
304- # differs from that of a signed int!
305- # However, so far we haven't encountered one of those, so we can live with
306- # the limited check for now.
307- #
308- echo_n "Type with 1 byte... "
309- type_1_byte=`find_type_with_size 1`
310- echo "$type_1_byte"
311-
312- echo_n "Type with 2 bytes... "
313- type_2_byte=`find_type_with_size 2`
314- echo "$type_2_byte"
315-
316- echo_n "Type with 4 bytes... "
317- type_4_byte=`find_type_with_size 4`
318- echo "$type_4_byte"
319-
320 fi
321
322 #