[Scummvm-cvs-logs] scummvm-tools master -> e3fad4057d13bdb28cded41109f864ed0b5d7b38

lordhoto lordhoto at gmail.com
Tue Jun 21 18:11:31 CEST 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm-tools' repo located at https://github.com/scummvm/scummvm-tools .

Summary:
e3fad4057d TOOLS: Update build system with changes from ScummVM's main repo.


Commit: e3fad4057d13bdb28cded41109f864ed0b5d7b38
    https://github.com/scummvm/scummvm-tools/commit/e3fad4057d13bdb28cded41109f864ed0b5d7b38
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-06-21T09:08:52-07:00

Commit Message:
TOOLS: Update build system with changes from ScummVM's main repo.

This should get rid of tons of warnings about incorrect compiler parameters in
recent g++ versions. Also recent MinGW g++ versions should work fine again now.
I only tested this on my Linux box though.

Changed paths:
    Makefile
    common/scummsys.h
    configure



diff --git a/Makefile b/Makefile
index 7201c50..34f2ced 100644
--- a/Makefile
+++ b/Makefile
@@ -26,23 +26,24 @@ NO_MAIN     := -DEXPORT_MAIN
 -include config.mk
 
 ifeq "$(HAVE_GCC)" "1"
-	# Additional warnings
 	CXXFLAGS:= -Wall $(CXXFLAGS)
 	# Turn off some annoying and not-so-useful warnings
 	CXXFLAGS+= -Wno-long-long -Wno-multichar -Wno-unknown-pragmas -Wno-reorder
 	# Enable even more warnings...
-	#CXXFLAGS+= -pedantic	# -pedantic is too pedantic, at least on Mac OS X
-	CXXFLAGS+= -Wpointer-arith -Wcast-align
-	CXXFLAGS+= -Wshadow -Wimplicit -Wundef -Wnon-virtual-dtor -Wwrite-strings
-
-	# Enable checking of pointers returned by "new"
+	CXXFLAGS+= -Wpointer-arith -Wcast-qual
+	CXXFLAGS+= -Wshadow -Wnon-virtual-dtor -Wwrite-strings
+
+	# Currently we disable this gcc flag, since it will also warn in cases,
+	# where using GCC_PRINTF (means: __attribute__((format(printf, x, y))))
+	# is not possible, thus it would fail compiliation with -Werror without
+	# being helpful.
+	#CXXFLAGS+= -Wmissing-format-attribute
+
+ifneq "$(HAVE_CLANG)" "1"
+	# enable checking of pointers returned by "new", but only when we do not
+	# build with clang
 	CXXFLAGS+= -fcheck-new
-
-	# There is a nice extra warning that flags variables that are potentially
-	# used before being initialized. Very handy to catch a certain kind of
-	# bugs. Unfortunately, it only works when optimizations are turned on,
-	# which is why we normally don't use it.
-	#CXXFLAGS+= -O -Wuninitialized
+endif
 endif
 
 ifeq "$(HAVE_CLANG)" "1"
diff --git a/common/scummsys.h b/common/scummsys.h
index a501ca9..164d42c 100644
--- a/common/scummsys.h
+++ b/common/scummsys.h
@@ -214,7 +214,7 @@
 
 	#define PLUGIN_EXPORT __declspec(dllexport)
 
-#elif defined(UNIX)
+#elif defined(POSIX)
 
 	#define scumm_stricmp strcasecmp
 	#define scumm_strnicmp strncasecmp
diff --git a/configure b/configure
index 119b7cb..d54f0ae 100755
--- a/configure
+++ b/configure
@@ -20,8 +20,6 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #
-# $URL$
-# $Id$
 
 # Save the current environment variables for next runs
 SAVED_CONFIGFLAGS=$@
@@ -108,16 +106,28 @@ fi
 TMPC=${TMPO}.cpp
 TMPLOG=config.log
 
