Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # initialy from $FreeBSD: src/usr.bin/kdump/mkioctls,v 1.18 2000/08/02 07:37:44 ru Exp $ |
| 4 | # changed by Gaƫl Roualland. |
| 5 | |
| 6 | # Validate arg count. |
| 7 | if [ $# -ne 1 ] |
| 8 | then |
| 9 | echo "usage: $0 include-directory" >&2 |
| 10 | exit 1 |
| 11 | fi |
| 12 | |
| 13 | # build a list of files with ioctls |
| 14 | ioctl_includes=` |
| 15 | cd $1 |
| 16 | find * -name '*.h' -follow | |
| 17 | egrep -v '^(netns)/' | |
| 18 | xargs egrep -l \ |
| 19 | '^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]'` |
| 20 | |
| 21 | # Generate the output file. |
| 22 | echo '/* This file is automatically generated by ioctlent.sh */' |
| 23 | echo |
| 24 | echo '/* XXX obnoxious prerequisites. */' |
| 25 | echo '#define COMPAT_43' |
| 26 | echo |
| 27 | echo '#include <sys/types.h>' |
| 28 | echo '#include <sys/param.h>' |
| 29 | echo '#include <sys/devicestat.h>' |
| 30 | echo '#include <sys/disklabel.h>' |
| 31 | echo '#include <sys/socket.h>' |
| 32 | echo '#include <sys/time.h>' |
| 33 | echo '#include <sys/tty.h>' |
| 34 | echo '#include <net/ethernet.h>' |
| 35 | echo '#include <net/if.h>' |
| 36 | echo '#include <net/if_var.h>' |
| 37 | echo '#include <net/route.h>' |
| 38 | echo '#include <netatm/atm.h>' |
| 39 | echo '#include <netatm/atm_if.h>' |
| 40 | echo '#include <netatm/atm_sap.h>' |
| 41 | echo '#include <netatm/atm_sys.h>' |
| 42 | echo '#include <netinet/in.h>' |
| 43 | echo '#include <netinet/ip_compat.h>' |
| 44 | echo '#include <netinet/ip_fil.h>' |
| 45 | echo '#include <netinet/ip_auth.h>' |
| 46 | echo '#include <netinet/ip_nat.h>' |
| 47 | echo '#include <netinet/ip_frag.h>' |
| 48 | echo '#include <netinet/ip_state.h>' |
| 49 | echo '#include <netinet/ip_mroute.h>' |
| 50 | echo '#include <netinet6/in6_var.h>' |
| 51 | echo '#include <netinet6/nd6.h>' |
| 52 | echo '#include <netinet6/ip6_mroute.h>' |
| 53 | echo '#include <cam/cam.h>' |
| 54 | echo '#include <stdio.h>' |
| 55 | echo |
| 56 | echo "$ioctl_includes" | sed -e 's/^/#include </' -e s'/$/>/' |
| 57 | echo |
| 58 | echo 'struct ioctlent ioctlent [] =' |
| 59 | echo '{' |
| 60 | (cd $1 && for i in $ioctl_includes ; do echo "#include <$i>" | gcc -I$1 -E -dM - | egrep '^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' | sed -n -e 's|^#[ ]*define[ ]*\([A-Za-z_][A-Za-z0-9_]*\).*| { "'$i'", "\1", \1 },|p' ; done ) |
| 61 | |
| 62 | echo '};' |