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_MMIO_CONF
25 ifdef PCI_HAVE_PM_DUMP
29 ifdef PCI_HAVE_PM_FBSD_DEVICE
31 CFLAGS += -I/usr/src/sys
33 CFLAGS += -I${FREEBSD_SYS}
37 ifdef PCI_HAVE_PM_OBSD_DEVICE
41 ifdef PCI_HAVE_PM_AIX_DEVICE
45 ifdef PCI_HAVE_PM_NBSD_LIBPCI
49 ifdef PCI_HAVE_PM_DARWIN_DEVICE
53 ifdef PCI_HAVE_PM_SYLIXOS_DEVICE
54 OBJS += sylixos-device
57 ifdef PCI_HAVE_PM_HURD_CONF
61 ifdef PCI_HAVE_PM_WIN32_CFGMGR32
63 OBJS += win32-cfgmgr32
66 ifdef PCI_HAVE_PM_WIN32_SYSDBG
70 all: $(PCILIB) $(PCILIBPC)
73 $(PCILIB): $(addsuffix .o,$(OBJS))
79 all: $(PCIIMPDEF) $(PCIIMPLIB)
80 build.def: $(PCIIMPDEF)
81 $(PCIIMPDEF): libpci.ver ver2def.pl
82 perl ver2def.pl libpci.ver $(PCILIB) build.def $(PCIIMPDEF)
83 $(PCIIMPLIB): $(PCIIMPDEF)
84 $(DLLTOOL) --input-def $< --output-lib $@
86 dllrsrc.rc: winrsrc.rc.in
87 sed <$< >$@ -e 's,@PCILIB_VERSION@,$(PCILIB_VERSION),' \
88 -e 's,@PCILIB_VERSION_WINRC@,$(subst .,\$(comma),$(PCILIB_VERSION).0),' \
89 -e 's,@FILENAME@,$(PCILIB),' \
90 -e 's,@DESCRIPTION@,libpci,' \
91 -e 's,@LIBRARY_BUILD@,1,' \
92 -e 's,@DEBUG_BUILD@,$(if $(findstring -g,$(CFLAGS)),1,0),'
94 $(WINDRES) --input=$< --output=$@ --input-format=rc --output-format=coff
97 CFLAGS += -fPIC -fvisibility=hidden
98 $(PCILIB): $(addsuffix .o,$(OBJS))
99 $(CC) -shared $(CFLAGS) $(LDFLAGS) $(PCILIB_LDFLAGS) -o $@ $^ $(LIB_LDLIBS)
105 $(PCILIBPC): libpci.pc.in
106 sed <$< >$@ -e 's,@PREFIX@,$(PREFIX),' \
107 -e 's,@INCDIR@,$(INCDIR),' \
108 -e 's,@LIBDIR@,$(LIBDIR),' \
109 -e 's,@IDSDIR@,$(IDSDIR),' \
110 -e 's,@VERSION@,$(VERSION),' \
111 -e 's,@LDLIBS@,$(LDLIBS),' \
112 -e 's,@WITH_LIBS@,$(WITH_LIBS),'
114 init.o: init.c $(INCL)
115 access.o: access.c $(INCL)
116 params.o: params.c $(INCL)
117 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
118 mmio-ports.o: mmio-ports.c $(INCL)
119 proc.o: proc.c $(INCL) pread.h
120 sysfs.o: sysfs.c $(INCL) pread.h
121 generic.o: generic.c $(INCL)
122 emulated.o: emulated.c $(INCL)
123 syscalls.o: syscalls.c $(INCL)
124 obsd-device.o: obsd-device.c $(INCL)
125 fbsd-device.o: fbsd-device.c $(INCL)
126 aix-device.o: aix-device.c $(INCL)
127 dump.o: dump.c $(INCL)
128 names.o: names.c $(INCL) names.h
129 names-cache.o: names-cache.c $(INCL) names.h
130 names-hash.o: names-hash.c $(INCL) names.h
131 names-net.o: names-net.c $(INCL) names.h
132 names-parse.o: names-parse.c $(INCL) names.h
133 names-hwdb.o: names-hwdb.c $(INCL) names.h
134 filter.o: filter.c $(INCL)
135 nbsd-libpci.o: nbsd-libpci.c $(INCL)
136 hurd.o: hurd.c $(INCL)
137 win32-cfgmgr32.o: win32-cfgmgr32.c $(INCL)
138 win32-sysdbg.o: win32-sysdbg.c $(INCL)
140 # MinGW32 toolchain has some required Win32 header files in /ddk subdirectory.
141 # But these header files include another header files from /ddk subdirectory
142 # and expect that build system has already set /ddk subdirectory into includes.
143 # So include /ddk subdirectory of each system predefined include path via -I.
144 ifdef PCI_HAVE_PM_WIN32_CFGMGR32
145 DDKCFLAGS:=$(shell echo | $(CC) $(CFLAGS) -E -Wp,-v -o /dev/null - 2>&1 | sed -n 's/^ \(.*\)/-I\1\/ddk/p')
146 win32-cfgmgr32.o: override CFLAGS+=$(DDKCFLAGS)