-cc_check() {
+cc_check_no_clean() {
 	echo >> "$TMPLOG"
 	cat "$TMPC" >> "$TMPLOG"
 	echo >> "$TMPLOG"
-	echo "$CXX $TMPC -o $TMPO$HOSTEXEEXT $@" >> "$TMPLOG"
+	echo "$CXX $LDFLAGS $CXXFLAGS $TMPC -o $TMPO$HOSTEXEEXT $@" >> "$TMPLOG"
 	rm -f "$TMPO$HOSTEXEEXT"
 	( $CXX $LDFLAGS $CXXFLAGS "$TMPC" -o "$TMPO$HOSTEXEEXT" "$@" ) >> "$TMPLOG" 2>&1
-	TMP="$?"
+	TMPR="$?"
+	echo "return code: $TMPR" >> "$TMPLOG"
 	echo >> "$TMPLOG"
-	return "$TMP"
+	return "$TMPR"
+}
+
+cc_check_clean() {
+	rm -rf $TMPC $TMPO $TMPO.o $TMPO.dSYM $TMPO$HOSTEXEEXT "$@"
+}
+
+cc_check() {
+	cc_check_no_clean "$@"
+	TMPR="$?"
+	cc_check_clean
+	return "$TMPR"
 }
 
 cc_check_define() {
@@ -134,11 +144,7 @@ EOF
 }
 
 gcc_get_define() {
-	# Note: The AmigaOS compiler doesn't like the "-" input file, so a real file
-	# is used instead
-	touch $TMPC
-	$CXX -dM -E $TMPC | fgrep "$1" | head -n1 | cut -d ' ' -f 3-
-	rm -f $TMPC
+	echo "" | $CXX -dM -E - | fgrep "$1" | head -n1 | cut -d ' ' -f 3-
 }
 
 #
@@ -164,6 +170,10 @@ add_line_to_config_h() {
 '"$1"
 }
 
+# Conditionally add a line of data to config.h. Takes two parameters:
+# The first one can be set to 'no' to "comment out" the line, i.e.
+# make it ineffective, use 'yes' otherwise.
+# The second param is the line to insert.
 add_to_config_h_if_yes() {
 	if test "$1" = yes ; then
 		add_line_to_config_h "$2"
@@ -184,15 +194,28 @@ add_to_config_mk_if_yes() {
 	fi
 }
 
-# Conditionally add a line of data to config.mk. Takes two parameters:
-# The first one can be set to 'yes' to "comment out" the line, i.e.
-# make it ineffective, use 'no' otherwise.
-# The second param is the line to insert.
-add_to_config_mk_if_no() {
-	if test "$1" = no ; then
-		add_line_to_config_mk "$2"
+# Conditionally add a '#define' line to config.h. Takes two parameters:
+# The first one can be set to 'yes' or 'no'. If 'yes' is used, then
+# the line "#define $2" is added to config.h, otherwise "#undef $2".
+define_in_config_h_if_yes() {
+	if test "$1" = yes ; then
+		add_line_to_config_h "#define $2"
 	else
-		add_line_to_config_mk "# $2"
+		add_line_to_config_h "#undef $2"
+	fi
+}
+
+# Conditionally add definitions to config.h and config.mk. Takes two parameters:
+# The first one can be set to 'yes' or 'no'. If 'yes' is used, then
+# the line "#define $2" is added to config.h and "$2 = 1" to config.mk.
+# Otherwise "#undef $2" is added to config.h and "# $2 = 1" to config.mk
+define_in_config_if_yes() {
+	if test "$1" = yes ; then
+		add_line_to_config_h "#define $2"
+		add_line_to_config_mk "$2 = 1"
+	else
+		add_line_to_config_h "#undef $2"
+		add_line_to_config_mk "# $2 = 1"
 	fi
 }
 
@@ -466,7 +489,8 @@ fi
 if test "$_release_build" = yes; then
 	# Release mode enabled: enable optimizations. This also
 	# makes it possible to use -Wuninitialized, so let's do that.
-	CXXFLAGS="$CXXFLAGS -O2 -Wuninitialized"
+	CXXFLAGS="$CXXFLAGS -O2"
+	CXXFLAGS="$CXXFLAGS -Wuninitialized"
 fi
 
 
@@ -491,7 +515,9 @@ test_compiler() {
 	}
 EOF
 
-	eval "$1 $CXXFLAGS $LDFLAGS -o tmp_cxx_compiler$HOSTEXEEXT tmp_cxx_compiler.cpp" 2> /dev/null && eval "./tmp_cxx_compiler$HOSTEXEEXT 2> /dev/null" && rm -rf tmp_cxx_compiler$HOSTEXEEXT tmp_cxx_compiler.dSYM tmp_cxx_compiler.cpp
+	echo "testing compiler: $1" >> "$TMPLOG"
+
+	eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO$HOSTEXEEXT tmp_cxx_compiler.cpp" 2> /dev/null && eval "$TMPO$HOSTEXEEXT 2> /dev/null" && cc_check_clean tmp_cxx_compiler.cpp
 }
 
 # Prepare a list of candidates for the C++ compiler
@@ -505,9 +531,12 @@ else
 	CXX=
 	for compiler in $compilers; do
 		if test_compiler $compiler; then
+			echo "success testing compiler: $compiler" >> "$TMPLOG"
 			CXX=$compiler
 			echo $CXX
 			break
+		else
+			echo "failure testing compiler: $compiler" >> "$TMPLOG"
 		fi
 	done
 fi
@@ -561,11 +590,12 @@ else
 		cxx_verc_fail=yes
 		echo found non-gcc compiler version ${cxx_version}
 	fi
+
 	case $_host_os in
 		irix*)
 			case $cxx_version in
 				7.4.4*)
