]> mj.ucw.cz Git - pciutils.git/blob - lib/Makefile
MacOS: An attempt to appease compiler picky about attribute placement
[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 all: $(PCILIB) $(PCILIBPC)
79
80 ifeq ($(SHARED),no)
81 $(PCILIB): $(addsuffix .o,$(OBJS))
82         rm -f $@
83         $(AR) rcs $@ $^
84         $(RANLIB) $@
85 else
86 ifeq ($(LIBEXT),dll)
87 all: $(PCIIMPDEF) $(PCIIMPLIB)
88 build.def: $(PCIIMPDEF)
89 $(PCIIMPDEF): libpci.ver ver2def.pl
90         perl ver2def.pl libpci.ver $(PCILIB) build.def $(PCIIMPDEF)
91 $(PCIIMPLIB): $(PCIIMPDEF)
92         $(DLLTOOL) --input-def $< --output-lib $@
93 comma := ,
94 dllrsrc.rc: winrsrc.rc.in
95         sed <$< >$@ -e 's,@PCILIB_VERSION@,$(PCILIB_VERSION),' \
96                 -e 's,@PCILIB_VERSION_WINRC@,$(subst .,\$(comma),$(PCILIB_VERSION).0),' \
97                 -e 's,@FILENAME@,$(PCILIB),' \
98                 -e 's,@DESCRIPTION@,libpci,' \
99                 -e 's,@LIBRARY_BUILD@,1,' \
100                 -e 's,@DEBUG_BUILD@,$(if $(findstring -g,$(CFLAGS)),1,0),'
101 dllrsrc.o: dllrsrc.rc
102         $(WINDRES) --input=$< --output=$@ --input-format=rc --output-format=coff
103 OBJS += dllrsrc
104 endif
105 CFLAGS += -fPIC -fvisibility=hidden
106 $(PCILIB): $(addsuffix .o,$(OBJS))
107         $(CC) -shared $(CFLAGS) $(LDFLAGS) $(PCILIB_LDFLAGS) -o $@ $^ $(LIB_LDLIBS)
108 ifeq ($(LIBEXT),dll)
109 $(PCILIB): build.def
110 endif
111 endif
112
113 $(PCILIBPC): libpci.pc.in
114         sed <$< >$@ -e 's,@PREFIX@,$(PREFIX),' \
115                 -e 's,@INCDIR@,$(INCDIR),' \
116                 -e 's,@LIBDIR@,$(LIBDIR),' \
117                 -e 's,@IDSDIR@,$(IDSDIR),' \
118                 -e 's,@VERSION@,$(VERSION),' \
119                 -e 's,@LDLIBS@,$(LDLIBS),' \
120                 -e 's,@WITH_LIBS@,$(WITH_LIBS),'
121
122 init.o: init.c $(INCL)
123 access.o: access.c $(INCL)
124 params.o: params.c $(INCL)
125 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
126 mmio-ports.o: mmio-ports.c $(INCL)
127 ecam.o: ecam.c $(INCL)
128 proc.o: proc.c $(INCL)
129 sysfs.o: sysfs.c $(INCL)
130 generic.o: generic.c $(INCL)
131 emulated.o: emulated.c $(INCL)
132 syscalls.o: syscalls.c $(INCL)
133 obsd-device.o: obsd-device.c $(INCL)
134 fbsd-device.o: fbsd-device.c $(INCL)
135 aix-device.o: aix-device.c $(INCL)
136 dump.o: dump.c $(INCL)
137 names.o: names.c $(INCL) names.h
138 names-cache.o: names-cache.c $(INCL) names.h
139 names-hash.o: names-hash.c $(INCL) names.h
140 names-net.o: names-net.c $(INCL) names.h
141 names-parse.o: names-parse.c $(INCL) names.h
142 names-hwdb.o: names-hwdb.c $(INCL) names.h
143 filter.o: filter.c $(INCL)
144 nbsd-libpci.o: nbsd-libpci.c $(INCL)
145 hurd.o: hurd.c $(INCL)
146 win32-cfgmgr32.o: win32-cfgmgr32.c $(INCL)
147 win32-kldbg.o: win32-kldbg.c $(INCL)
148 win32-sysdbg.o: win32-sysdbg.c $(INCL)
149
150 # MinGW32 toolchain has some required Win32 header files in /ddk subdirectory.
151 # But these header files include another header files from /ddk subdirectory
152 # and expect that build system has already set /ddk subdirectory into includes.
153 # So include /ddk subdirectory of each system predefined include path via -I.
154 ifdef PCI_HAVE_PM_WIN32_CFGMGR32
155 DDKCFLAGS:=$(shell echo | $(CC) $(CFLAGS) -E -Wp,-v -o /dev/null - 2>&1 | sed -n 's/^ \(.*\)/-I\1\/ddk/p')
156 win32-cfgmgr32.o: override CFLAGS+=$(DDKCFLAGS)
157 endif