summaryrefslogtreecommitdiff
path: root/hurd/Makefile
blob: 078c80ab928aa68af01776ebaa90376a871e26b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#
#   Copyright (C) 1993,94,95,96,99,2002 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
#   published by the Free Software Foundation; either version 2, or (at
#   your option) any later version.
#
#   This program is distributed in the hope that it will be useful, but
#   WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#   General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

dir := hurd
makemode := misc

hdrs = $(wildcard $(srcdir)/*.defs $(srcdir)/*.h)
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))

include ../Makeconf

install-headers install: $(includedir)/hurd \
	$(addprefix $(includedir)/hurd/,$(INSTHDRS))

$(includedir)/hurd/%: $(srcdir)/%; $(INSTALL_DATA) $< $@

$(includedir)/hurd:;mkdir -p $@

%.msgids: $(srcdir)/%.defs
	if grep -q '^subsystem' $<; \
	then $(CPP) $(CPPFLAGS) $< | $(MIGCOM) -n -list $@; \
	else > $@; fi
hurd.msgids: $(patsubst %.defs,%.msgids,$(filter %.defs,$(INSTHDRS)))
	cat $^ > $@

#
# 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,$^) > $@