-					# We just assume this is SGI MIPSPro
+					# We just assume this is SGI MIPSpro
 					_cxx_major=7
 					_cxx_minor=4
 					cxx_verc_fail=no
@@ -583,7 +613,6 @@ else
 			cxx_verc_fail=yes
 			;;
 	esac
-
 fi
 
 echo "$cxx_version"
@@ -596,33 +625,90 @@ if test "$cxx_verc_fail" = yes ; then
 fi
 
 #
+# Setup compiler specific CXXFLAGS now that we know the compiler version.
+# Foremost, this means enabling various warnings.
+# In addition, we set CXX_UPDATE_DEP_FLAG for GCC >= 3.0 and for ICC.
+#
+if test "$have_gcc" = yes ; then
+	if test "$_cxx_major" -ge "3" ; then
+		case $_host_os in
+		# newlib-based system include files suppress non-C89 function
+		# declarations under __STRICT_ANSI__
+		amigaos* | android | dreamcast | ds | gamecube | mingw* | n64 | psp | ps2 | wii | wince )
+			;;
+		*)
+			CXXFLAGS="$CXXFLAGS -ansi"
+			;;
+		esac
+		CXXFLAGS="$CXXFLAGS -W -Wno-unused-parameter"
+		add_line_to_config_mk 'HAVE_GCC3 = 1'
+		add_line_to_config_mk 'CXX_UPDATE_DEP_FLAG = -MMD -MF "$(*D)/$(DEPDIR)/$(*F).d" -MQ "$@" -MP'
+	fi;
+
+	if test "$_cxx_major" -eq 4 && test "$_cxx_minor" -ge 3 || \
+	   test "$_cxx_major" -gt 4 ; then
+		CXXFLAGS="$CXXFLAGS -Wno-empty-body"
+	else
+		CXXFLAGS="$CXXFLAGS -Wconversion"
+	fi;
+fi;
+
+# By default, we add -pedantic to the CXXFLAGS to catch some potentially
+# non-portable constructs, like use of GNU extensions.
+# However, some platforms use GNU extensions in system header files, so
+# for these we must not use -pedantic.
+case $_host_os in
+android | gamecube | psp | wii)
+	;;
+*)
+	# ICC does not support pedantic, while GCC and clang do.
+	if test "$have_icc" = no ; then
+		CXXFLAGS="$CXXFLAGS -pedantic"
+	fi
+	;;
+esac
+#
 # Check for endianness
 #
 echo_n "Checking endianness... "
-cat <<EOF >tmp_endianness_check.cpp
-short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
-short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
+cat > tmp_endianness_check.cpp << EOF
+unsigned short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
+unsigned short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
 void _ascii() { char* s = (char*) ascii_mm; s = (char*) ascii_ii; }
-short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
-short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
+unsigned short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
+unsigned short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
 void _ebcdic() { char* s = (char*) ebcdic_mm; s = (char*) ebcdic_ii; }
 int main() { _ascii (); _ebcdic (); return 0; }
 EOF
-$CXX $CXXFLAGS -c -o tmp_endianness_check.o tmp_endianness_check.cpp
-if strings tmp_endianness_check.o | grep BIGenDianSyS >/dev/null; then
+$CXX $CXXFLAGS -c -o $TMPO.o tmp_endianness_check.cpp
+if strings $TMPO.o | grep BIGenDianSyS >/dev/null; then
 	_endian=big
-else
+elif strings $TMPO.o | grep LiTTleEnDian >/dev/null; then
 	_endian=little
 fi
 echo $_endian;
