From 6a8a710ecf98f7bb05116784171ee13e6e32aa0a Mon Sep 17 00:00:00 2001 From: Olaf Seibert Date: Sat, 15 Sep 2018 00:04:31 +0200 Subject: [PATCH] Change configure to control the compilation of the Panda lights. This needs to check for libusb-1.0. Since this shouldn't be linked to the auxiliary programs, add another Makefile variable to record it in: CPULIBS. Stub out calls to outb() if it is unavailable, so that it can at least use libusb in that case. --- configure.ac | 42 +++++++++++++++++++++++++++++++++++++++--- mk/top.mk | 1 + src/Makefile.mk | 19 +++++++++++++++---- src/dvlites.c | 11 +++++++++++ 4 files changed, 66 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 885257e..5047746 100644 --- a/configure.ac +++ b/configure.ac @@ -5,7 +5,7 @@ dnl This configure.ac script was created for Autoconf 2.69, but I dnl tried it with one as old as 2.61, and that seemed to work fine. AC_PREREQ([2.69]) -AC_INIT([klh10], [2.0k-Rhialto], [https://github.com/PDP-10/klh10], +AC_INIT([klh10], [2.0l], [https://github.com/PDP-10/klh10], [], [https://github.com/PDP-10/klh10]) AC_CONFIG_SRCDIR([src/klh10.h]) AC_CONFIG_HEADERS([src/config.h]) @@ -35,6 +35,25 @@ do done CFLAGS="$NEWCFLAGS -g3 -O3" +# ------------------------------------------------------------------------- +# Check whether we want LIGHTS support +# ------------------------------------------------------------------------- + +AC_ARG_ENABLE(lights, + AS_HELP_STRING([--enable-lights],[enable Panda lights (which requires libusb-1.0)])) + +case "${enable_lights}" in + yes) + AC_MSG_NOTICE([Compiling with Panda lights support]) + AC_DEFINE(KLH10_DEV_LITES, 1, [Set to 1 to enable Panda lights]) + need_libusb=yes + ;; + no | "") + AC_DEFINE(KLH10_DEV_LITES, 0, [Set to 0 to disable Panda lights]) + ;; + *) AC_MSG_ERROR([bad value ${enable_lights} for --enable-lights]) ;; +esac + # ------------------------------------------------------------------------- # Check whether we want VDE support # ------------------------------------------------------------------------- @@ -81,7 +100,23 @@ AC_CHECK_FUNC([nanosleep], AC_CHECK_LIB([rt], [nanosleep]) ]) -# -lsocket and -lpcap should go into NETLIBS +case "${need_libusb}" in + yes) + # Check if libusb-1.0 is present, otherwise fail. + # CPULIBS is for libraries only needed by the CPU, not by other programs. + SAVE_LIBS="$LIBS" + LIBS="" + AC_CHECK_LIB([usb-1.0], [libusb_get_device_descriptor], + [], + [AC_MSG_ERROR([Lights require libusb-1.0, which I could not find.])] + ) + CPULIBS="$LIBS" + LIBS="$SAVE_LIBS" + ;; +esac + +# -lsocket, -lpcap and -lvdeplug should go into NETLIBS. +# NETLIBS is for libraries only needed by programs doing networking. SAVE_LIBS="$LIBS" LIBS="" AC_CHECK_LIB([socket], [if_nameindex]) @@ -100,7 +135,7 @@ AC_CHECK_HEADERS([arpa/inet.h errno.h fcntl.h limits.h netinet/in.h sgtty.h \ sys/socket.h sys/time.h termios.h unistd.h net/if_tun.h \ linux/if_tun.h linux/if_packet.h net/if_tap.h sys/mtio.h \ net/nit.h sys/dlpi.h net/if_dl.h net/if_types.h \ - libvdeplug.h]) + sys/io.h libvdeplug.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_INLINE @@ -248,6 +283,7 @@ AC_SUBST([CPPFLAGS]) AC_SUBST([DESTDIR]) AC_SUBST([PREFIX]) AC_SUBST([LIBS]) +AC_SUBST([CPULIBS]) AC_SUBST([NETLIBS]) AC_SUBST([MAKEFILE], [Makefile]) AC_SUBST([CENVFLAGS]) diff --git a/mk/top.mk b/mk/top.mk index 45d3c9c..46288a3 100644 --- a/mk/top.mk +++ b/mk/top.mk @@ -25,6 +25,7 @@ CFLAGS_LINT = -ansi -pedantic -Wall -Wshadow \ -Wmissing-declarations -Wredundant-decls LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ +CPULIBS = @CPULIBS@ NETLIBS = @NETLIBS@ prefix = @prefix@ diff --git a/src/Makefile.mk b/src/Makefile.mk index 1644fa2..7119b08 100644 --- a/src/Makefile.mk +++ b/src/Makefile.mk @@ -54,7 +54,8 @@ CFLAGS_LINT ?= LINKER ?= $(CC) LDFLAGS ?= LDOUTF ?= -o -LIBS := -lusb-1.0 +LIBS ?= +CPULIBS ?= NETLIBS ?= -lpcap # Variables specific to this makefile setup @@ -108,6 +109,7 @@ showdefs: @echo "CPPFLAGS= $(CPPFLAGS)" @echo "LDFLAGS = $(LDFLAGS)" @echo "LIBS = $(LIBS)" + @echo "CPULIBS = $(CPULIBS)" @echo "NETLIBS = $(NETLIBS)" @echo "CENVFLAGS = $(CENVFLAGS)" @echo "CONFFLAGS = $(CONFFLAGS)" @@ -252,13 +254,13 @@ DINTFLAGS = \ ## kn10-ks: $(OFILES_KS) - $(LINKER) $(LDFLAGS) $(LDOUTF) kn10-ks $(OFILES_KS) $(LIBS) + $(LINKER) $(LDFLAGS) $(LDOUTF) kn10-ks $(OFILES_KS) $(LIBS) $(CPULIBS) kn10-ks-its: $(OFILES_KS) - $(LINKER) $(LDFLAGS) $(LDOUTF) kn10-ks-its $(OFILES_KS) $(LIBS) + $(LINKER) $(LDFLAGS) $(LDOUTF) kn10-ks-its $(OFILES_KS) $(LIBS) $(CPULIBS) kn10-kl: $(OFILES_KL) - $(LINKER) $(LDFLAGS) $(LDOUTF) kn10-kl $(OFILES_KL) $(LIBS) + $(LINKER) $(LDFLAGS) $(LDOUTF) kn10-kl $(OFILES_KL) $(LIBS) $(CPULIBS) #################################################################### @@ -325,6 +327,7 @@ base-ks-its: "CPPFLAGS = $(CPPFLAGS)" \ "LDFLAGS = $(LDFLAGS)" \ "LIBS = $(LIBS)" \ + "CPULIBS = $(CPULIBS)" \ "NETLIBS = $(NETLIBS)" \ "CENVFLAGS = $(CENVFLAGS)" \ "CONFFLAGS = \ @@ -355,6 +358,7 @@ base-ks: "CPPFLAGS = $(CPPFLAGS)" \ "LDFLAGS = $(LDFLAGS)" \ "LIBS = $(LIBS)" \ + "CPULIBS = $(CPULIBS)" \ "NETLIBS = $(NETLIBS)" \ "CENVFLAGS = $(CENVFLAGS)" \ "CONFFLAGS = \ @@ -381,6 +385,7 @@ base-kl: "CPPFLAGS = $(CPPFLAGS)" \ "LDFLAGS = $(LDFLAGS)" \ "LIBS = $(LIBS)" \ + "CPULIBS = $(CPULIBS)" \ "NETLIBS = $(NETLIBS)" \ "CENVFLAGS = $(CENVFLAGS)" \ "CONFFLAGS = \ @@ -434,6 +439,7 @@ lint-ks-its: "CPPFLAGS = $(CPPFLAGS)" \ "LDFLAGS = $(LDFLAGS)" \ "LIBS = $(LIBS)" \ + "CPULIBS = $(CPULIBS)" \ "NETLIBS = $(NETLIBS)" \ "CENVFLAGS = $(CENVFLAGS)" \ "CONFFLAGS = $(CONFFLAGS) $(CONFFLAGS_AUX) $(CONFFLAGS_USR)" @@ -446,6 +452,7 @@ lint-ks: "CPPFLAGS = $(CPPFLAGS)" \ "LDFLAGS = $(LDFLAGS)" \ "LIBS = $(LIBS)" \ + "CPULIBS = $(CPULIBS)" \ "NETLIBS = $(NETLIBS)" \ "CENVFLAGS = $(CENVFLAGS)" \ "CONFFLAGS = $(CONFFLAGS) $(CONFFLAGS_AUX) $(CONFFLAGS_USR)" @@ -458,6 +465,7 @@ lint-kl: "CPPFLAGS = $(CPPFLAGS)" \ "LDFLAGS = $(LDFLAGS)" \ "LIBS = $(LIBS)" \ + "CPULIBS = $(CPULIBS)" \ "NETLIBS = $(NETLIBS)" \ "CENVFLAGS = $(CENVFLAGS)" \ "CONFFLAGS = $(CONFFLAGS) $(CONFFLAGS_AUX) $(CONFFLAGS_USR)" @@ -480,6 +488,7 @@ port-ks: "CPPFLAGS = $(CPPFLAGS)" \ "LDFLAGS = $(LDFLAGS)" \ "LIBS = $(LIBS)" \ + "CPULIBS = $(CPULIBS)" \ "NETLIBS = $(NETLIBS)" \ "CENVFLAGS = $(CENVFLAGS)" \ "CONFFLAGS = \ @@ -507,6 +516,7 @@ kl0i-sync: "CPPFLAGS = $(CPPFLAGS)" \ "LDFLAGS = $(LDFLAGS)" \ "LIBS = $(LIBS)" \ + "CPULIBS = $(CPULIBS)" \ "NETLIBS = $(NETLIBS)" \ "CENVFLAGS = $(CENVFLAGS)" \ "CONFFLAGS = \ @@ -533,6 +543,7 @@ kl0i-rtmopt: "CPPFLAGS = $(CPPFLAGS)" \ "LDFLAGS = $(LDFLAGS)" \ "LIBS = $(LIBS)" \ + "CPULIBS = $(CPULIBS)" \ "NETLIBS = $(NETLIBS)" \ "CENVFLAGS = $(CENVFLAGS)" \ "CONFFLAGS = \ diff --git a/src/dvlites.c b/src/dvlites.c index 48b51c1..fa1cbcb 100644 --- a/src/dvlites.c +++ b/src/dvlites.c @@ -33,8 +33,19 @@ static int decosfcclossage; #if KLH10_DEV_LITES /* Moby conditional for entire file */ +#if HAVE_LIBUSB_1_0 #include +#endif +/* + * For now, assume that having is equivalent to having + * outb(). That may not be exactly true but it's the code we have. + */ +#ifdef HAVE_SYS_IO_H #include +#else +static inline int ioperm(int a, int b, int c) { return -1; } +static inline void outb(int a, int b) {} +#endif #include "dvlites.h"