1 # Makefile for The PCI Library
2 # (c) 1999--2014 Martin Mares <mj@ucw.cz>
4 # Expects to be invoked from the top-level Makefile and uses lots of its variables.
6 OBJS=init access generic dump names filter names-hash names-parse names-net names-cache names-hwdb params caps
7 INCL=internal.h pci.h config.h header.h sysdep.h types.h
9 ifdef PCI_HAVE_PM_LINUX_SYSFS
13 ifdef PCI_HAVE_PM_LINUX_PROC
17 ifdef PCI_HAVE_PM_INTEL_CONF
21 ifdef PCI_HAVE_PM_DUMP
25 ifdef PCI_HAVE_PM_FBSD_DEVICE
27 CFLAGS += -I/usr/src/sys
29 CFLAGS += -I${FREEBSD_SYS}
33 ifdef PCI_HAVE_PM_OBSD_DEVICE
37 ifdef PCI_HAVE_PM_AIX_DEVICE
41 ifdef PCI_HAVE_PM_NBSD_LIBPCI
45 ifdef PCI_HAVE_PM_DARWIN_DEVICE
49 ifdef PCI_HAVE_PM_SYLIXOS_DEVICE
50 OBJS += sylixos-device
53 ifdef PCI_HAVE_PM_HURD_CONF
57 ifdef PCI_HAVE_PM_WIN32_CFGMGR32
59 OBJS += win32-cfgmgr32
62 all: $(PCILIB) $(PCILIBPC)
65 $(PCILIB): $(addsuffix .o,$(OBJS))
71 all: $(PCIIMPDEF) $(PCIIMPLIB)
72 build.def: $(PCIIMPDEF)
73 $(PCIIMPDEF): libpci.ver ver2def.pl
74 perl ver2def.pl libpci.ver $(PCILIB) build.def $(PCIIMPDEF)
75 $(PCIIMPLIB): $(PCIIMPDEF)
76 $(DLLTOOL) --input-def $< --output-lib $@
78 dllrsrc.rc: dllrsrc.rc.in
79 sed <$< >$@ -e 's,@PCILIB_VERSION@,$(PCILIB_VERSION),' \
80 -e 's,@PCILIB_VERSION_WINRC@,$(subst .,\$(comma),$(PCILIB_VERSION).0),' \
81 -e 's,@PCILIB@,$(PCILIB),' \
82 -e 's,@DEBUG_BUILD@,$(if $(findstring -g,$(CFLAGS)),1,0),'
84 $(WINDRES) --input=$< --output=$@ --input-format=rc --output-format=coff
87 CFLAGS += -fPIC -fvisibility=hidden
88 $(PCILIB): $(addsuffix .o,$(OBJS))
89 $(CC) -shared $(CFLAGS) $(LDFLAGS) $(PCILIB_LDFLAGS) -o $@ $^ $(LIB_LDLIBS)
95 $(PCILIBPC): libpci.pc.in
96 sed <$< >$@ -e 's,@PREFIX@,$(PREFIX),' \
97 -e 's,@INCDIR@,$(INCDIR),' \
98 -e 's,@LIBDIR@,$(LIBDIR),' \
99 -e 's,@IDSDIR@,$(IDSDIR),' \
100 -e 's,@VERSION@,$(VERSION),' \
101 -e 's,@LDLIBS@,$(LDLIBS),' \
102 -e 's,@WITH_LIBS@,$(WITH_LIBS),'
104 init.o: init.c $(INCL)
105 access.o: access.c $(INCL)
106 params.o: params.c $(INCL)
107 i386-ports.o: i386-ports.c $(INCL) i386-io-hurd.h i386-io-linux.h i386-io-sunos.h i386-io-windows.h i386-io-cygwin.h
108 proc.o: proc.c $(INCL) pread.h
109 sysfs.o: sysfs.c $(INCL) pread.h
110 generic.o: generic.c $(INCL)
111 emulated.o: emulated.c $(INCL)
112 syscalls.o: syscalls.c $(INCL)
113 obsd-device.o: obsd-device.c $(INCL)
114 fbsd-device.o: fbsd-device.c $(INCL)
115 aix-device.o: aix-device.c $(INCL)
116 dump.o: dump.c $(INCL)
117 names.o: names.c $(INCL) names.h
118 names-cache.o: names-cache.c $(INCL) names.h
119 names-hash.o: names-hash.c $(INCL) names.h
120 names-net.o: names-net.c $(INCL) names.h
121 names-parse.o: names-parse.c $(INCL) names.h
122 names-hwdb.o: names-hwdb.c $(INCL) names.h
123 filter.o: filter.c $(INCL)
124 nbsd-libpci.o: nbsd-libpci.c $(INCL)
125 hurd.o: hurd.c $(INCL)
126 win32-cfgmgr32.o: win32-cfgmgr32.c $(INCL)
128 # MinGW32 toolchain has some required Win32 header files in /ddk subdirectory.
129 # But these header files include another header files from /ddk subdirectory
130 # and expect that build system has already set /ddk subdirectory into includes.
131 # So include /ddk subdirectory of each system predefined include path via -I.
132 ifdef PCI_HAVE_PM_WIN32_CFGMGR32
133 DDKCFLAGS:=$(shell echo | $(CC) $(CFLAGS) -E -Wp,-v -o /dev/null - 2>&1 | sed -n 's/^ \(.*\)/-I\1\/ddk/p')
134 win32-cfgmgr32.o: override CFLAGS+=$(DDKCFLAGS)