-rm -f tmp_endianness_check.o tmp_endianness_check.cpp
+cc_check_clean tmp_endianness_check.cpp
+
+case $_endian in
+	big)
+		add_line_to_config_h '#undef SCUMM_LITTLE_ENDIAN'
+		add_line_to_config_h '#define SCUMM_BIG_ENDIAN'
+		;;
+	little)
+		add_line_to_config_h '#define SCUMM_LITTLE_ENDIAN'
+		add_line_to_config_h '#undef SCUMM_BIG_ENDIAN'
+		;;
+	*)
+		exit 1
+		;;
+esac
 
 #
 # Determine a data type with the given length
 #
 find_type_with_size() {
 	for datatype in int short char long unknown; do
-	cat <<EOF >tmp_find_type_with_size.cpp
+		cat > tmp_find_type_with_size.cpp << EOF
 typedef $datatype ac__type_sizeof_;
 int main() {
 	static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) == $1)];
@@ -630,17 +716,17 @@ int main() {
 	return 0;
 }
 EOF
-	if $CXX $CXXFLAGS -c -o tmp_find_type_with_size$HOSTEXEEXT tmp_find_type_with_size.cpp 2>/dev/null ; then
-		break
-	else
-		if test "$datatype" = "unknown"; then
-			echo "couldn't find data type with $1 bytes"
-			exit 1
+		if $CXX $CXXFLAGS -c -o $TMPO.o tmp_find_type_with_size.cpp 2>/dev/null ; then
+			break
+		else
+			if test "$datatype" = "unknown"; then
+				echo "couldn't find data type with $1 bytes"
+				exit 1
+			fi
+			continue
 		fi
-		continue
-	fi
 	done
-	rm -f tmp_find_type_with_size$HOSTEXEEXT tmp_find_type_with_size.cpp
+	cc_check_clean tmp_find_type_with_size.cpp
 	echo $datatype
 }
 
@@ -649,21 +735,65 @@ EOF
 #
 echo_n "Type with 1 byte... "
 type_1_byte=`find_type_with_size 1`
-TMP="$?"
+TMPR="$?"
 echo "$type_1_byte"
-test $TMP -eq 0 || exit 1	# check exit code of subshell
+test $TMPR -eq 0 || exit 1	# check exit code of subshell
 
 echo_n "Type with 2 bytes... "
 type_2_byte=`find_type_with_size 2`
-TMP="$?"
+TMPR="$?"
 echo "$type_2_byte"
-test $TMP -eq 0 || exit 1	# check exit code of subshell
+test $TMPR -eq 0 || exit 1	# check exit code of subshell
 
 echo_n "Type with 4 bytes... "
 type_4_byte=`find_type_with_size 4`
-TMP="$?"
+TMPR="$?"
 echo "$type_4_byte"
-test $TMP -eq 0 || exit 1	# check exit code of subshell
+test $TMPR -eq 0 || exit 1	# check exit code of subshell
+
+#
+# Check whether memory alignment is required
+#
+# For some CPU types, unaligned memory access is either not supported at
+# all (and so leads to a crash), requires a super-slow emulation via an
+# exception handler, or just results in incorrect results.
+# On the other hand, accessing data in a manner that works regardless of
+# alignment can be a lot slower than regular access, so we don't want
+# to use it if we don't have to.
+#
+# So we do the following: For CPU families where we know whether unaligned
+# access is safe & fast, we enable / disable unaligned access accordingly.
+# Otherwise, we just disable memory alignment.
+#
+# NOTE: In the past, for non-cross compiled builds, we would also run some code
+# which would try to test whether unaligned access worked or not. But this test
+# could not reliably determine whether unaligned access really worked in all
+# situations (and across different implementations of the target CPU arch), nor
+# whether it was fast (as opposed to slowly emulated by fault handlers). Hence,
+# we do not use this approach anymore.
+#
+# NOTE: The only kinds of unaligned access we allow are for 2 byte and 4
+# byte loads / stores. No promises are made for bigger sizes, such as 8
+# or 16 byte loads, for which architectures may behave differently than
+# for the smaller sizes.
+echo_n "Alignment required... "
+case $_host_cpu in
+	i[3-6]86 | x86_64 | ppc*)
+		# Unaligned access should work
+		_need_memalign=no
+		;;
+	alpha* | arm* | bfin* | hp* | mips* | sh* | sparc* | ia64 | nv1*)
+		# Unaligned access is not supported or extremely slow.
+		_need_memalign=yes
+		;;
+	*)
+		# Status of unaligned access is unknown, so assume the worst.
+		_need_memalign=yes
+		;;
+esac
+echo "$_need_memalign"
+
+define_in_config_h_if_yes $_need_memalign 'SCUMM_NEED_ALIGNMENT'
 
 #
 # Determine build settings
