about summary refs log tree commit diff
path: root/mach/Machrules
diff options
context:
space:
mode:
Diffstat (limited to 'mach/Machrules')
-rw-r--r--mach/Machrules53
1 files changed, 28 insertions, 25 deletions
diff --git a/mach/Machrules b/mach/Machrules
index ef5809b86c..f7f6d2df63 100644
--- a/mach/Machrules
+++ b/mach/Machrules
@@ -81,19 +81,14 @@ endif
 # other useful pattern) causes the rule for `host_info' to also match
 # `xxx_host_info', and analogous lossage.
 #
-# While we're at it, we figure out the imports used by %.defs and give them
-# as dependencies of the object files for the generated RPC_*.c files.
-#
 # Depend on %.h just so they will be built from %.uh in the
 # makefile-rebuilding run which builds %.ir; otherwise, %.uh is built as an
 # intermediate in order to make %.ir and then removed before re-exec, when
 # %.uh is built all over again to build %.h.
 $(objpfx)%.ir: $(objpfx)%.uh $(objpfx)%.h
 	(awk "NF == 4 && (\$$2 == \"Routine\" || \$$2 == \"SimpleRoutine\")\
-	        { printf \"$*-calls += %s\\n\", \$$3 }	\
-	      /^#include/ { printf \"$*-imports += %s\\n\", \$$2 }" $<	;\
+	        { printf \"$*-calls += %s\\n\", \$$3 }" $<	;\
 	 echo '$$($*-calls:%=$$(objpfx)R\%C_%.c): $$(objpfx)$*.ustamp ;';\
-	 echo '$$($*-calls:%=$$(objpfx)RPC_%.o): $$($*-imports:<%>=%)'	;\
 	) > $@-new
 	mv $@-new $@
 vpath Machrules ../mach	# Find ourselves.
@@ -106,9 +101,12 @@ endef
 endif
 
 # Not an implicit rule so the stamps are never removed as intermediates!
-$(patsubst %,$(objpfx)%.ustamp,$(user-interfaces)): $(objpfx)%.ustamp: %.defs
-	$(MIG) $< $(MIGFLAGS) $(user-MIGFLAGS) \
-	       -prefix __ -i $(objpfx)tmp_ \
+$(patsubst %,$(objpfx)%.ustamp,$(user-interfaces)): $(objpfx)%.ustamp:
+	rm -f $@
+	echo '#include <$*.defs>' | \
+	$(MIG) - /dev/null -prefix __ \
+	       $(MIGFLAGS) $(user-MIGFLAGS) $(MIGFLAGS-$*) \
+	       -i $(objpfx)tmp_ \
 	       -server /dev/null -user /dev/null -header /dev/null
 	for call in $($*-calls); do \
 	  $(transform-user-stub) \
@@ -116,15 +114,24 @@ $(patsubst %,$(objpfx)%.ustamp,$(user-interfaces)): $(objpfx)%.ustamp: %.defs
 			    $(objpfx)RPC_$${call}.c; \
 	done
 	touch $@
+-include $(patsubst %,$(objpfx)%.udeps,$(user-interfaces))
+$(patsubst %,$(objpfx)%.udeps,$(user-interfaces)): $(objpfx)%.udeps:
+	echo '#include <$*.defs>' | \
+	$(CC) $(CPPFLAGS) -M -x c - | \
+	sed -e 's,- *:,$@ $(@:.udeps=.ustamp) \
+			  $(@:.udeps=_server.c) $(@:.udeps=_server.h):,' \
+	    $(sed-remove-objpfx) > $@.new
+	mv -f $@.new $@
 
 # Look for the server stub files where they will be written.
 vpath %_server.c $(addprefix $(objpfx),$(sort $(dir $(server-interfaces))))
 
 # Build the server stubs in $(objdir).
-$(objpfx)%_server.c $(objpfx)%_server.h: %.defs
-	$(MIG) $< $(MIGFLAGS) $(server-MIGFLAGS) \
-	       -prefix _S_ \
-	       -user /dev/null -header /dev/null \
+$(objpfx)%_server.c $(objpfx)%_server.h:
+	echo '#include <$*.defs>' | \
+	$(MIG) - /dev/null -prefix _S_ \
+	       $(MIGFLAGS) $(server-MIGFLAGS) $(MIGFLAGS-$*) \
+	       $< -user /dev/null -header /dev/null \
 	       -server $(@:.h=.c) -sheader $(@:.c=.h)
 
 # To get header files that declare both the straight and __ functions,
@@ -176,18 +183,14 @@ interface-headers: $(interface-headers)
 # dependencies ahead of time anyway because they're boilerplate.
 omit-deps += $(interface-routines)
 
-# Specify the static dependencies of the generated files.
-$(foreach o,$(object-suffixes),\
-$(foreach if,$(user-interfaces),$($(if)-calls:%=$(objpfx)RPC_%$o))): \
-    mach/boolean.h mach/kern_return.h mach/message.h mach/notify.h \
-    mach/mach_types.h mach/mig_errors.h mach/mig_support.h mach/msg_type.h \
-    $(..)libc-symbols.h $(objpfx)config.h
-$(foreach o,$(object-suffixes),\
-$(server-interfaces:%=$(objpfx)%$o)): \
-    mach/boolean.h mach/kern_return.h mach/message.h mach/mig_errors.h \
-    mach/mig_support.h mach/std_types.h
-# The MiG-generated sources also depend on the imports in their .defs files.
-# These dependencies are generated into the .ir files above.
+# Choose any single module generated by MiG.  We will compute this module's
+# dependencies and then assume all other MiG-generated modules depend on the
+# same headers.
+some-if-rtn := $(firstword $(interface-routines))
+ifdef some-if-rtn
+$(foreach o,$(object-suffixes),$(interfaces-routines:%=%$o)): $(some-if-rtn).d
+generated += $(some-if-rtn).d
+endif
 
 # If defined, $(interface-library) is `libNAME'.  It is to be a library
 # containing all the MiG-generated functions for the specified interfaces.