Revert "kdump: Add net/if_arp.h include"
[dragonfly.git] / usr.bin / kdump / mkioctls
CommitLineData
984263bc
MD
1set -e
2
3# $FreeBSD: src/usr.bin/kdump/mkioctls,v 1.15.2.5 2002/11/15 18:22:31 ru Exp $
a554e8a1 4# $DragonFly: src/usr.bin/kdump/mkioctls,v 1.9 2008/01/05 13:36:37 corecode Exp $
984263bc
MD
5
6if [ "x$1" = "x-s" ]; then
7 use_switch=1
8 shift
9else
10 use_switch=0
11fi
12
13if [ -z "$1" ]; then
14 echo "usage: sh $0 [-s] include-dir"
15 exit 1
16fi
17
18LC_ALL=C; export LC_ALL
19
20# Build a list of headers that have ioctls in them.
21# XXX should we use an ANSI cpp?
22# XXX netipx conflicts with netns (leave out netns).
9efd72e6
MD
23# XXX leave out cam/, isa/ pccard/, pci/, and usb/ because they
24# are fake softlinks and handled by bus/
984263bc
MD
25ioctl_includes=`
26 cd $1
27 find -s * -name '*.h' -follow |
9efd72e6 28 egrep -v '^(netns/)|^(cam/)|^(isa/)|^(pccard/)|^(pci/)|^(usb/)|^(netproto/natm/)' |
984263bc
MD
29 xargs egrep -l \
30'^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' |
31 awk '{printf("#include <%s>\\\\n", $1)}'
32`
33
34awk -v x="$ioctl_includes" 'BEGIN {print x}' |
a554e8a1 35 gcc -D_KERNEL_STRUCTURES -E -I$1 -dM - |
984263bc
MD
36 awk -v ioctl_includes="$ioctl_includes" -v use_switch="$use_switch" '
37BEGIN {
38 print "/* XXX obnoxious prerequisites. */"
39 print "#define COMPAT_43"
d9f3f6fa 40 print "#define _KERNEL_STRUCTURES"
984263bc
MD
41 print "#include <sys/param.h>"
42 print "#include <sys/devicestat.h>"
43 print "#include <sys/disklabel.h>"
595e3440 44 print "#include <sys/diskslice.h>"
984263bc
MD
45 print "#include <sys/socket.h>"
46 print "#include <sys/time.h>"
47 print "#include <sys/tty.h>"
48 print "#include <net/ethernet.h>"
49 print "#include <net/if.h>"
50 print "#include <net/if_var.h>"
51 print "#include <net/route.h>"
52 print "#include <netatm/atm.h>"
53 print "#include <netatm/atm_if.h>"
54 print "#include <netatm/atm_sap.h>"
55 print "#include <netatm/atm_sys.h>"
56 print "#include <netinet/in.h>"
38a690d7 57 print "#include <net/ip_mroute/ip_mroute.h>"
984263bc
MD
58 print "#include <netinet6/in6_var.h>"
59 print "#include <netinet6/nd6.h>"
60 print "#include <netinet6/ip6_mroute.h>"
984263bc 61 print "#include <stdio.h>"
b05e84c9 62 print "#include <cam/cam.h>"
984263bc
MD
63 print ""
64 print ioctl_includes
65 print ""
66 print "char *"
67 print "ioctlname(register_t val)"
68 print "{"
69 print ""
70 if (use_switch)
71 print "\tswitch(val) {"
72}
73
74/^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ {
75
76 # find where the name starts
77 for (i = 1; i <= NF; i++)
78 if ($i ~ /define/)
79 break;
80 ++i;
81 #
82 if (use_switch)
83 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $i, $i);
84 else
85 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i);
86
87}
88END {
89 if (use_switch)
90 print "\t}"
91 print "\n\treturn(NULL);"
92 print "}"
93}
94'