
CheckXF86DGA()
{
	cat >xf86dga.c <<__EOF__
#include <X11/Xlib.h>
#include <X11/extensions/xf86dga.h>
#include <X11/extensions/xf86vmode.h>
int main () { exit(0); }
__EOF__
	make CFLAGS="-I/usr/X11R6/include" xf86dga >/dev/null 2>&1
	status=$?
	rm -f xf86dga.c xf86dga
	return $status
}

CheckESD()
{
	cat >esd.c <<__EOF__
#include <esd.h>
int main () { exit(0); }
__EOF__
	make LDFLAGS="-lesd -laudiofile" esd >/dev/null 2>&1
	status=$?
	rm -f esd.c esd
	return $status
}

CheckNASM()
{
	if findexe nasm >/dev/null; then
	    echo \
"
* Detected iX86 processor and NASM compiler, adding MMX support"
#
	    status=0
	else
	    echo \
"
* Couldn't find NASM compiler -- not compiling MMX support for $1
  (NASM is available from: http://www.cryogen.com/Nasm/ ) "
#
		status=1
	fi
	return $status
}

# The following global variables must be set:
#
#	$1		The interface subsystem
#
# The following global variables are set by this function:
#
#	$includes	Header directories for building shared library
#	$options	Compiler flags for building shared library
#	$asmobjs	Assembler objects to add to the build list
#	$libraries	The set of SDL libraries to build
#	$extralibs	Extra libraries necessary for building SDL
#
GenSubsystemFlags()
{
	case $1 in
	  x11)
		includes="$includes -I/usr/X11R6/include -Isrc/linux/x11"
		libraries="$libraries lib/libSDLx11.so.\$(version)"
		if CheckXF86DGA; then
		    echo \
"
* Detected XFree86 Direct Graphics Access extension (supported) "
#
		    options="$options -DXFREE86_DGA"
		    extralibs="$extralibs -lXxf86dga -lXxf86vm"
		fi
		;;
	  *)
		echo "Unknown subsystem '$1'"
		exit 3
		;;
	esac
}

# The following global variables must be set:
#
#	$1		The interface subsystem directory
#
# The following global variables are set by this function:
#
#	$includes	Header directories for building shared library
#	$options	Compiler flags for building shared library
#	$asmobjs	Assembler objects to add to the build list
#	$libraries	The set of SDL libraries to build
#	$extralibs	Extra libraries necessary for building SDL
#
GenMakeFlags()
{
	# Check for NASM and X86 for assembly blitter support
	case `uname -m` in
	  i?86)	if CheckNASM $subsystem; then
		    options="$options -DUSE_ASMBLIT"
		    asmobjs="$asmobjs obj/mmx_main.o"
		    asmobjs="$asmobjs obj/mmxp_32.o"
		    asmobjs="$asmobjs obj/x86_main.o"
		    asmobjs="$asmobjs obj/x86p_16.o"
		    asmobjs="$asmobjs obj/x86p_32.o"
		fi
		;;
	  *)    ;;
	esac

	# Check for ESD audio daemon support
	if CheckESD; then
	    echo \
"
* Detected Enlightenment Sound Daemon audio API (supported) "
#
	    options="$options -DESD_SUPPORT"
	    extralibs="$extralibs -lesd -laudiofile"
	fi

	# Tell the user what they need for thread support
	echo \
"
* Compiling with pthreads -- you need compile your application with
   the -pthread flag to get thread-safe C runtime routines "
#
	options="$options -DSDL_USE_PTHREADS -D_REENTRANT"
}

# Determine which subsystems to build
possible="X11"
