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