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 ifdef PCI_HAVE_PM_WIN32_SYSDBG
66 all: $(PCILIB) $(PCILIBPC)
69 $(PCILIB): $(addsuffix .o,$(OBJS))
75 all: $(PCIIMPDEF) $(PCIIMPLIB)
76 build.def: $(PCIIMPDEF)
77 $(PCIIMPDEF): libpci.ver ver2def.pl
78 perl ver2def.pl libpci.ver $(PCILIB) build.def $(PCIIMPDEF)
79 $(PCIIMPLIB): $(PCIIMPDEF)
80 $(DLLTOOL) --input-def $< --output-lib $@
82 dllrsrc.rc: winrsrc.rc.in
83 sed <$< >$@ -e 's,@PCILIB_VERSION@,$(PCILIB_VERSION),' \
84 -e 's,@PCILIB_VERSION_WINRC@,$(subst .,\$(comma),$(PCILIB_VERSION).0),' \
85 -e 's,@FILENAME@,$(PCILIB),' \
86 -e 's,@DESCRIPTION@,libpci,' \
87 -e 's,@LIBRARY_BUILD@,1,' \
88 -e 's,@DEBUG_BUILD@,$(if $(findstring -g,$(CFLAGS)),1,0),'
90 $(WINDRES) --input=$< --output=$@ --input-format=rc --output-format=coff
93 CFLAGS += -fPIC -fvisibility=hidden
94 $(PCILIB): $(addsuffix .o,$(OBJS))
95 $(CC) -shared $(CFLAGS) $(LDFLAGS) $(PCILIB_LDFLAGS) -o $@ $^ $(LIB_LDLIBS)
101 $(PCILIBPC): libpci.pc.in
102 sed <$< >$@ -e 's,@PREFIX@,$(PREFIX),' \
103 -e 's,@INCDIR@,$(INCDIR),' \
104 -e 's,@LIBDIR@,$(LIBDIR),' \
105 -e 's,@IDSDIR@,$(IDSDIR),' \
106 -e 's,@VERSION@,$(VERSION),' \
107 -e 's,@LDLIBS@,$(LDLIBS),' \
108 -e 's,@WITH_LIBS@,$(WITH_LIBS),'
110 init.o: init.c $(INCL)
111 access.o: access.c $(INCL)
112 params.o: params.c $(INCL)
113 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
114 proc.o: proc.c $(INCL) pread.h
115 sysfs.o: sysfs.c $(INCL) pread.h
116 generic.o: generic.c $(INCL)
117 emulated.o: emulated.c $(INCL)
118 syscalls.o: syscalls.c $(INCL)
119 obsd-device.o: obsd-device.c $(INCL)
120 fbsd-device.o: fbsd-device.c $(INCL)
121 aix-device.o: aix-device.c $(INCL)
122 dump.o: dump.c $(INCL)
123 names.o: names.c $(INCL) names.h
124 names-cache.o: names-cache.c $(INCL) names.h
125 names-hash.o: names-hash.c $(INCL) names.h
126 names-net.o: names-net.c $(INCL) names.h
127 names-parse.o: names-parse.c $(INCL) names.h
128 names-hwdb.o: names-hwdb.c $(INCL) names.h
129 filter.o: filter.c $(INCL)
130 nbsd-libpci.o: nbsd-libpci.c $(INCL)
131 hurd.o: hurd.c $(INCL)
132 win32-cfgmgr32.o: win32-cfgmgr32.c $(INCL)
133 win32-sysdbg.o: win32-sysdbg.c $(INCL)
135 # MinGW32 toolchain has some required Win32 header files in /ddk subdirectory.
136 # But these header files include another header files from /ddk subdirectory
137 # and expect that build system has already set /ddk subdirectory into includes.
138 # So include /ddk subdirectory of each system predefined include path via -I.
139 ifdef PCI_HAVE_PM_WIN32_CFGMGR32
140 DDKCFLAGS:=$(shell echo | $(CC) $(CFLAGS) -E -Wp,-v -o /dev/null - 2>&1 | sed -n 's/^ \(.*\)/-I\1\/ddk/p')
141 win32-cfgmgr32.o: override CFLAGS+=$(DDKCFLAGS)