summaryrefslogtreecommitdiff
path: root/Makerules.in
blob: 271cf7c5c3b3eddbd3432052ca8446199970f3cb (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# Makerules
# Copyright 2006 Free Software Foundation, Inc.
#
# Permission to use, copy, modify and distribute this software and its
# documentation is hereby granted, provided that both the copyright
# notice and this permission notice appear in all copies of the
# software, derivative works or modified versions, and any portions
# thereof, and that both notices appear in supporting documentation.
#
# THE FREE SOFTWARE FOUNDATION ALLOWS FREE USE OF THIS SOFTWARE IN ITS
# "AS IS" CONDITION.  THE FREE SOFTWARE FOUNDATION DISCLAIMS ANY
# LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE
# USE OF THIS SOFTWARE.


#
# configure's findings.
#

systype = @systype@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@

AR = @AR@
AWK = @AWK@
CC = @CC@
CPP = @CPP@
GZIP = @GZIP@
LD = @LD@
MBCHK = @MBCHK@
MIG = @MIG@
NM = @NM@
RANLIB = @RANLIB@
STRIP = @STRIP@

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

CFLAGS-common = @CFLAGS@
CPPFLAGS-common = @CPPFLAGS@
DEFS-common = @DEFS@
LDFLAGS-common = @LDFLAGS@


#
# System dependent Makerules
#

include $(abs_top_builddir)/$(systype)/Makerules


#
# Compilation flags
#

DEFS += $(DEFS-common)

DEFINES += $(DEFS) -DMACH -DCMU -DMACH_KERNEL -DKERNEL

INCLUDES += -I$(abs_top_builddir) -I$(abs_top_srcdir) \
	-I$(abs_top_srcdir)/include -I$(abs_top_srcdir)/$(systype) \
	-I$(abs_top_srcdir)/$(systype)/include/mach/sa \
	-I$(abs_top_srcdir)/bogus -I$(abs_top_srcdir)/util \
	-I$(abs_top_srcdir)/kern -I$(abs_top_srcdir)/device

CPPFLAGS += -nostdinc $(DEFINES) $(INCLUDES) $(CPPFLAGS-common)

MIGFLAGS += $(CPPFLAGS)

CFLAGS += $(CFLAGS-common)

# See <URL:http://lists.gnu.org/archive/html/bug-hurd/2006-01/msg00148.html>.
CFLAGS += -fno-strict-aliasing

LDFLAGS += $(LDFLAGS-common)

# Assemble .S files correctly
ASFLAGS += -DASSEMBLER


#
# How to do some things
#

# Building foo.h from foo.sym:
%.symc: %.sym $(abs_top_srcdir)/gensym.awk
	$(AWK) -f $(word 2,$^) $< > $@
%.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]*//' >$@

# Building from foo.cli
.PRECIOUS: %_user.c
%.h %_user.c: %.cli
	$(MIG) $(MIGFLAGS) -header $*.h -user $*_user.c -server /dev/null $<

# Building from foo.srv
.PRECIOUS: %_server.c
%_interface.h %_server.c: %.srv
	$(MIG) $(MIGFLAGS) -sheader $*_interface.h -server $*_server.c \
			   -header /dev/null -user /dev/null $<

# gzip files
%.gz: %
	$(GZIP) -9 < $< > $@

# strip files
%.stripped: %
	$(STRIP) -o $@ $<

#
# Dependency generation
#

# Don't build and include dependency files if they're not needed.
ifneq ($(strip $(filter %clean, $(MAKECMDGOALS))),)
no_deps = t
endif

# Include dependency files
ifneq ($(no_deps),t)

# For each file generated by MiG we need a .d file.
-include $(subst _server.o,.migs.d,$(servers)) /dev/null
-include $(subst _user.o,.migu.d,$(users)) /dev/null

# For each .o file we need a .d file.
-include $(subst .o,.d,$(filter %.o,$(objfiles))) /dev/null

endif

# Here is how to make those dependency files
%.migs.d: %.srv
	(set -e; $(CPP) $(MIGFLAGS) -M -MG -x c $< | \
	  sed -e 's/[^:]*:/$*_server.c $*_interface.h $@:/' > $@)
%.migu.d: %.cli
	(set -e; $(CPP) $(MIGFLAGS) -M -MG -x c $< | \
	  sed -e 's/[^:]*:/$*_user.c $*.h $@:/' > $@)

# Generic rule for $(CC) based compilation for making dependencies
define make-deps
set -e; $(CC) $(CFLAGS) $(CPPFLAGS) -M -MG $< | \
	sed > $@.new -e 's/$*\.o:/$*.o $@:/'
mv -f $@.new $@
endef

%.d: %.c; $(make-deps)
%.d: %.S; $(make-deps)

# .s files don't go through the preprocessor, so we do this
# This rule must come *after* the genuine ones above, so that
# make doesn't build a .s file and then make an empty dependency
# list.
%.d: %.s
	echo '$*.o: $<' > $@


#
# Autoconf support
#

$(top_builddir)/Makerules $(abs_top_builddir)/Makerules: \
  $(abs_top_srcdir)/Makerules.in $(abs_top_builddir)/config.status
	cd $(abs_top_builddir) && ./config.status $(@F)