]> mj.ucw.cz Git - pciutils.git/commitdiff
Moved the example program from lib/example.c to example.c.
authorMartin Mares <mj@ucw.cz>
Sun, 17 Feb 2008 22:27:16 +0000 (23:27 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 17 Feb 2008 22:27:16 +0000 (23:27 +0100)
Also, include it in the default targets, so that we always check
that it builds correctly.

Makefile
README
example.c [new file with mode: 0644]
lib/Makefile
lib/example.c [deleted file]

index 4624d72b98ed0be5a1b57190c60db0777a43f893..ec46ba0adedf352550340daf9fb917660a48b8a0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,7 @@ PCIINC_INS=lib/config.h lib/header.h lib/pci.h lib/types.h
 
 export
 
-all: lib/$(PCILIB) lspci setpci lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS)
+all: lib/$(PCILIB) lspci setpci example lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS)
 
 lib/$(PCILIB): $(PCIINC) force
        $(MAKE) -C lib all
@@ -71,6 +71,10 @@ update-pciids: update-pciids.sh
        sed <$< >$@ "s@^DEST=.*@DEST=$(IDSDIR)/$(PCI_IDS)@;s@^PCI_COMPRESSED_IDS=.*@PCI_COMPRESSED_IDS=$(PCI_COMPRESSED_IDS)@"
        chmod +x $@
 
+# The example of use of libpci
+example: example.o lib/$(PCILIB)
+example.o: example.c $(PCIINC)
+
 %: %.o
        $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
 
@@ -79,7 +83,7 @@ update-pciids: update-pciids.sh
 
 clean:
        rm -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core -o -name "*.orig"`
-       rm -f update-pciids lspci setpci lib/config.* lib/example *.[78] pci.ids.* lib/*.pc lib/*.so lib/*.so.*
+       rm -f update-pciids lspci setpci example lib/config.* *.[78] pci.ids.* lib/*.pc lib/*.so lib/*.so.*
        rm -rf maint/dist
 
 distclean: clean
diff --git a/README b/README
index 8c354bf57b119ed34475b46226c1063708518c8e..577c46a948c5b5e86d2404e38a45ba4ec4163a33 100644 (file)
--- a/README
+++ b/README
@@ -117,7 +117,7 @@ There is also a public GIT tree at:
 So far, there is only a little documentation for the library except for the
 general introduction in the pcilib(7) man page. If you want to use the
 library in your programs, please follow the comments in lib/pci.h and in
-the example program lib/example.c.
+the example program example.c.
 
 
 6. Feedback
diff --git a/example.c b/example.c
new file mode 100644 (file)
index 0000000..c7e4e8a
--- /dev/null
+++ b/example.c
@@ -0,0 +1,32 @@
+/*
+ *     The PCI Library -- Example of use (simplistic lister of PCI devices)
+ *
+ *     Written by Martin Mares and put to public domain. You can do
+ *     with it anything you want, but I don't give you any warranty.
+ */
+
+#include <stdio.h>
+
+#include "lib/pci.h"
+
+int main(void)
+{
+  struct pci_access *pacc;
+  struct pci_dev *dev;
+  unsigned int c;
+
+  pacc = pci_alloc();          /* Get the pci_access structure */
+  /* Set all options you want -- here we stick with the defaults */
+  pci_init(pacc);              /* Initialize the PCI library */
+  pci_scan_bus(pacc);          /* We want to get the list of devices */
+  for(dev=pacc->devices; dev; dev=dev->next)   /* Iterate over all devices */
+    {
+      pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES | PCI_FILL_CLASS);    /* Fill in header info we need */
+      c = pci_read_byte(dev, PCI_INTERRUPT_PIN);                               /* Read config register directly */
+      printf("%02x:%02x.%d vendor=%04x device=%04x class=%04x irq=%d (pin %d) base0=%lx\n",
+            dev->bus, dev->dev, dev->func, dev->vendor_id, dev->device_id,
+            dev->device_class, dev->irq, c, dev->base_addr[0]);
+    }
+  pci_cleanup(pacc);           /* Close everything */
+  return 0;
+}
index 83f413ec123c034533e36a73b1dd63d58f507f11..76083f502be248c8d997fa9f8acecd946fef6eef 100644 (file)
@@ -82,5 +82,3 @@ names-net.o: names-net.c $(INCL) names.h
 names-parse.o: names-parse.c $(INCL) names.h
 filter.o: filter.c $(INCL)
 nbsd-libpci.o: nbsd-libpci.c $(INCL)
-
-example: example.c $(PCILIB)
diff --git a/lib/example.c b/lib/example.c
deleted file mode 100644 (file)
index e7b5b66..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *     The PCI Library -- Example of use (simplistic lister of PCI devices)
- *
- *     Written by Martin Mares and put to public domain. You can do
- *     with it anything you want, but I don't give you any warranty.
- */
-
-#include <stdio.h>
-
-#include "pci.h"
-
-int main(void)
-{
-  struct pci_access *pacc;
-  struct pci_dev *dev;
-  unsigned int c;
-
-  pacc = pci_alloc();          /* Get the pci_access structure */
-  /* Set all options you want -- here we stick with the defaults */
-  pci_init(pacc);              /* Initialize the PCI library */
-  pci_scan_bus(pacc);          /* We want to get the list of devices */
-  for(dev=pacc->devices; dev; dev=dev->next)   /* Iterate over all devices */
-    {
-      pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES | PCI_FILL_CLASS);    /* Fill in header info we need */
-      c = pci_read_byte(dev, PCI_INTERRUPT_PIN);                               /* Read config register directly */
-      printf("%02x:%02x.%d vendor=%04x device=%04x class=%04x irq=%d (pin %d) base0=%lx\n",
-            dev->bus, dev->dev, dev->func, dev->vendor_id, dev->device_id,
-            dev->device_class, dev->irq, c, dev->base_addr[0]);
-    }
-  pci_cleanup(pacc);           /* Close everything */
-  return 0;
-}