]> mj.ucw.cz Git - pciutils.git/blob - lib/Makefile
windows: Deduplicate code and move helper functions to new file win32-helpers.c
[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_MMIO_CONF
22 OBJS += mmio-ports
23 endif
24
25 ifdef PCI_HAVE_PM_ECAM
26 OBJS += ecam
27 endif
28
29 ifdef PCI_HAVE_PM_DUMP
30 OBJS += dump
31 endif
32
33 ifdef PCI_HAVE_PM_FBSD_DEVICE
34 OBJS += fbsd-device
35 CFLAGS += -I/usr/src/sys
36 ifdef FREEBSD_SYS
37 CFLAGS += -I${FREEBSD_SYS}
38 endif
39 endif
40
41 ifdef PCI_HAVE_PM_OBSD_DEVICE
42 OBJS += obsd-device
43 endif
44
45 ifdef PCI_HAVE_PM_AIX_DEVICE
46 OBJS += aix-device
47 endif
48
49 ifdef PCI_HAVE_PM_NBSD_LIBPCI
50 OBJS += nbsd-libpci
51 endif
52
53 ifdef PCI_HAVE_PM_DARWIN_DEVICE
54 OBJS += darwin
55 endif
56
57 ifdef PCI_HAVE_PM_SYLIXOS_DEVICE
58 OBJS += sylixos-device
59 endif
60
61 ifdef PCI_HAVE_PM_HURD_CONF
62 OBJS += hurd
63 endif
64
65 ifdef PCI_HAVE_PM_WIN32_CFGMGR32
66 OBJS += emulated
67 OBJS += win32-cfgmgr32
68 endif
69
70 ifdef PCI_HAVE_PM_WIN32_KLDBG
71 OBJS += win32-kldbg
72 endif
73
74 ifdef PCI_HAVE_PM_WIN32_SYSDBG
75 OBJS += win32-sysdbg
76 endif
77
78 ifdef PCI_OS_WINDOWS
79 OBJS += win32-helpers
80 endif
81
82 all: $(PCILIB) $(PCILIBPC)
83
84 ifeq ($(SHARED),no)
85 $(PCILIB): $(addsuffix .o,$(OBJS))
86         rm -f $@
87         $(AR) rcs $@ $^
88         $(RANLIB) $@
89 else
90 ifeq ($(LIBEXT),dll)
91 all: $(PCIIMPDEF) $(PCIIMPLIB)
92 build.def: $(PCIIMPDEF)
93 $(PCIIMPDEF): libpci.ver ver2def.pl
94         perl ver2def.pl libpci.ver $(PCILIB) build.def $(PCIIMPDEF)
95 $(PCIIMPLIB): $(PCIIMPDEF)
96         $(DLLTOOL) --input-def $< --output-lib $@
97 comma := ,
98 dllrsrc.rc: winrsrc.rc.in
99         sed <$< >$@ -e 's,@PCILIB_VERSION@,$(PCILIB_VERSION),' \
100                 -e 's,@PCILIB_VERSION_WINRC@,$(subst .,\$(comma),$(PCILIB_VERSION).0),' \
101                 -e 's,@FILENAME@,$(PCILIB),' \
102                 -e 's,@DESCRIPTION@,libpci,' \
103                 -e 's,@LIBRARY_BUILD@,1,' \
104                 -e 's,@DEBUG_BUILD@,$(if $(findstring -g,$(CFLAGS)),1,0),'
105 dllrsrc.o: dllrsrc.rc
106         $(WINDRES) --input=$< --output=$@ --input-format=rc --output-format=coff
107 OBJS += dllrsrc
108 endif
109 CFLAGS += -fPIC -fvisibility=hidden
110 $(PCILIB): $(addsuffix .o,$(OBJS))
111         $(CC) -shared $(CFLAGS) $(LDFLAGS) $(PCILIB_LDFLAGS) -o $@ $^ $(LIB_LDLIBS)
112 ifeq ($(LIBEXT),dll)
113 $(PCILIB): build.def
114 endif
115 endif
116
117 $(PCILIBPC): libpci.pc.in
118         sed <$< >$@ -e 's,@PREFIX@,$(PREFIX),' \
119                 -e 's,@INCDIR@,$(INCDIR),' \
120                 -e 's,@LIBDIR@,$(LIBDIR),' \
121                 -e 's,@IDSDIR@,$(IDSDIR),' \
122                 -e 's,@VERSION@,$(VERSION),' \
123                 -e 's,@LDLIBS@,$(LDLIBS),' \
124                 -e 's,@WITH_LIBS@,$(WITH_LIBS),'
125
126 init.o: init.c $(INCL)
127 access.o: access.c $(INCL)
128 params.o: params.c $(INCL)
129 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
130 mmio-ports.o: mmio-ports.c $(INCL)
131 ecam.o: ecam.c $(INCL)
132 proc.o: proc.c $(INCL)
133 sysfs.o: sysfs.c $(INCL)
134 generic.o: generic.c $(INCL)
135 emulated.o: emulated.c $(INCL)
136 syscalls.o: syscalls.c $(INCL)
137 obsd-device.o: obsd-device.c $(INCL)
138 fbsd-device.o: fbsd-device.c $(INCL)
139 aix-device.o: aix-device.c $(INCL)
140 dump.o: dump.c $(INCL)
141 names.o: names.c $(INCL) names.h
142 names-cache.o: names-cache.c $(INCL) names.h
143 names-hash.o: names-hash.c $(INCL) names.h
144 names-net.o: names-net.c $(INCL) names.h
145 names-parse.o: names-parse.c $(INCL) names.h
146 names-hwdb.o: names-hwdb.c $(INCL) names.h
147 filter.o: filter.c $(INCL)
148 nbsd-libpci.o: nbsd-libpci.c $(INCL)
149 hurd.o: hurd.c $(INCL)
150 win32-helpers.o: win32-helpers.c $(INCL) win32-helpers.h
151 win32-cfgmgr32.o: win32-cfgmgr32.c $(INCL) win32-helpers.h
152 win32-kldbg.o: win32-kldbg.c $(INCL) win32-helpers.h
153 win32-sysdbg.o: win32-sysdbg.c $(INCL) win32-helpers.h
154 i386-io-windows.h: win32-helpers.h
155
156 # MinGW32 toolchain has some required Win32 header files in /ddk subdirectory.
157 # But these header files include another header files from /ddk subdirectory
158 # and expect that build system has already set /ddk subdirectory into includes.
159 # So include /ddk subdirectory of each system predefined include path via -I.
160 ifdef PCI_HAVE_PM_WIN32_CFGMGR32
161 DDKCFLAGS:=$(shell echo | $(CC) $(CFLAGS) -E -Wp,-v -o /dev/null - 2>&1 | sed -n 's/^ \(.*\)/-I\1\/ddk/p')
162 win32-cfgmgr32.o: override CFLAGS+=$(DDKCFLAGS)
163 endif