@@ -671,139 +801,107 @@ test $TMP -eq 0 || exit 1	# check exit code of subshell
 echo_n "Checking hosttype... "
 echo $_host_os
 case $_host_os in
-	linux* | uclinux* | openbsd* | netbsd* | bsd* | sunos* | hpux*)
-		DEFINES="$DEFINES -DUNIX"
-		;;
-	freebsd*)
-		DEFINES="$DEFINES -DUNIX"
-		LDFLAGS="$LDFLAGS -L/usr/local/lib"
-		CXXFLAGS="$CXXFLAGS -I/usr/local/include"
+	amigaos*)
+		LDFLAGS="$LDFLAGS -use-dynld"
+		LDFLAGS="$LDFLAGS -L/sdk/local/newlib/lib"
+		# We have to use 'long' for our 4 byte typedef because AmigaOS already typedefs (u)int32
+		# as (unsigned) long, and consequently we'd get a compiler error otherwise.
+		type_4_byte='long'
+		add_line_to_config_mk 'AMIGAOS = 1'
 		;;
 	beos*)
-		DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
+		DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE"
 		# Needs -lbind -lsocket for the timidity MIDI driver
 		LDFLAGS="-L/boot/home/config/lib"
 		CFLAGS="-I/boot/home/config/include"
 		CXXFLAGS="$CXXFLAGS -fhuge-objects"
 		LIBS="$LIBS -lbind -lsocket"
-		# FIXME: Please document why 'long' has to be used instead of int
-		#type_4_byte='long'
+		_seq_midi=no
+		;;
+	cygwin*)
+		echo ERROR: Cygwin building is not supported by ScummVM anymore. Consider using MinGW.
+		exit 1
+		;;
+	darwin*)
+		DEFINES="$DEFINES -DMACOSX"
+		LIBS="$LIBS -framework AudioUnit -framework AudioToolbox -framework Carbon -framework CoreMIDI"
+		add_line_to_config_mk 'MACOSX = 1'
+		;;
+	freebsd*)
+		LDFLAGS="$LDFLAGS -L/usr/local/lib"
+		CXXFLAGS="$CXXFLAGS -I/usr/local/include"
 		;;
 	haiku*)
-		DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
+		DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE"
 		# Needs -lnetwork for the timidity MIDI driver
 		LIBS="$LIBS -lnetwork"
-		CXXFLAGS="$CXXFLAGS -fhuge-objects"
-		# FIXME: Please document why 'long' has to be used instead of int
-		#type_4_byte='long'
-		;;
-	solaris*)
-		DEFINES="$DEFINES -DUNIX -DSOLARIS -DSYSTEM_NOT_SUPPORTING_D_TYPE"
-		# Needs -lbind -lsocket for the timidity MIDI driver
-		LIBS="$LIBS -lnsl -lsocket"
+		_seq_midi=no
 		;;
 	irix*)
-		DEFINES="$DEFINES -DUNIX -DIRIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
+		DEFINES="$DEFINES -DIRIX"
+		DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE"
 		LIBS="$LIBS -lmd -lfastm -lm"
 		_ranlib=:
 		;;
-	darwin*)
-		DEFINES="$DEFINES -DUNIX -DMACOSX"
-		LIBS="$LIBS -framework AudioUnit -framework AudioToolbox -framework Carbon -framework CoreMIDI"
-		add_line_to_config_mk 'MACOSX = 1'
+	linux* | uclinux*)
+		# When not cross-compiling, enable large file support, but don't
+		# care if getconf doesn't exist or doesn't recognize LFS_CFLAGS.
+		if test -z "$_host"; then
+			CXXFLAGS="$CXXFLAGS $(getconf LFS_CFLAGS 2>/dev/null)"
+		fi
 		;;
 	mingw*)
