]> mj.ucw.cz Git - pciutils.git/blob - lib/Makefile
ae2314408eaf252fb8356583503e9c9e5d8008f6
[pciutils.git] / lib / Makefile
1 # Makefile for The PCI Library
2 # (c) 1999--2014 Martin Mares <mj@ucw.cz>
3
4 # Expects to be invoked from the top-level Makefile and uses lots of its variables.
5
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
8
9 ifdef PCI_HAVE_PM_LINUX_SYSFS
10 OBJS += sysfs
11 endif
12
13 ifdef PCI_HAVE_PM_LINUX_PROC
14 OBJS += proc
15 endif
16
17 ifdef PCI_HAVE_PM_INTEL_CONF
18 OBJS += i386-ports
19 endif
20
21 ifdef PCI_HAVE_PM_DUMP
22 OBJS += dump
23 endif
24
25 ifdef PCI_HAVE_PM_FBSD_DEVICE
26 OBJS += fbsd-device
27 CFLAGS += -I/usr/src/sys
28 ifdef FREEBSD_SYS
29 CFLAGS += -I${FREEBSD_SYS}
30 endif
31 endif
32
33 ifdef PCI_HAVE_PM_OBSD_DEVICE
34 OBJS += obsd-device
35 endif
36
37 ifdef PCI_HAVE_PM_AIX_DEVICE
38 OBJS += aix-device
39 endif
40
41 ifdef PCI_HAVE_PM_NBSD_LIBPCI
42 OBJS += nbsd-libpci
43 endif
44
45 ifdef PCI_HAVE_PM_DARWIN_DEVICE
46 OBJS += darwin
47 endif
48
49 ifdef PCI_HAVE_PM_SYLIXOS_DEVICE
50 OBJS += sylixos-device
51 endif
52
53 ifdef PCI_HAVE_PM_HURD_CONF
54 OBJS += hurd
55 endif
56
57 ifdef PCI_HAVE_PM_WIN32_CFGMGR32
58 OBJS += emulated
59 OBJS += win32-cfgmgr32
60 endif
61
62 all: $(PCILIB) $(PCILIBPC)
63
64 ifeq ($(SHARED),no)
65 $(PCILIB): $(addsuffix .o,$(OBJS))
66         rm -f $@
67         $(AR) rcs $@ $^
68         $(RANLIB) $@
69 else
70 ifeq ($(LIBEXT),dll)
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 $@
77 endif
78 CFLAGS += -fPIC -fvisibility=hidden
79 $(PCILIB): $(addsuffix .o,$(OBJS))
80         $(CC) -shared $(CFLAGS) $(LDFLAGS) $(PCILIB_LDFLAGS) -o $@ $^ $(LIB_LDLIBS)
81 ifeq ($(LIBEXT),dll)
82 $(PCILIB): build.def
83 endif
84 endif
85
86 $(PCILIBPC): libpci.pc.in
87         sed <$< >$@ -e 's,@PREFIX@,$(PREFIX),' \
88                 -e 's,@INCDIR@,$(INCDIR),' \
89                 -e 's,@LIBDIR@,$(LIBDIR),' \
90                 -e 's,@IDSDIR@,$(IDSDIR),' \
91                 -e 's,@VERSION@,$(VERSION),' \
92                 -e 's,@LDLIBS@,$(LDLIBS),' \
93                 -e 's,@WITH_LIBS@,$(WITH_LIBS),'
94
95 init.o: init.c $(INCL)
96 access.o: access.c $(INCL)
97 params.o: params.c $(INCL)
98 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
99 proc.o: proc.c $(INCL) pread.h
100 sysfs.o: sysfs.c $(INCL) pread.h
101 generic.o: generic.c $(INCL)
102 emulated.o: emulated.c $(INCL)
103 syscalls.o: syscalls.c $(INCL)
104 obsd-device.o: obsd-device.c $(INCL)
105 fbsd-device.o: fbsd-device.c $(INCL)
106 aix-device.o: aix-device.c $(INCL)
107 dump.o: dump.c $(INCL)
108 names.o: names.c $(INCL) names.h
109 names-cache.o: names-cache.c $(INCL) names.h
110 names-hash.o: names-hash.c $(INCL) names.h
111 names-net.o: names-net.c $(INCL) names.h
112 names-parse.o: names-parse.c $(INCL) names.h
113 names-hwdb.o: names-hwdb.c $(INCL) names.h
114 filter.o: filter.c $(INCL)
115 nbsd-libpci.o: nbsd-libpci.c $(INCL)
116 hurd.o: hurd.c $(INCL)
117 win32-cfgmgr32.o: win32-cfgmgr32.c $(INCL)
118
119 # MinGW32 toolchain has some required Win32 header files in /ddk subdirectory.
120 # But these header files include another header files from /ddk subdirectory
121 # and expect that build system has already set /ddk subdirectory into includes.
122 # So include /ddk subdirectory of each system predefined include path via -I.
123 ifdef PCI_HAVE_PM_WIN32_CFGMGR32
124 DDKCFLAGS:=$(shell echo | $(CC) $(CFLAGS) -E -Wp,-v -o /dev/null - 2>&1 | sed -n 's/^ \(.*\)/-I\1\/ddk/p')
125 win32-cfgmgr32.o: override CFLAGS+=$(DDKCFLAGS)
126 endif