summaryrefslogtreecommitdiffstats
path: root/usr.bin/kdump
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>1999-12-03 12:50:02 +0000
committermarcel <marcel@FreeBSD.org>1999-12-03 12:50:02 +0000
commitc0a34be120b2de37d57788f7bcfa77b2dcc24361 (patch)
tree4f0eb42e86e10ee8df71b00c4b09be260150a287 /usr.bin/kdump
parent1549e3aa74b7557d9a7f6425fc83de63c9dd4f84 (diff)
downloadFreeBSD-src-c0a34be120b2de37d57788f7bcfa77b2dcc24361.zip
FreeBSD-src-c0a34be120b2de37d57788f7bcfa77b2dcc24361.tar.gz
Avoid hardcoding any paths and variables. The include directory must
now be specified on the command line. Accept a '-s' option which controls whether a switch-statement is to be used instead of a series of if-statements. Replace cpp with gcc -E. Discussed with: bde
Diffstat (limited to 'usr.bin/kdump')
-rw-r--r--usr.bin/kdump/Makefile2
-rw-r--r--usr.bin/kdump/mkioctls25
2 files changed, 19 insertions, 8 deletions
diff --git a/usr.bin/kdump/Makefile b/usr.bin/kdump/Makefile
index daa288f..534538f 100644
--- a/usr.bin/kdump/Makefile
+++ b/usr.bin/kdump/Makefile
@@ -8,6 +8,6 @@ SRCS= kdump.c ioctl.c subr.c
CLEANFILES+=ioctl.c
ioctl.c: mkioctls
- DESTDIR=${DESTDIR} /bin/sh ${.CURDIR}/mkioctls > ioctl.c
+ sh ${.CURDIR}/mkioctls ${DESTDIR}/usr/include > ioctl.c
.include <bsd.prog.mk>
diff --git a/usr.bin/kdump/mkioctls b/usr.bin/kdump/mkioctls
index cbf2f06..5c5dca9 100644
--- a/usr.bin/kdump/mkioctls
+++ b/usr.bin/kdump/mkioctls
@@ -2,11 +2,23 @@ set -e
# $FreeBSD$
+if [ "x$1" = "x-s" ]; then
+ use_switch=1
+ shift
+else
+ use_switch=0
+fi
+
+if [ -z "$1" ]; then
+ echo "usage: sh $0 [-s] include-dir"
+ exit 1
+fi
+
# Build a list of headers that have ioctls in them.
# XXX should we use an ANSI cpp?
# XXX netipx conflicts with netns (leave out netns).
ioctl_includes=`
- cd $DESTDIR/usr/include
+ cd $1
find * -name '*.h' -follow |
egrep -v '^(netns)/' |
xargs egrep -l \
@@ -15,8 +27,8 @@ ioctl_includes=`
`
echo "$ioctl_includes" |
- cpp -I$DESTDIR/usr/include -dM |
- awk -v ioctl_includes="$ioctl_includes" '
+ gcc -E -I$1 -dM - |
+ awk -v ioctl_includes="$ioctl_includes" -v use_switch="$use_switch" '
BEGIN {
print "/* XXX obnoxious prerequisites. */"
print "#define COMPAT_43"
@@ -51,8 +63,7 @@ BEGIN {
print "ioctlname(register_t val)"
print "{"
print ""
- generate_case_statement = 0
- if (generate_case_statement)
+ if (use_switch)
print "\tswitch(val) {"
}
@@ -64,14 +75,14 @@ BEGIN {
break;
++i;
#
- if (generate_case_statement)
+ if (use_switch)
printf("\tcase %s:\n\t\treturn(\"%s\");\n", $i, $i);
else
printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i);
}
END {
- if (generate_case_statement)
+ if (use_switch)
print "\t}"
print "\n\treturn(NULL);"
print "}"
OpenPOWER on IntegriCloud