summaryrefslogtreecommitdiff
path: root/hurd/Makefile
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-01-24 22:53:41 +0000
committerRoland McGrath <roland@gnu.org>1999-01-24 22:53:41 +0000
commitc2d213e2c185befda32325691750461b8395ba3d (patch)
tree71d8946d53e3bb4cffd297de6d958fe427258799 /hurd/Makefile
parente2d39f1f8f05d27d82e50159846128cdbf835c98 (diff)
1999-01-24 Roland McGrath <roland@baalperazim.frob.com>
* Makefile: Add rules for generating prototype ?ioctl.defs files from a list of C headers that define the ioctl request macros. (DIST_FILES): Add ioctl-tmpl.sym ioctl.awk gensym.awk. * gensym.awk, ioctl-decode.h, ioctl-tmpl.sym, ioctl.awk: New files supporting those rules.
Diffstat (limited to 'hurd/Makefile')
-rw-r--r--hurd/Makefile49
1 files changed, 47 insertions, 2 deletions
diff --git a/hurd/Makefile b/hurd/Makefile
index 53436d87..1b133aaa 100644
--- a/hurd/Makefile
+++ b/hurd/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation
+# Copyright (C) 1993, 94, 95, 96, 99 Free Software Foundation
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -19,7 +19,7 @@ dir := hurd
makemode := misc
hdrs = $(wildcard $(srcdir)/*.defs $(srcdir)/*.h)
-DIST_FILES = subsystems $(notdir $(hdrs))
+DIST_FILES = subsystems $(notdir $(hdrs)) ioctl-tmpl.sym ioctl.awk gensym.awk
INSTHDRS = hurd_types.h ioctl_types.h paths.h shared.h \
$(notdir $(wildcard $(srcdir)/*.defs))
@@ -32,3 +32,48 @@ install-headers install: $(includedir)/hurd \
$(includedir)/hurd/%: $(srcdir)/%; $(INSTALL_DATA) $< $@
$(includedir)/hurd:;mkdir -p $@
+
+
+
+#
+# The following rules assist in creating an `Xioctl.defs' file
+# to define RPCs that are sent primarily by ioctl commands.
+# To use them, write a file `Xioctl-headers.h', e.g. for `mioctl-headers.h':
+# #include <sys/mtio.h>
+# with an #include for each header that defines ioctl request macros
+# using _IO('X') et al. Then `make Xioctl-proto.defs' will create
+# a prototype file for you to hand-edit into `Xioctl.defs'.
+
+# Building foo.h from foo.sym:
+%.symc: %.sym
+ $(AWK) -f $(srcdir)/gensym.awk $< >$*.symc
+%.symc.o: %.symc
+ $(CC) -S $(CPPFLAGS) $(CFLAGS) $(CPPFLAGS-$@) -x c -o $@ $<
+%.h: %.symc.o
+ sed <$< -e 's/^[^*].*$$//' | \
+ sed -e 's/^[*]/#define/' -e 's/mAgIc[^-0-9]*//' -e '/^ *$$/d' >$@
+
+%-ioctls.sym: tmpl-ioctls.sym
+ sed 's|HEADER|<$(subst +,/,$*)>|' $< > $@
+
+cpp = $(CC) $(CPPFLAGS) $(CFLAGS) $(CPPFLAGS-$@) -E -x c
+
+%ioctl-requests.list: %ioctl-headers.h
+ $(cpp) $< | sed -n 's/^#.*"\([^"]*\)".*$$/\1/p' | sort | uniq | \
+ while read f; do \
+ sed -n 's/^[ ]*#[ ]*define[ ]*\([A-Z0-9_]*\)[^A-Z0-9_][^A-Z0-9_]*_IO.*'\'$*\'.*$$'/\1/p' $$f; \
+ done | sort | uniq > $@
+
+%ioctl.defs: %ioctl.sym
+
+%ioctl-values.sym: %ioctl-headers.h %ioctl-requests.list ioctl-tmpl.sym
+ (sed 's%@HEADER_LIST@%$<%;s/@GROUP@/$*/g' < $(filter %.sym,$^); \
+ while read r; do \
+ for x in CMD SUBID INOUT TYPE \
+ TYPE0 TYPE1 TYPE2 COUNT0 COUNT1 COUNT2; do \
+ echo "expr $${x}($${r}) $${r}_$${x}"; \
+ done; \
+ done < $(filter %.list,$^)) > $@
+
+%ioctl-proto.defs: %ioctl-values.h ioctl.awk
+ sed 's/^#define//;s/_/ /g' $< | $(AWK) -f $(filter %.awk,$^) > $@