[Nut-upsdev] Re: Status of the PSE NUT patches (was: NUT patches)

Peter Selinger selinger at mathstat.dal.ca
Mon Sep 12 20:36:14 UTC 2005


Arnaud Quette wrote:
> Peter Selinger wrote:
> > > Arnaud Quette wrote:
> > >
> > > Here is the status of PSE (Peter Selinger) NUT patches
> > > for newhidups (hidparser, apc support, ...).
> > >
> > > - nut-cvs-patch-REOPEN-2005-08-24:
> > > approved and applied on Development tree
> > > Notes: - avoid cpp style comment
> > >             - I don't see the difference as we return when
> > >       the driver unbind has been done. You'll only get
> > >       again the mfr,model and serial strings! Or maybe
> > >       that was previous to my change to it (move after
> > >       unbind)...
> > 
> > You are right; when I made this change, the order of the operations
> > was different. Still, I think there are some benefits to repeating all
> > the "open" steps when "reopening" a device; for example, if a serial
> > number is found, but is not equal to that of the previous device, we
> > can search for the device with the correct serial number. This should
> > be reasonably accurate for ensuring that the same device is reopened,
> > in case someone has more than one device attached.
> 
> right. Note that I've an evolution/todo for newhidups with the
> mfr,prod,ser= ial params to get the right unit when there are
> multiple. These can be used for the same purpose... (part of the
> switch to libhid)

I can work on this. It would be nice to be able to specify the device
in a flexible manner, for example, by a regular expression.

> > > - nut-cvs-patch-DEP-2005-08-24:
> > > not applied. I'd like to have something more generic, along
> > > with the gendb system, that will declare some base deps
> > > (ie "main.h dstate.h serial.h" for serial drivers), and a @.h
> > > one (need to have a .h for every driver). Then, there will
> > > be the special cases (usb, snmp, ... drivers)
> >=20
> > A permanent solution would be very nice. In the meantime, the complete
> > absence of useful dependencies is annoying, especially as they can be
> > generated automatically.
> 
> yep, that's also a long standing (low prio) point of my todo list.
> 
> ok, I've prioritized my work on this subject. So we currently have 3 catego=
> ries
> (detailled audit attached):
> 1) standard deps (serial with ${drv}.h (ie "main.h dstate.h serial.h
> mge-shut.h")
> Added to gendb as generic (ie with HDEPS and EXTRAHDEPS) in the
> current CVS Development branch
> 
> 2) standard deps (serial without ${drv}.h (ie "main.h dstate.h serial.h")
> I have added a ${drv}.h for each of these drivers, with the same
> header as the .c but with the DRV_VERSION, and added to gendb as
> generic (same as in the above (1)).
> 
> 3) specific deps (ie dummy-ups, newhidups, energizerups, ...)
> These specific case will remain handled in Makefile.in, at least for
> the moment. These might one day be added to gendb too...
> 
> This way, we don't forget new drivers (ie gamatronic was missing)
> I've just commited it in the CVS Dev...

Attached is a patch with a better solution to this problem. 

* the dependencies for a "standard serial driver", currently specified
as main.h dstate.h serial.h, are incomplete. Each serial driver also
depends on the following files, and must be re-built if any of these
files change:

include/common.h
include/attribute.h
include/config.h
include/proto.h
include/version.h
include/upsconf.h
include/parseconf.h
include/upshandler.h
include/extstate.h

* the nice thing about .h dependencies is that they can be generated
fully automatically, without any need for "standard" or "specific"
cases. Assuming your version of gcc is reasonably new, the following
command will generate them:

for i in *.c
do
        gcc -I../include -MG -MM "$i"
done

The attached patch adds this to the gendb script, and removes the
static dependencies from Makefile.in. 

* note that .o dependencies can *not* be generated in this way; there
is no way around having to specify them. So I did not change anything
about .o dependencies. The above distinction 1)/2)/3) make sense for
this purpose.

