[AD] 3.9.21 patch6 -- configuration fixes

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Hi

This patch ought to apply to a clean 3.9.21 distribution,
although it's not actually based on one.  Use `-p 0' from the
directory you unzipped Allegro from, or `-p 1' from the Allegro
directory itself.

The patch works around the various disagreements between Linux
distributions that have turned up -- code using mmap now defines
MAP_FAILED if sys/mman.h neglects to do this, and sys/io.h is
only included if it exists.  I'm not too comfortable with the
way I handled the MAP_FAILURE problem; maybe the checks should
be put in a common header file.

Also, the joystick code is disabled if `linux/joystick.h'
doesn't exist (joystick support wasn't in the kernel in Linux
2.0); the fbcon code is disabled if `linux/fb.h' doesn't exist
(that wasn't in 2.0 either); and the GGI code is disabled if
`ggi/ggi.h' doesn't exist or libggi doesn't exist.

If anyone can think of any other checks we ought to make, please
say.

Don't worry about the fact that this is patch6 and you haven't
seen patches 1 to 5 -- patch6 was just a conveniently
so-far-unused, admittedly rather unimaginative, filename for the
patch.  In fact patches 1 to 5 do exist (or did), but don't
matter too much at the moment.

-- 
George

Apply this patch to the 3.9.21 distribution -- it should work with 
no errors.  Use `-p 1' from the `allegro' directory, or `-p 0' from 
the directory you unzipped allegro from.

This patch works around various glitches in different Linux 
distributions, and adds detection of the machines ability to
compile some library features (GGI, fbcon, joystick -- things
needing external libraries or kernel 2.2 features).


diff -urN allegro-3.9.21-3/configure.in allegro/configure.in
--- allegro-3.9.21-3/configure.in	Mon Jul  5 03:44:58 1999
+++ allegro/configure.in	Fri Jul  9 02:32:36 1999
@@ -199,28 +199,46 @@
 
 dnl Some miscellaneous defines.
 ALLEGRO_MAYBE_LINUX_FILES=ALLEGRO_EMPTY_LIST
+
 allegro_system=`uname -s | tr A-Z a-z`
 case "$allegro_system" in
+
 *linux*)
   if test "$allegro_support_linux" = yes; then
     AC_DEFINE(ALLEGRO_LINUX)
     ALLEGRO_MAYBE_LINUX_FILES=ALLEGRO_SRC_LINUX_FILES
+
+    AC_CHECK_HEADERS(sys/io.h linux/joystick.h)
+
     if test "$allegro_enable_vga" = yes; then
       AC_DEFINE(ALLEGRO_LINUX_VGA)
     fi
+
     if test "$allegro_enable_fbcon" = yes; then
-      AC_DEFINE(ALLEGRO_LINUX_FBCON)
+      AC_CHECK_HEADER(linux/fb.h,
+        AC_DEFINE(ALLEGRO_LINUX_FBCON)
+      )
     fi
+
     if test "$allegro_enable_vbeaf" = yes; then
       AC_DEFINE(ALLEGRO_LINUX_VBEAF)
     fi
+
     if test "$allegro_enable_ggi" = yes; then
-      AC_DEFINE(ALLEGRO_LINUX_GGI)
+      AC_CHECK_HEADER(ggi/ggi.h,
+        AC_CHECK_LIB(ggi, ggiInit,
+          AC_DEFINE(ALLEGRO_LINUX_GGI)
+        )
+      )
     fi
+
   fi
   ;;
+
 esac
+
 AC_SUBST(ALLEGRO_MAYBE_LINUX_FILES)
+
 
 dnl Headers, features, functions and macros.
 AC_HEADER_STDC
diff -urN allegro-3.9.21-3/include/allegro/alunixac.hin allegro/include/allegro/alunixac.hin
--- allegro-3.9.21-3/include/allegro/alunixac.hin	Mon Jul  5 11:57:09 1999
+++ allegro/include/allegro/alunixac.hin	Fri Jul  9 02:40:33 1999
@@ -109,6 +109,9 @@
 /* Define if you have the <limits.h> header file.  */
 #undef HAVE_LIMITS_H
 
+/* Define if you have the <linux/joystick.h> header file.  */
+#undef HAVE_LINUX_JOYSTICK_H
+
 /* Define if you have the <machine/soundcard.h> header file.  */
 #undef HAVE_MACHINE_SOUNDCARD_H
 
@@ -120,6 +123,9 @@
 
 /* Define if you have the <sys/dir.h> header file.  */
 #undef HAVE_SYS_DIR_H
+
+/* Define if you have the <sys/io.h> header file.  */
+#undef HAVE_SYS_IO_H
 
 /* Define if you have the <sys/ndir.h> header file.  */
 #undef HAVE_SYS_NDIR_H
