-printf "Checking which platform we are on... "
-uname=`uname`
-if [ $uname = "Darwin" ] ; then
- printf "Mac OS X.\n"
- platform=MACOSX
- linker_resolves_library_dependencies=0
-elif [ $uname = "SunOS" ] ; then
- printf "Solaris.\n"
- platform=SOLARIS
- linker_resolves_library_dependencies=0
-elif [ $uname = "FreeBSD" ] ; then
- printf "FreeBSD.\n"
- platform=FREEBSD
- linker_resolves_library_dependencies=0
-elif [ $uname = "OpenBSD" ] ; then
- printf "OpenBSD.\n"
- platform=OPENBSD
- linker_resolves_library_dependencies=0
-elif [ $uname = "Linux" ] || [ $uname = "GNU" ] ; then
- printf "$uname\n"
- platform="$uname"
- linker_resolves_library_dependencies=1
+printf "Checking for libelf... "
+printf "#include <gelf.h>\nint main(void){return elf_version (EV_CURRENT);}\n" > elf-minimal.c
+if ${CC} -o elf-minimal elf-minimal.c -lelf > /dev/null 2>&1
+then
+ printf "Yes.\n"
+ have_libelf=1
+ libelf_cflags=
+ libelf_ldflags=-lelf
+else
+ printf "No.\n"
+ have_libelf=0
+ libelf_cflags=
+ libelf_ldflags=
+ errors=$((errors + 1))
+fi
+rm -f elf-minimal elf-minimal.c
+
+printf "Checking for GL/gl.h... "
+have_gl=0
+if pkg-config --exists gl; then
+ printf "Yes.\n"
+ have_gl=1
+ gl_cflags=$(pkg-config --cflags gl)
+ gl_ldflags=$(pkg-config --libs gl)
+else
+ printf "#include <GL/gl.h>\nint main(void){return 0;}\n" > gl-minimal.c
+ if ${CC} -o gl-minimal gl-minimal.c > /dev/null 2>&1
+ then
+ printf "Yes.\n"
+ have_gl=1
+ else
+ printf "No.\n"
+ errors=$((errors + 1))
+ fi
+ rm -f gl-minimal gl-minimal.c
+fi
+
+printf "Checking for GL window-system-binding headers:\n"
+have_gl_winsys=0
+
+printf " Checking for GL/glx.h... "
+have_glx=No
+printf "#include <GL/glx.h>\nint main(void){return 0;}\n" > glx-minimal.c
+if ${CC} -o glx-minimal glx-minimal.c ${gl_cflags} > /dev/null 2>&1
+then
+ printf "Yes.\n"
+ have_gl_winsys=1
+ have_glx=Yes
+else
+ printf "No.\n"
+fi
+rm -f glx-minimal glx-minimal.c
+
+printf " Checking for X11... "
+have_x11=No
+if pkg-config --exists x11; then
+ printf "Yes.\n"
+ have_x11=Yes
+ x11_cflags=$(pkg-config --cflags x11)
+ x11_ldflags=$(pkg-config --libs x11)
+else
+ printf "No.\n"
+fi
+
+printf " Checking for EGL/egl.h... "
+have_egl=No
+if pkg-config --exists egl; then
+ printf "Yes.\n"
+ have_egl=Yes
+ egl_cflags=$(pkg-config --cflags egl)
+ egl_ldflags=$(pkg-config --libs egl)
+else
+ printf "#include <EGL/egl.h>\nint main(void){return 0;}\n" > egl-minimal.c
+ if ${CC} -o egl-minimal egl-minimal.c ${gl_cflags} > /dev/null 2>&1
+ then
+ printf "Yes.\n"
+ have_gl_winsys=1
+ have_egl=1
+ else
+ printf "No.\n"
+ fi
+ rm -f egl-minimal egl-minimal.c
+fi
+
+if [ $have_gl_winsys -eq 0 ]; then
+ errors=$((errors + 1))
+fi
+
+printf "int main(void){return 0;}\n" > minimal.c
+
+WARN_CFLAGS=""
+printf "Checking for available C compiler warning flags:\n"
+for flag in -Wall -Wextra -Wmissing-declarations; do
+ if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
+ then
+ WARN_CFLAGS="${WARN_CFLAGS}${WARN_CFLAGS:+ }${flag}"
+ fi
+done
+printf "\t${WARN_CFLAGS}\n"
+
+rm -f minimal minimal.c
+
+printf "#include <features.h>\nint main(void){return 0;}\n" > arch-minimal.c
+
+printf "Checking for machine-dependent compiler support:\n"
+
+printf " Compiler can create 32-bit binaries... "
+have_m32=Yes
+if ${CC} -m32 -o arch-minimal arch-minimal.c > /dev/null 2>&1
+then
+ printf "Yes.\n"
+else
+ printf "No.\n"
+ have_m32=No
+fi
+
+printf " Compiler can create 64-bit binaries... "
+have_m64=Yes
+if ${CC} -m64 -o arch-minimal arch-minimal.c > /dev/null 2>&1
+then
+ printf "Yes.\n"