sysinfo: Make libpci an optional dependency

This commit is contained in:
Patrick Griffis 2017-11-18 20:47:32 -05:00
parent 47b653cc7c
commit 3e53635dfb
2 changed files with 29 additions and 10 deletions

View File

@ -19,14 +19,17 @@ if system == 'linux' or system == 'darwin'
] ]
if system == 'linux' if system == 'linux'
libpci = dependency('libpci') libpci = dependency('libpci', required: false)
if libpci.found()
sysinfo_deps += libpci sysinfo_deps += libpci
sysinfo_cargs += '-DHAVE_LIBPCI'
sysinfo_sources += 'unix/pci.c'
endif
sysinfo_includes += 'unix' sysinfo_includes += 'unix'
sysinfo_sources += [ sysinfo_sources += [
'unix/backend.c', 'unix/backend.c',
'unix/match.c', 'unix/match.c',
'unix/parse.c', 'unix/parse.c',
'unix/pci.c',
] ]
picidsdir = libpci.get_pkgconfig_variable('idsdir') picidsdir = libpci.get_pkgconfig_variable('idsdir')

View File

@ -140,6 +140,9 @@ gint64 xs_parse_uptime(void)
int xs_parse_sound(char *snd_card) int xs_parse_sound(char *snd_card)
{ {
#ifndef HAVE_LIBPCI
return 1;
#else
char buffer[bsize], cards[bsize] = "\0", vendor[7] = "\0", device[7] = "\0", *pos; char buffer[bsize], cards[bsize] = "\0", vendor[7] = "\0", device[7] = "\0", *pos;
u16 class = PCI_CLASS_MULTIMEDIA_AUDIO; u16 class = PCI_CLASS_MULTIMEDIA_AUDIO;
@ -178,10 +181,14 @@ int xs_parse_sound(char *snd_card)
fclose(fp); fclose(fp);
return 0; return 0;
#endif
} }
int xs_parse_video(char *vid_card) int xs_parse_video(char *vid_card)
{ {
#ifndef HAVE_LIBPCI
return 1;
#else
char vendor[7] = "\0", device[7] = "\0"; char vendor[7] = "\0", device[7] = "\0";
u16 class = PCI_CLASS_DISPLAY_VGA; u16 class = PCI_CLASS_DISPLAY_VGA;
if (pci_find_by_class(&class, vendor, device)) if (pci_find_by_class(&class, vendor, device))
@ -189,10 +196,14 @@ int xs_parse_video(char *vid_card)
else else
pci_find_fullname(vid_card, vendor, device); pci_find_fullname(vid_card, vendor, device);
return 0; return 0;
#endif
} }
int xs_parse_ether(char *ethernet_card) int xs_parse_ether(char *ethernet_card)
{ {
#ifndef HAVE_LIBPCI
return 1;
#else
char vendor[7] = "\0", device[7] = "\0"; char vendor[7] = "\0", device[7] = "\0";
u16 class = PCI_CLASS_NETWORK_ETHERNET; u16 class = PCI_CLASS_NETWORK_ETHERNET;
if (pci_find_by_class(&class, vendor, device)) if (pci_find_by_class(&class, vendor, device))
@ -200,10 +211,14 @@ int xs_parse_ether(char *ethernet_card)
else else
pci_find_fullname(ethernet_card, vendor, device); pci_find_fullname(ethernet_card, vendor, device);
return 0; return 0;
#endif
} }
int xs_parse_agpbridge(char *agp_bridge) int xs_parse_agpbridge(char *agp_bridge)
{ {
#ifndef HAVE_LIBPCI
return 1;
#else
char vendor[7] = "\0", device[7] = "\0"; char vendor[7] = "\0", device[7] = "\0";
u16 class = PCI_CLASS_BRIDGE_HOST; u16 class = PCI_CLASS_BRIDGE_HOST;
if (pci_find_by_class(&class, vendor, device)) if (pci_find_by_class(&class, vendor, device))
@ -211,6 +226,7 @@ int xs_parse_agpbridge(char *agp_bridge)
else else
pci_find_fullname(agp_bridge, vendor, device); pci_find_fullname(agp_bridge, vendor, device);
return 0; return 0;
#endif
} }
int xs_parse_meminfo(unsigned long long *mem_tot, unsigned long long *mem_free, int swap) int xs_parse_meminfo(unsigned long long *mem_tot, unsigned long long *mem_free, int swap)