diff -urN allegro-3.9.21-3/src/linux/fbcon.c allegro/src/linux/fbcon.c
--- allegro-3.9.21-3/src/linux/fbcon.c	Mon Jul  5 03:44:58 1999
+++ allegro/src/linux/fbcon.c	Fri Jul  9 02:29:45 1999
@@ -23,11 +23,18 @@
 
 #ifdef ALLEGRO_LINUX_FBCON
 
+#if !defined(_POSIX_MAPPED_FILES) || !defined(HAVE_MMAP)
+#error "Sorry, mapped files are required for Linux console Allegro to work!"
+#endif
+
 #include <stdio.h>
-#include <sys/mman.h>
 #include <sys/ioctl.h>
 #include <linux/fb.h>
+#include <sys/mman.h>
 
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
 
 
 static BITMAP *fb_init(int w, int h, int v_w, int v_h, int color_depth);
diff -urN allegro-3.9.21-3/src/linux/ggi.c allegro/src/linux/ggi.c
--- allegro-3.9.21-3/src/linux/ggi.c	Mon Jul  5 03:44:58 1999
+++ allegro/src/linux/ggi.c	Fri Jul  9 02:31:51 1999
@@ -23,6 +23,10 @@
 
 #ifdef ALLEGRO_LINUX_GGI
 
+#if !defined(_POSIX_MAPPED_FILES) || !defined(HAVE_MMAP)
+#error "Sorry, mapped files are required for Linux console Allegro to work!"
+#endif
+
 #include <sys/mman.h>
 #include <sys/ioctl.h>
 #include <linux/fb.h>
@@ -30,6 +34,10 @@
 #include <linux/kd.h>
 
 #include <ggi/ggi.h>
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
 
 
 #define ALLEGRO_GGI_LFB 0x01    /* linear frame buffer */
diff -urN allegro-3.9.21-3/src/linux/ljoy.c allegro/src/linux/ljoy.c
--- allegro-3.9.21-3/src/linux/ljoy.c	Mon Jul  5 03:44:58 1999
+++ allegro/src/linux/ljoy.c	Fri Jul  9 02:01:00 1999
@@ -15,7 +15,6 @@
  *      See readme.txt for copyright information.
  */
 
-#include <linux/joystick.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <fcntl.h>
@@ -27,6 +26,11 @@
 #include "allegro/aintunix.h"
 
 
+#ifdef HAVE_LINUX_JOYSTICK_H
+
+#include <linux/joystick.h>
+
+
 static int joy_fd = -1;
 static int num_buttons, num_axes;
 static char description[100];
@@ -195,4 +199,13 @@
 	{    0,                        0,                         0      }
 };
 
+#else /* HAVE_LINUX_JOYSTICK_H */
+
+/* list the available drivers */
+_DRIVER_INFO _linux_joystick_driver_list[] = {
+	{    JOY_TYPE_NONE,            &joystick_none,            TRUE   },
+	{    0,                        0,                         0      }
+};
+
+#endif /* HAVE_LINUX_JOYSTICK_H */
 
diff -urN allegro-3.9.21-3/src/linux/lmemory.c allegro/src/linux/lmemory.c
--- allegro-3.9.21-3/src/linux/lmemory.c	Tue Jun 29 12:50:36 1999
+++ allegro/src/linux/lmemory.c	Fri Jul  9 02:31:53 1999
@@ -30,6 +30,10 @@
 #include <unistd.h>
 #include <sys/mman.h>
 
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
 
 static int mem_fd;      /* fd of /dev/mem */
 
diff -urN allegro-3.9.21-3/src/linux/lsystem.c allegro/src/linux/lsystem.c
--- allegro-3.9.21-3/src/linux/lsystem.c	Mon Jul  5 03:44:58 1999
+++ allegro/src/linux/lsystem.c	Fri Jul  9 01:47:29 1999
@@ -19,15 +19,21 @@
 #include <stdio.h>
 #include <signal.h>
 #include <sys/utsname.h>
-#include <sys/io.h>
+#include <unistd.h>
 #include <string.h>
 
-
 #include "allegro.h"
 #include "allegro/aintern.h"
 #include "allegro/aintunix.h"
 #include "allegro/aintvga.h"
 #include "linalleg.h"
+
+#ifdef HAVE_SYS_IO_H
+/* This exists in Red Hat systems, at least, and defines the iopl function
+ * which, contrary to the documentation, is left out of unistd.h.
+ */
+#include <sys/io.h>
+#endif
 
 #ifndef ALLEGRO_LINUX
    #error Something is wrong with the makefile


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/