-		DEFINES="$DEFINES -DWIN32 -D__USE_MINGW_ANSI_STDIO=0"
-		LIBS="$LIBS -lmingw32"
-		;;
-	cygwin*)
-		echo ERROR: Cygwin building is not supported by ScummVM anymore. Consider using MinGW.
-		exit 1
-		;;
-	os2-emx*)
-		DEFINES="$DEFINES -DUNIX"
+		DEFINES="$DEFINES -DWIN32"
+		DEFINES="$DEFINES -D__USE_MINGW_ANSI_STDIO=0"
+		LIBS="$LIBS -lmingw32 -lwinmm"
+		OBJS="$OBJS scummvmwinres.o"
+		add_line_to_config_mk 'WIN32 = 1'
 		;;
 	mint*)
-		DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
+		DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE"
 		;;
-	amigaos*)
-		CXXFLAGS="$CXXFLAGS -mcrt=newlib -mstrict-align -mcpu=750 -mtune=7400"
-		LDFLAGS="$LDFLAGS -mcrt=newlib -use-dynld -Lsobjs:"
-		# We have to use 'long' for our 4 byte typedef because AmigaOS already typedefs (u)int32
-		# as (unsigned) long, and consequently we'd get a compiler error otherwise.
-		type_4_byte='long'
-		;;
-	# given this is a shell script assume some type of unix
-	*)
-		echo "WARNING: could not establish system type, assuming unix like"
-		DEFINES="$DEFINES -DUNIX"
+	solaris*)
+		DEFINES="$DEFINES -DSOLARIS"
+		DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE"
+		# Needs -lbind -lsocket for the timidity MIDI driver
+		LIBS="$LIBS -lnsl -lsocket"
 		;;
 esac
 
 #
-# Check whether memory alignment is required
-#
-echo_n "Alignment required... "
-case $_host_cpu in
-	alpha*)
-		# Hardcode alignment requirements for Alpha processsors
-		_need_memalign=yes
-		;;
-	arm*)
-		_need_memalign=yes
-		;;
-	mips*)
-		# Hardcode alignment requirements for MIPS processsors.
-		# While these can emulate unaligned memory access, this
-		# emulation is rather slow.
-		_need_memalign=yes
-		;;
-	sh*)
-		# Hardcode alignment requirements for SH processsors.
-		# While these can emulate unaligned memory access, this
-		# emulation is rather slow.
-		_need_memalign=yes
-		;;
-	*)
-		# Try to auto-detect....
-		cat > $TMPC << EOF
-#include <stdlib.h>
-#include <signal.h>
-int main(int argc, char **argv) {
-	unsigned char test[8] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 };
-	signal(SIGBUS, exit);
-	signal(SIGABRT, exit);
-	signal(SIGSEGV, exit);
-	if (*((unsigned int *)(test + 1)) != 0x55443322 && *((unsigned int *)(test + 1)) != 0x22334455) {
-		return 1;
-	}
-	return 0;
-}
-EOF
-		_need_memalign=yes
-		cc_check && $TMPO$HOSTEXEEXT && _need_memalign=no
-		;;
-esac
-echo "$_need_memalign"
-
+# Determine whether host is POSIX compliant, or at least POSIX
+# compatible enough to support our POSIX code (including dlsym(),
+# mkdir() and some other APIs).
 #
-# Add the results of the above checks to config.h
+# TODO: Instead of basing this on the host name, we should really base
+# this on the presence of features (such as the dlsym and mkdir APIs).
 #
-case $_endian in
-	big)
-		add_line_to_config_h '/* #define SCUMM_LITTLE_ENDIAN */'
-		add_line_to_config_h '#define SCUMM_BIG_ENDIAN'
+echo_n "Checking if host is POSIX compliant... "
+case $_host_os in
+	amigaos* | cygwin* | dreamcast | ds | gamecube | mingw* | n64 | ps2 | psp | wii | wince)
+		_posix=no
 		;;
-	little)
-		add_line_to_config_h '#define SCUMM_LITTLE_ENDIAN'
-		add_line_to_config_h '/* #define SCUMM_BIG_ENDIAN */'
+	android | beos* | bsd* | darwin* | freebsd* | gph-linux | haiku* | hpux* | iphone | irix* | linux* | mint* | netbsd* | openbsd* | solaris* | sunos* | uclinux* | webos)
+		_posix=yes
+		;;
+	os2-emx*)
+		_posix=yes	# FIXME: Really???
 		;;
 	*)
-		exit 1
+		# given this is a shell script, we might assume some type of posix.
+		# However, the host system might be a totally different one, so
+		# we can assume nothing about it.
+		# Indeed, as mentioned further above, we really should test for the
+		# presences of relevant APIs on the host anyway...
+		_posix=no
 		;;
 esac
+echo $_posix
 
