3 # $FreeBSD: src/usr.bin/kdump/mkioctls,v 1.15.2.5 2002/11/15 18:22:31 ru Exp $
7 if [ "x$1" = "x-s" ]; then
14 if [ -z "$1" -o -z "$2" ]; then
15 echo "usage: sh $0 [-s] include-dir current-dir"
19 LC_ALL
=C
; export LC_ALL
21 # Build a list of headers that have ioctls in them.
22 # Leave out fake softlinks.
25 find -s * -name '*.h' -follow |
26 egrep -v '^(cam/)|^(compat/)|^(fs/)|^(isofs/)|^(mfs/)|^(msdosfs/)|^(netipsec/)|^(netkey/)|^(netsmb/)|^(nfs/)|^(ntfs/)|^(pccard/)|^(ufs/)' |
28 '^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' |
29 awk '{printf("#include <%s>\\\\n", $1)}'
30 printf '#undef loff_t /* XXX ext2_fs.h defines it */\\\\n'
31 printf '#include <dev/drm/include/uapi_drm/drm.h>\\\\n'
32 printf '#include <dev/drm/include/uapi_drm/i915_drm.h>\\\\n'
33 printf '#include <dev/drm/include/uapi_drm/radeon_drm.h>\\\\n'
36 awk -v x
="$ioctl_includes" 'BEGIN {print x}' |
37 gcc
-D_KERNEL_STRUCTURES -E -I$1 -I$2/..
/..
/sys
-I$2/..
/..
/sys
/dev
/drm
/include
-dM - |
38 awk -v ioctl_includes
="$ioctl_includes" -v use_switch
="$use_switch" '
40 print "/* XXX obnoxious prerequisites. */"
41 print "#define _KERNEL_STRUCTURES"
42 print "#include <sys/tty.h>"
43 print "#include <net/if_arp.h>"
44 print "#include <net/route.h>"
45 print "#include <netinet/in.h>"
46 print "#include <net/ip_mroute/ip_mroute.h>"
47 print "#include <netinet6/nd6.h>"
48 print "#include <netinet6/ip6_mroute.h>"
49 print "#include <stdio.h>"
50 print "#include <cam/cam.h>"
51 print "#define ACPI_DEBUG_OUTPUT"
52 print "#define ACPI_APPLICATION"
53 print "#include <contrib/dev/acpica/source/include/acpi.h>"
54 print "#undef ACPI_APPLICATION"
55 print "#undef ACPI_DEBUG_OUTPUT"
58 print "const char *ioctlname(u_long);"
61 print "ioctlname(u_long val)"
64 print "\tswitch(val) {"
67 /^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ {
69 # find where the name starts
70 for (i = 1; i <= NF; i++)
76 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $i, $i);
78 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i);
82 /^#[ ]*define[ ]+[^ ]+[ ]+DRM_IO/ {
84 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $2, $2);
86 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $2, $2);
89 /^#[ ]*define[ ]+[^ ]+[ ]+MIXER_(READ|WRITE)/ {
91 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $2, $2);
93 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $2, $2);
99 print "\n\treturn(NULL);"