blob: 7d8a21c92fe9a9052158a1dcf065295850a804c9 [file] [log] [blame]
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001#!/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.
7if [ $# -ne 1 ]
8then
9 echo "usage: $0 include-directory" >&2
10 exit 1
11fi
12
13# build a list of files with ioctls
14ioctl_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.
22echo '/* This file is automatically generated by ioctlent.sh */'
23echo
24echo '/* XXX obnoxious prerequisites. */'
25echo '#define COMPAT_43'
26echo
27echo '#include <sys/types.h>'
28echo '#include <sys/param.h>'
29echo '#include <sys/devicestat.h>'
30echo '#include <sys/disklabel.h>'
31echo '#include <sys/socket.h>'
32echo '#include <sys/time.h>'
33echo '#include <sys/tty.h>'
34echo '#include <net/ethernet.h>'
35echo '#include <net/if.h>'
36echo '#include <net/if_var.h>'
37echo '#include <net/route.h>'
38echo '#include <netatm/atm.h>'
39echo '#include <netatm/atm_if.h>'
40echo '#include <netatm/atm_sap.h>'
41echo '#include <netatm/atm_sys.h>'
42echo '#include <netinet/in.h>'
43echo '#include <netinet/ip_compat.h>'
44echo '#include <netinet/ip_fil.h>'
45echo '#include <netinet/ip_auth.h>'
46echo '#include <netinet/ip_nat.h>'
47echo '#include <netinet/ip_frag.h>'
48echo '#include <netinet/ip_state.h>'
49echo '#include <netinet/ip_mroute.h>'
50echo '#include <netinet6/in6_var.h>'
51echo '#include <netinet6/nd6.h>'
52echo '#include <netinet6/ip6_mroute.h>'
53echo '#include <cam/cam.h>'
54echo '#include <stdio.h>'
55echo
56echo "$ioctl_includes" | sed -e 's/^/#include </' -e s'/$/>/'
57echo
58echo 'struct ioctlent ioctlent [] ='
59echo '{'
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
62echo '};'