-add_to_config_h_if_yes $_need_memalign '#define SCUMM_NEED_ALIGNMENT'
+if test "$_posix" = yes ; then
+	DEFINES="$DEFINES -DPOSIX"
+	add_line_to_config_mk 'POSIX = 1'
+fi
 
 #
 # Check whether to enable a verbose build
@@ -834,13 +932,10 @@ EOF
 		-lvorbisfile -lvorbis -logg && _vorbis=yes
 fi
 if test "$_vorbis" = yes ; then
-	_def_vorbis='#define USE_VORBIS'
 	LIBS="$LIBS $OGG_LIBS $VORBIS_LIBS -lvorbisfile -lvorbis -lvorbisenc -logg"
 	INCLUDES="$INCLUDES $OGG_CFLAGS $VORBIS_CFLAGS"
-else
-	_def_vorbis='#undef USE_VORBIS'
 fi
-add_to_config_mk_if_yes "$_vorbis" 'USE_VORBIS = 1'
+define_in_config_if_yes "$_vorbis" 'USE_VORBIS'
 echo "$_vorbis"
 
 #
@@ -853,19 +948,19 @@ if test "$_tremor" = auto ; then
 #include <tremor/ivorbiscodec.h>
 int main(void) { vorbis_info_init(0); return 0; }
 EOF
-	cc_check $TREMOR_CFLAGS $TREMOR_LIBS -lvorbisienc && \
+	cc_check $TREMOR_CFLAGS $TREMOR_LIBS -lvorbisidec && \
 	_tremor=yes
 fi
 if test "$_tremor" = yes && test "$_vorbis" = no; then
-	_def_tremor='#define USE_TREMOR'
-	_def_vorbis='#define USE_VORBIS'
+	add_line_to_config_h '#define USE_TREMOR'
+	add_line_to_config_h '#define USE_VORBIS'
 	LIBS="$LIBS $TREMOR_LIBS -lvorbisenc"
 	INCLUDES="$INCLUDES $TREMOR_CFLAGS"
 else
 	if test "$_vorbis" = yes; then
 		_tremor="no (Ogg Vorbis/Tremor support is mutually exclusive)"
 	fi
-	_def_tremor='#undef USE_TREMOR'
+	add_line_to_config_h '#undef USE_TREMOR'
 fi
 add_to_config_mk_if_yes "$_tremor" 'USE_TREMOR = 1'
 echo "$_tremor"
@@ -891,17 +986,14 @@ EOF
 	fi
 fi
 if test "$_flac" = yes ; then
-	_def_flac='#define USE_FLAC'
 	if test "$_vorbis" = yes ; then
 		LIBS="$LIBS $FLAC_LIBS $OGG_LIBS -lFLAC -logg"
 	else
 		LIBS="$LIBS $FLAC_LIBS -lFLAC"
 	fi
 	INCLUDES="$INCLUDES $FLAC_CFLAGS"
-else
-	_def_flac='#undef USE_FLAC'
 fi
-add_to_config_mk_if_yes "$_flac" 'USE_FLAC = 1'
+define_in_config_if_yes "$_flac" 'USE_FLAC'
 echo "$_flac"
 
 #
@@ -917,41 +1009,35 @@ EOF
 	cc_check $MAD_CFLAGS $MAD_LIBS -lmad && _mad=yes
 fi
 if test "$_mad" = yes ; then
-	_def_mad='#define USE_MAD'
 	LIBS="$LIBS $MAD_LIBS -lmad"
 	INCLUDES="$INCLUDES $MAD_CFLAGS"
-else
-	_def_mad='#undef USE_MAD'
 fi
-add_to_config_mk_if_yes "$_mad" 'USE_MAD = 1'
+define_in_config_if_yes "$_mad" 'USE_MAD'
 echo "$_mad"
 
 #
 # Check for PNG
 #
-echocheck "png"
+echocheck "PNG >= 1.2.8"
 if test "$_png" = auto ; then
 	_png=no
 	cat > $TMPC << EOF
 #include <png.h>
 int main(void) {
-#ifdef PNG_LIBPNG_VER_STRING
-	return 0;
+#if PNG_LIBPNG_VER >= 10208
 #else
-	return -1;
+  syntax error
 #endif
+  return 0;
 }
 EOF
 	cc_check $PNG_CFLAGS $PNG_LIBS -lpng && _png=yes
 fi
 if test "$_png" = yes ; then
