#!/bin/bash
cd /usr/src/udev-[0-9]*/ ||exit

#Create some devices and directories that Udev cannot handle due to
#them being required very early in the boot process:
install -dv /lib/{firmware,udev/devices/{pts,shm}}
mknod -m0666 /lib/udev/devices/null c 1 3
ln -sv /proc/self/fd /lib/udev/devices/fd
ln -sv /proc/self/fd/0 /lib/udev/devices/stdin
ln -sv /proc/self/fd/1 /lib/udev/devices/stdout
ln -sv /proc/self/fd/2 /lib/udev/devices/stderr
ln -sv /proc/kcore /lib/udev/devices/core

export MYCFLAGS=$CFLAGS &&
make EXTRAS="extras/ata_id extras/cdrom_id extras/edd_id \
            extras/firmware extras/floppy extras/path_id \
            extras/scsi_id extras/usb_id extras/volume_id" V=true OPTFLAGS='$(MYCFLAGS)' &&
#make test &&
make DESTDIR=/ EXTRAS="extras/ata_id extras/cdrom_id extras/edd_id \
            extras/firmware extras/floppy extras/path_id \
            extras/scsi_id extras/usb_id extras/volume_id" V=true install
#Udev's configuration is far from ideal by default, so install the
#configuration files here:
cp -v ../udev-config-[0-9]*/[0-9]* /etc/udev/rules.d/

#install missing helper script:
install -v -m 744 ../udev-config-[0-9]*/write_cd_aliases /lib/udev/

#Install the documentation that explains how to create Udev rules:
install -m644 -D -v docs/writing_udev_rules/index.html /usr/share/doc/udev/index.html