* also, I added a target for "make depend" in drivers/. This way, it
is possible to re-generate the dependencies without having to re-make
everything.

-- Peter

-------------- next part --------------
Index: Makefile.in
===================================================================
RCS file: /cvsroot/nut/nut/drivers/Makefile.in,v
retrieving revision 1.1.1.1.8.1.2.7
diff -u -r1.1.1.1.8.1.2.7 Makefile.in
--- Makefile.in	12 Sep 2005 12:38:35 -0000	1.1.1.1.8.1.2.7
+++ Makefile.in	12 Sep 2005 20:29:27 -0000
@@ -48,13 +48,6 @@
 include Makefile.drvbuild
 
 # ==========================================================================
-# Intermediate objects dependencies
-
-dstate.o: dstate.h
-main.o: main.h dstate.h
-serial.o: serial.h
-
-# ==========================================================================
 # upsdrvctl: the new all-singing all-dancing driver control program
 
 upsdrvctl: upsdrvctl.c ../common/upsconf.o ../common/parseconf.o $(LIBDEP)
@@ -64,9 +57,9 @@
 # ==========================================================================
 # Testing driver for doing things without real UPS hardware attached
 
-dummy-ups: dummy-ups.c dummy-ups.h dstate.h main.o dstate.o \
+dummy-ups: dummy-ups.o main.o dstate.o \
 	../common/state.o ../common/upsconf.o ../common/parseconf.o $(LIBDEP)
-	$(CC) $(CFLAGS) -o $@ $@.c main.o dstate.o ../common/state.o \
+	$(CC) $(CFLAGS) -o $@ $@.o main.o dstate.o ../common/state.o \
 	../common/upsconf.o ../common/parseconf.o $(LIBOBJ) $(LDFLAGS)
 
 # ==========================================================================
@@ -81,7 +74,7 @@
 		../common/state.o ../common/upsconf.o ../common/parseconf.o \
 		$(LIBOBJ) $(LDFLAGS)
 
-hidups.o: hidups.c main.h dstate.h hidups.h
+hidups.o:
 	$(CC) $(CFLAGS) -c hidups.c
 
 energizerups: energizerups.o main.o dstate.o ../common/state.o \
@@ -91,7 +84,7 @@
 		../common/state.o ../common/upsconf.o ../common/parseconf.o \
 		$(LIBOBJ) $(LDFLAGS)
 
-energizerups.o: energizerups.c main.h dstate.h
+energizerups.o:
 	$(CC) $(CFLAGS) -c energizerups.c
 
 
@@ -105,18 +98,15 @@
 		../common/state.o ../common/upsconf.o ../common/parseconf.o \
 		$(LIBOBJ) $(LIBUSB_LIBS) $(LDFLAGS) libhid.o libusb.o hidparser.o
 
-newhidups.o: newhidups.c newhidups.h main.h dstate.h \
-		libhid.h hidtypes.h mge-hid.h apc-hid.h
+newhidups.o:
 	$(CC) $(CFLAGS) $(LIBUSB_CFLAGS) -c newhidups.c
 
-libhid.o: libhid.c hidparser.h hidtypes.h libhid.h hid-usb.h
+libhid.o:
 	$(CC) $(CFLAGS) $(LIBUSB_CFLAGS) -o libhid.o -c libhid.c
 
-libusb.o: libusb.c libhid.h hidtypes.h hid-usb.h
+libusb.o:
 	$(CC) $(CFLAGS) $(LIBUSB_CFLAGS) -o libusb.o -c libusb.c
 
-hidparser.o: hidparser.h hidtypes.h
-
 # ==========================================================================
 # Special case: tripplite_usb driver - development version (early beta)
 
@@ -127,7 +117,7 @@
 		../common/state.o ../common/upsconf.o ../common/parseconf.o \
 		$(LIBOBJ) $(LIBUSB_LIBS) $(LDFLAGS) -lm libhid.o libusb.o hidparser.o
 