-	_def_png='#define USE_PNG'
 	LIBS="$LIBS $PNG_LIBS -lpng"
 	INCLUDES="$INCLUDES $PNG_CFLAGS"
-else
-	_def_png='#undef USE_PNG'
 fi
-add_to_config_mk_if_yes "$_png" 'USE_PNG = 1'
+define_in_config_if_yes "$_png" 'USE_PNG'
 echo "$_png"
 
 #
@@ -968,13 +1054,10 @@ EOF
 	cc_check $ZLIB_CFLAGS $ZLIB_LIBS -lz && _zlib=yes
 fi
 if test "$_zlib" = yes ; then
-	_def_zlib='#define USE_ZLIB'
 	LIBS="$LIBS $ZLIB_LIBS -lz"
 	INCLUDES="$INCLUDES $ZLIB_CFLAGS"
-else
-	_def_zlib='#undef USE_ZLIB'
 fi
-add_to_config_mk_if_yes "$_zlib" 'USE_ZLIB = 1'
+define_in_config_if_yes "$_zlib" 'USE_ZLIB'
 echo "$_zlib"
 
 #
@@ -991,14 +1074,12 @@ fi
 if test "$_freetype" = yes ; then
 	freetype_version=`freetype-config --ftversion 2>/dev/null`
 
-	_def_freetype='#define USE_FREETYPE'
 	_freetypelibs=`freetype-config --libs`
 	_freetypeincludes=`freetype-config --cflags`
 else
-	_def_freetype='#undef USE_FREETYPE'
 	freetype_version="no"
 fi
-add_to_config_mk_if_yes "$_freetype" 'USE_FREETYPE = 1'
+define_in_config_if_yes "$_freetype" 'USE_FREETYPE'
 echo "$freetype_version"
 
 #
@@ -1108,14 +1189,8 @@ EOF
 	fi
 fi
 
-if test "$_iconv" = yes ; then
-	_def_iconv='#define USE_ICONV'
-else
-	_def_iconv='#undef USE_ICONV'
-fi
-
 echocheck "iconv"
-add_to_config_mk_if_yes "$_iconv" 'USE_ICONV = 1'
+define_in_config_if_yes "$_iconv" 'USE_ICONV'
 echo "$_iconv"
 
 #
@@ -1182,42 +1257,6 @@ test -z "$_libdir" && _libdir="$_prefix/lib"
 
 _def_media_path='#define APP_MEDIA_PATH "'$_datadir'"'
 
-#
-# Do CXXFLAGS now we know the compiler version
-#
-if test "$have_gcc" = yes ; then
-	if test "$_cxx_major" -ge "3" ; then
-		case $_host_os in
-		# newlib-based system include files suppress non-C89 function
-		# declarations under __STRICT_ANSI__
-		mingw* | amigaos*)
-			CXXFLAGS="$CXXFLAGS -W -Wno-unused-parameter"
-			;;
-		*)
-			CXXFLAGS="$CXXFLAGS -ansi -W -Wno-unused-parameter"
-			;;
-		esac
-		add_line_to_config_mk 'HAVE_GCC3 = 1'
-		add_line_to_config_mk 'CXX_UPDATE_DEP_FLAG = -MMD -MF "$(*D)/$(DEPDIR)/$(*F).d" -MQ "$@" -MP'
-	fi;
-
-	if test "$_cxx_major" -eq 4 && test "$_cxx_minor" -ge 3 || \
-	   test "$_cxx_major" -gt 4 ; then
-		CXXFLAGS="$CXXFLAGS -Wno-empty-body"
-	else
-		CXXFLAGS="$CXXFLAGS -Wconversion"
-	fi;
-fi;
-
-# Some platforms use certain GNU extensions in header files
-case $_host_os in
-gamecube | psp | wii)
-	;;
-*)
-	CXXFLAGS="$CXXFLAGS -pedantic"
-	;;
-esac
-
 echo
 echo "Creating config.h"
 cat > config.h << EOF
@@ -1242,16 +1281,6 @@ typedef signed $type_1_byte int8;
 typedef signed $type_2_byte int16;
 typedef signed $type_4_byte int32;
 
-/* Libs */
-$_def_vorbis
-$_def_tremor
-$_def_flac
-$_def_mad
-$_def_zlib
-$_def_png
-$_def_freetype
-$_def_iconv
-
 #endif /* CONFIG_H */
 EOF
 






More information about the Scummvm-git-logs mailing list