From 8cff8dbf7757da96feecc75cd3c0bab901474bbf Mon Sep 17 00:00:00 2001 From: gfk Date: Thu, 2 May 2002 01:17:28 +0000 Subject: [PATCH] Using autoconf check to detect if there's a parallel port. --- acinclude.m4 | 36 ++++++++++++++++++++++++++++-------- configure.in | 17 ++++++++++++++++- server/drivers/port.h | 4 ++-- server/drivers/timing.h | 10 +++++----- 4 files changed, 51 insertions(+), 16 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 2fe3ed1..d9bf369 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -152,16 +152,31 @@ dnl else ) ;; sed1330) - DRIVERS="$DRIVERS sed1330${SO}" - actdrivers=["$actdrivers sed1330"] + if test "$ac_cv_port_have_lpt" = yes + then + DRIVERS="$DRIVERS sed1330${SO}" + actdrivers=["$actdrivers sed1330"] + else + AC_MSG_WARN([The sed1330 driver needs a parallel port.]) + fi ;; sed1520) - DRIVERS="$DRIVERS sed1520${SO}" - actdrivers=["$actdrivers sed1520"] + if test "$ac_cv_port_have_lpt" = yes + then + DRIVERS="$DRIVERS sed1520${SO}" + actdrivers=["$actdrivers sed1520"] + else + AC_MSG_WARN([The sed1330 driver needs a parallel port.]) + fi ;; stv5730) - DRIVERS="$DRIVERS stv5730${SO}" - actdrivers=["$actdrivers stv5730"] + if test "$ac_cv_port_have_lpt" = yes + then + DRIVERS="$DRIVERS stv5730${SO}" + actdrivers=["$actdrivers stv5730"] + else + AC_MSG_WARN([The sed1330 driver needs a parallel port.]) + fi ;; svga) AC_CHECK_LIB(vga, main, @@ -179,8 +194,13 @@ dnl else ) ;; t6963) - DRIVERS="$DRIVERS t6963${SO}" - actdrivers=["$actdrivers t6963"] + if test "$ac_cv_port_have_lpt" = yes + then + DRIVERS="$DRIVERS t6963${SO}" + actdrivers=["$actdrivers t6963"] + else + AC_MSG_WARN([The sed1330 driver needs a parallel port.]) + fi ;; *) AC_MSG_ERROR([Unknown driver $driver]) diff --git a/configure.in b/configure.in index 8db5d38..e240051 100644 --- a/configure.in +++ b/configure.in @@ -82,7 +82,7 @@ AC_CHECK_LIB(kvm, kvm_open,[ ]) dnl NetBSD, OpenBSD and FreeBSD -AC_CHECK_HEADERS(sched.h sys/sched.h sys/types.h machine/pio.h machine/sysarch.h) +AC_CHECK_HEADERS(sched.h sys/sched.h machine/cpufunc.h sys/types.h machine/pio.h machine/sysarch.h) ETR_SYSV_IPC ETR_UNION_SEMUN @@ -97,6 +97,21 @@ AC_CHECK_LIB(i386, i386_get_ioperm, [])] ) +AC_CHECK_FUNCS(ioperm) +AC_CHECK_HEADERS(sys/io.h) + +dnl Check if we support this parallel (LPT) port +dnl IMPORTANT: we must do all the checks used in port.h before doing this test! +AC_CACHE_CHECK([for a parallel port], ac_cv_port_have_lpt, +[AC_TRY_COMPILE([#include "server/drivers/port.h"], [char val = port_in(0x350)], ac_cv_port_have_lpt=yes, ac_cv_port_have_lpt=no)]) + +if test "$ac_cv_port_have_lpt" = yes +then + AC_DEFINE([HAVE_LPT_PORT],[1],[Define if you have a parallel port and LCDproc knows how to talk to it.]) +else + AC_MSG_WARN([Can't talk to the parallel port, disabling drivers that use it.]) +fi + dnl Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC diff --git a/server/drivers/port.h b/server/drivers/port.h index 5c62065..4f27dda 100644 --- a/server/drivers/port.h +++ b/server/drivers/port.h @@ -86,7 +86,7 @@ static inline int port_deny_full (unsigned short int port) { /* ------------------------------------------------------------- */ /* Use i386_get_ioperm, i386_set_ioperm, inb and outb from (NetBSD&OpenBSD) */ -#elif defined HAVE_I386_IOPERM_NETBSD && defined HAVE_MACHINE_PIO_H && defined HAVE_MACHINE_SYSARCH_H +#elif defined HAVE_I386_IOPERM_NETBSD && defined HAVE_MACHINE_PIO_H && defined HAVE_MACHINE_SYSARCH_H && defined HAVE_SYS_TYPES_H #include #include #include @@ -175,7 +175,7 @@ static inline int port_deny_full (unsigned short int port) { /*#endif // defined HAVE_I386_IOPERM_NETBSD && defined HAVE_MACHINE_PIO_H && defined HAVE_MACHINE_SYSARCH_H ------------------------------------------------------------- Use i386_get_ioperm, i386_set_ioperm from and inb and outb from (FreeBSD) */ -#elif defined HAVE_I386_IOPERM_FREEBSD && defined HAVE_MACHINE_SYSARCH_H +#elif defined HAVE_I386_IOPERM_FREEBSD && defined HAVE_MACHINE_CPUFUNC_H && defined HAVE_MACHINE_SYSARCH_H && defined HAVE_SYS_TYPES_H #include #include #include diff --git a/server/drivers/timing.h b/server/drivers/timing.h index e5fe1c4..07f574d 100644 --- a/server/drivers/timing.h +++ b/server/drivers/timing.h @@ -66,14 +66,14 @@ #if defined DELAY_GETTIMEOFDAY # undef DELAY_NANOSLEEP # undef DELAY_IOCALLS -#elif defined DELAY_NANOSLEEP -# undef DELAY_GETTIMEOFDAY -# undef DELAY_IOCALLS -# include -#else // assume DELAY_IOCALLS +#elif defined DELAY_IOCALLS && defined HAVE_LPT_PORT # undef DELAY_GETTIMEOFDAY # undef DELAY_NANOSLEEP # include "port.h" +#else // assume DELAY_NANOSLEEP +# undef DELAY_GETTIMEOFDAY +# undef DELAY_IOCALLS +# include #endif /////////////////////////////////////////////////////////////////