| 1 |
DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) |
| 2 |
DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null) |
| 3 |
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) |
| 4 |
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) |
| 5 |
|
| 6 |
# Take account of old dpkg-architecture output. |
| 7 |
ifeq ($(DEB_HOST_ARCH_OS),) |
| 8 |
DEB_HOST_ARCH_OS := $(subst -gnu,,$(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)) |
| 9 |
ifeq ($(DEB_HOST_ARCH_OS),gnu) |
| 10 |
DEB_HOST_ARCH_OS := hurd |
| 11 |
endif |
| 12 |
endif |
| 13 |
|
| 14 |
CC = gcc |
| 15 |
ifneq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE)) |
| 16 |
export CC=$(DEB_HOST_GNU_TYPE)-gcc |
| 17 |
endif |
| 18 |
CPPFLAGS = |
| 19 |
CFLAGS = -W -Wall -Os -g |
| 20 |
CFLAGS_ARCH = -DCPU_TEXT='"$(DEB_HOST_ARCH)"' |
| 21 |
|
| 22 |
# Use hardening flags too |
| 23 |
CFLAGS += `dpkg-buildflags --get CFLAGS` |
| 24 |
CPPFLAGS += `dpkg-buildflags --get CPPFLAGS` |
| 25 |
|
| 26 |
bindir=$(DESTDIR)/usr/bin/ |
| 27 |
hpdir=$(DESTDIR)/etc/hotplug.d |
| 28 |
netdir=$(DESTDIR)/etc/network |
| 29 |
udevdir=$(DESTDIR)/usr/lib/udev/rules.d |
| 30 |
didir=$(DESTDIR)/usr/lib/debian-installer.d |
| 31 |
fidir=$(DESTDIR)/usr/lib/finish-install.d |
| 32 |
sharedir=$(DESTDIR)/usr/share/hw-detect/ |
| 33 |
postbaseinstallerdir=$(DESTDIR)/usr/lib/post-base-installer.d/ |
| 34 |
prepkgseldir=$(DESTDIR)/usr/lib/pre-pkgsel.d/ |
| 35 |
man1dir=$(DESTDIR)/usr/share/man/man1 |
| 36 |
|
| 37 |
INSTALL=install |
| 38 |
INSTALL_DATA = ${INSTALL} -m 644 |
| 39 |
|
| 40 |
all: archdetect devnames-static.gz |
| 41 |
|
| 42 |
test: |
| 43 |
set -e; for sh in *.sh; do sh -n $$sh; done |
| 44 |
|
| 45 |
clean: |
| 46 |
rm -f *~ |
| 47 |
rm -f *.o |
| 48 |
rm -f archdetect |
| 49 |
rm -f devnames-static.gz |
| 50 |
|
| 51 |
install: install-hw-detect install-ethdetect install-disk-detect install-driver-injection-disk-detect install-archdetect install-archdetect-deb |
| 52 |
|
| 53 |
install-hw-detect: hw-detect.sh |
| 54 |
$(INSTALL) -d $(bindir) |
| 55 |
ifeq ($(DEB_HOST_ARCH_OS),linux) |
| 56 |
$(INSTALL) hw-detect.sh $(bindir)/hw-detect |
| 57 |
$(INSTALL) hotplug-pcmcia.sh $(bindir)/hotplug-pcmcia |
| 58 |
$(INSTALL) sysfs-update-devnames.sh $(bindir)/sysfs-update-devnames |
| 59 |
$(INSTALL) -d $(udevdir) |
| 60 |
$(INSTALL_DATA) net-hotplug.rules $(udevdir)/010_net-hotplug.rules |
| 61 |
$(INSTALL) check-missing-firmware.sh $(bindir)/check-missing-firmware |
| 62 |
$(INSTALL) -d $(postbaseinstallerdir) |
| 63 |
$(INSTALL) hw-detect.post-base-installer.d/* $(postbaseinstallerdir) |
| 64 |
$(INSTALL) -d $(prepkgseldir) |
| 65 |
$(INSTALL) hw-detect.pre-pkgsel.d/* $(prepkgseldir) |
| 66 |
$(INSTALL) -d $(hpdir)/net |
| 67 |
$(INSTALL) net-hotplug.sh $(hpdir)/net/hw-detect.hotplug |
| 68 |
$(INSTALL) -d $(fidir) |
| 69 |
$(INSTALL) hw-detect.finish-install.d/* $(fidir) |
| 70 |
ifeq ($(DEB_HOST_ARCH),powerpc) |
| 71 |
$(INSTALL) discover-mac-io.sh $(bindir)/discover-mac-io |
| 72 |
$(INSTALL) discover-ibm.sh $(bindir)/discover-ibm |
| 73 |
endif |
| 74 |
ifeq ($(DEB_HOST_ARCH),sparc) |
| 75 |
$(INSTALL) discover-sbus.sh $(bindir)/discover-sbus |
| 76 |
$(INSTALL) -d $(sharedir) |
| 77 |
$(INSTALL_DATA) sbus.list $(sharedir)/sbus.list |
| 78 |
endif |
| 79 |
else |
| 80 |
$(INSTALL) detect-stub.sh $(bindir)/hw-detect |
| 81 |
endif |
| 82 |
|
| 83 |
install-ethdetect: ethdetect.sh |
| 84 |
$(INSTALL) -d $(bindir) $(netdir) |
| 85 |
$(INSTALL) ethdetect.sh $(bindir)/ethdetect |
| 86 |
$(INSTALL) -m644 devnames-static.gz $(netdir)/ |
| 87 |
|
| 88 |
install-disk-detect: disk-detect.sh |
| 89 |
$(INSTALL) -d $(bindir) |
| 90 |
$(INSTALL) disk-detect.sh $(bindir)/disk-detect |
| 91 |
|
| 92 |
install-driver-injection-disk-detect: driver-injection-disk.sh |
| 93 |
$(INSTALL) -d $(bindir) |
| 94 |
$(INSTALL) driver-injection-disk.sh $(bindir)/driver-injection-disk |
| 95 |
|
| 96 |
install-archdetect: archdetect |
| 97 |
$(INSTALL) -d $(bindir) |
| 98 |
$(INSTALL) archdetect $(bindir) |
| 99 |
|
| 100 |
install-archdetect-deb: archdetect |
| 101 |
$(INSTALL) -d $(bindir) |
| 102 |
$(INSTALL) archdetect $(bindir) |
| 103 |
$(INSTALL) -d $(man1dir) |
| 104 |
$(INSTALL) archdetect.1 $(man1dir) |
| 105 |
|
| 106 |
archdetect: archdetect.o |
| 107 |
${CC} ${LDFLAGS} -o $@ $^ -ldebian-installer |
| 108 |
|
| 109 |
archdetect.o: %.o:%.c |
| 110 |
$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_ARCH) -c $< |
| 111 |
|
| 112 |
devnames-static.gz: devnames-static.txt |
| 113 |
grep -v '^#' $< | gzip -9cn > $@ |