-tripplite_usb.o: tripplite_usb.c newhidups.h libhid.h
+tripplite_usb.o:
 	$(CC) $(CFLAGS) $(LIBUSB_CFLAGS) -c tripplite_usb.c
 
 # ==========================================================================
@@ -140,10 +130,10 @@
 		../common/parseconf.o \
 		$(LIBOBJ) $(LIBUSB_LIBS) $(LDFLAGS)
 
-bcmxcp_usb.o: bcmxcp_usb.c bcmxcp.h
+bcmxcp_usb.o:
 	$(CC) $(CFLAGS) $(LIBUSB_CFLAGS) -c bcmxcp_usb.c
 
-nut_usb.o: nut_usb.c nut_usb.h
+nut_usb.o:
 	$(CC) $(CFLAGS) $(LIBUSB_CFLAGS) -o nut_usb.o -c nut_usb.c
 
 
@@ -157,11 +147,10 @@
 		dstate.o serial.o ../common/state.o ../common/upsconf.o \
 		../common/parseconf.o $(LIBOBJ) $(LDFLAGS)
 
-mge-shut.o: mge-shut.c mge-shut.h main.h dstate.h serial.h \
-		hidparser.h hidtypes.h
+mge-shut.o:
 	$(CC) $(CFLAGS) -c mge-shut.c
 
-hidparser.o: hidparser.h hidparser.c
+hidparser.o:
 	$(CC) $(CFLAGS) -c hidparser.c
 
 # ==========================================================================
@@ -174,8 +163,7 @@
 		../common/state.o ../common/upsconf.o ../common/parseconf.o \
 		$(LIBOBJ) $(LDFLAGS) $(NETSNMP_LIBS)
 
-snmp-ups.o: snmp-ups.c snmp-ups.h main.h dstate.h \
-		ietfmib.h apccmib.h mgemib.h netvisionmib.h pwmib.h
+snmp-ups.o:
 	$(CC) $(CFLAGS) $(NETSNMP_CFLAGS) -c snmp-ups.c
 
 
@@ -187,7 +175,7 @@
 		../common/state.o ../common/upsconf.o ../common/parseconf.o \
 		$(LIBOBJ) $(LDFLAGS)
 
-skel.o: main.h dstate.h
+skel.o:
 	$(CC) $(CFLAGS) -c skel.c
 
 # ==========================================================================
@@ -196,10 +184,12 @@
 # gendb runs here so that the source always goes out the door with a
 # current Makefile.drvbuild file
 
-clean:
+depend:
+	./gendb $(PROGS)
+
+clean: depend
 	rm -f *~ *.o $(PROGS) Makefile.drvbuild
 	rm -f dummy-ups snmp-ups $(USB_DRIVER_LIST) mge-shut upsdrvctl
-	./gendb $(PROGS)
 
 distclean: clean
 
Index: gendb
===================================================================
RCS file: /cvsroot/nut/nut/drivers/gendb,v
retrieving revision 1.1.1.1.8.1.2.3
diff -u -r1.1.1.1.8.1.2.3 gendb
--- gendb	12 Sep 2005 12:38:35 -0000	1.1.1.1.8.1.2.3
+++ gendb	12 Sep 2005 20:29:27 -0000
@@ -42,7 +42,11 @@
 			;;
 	esac	
 
-	echo "$i.o: main.h dstate.h serial.h $i.c $i.h" >> $MFDB
 	echo "$i: $i.o main.o serial.o dstate.o ../common/state.o ../common/upsconf.o ../common/parseconf.o $EXTRAOBJ \$(LIBDEP)" >> $MFDB
 	echo "	\$(CC) \$(CFLAGS) \$(LDFLAGS) -o $i $i.o main.o serial.o dstate.o ../common/state.o ../common/upsconf.o ../common/parseconf.o $EXTRAOBJ \$(LIBOBJ) $EXTRA" >> $MFDB
 done
+
+for i in *.c
+do
+	gcc -I../include -MG -MM "$i" >> $MFDB
+done


More information about the Nut-upsdev mailing list