summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog78
-rw-r--r--Makeconfig6
-rw-r--r--Makerules5
-rw-r--r--elf/dl-fini.c8
-rw-r--r--hurd/Makefile36
-rw-r--r--hurd/faultexc.defs5
-rw-r--r--hurd/hurdfault.c2
-rw-r--r--mach/Machrules53
-rw-r--r--mach/Makefile68
-rw-r--r--posix/regex.c6
-rw-r--r--stdio-common/vfprintf.c10
-rw-r--r--stdio-common/vfscanf.c9
-rw-r--r--sysdeps/mach/Makefile29
-rw-r--r--sysdeps/mach/hurd/Makefile71
-rw-r--r--sysdeps/mach/hurd/errnos.awk12
15 files changed, 187 insertions, 211 deletions
diff --git a/ChangeLog b/ChangeLog
index ed83e1058c..8a9c09d2bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,83 @@
+Sun May 12 11:16:58 1996  Roland McGrath  <roland@delasyd.gnu.ai.mit.edu>
+
+	* mach/Machrules (%.udeps rule): Write deps for %_server.[ch] too.
+	(%_server.[ch] rule): Don't depend on %.defs; use #include to get
+	installed .defs file.
+
+	* stdio-common/vfprintf.c (flockfile, funlockfile): Define to
+	nothing for stdio.  Fix fUNlockfile -> funlockfile for libio.
+	* stdio-common/vfscanf.c: Likewise.
+
+Sat May 11 13:43:41 1996  Roland McGrath  <roland@delasyd.gnu.ai.mit.edu>
+
+	* hurd/hurdfault.c: Include faultexc_server.h instead of faultexc.h.
+
+	* mach/Machrules (%.ir rule): Don't produce deps for imports.
+
+	* elf/dl-fini.c (_dl_fini): Clear L->l_init_called after calling fn.
+
+	* Makerules (install): Depend on $(slibdir)/libc.so$(libc.so-version).
+	[!subdir] ($(libdir)/libc.so, $(common-objpfx)/libc-syms.so): Protect
+	these targets and install dep on $(libdir)/libc.so with this.
+
+	* hurd/Makefile: Removed all rules and defns for using code from Hurd
+	sources and installing headers from there.
+
+	* sysdeps/mach/hurd/errnos.awk: Set in_mach_errors to FILENAME when we
+ 	set it.  In Mach error matching clause, only match if FILENAME is
+ 	still the same value.
+
+	* sysdeps/mach/hurd/Makefile: Don't include sysdeps/mach/Makefile;
+	$(mach-srcdir) no longer exists.
+	(hurd-srcdir): Variable removed.
+	(includes): Don't append -I$(hurd-srcdir).
+	(last-includes): Variable removed.
+	Remove vpath specs using $(hurd-srcdir).
+	(mach-errno-h): New canned sequence.
+	($(common-objpfx)errnos.d): New target, generated included makefile
+	to determine absolute file names of Mach headers to search for error
+	codes and set variable mach-errnos-deps.
+	($(common-objpfx)stamp-errnos): Depend on $(mach-errnos-deps) instead
+	of prior explicit list.
+	(generated): Add errnos.d, stamp-errnos.
+
+	* mach/Machrules (some-if-rtn): New variable and target; compute deps
+	of some if routine and make all if routines depend on that .d file
+	instead of static list of .h files.
+
+	* mach/Makefile (mach/mach_interface.defs,
+	mach/memory_object_user.defs): Targets removed.
+	($(objpfx)mach-syscalls.mk): Tweak this kludge so it doesn't depend
+	directly on Mach sources.
+
+	* sysdeps/mach/Makefile (mach-srcdir): Variable removed.
+	(includes): Don't append -I$(mach-srcdir).
+	Remove vpath specs using $(mach-srcdir).
+
+	* hurd/Makefile (server-interfaces): Add faultexc.
+	(sig): Remove it from here.
+	(fault%.[ch]): Rule removed.
+	(MIGFLAGS-faultexc): New variable.
+
+	* hurd/faultexc.defs: New file.
+
+	* mach/Machrules (%.ustamp rule): Pass $(MIGFLAGS-$*) to mig.
+	(%_server.[ch] rule): Likewise.
+
+	* mach/Makefile: Removed all rules and defns for using code from Mach
+	sources and installing headers from there.
+
+	* Makeconfig [$(build-shared)=yes] (link-libc): Append
+	$(libc.so-version) to libc.so.
+
 Fri May 10 18:36:14 1996  Roland McGrath  <roland@delasyd.gnu.ai.mit.edu>
 
+	* mach/Machrules (%.ustamp rule): Don't depend on %.defs.
+	(%.udeps): New rule parallel to that one, generating included
+	makefiles with -M output from `#include <%.defs>'.
+
+	* Makerules (sed-remove-objpfx): Remove space before \ at eol.
+
 	* Makefile (distribute): Add FAQ.
 	* FAQ: New file contributed by drepper.
 
diff --git a/Makeconfig b/Makeconfig
index ba0c940fbb..41f5839afc 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -291,8 +291,12 @@ endif
 endif
 ifndef link-libc
 ifeq (yes,$(build-shared))
+# We need the versioned name of libc.so in the deps of $(others) et al
+# so that the symlink to libc.so is created before anything tries to
+# run the linked programs.
 link-libc = -Wl,-rpath-link=$(common-objdir) \
-	    $(common-objpfx)libc.so $(common-objpfx)libc.a $(gnulib)
+	    $(common-objpfx)libc.so$(libc.so-version) \
+	    $(common-objpfx)libc.a $(gnulib)
 # Choose the default search path for the dynamic linker based on
 # where we will install libraries.
 ifneq ($(libdir),$(slibdir))
diff --git a/Makerules b/Makerules
index 1c11fb930b..66a5f28281 100644
--- a/Makerules
+++ b/Makerules
@@ -281,7 +281,7 @@ $(sed-remove-objpfx) > $(@:.d=.T)
 mv -f $(@:.d=.T) $@
 endef
 ifneq (,$(objpfx))
-sed-remove-objpfx = -e 's@ $(subst .,\., \
+sed-remove-objpfx = -e 's@ $(subst .,\.,\
 				     $(subst @,\@,$(objpfx)))@ $$(objpfx)@g' \
 		    -e 's@^$(subst .,\.,$(subst @,\@,$(objpfx)))@$$(objpfx)@g'
 endif
@@ -569,7 +569,9 @@ ifdef libc.so-version
 $(slibdir)/libc.so$(libc.so-version): $(slibdir)/libc-$(version).so
 	$(make-link)
 $(slibdir)/libc-$(version).so: $(common-objpfx)libc.so; $(do-install-program)
+install: $(slibdir)/libc.so$(libc.so-version)
 
+ifndef subdir
 # What we install as libc.so for programs to link against is in fact an
 # archive.  It contains the various $(static-only-routines) objects, and
 # the special object libc-syms.so that contains just the dynamic symbol
@@ -586,6 +588,7 @@ $(common-objpfx)libc-syms.so: $(common-objpfx)libc.so
 ifndef subdir
 generated += libc-syms.so
 endif
+endif
 
 else
 install: $(slibdir)/libc.so
diff --git a/elf/dl-fini.c b/elf/dl-fini.c
index 69ff83d488..36b4390663 100644
--- a/elf/dl-fini.c
+++ b/elf/dl-fini.c
@@ -1,5 +1,5 @@
 /* Call the termination functions of loaded shared objects.
-Copyright (C) 1995 Free Software Foundation, Inc.
+Copyright (C) 1995, 1996 Free Software Foundation, Inc.
 This file is part of the GNU C Library.
 
 The GNU C Library is free software; you can redistribute it and/or
@@ -26,5 +26,9 @@ _dl_fini (void)
 
   for (l = _dl_loaded; l; l = l->l_next)
     if (l->l_init_called && l->l_info[DT_FINI])
-      (*(void (*) (void)) (l->l_addr + l->l_info[DT_FINI]->d_un.d_ptr)) ();
+      {
+	(*(void (*) (void)) (l->l_addr + l->l_info[DT_FINI]->d_un.d_ptr)) ();
+	/* Make sure nothing happens if we are called twice.  */
+	l->l_init_called = 0;
+      }
 }
diff --git a/hurd/Makefile b/hurd/Makefile
index 3a9d08e4a4..90d4b43359 100644
--- a/hurd/Makefile
+++ b/hurd/Makefile
@@ -38,7 +38,7 @@ user-interfaces		:= $(addprefix hurd/,\
 				       msg msg_reply msg_request \
 				       exec exec_startup crash interrupt \
 				       fs fsys io term tioctl socket ifsock)
-server-interfaces	:= hurd/msg
+server-interfaces	:= hurd/msg faultexc
 
 routines = hurdstartup hurdinit \
 	   hurdid hurdlookup hurdpid hurdrlimit hurdprio hurdexec \
@@ -53,7 +53,7 @@ routines = hurdstartup hurdinit \
  	   vpprintf \
 	   ports-get ports-set hurdports hurdmsg \
 	   $(sig) $(dtable) hurdinline port-cleanup report-wait
-sig	= hurdsig hurdfault faultexc siginfo hurd-raise preempt-sig \
+sig	= hurdsig hurdfault siginfo hurd-raise preempt-sig \
 	  trampoline longjmp-ts catch-exc exc2signal hurdkill sigunwind \
 	  thread-self thread-cancel intr-msg catch-signal
 dtable	= dtable port2fd new-fd alloc-fd intern-fd \
@@ -64,28 +64,6 @@ dtable	= dtable port2fd new-fd alloc-fd intern-fd \
 routines += hurdmalloc
 distribute += hurdmalloc.h
 
-# Get the proper definition of `hurd-srcdir'.
-include ../sysdeps/mach/hurd/Makefile
-
-# Use and install the Hurd header files directly out of the Hurd source.
-
-# Find the MiG defs files in the Hurd source.
-vpath %.defs $(hurd-srcdir)
-
-# Install all .h and .defs files we find in the Hurd's hurd/ directory.
-hurd-headers := $(patsubst $(hurd-srcdir)/%,%,\
-			   $(wildcard $(addprefix $(hurd-srcdir)/hurd/,\
-						  *.defs *.h)))
-
-
-# Don't distribute the Hurd headers; they are in the Hurd distribution.
-dont_distribute = $(hurd-headers)
-
-# DO NOT try to remake these in any way!!!
-$(addprefix $(hurd-srcdir)/,$(hurd-headers)) : ;
-install-others += $(addprefix $(includedir)/,$(hurd-headers))
-$(includedir)/hurd/%: $(hurd-srcdir)/hurd/%; $(do-install)
-
 include ../mach/Machrules
 include ../Rules
 
@@ -94,13 +72,9 @@ include ../Rules
 # _hurd_intr_rpc_mach_msg.
 user-MIGFLAGS += -imacros intr-rpc.defs
 
-$(objpfx)fault%.c $(objpfx)fault%.h: $(mach-srcdir)/mach/%.defs
-	$(MIG) $(MIGFLAGS) -prefix _hurdsig_fault_ \
-	       -server $(@:.h=.c) -sheader $(@:.c=.h) \
-	       -user /dev/null -header /dev/null \
-	       $<
-generated += faultexc.c faultexc.h
+# The special exc server for sigthread faults uses a special prefix.
+MIGFLAGS-faultexc = -prefix _hurdsig_fault_
 
 # We need this static dependency to get faultexc.h generated the first time.
 $(objpfx)hurdfault.o $(objpfx)hurdfault.d: \
-	$(objpfx)faultexc.h $(objpfx)faultexc.c
+	$(objpfx)faultexc_server.h $(objpfx)faultexc_server.c
diff --git a/hurd/faultexc.defs b/hurd/faultexc.defs
new file mode 100644
index 0000000000..fe7f02a4cc
--- /dev/null
+++ b/hurd/faultexc.defs
@@ -0,0 +1,5 @@
+/* This file is processed by mig with -prefix _hurdsig_fault_
+   to create the special exception server used for signal thread
+   fault recovery.  */
+
+#include <mach/exc.defs>
diff --git a/hurd/hurdfault.c b/hurd/hurdfault.c
index a8fe8fb07f..e1b06a3f9f 100644
--- a/hurd/hurdfault.c
+++ b/hurd/hurdfault.c
@@ -25,7 +25,7 @@ Cambridge, MA 02139, USA.  */
 #include <setjmp.h>
 #include <stdio.h>
 #include "thread_state.h"
-#include "faultexc.h"		/* mig-generated header for our exc server.  */
+#include "faultexc_server.h"	/* mig-generated header for our exc server.  */
 #include <assert.h>
 
 jmp_buf _hurdsig_fault_env;
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.
diff --git a/mach/Makefile b/mach/Makefile
index 747a6bfead..c4665c204c 100644
--- a/mach/Makefile
+++ b/mach/Makefile
@@ -57,57 +57,21 @@ distribute += Machrules syscalls.awk shortcut.awk \
 # Clear any environment	value.
 generated =
 
-# Get the proper definition of `mach-srcdir'.
-include ../sysdeps/mach/Makefile
-
-# Use and install the Mach header files directly out of the Mach kernel source.
-
-# Find the MiG defs files in the kernel source.
-vpath %.defs $(mach-srcdir)
-
-# Install all .h and .defs files we find in some of the kernel's source
-# directories and their subdirectories (in MK82, max one level deep).
-mach-src-headers := $(wildcard $(foreach dir,mach device mach_debug \
-					     $(base-machine),\
-					 $(addprefix $(mach-srcdir)/$(dir)/,\
-						     *.defs *.h \
-						     */*.defs */*.h)))
-# Exclude mach/machine/*.  A symlink will be installed for mach/machine.
-# Exclude $(headers) for Mach files we have our own versions of.
-mach-headers = $(filter-out mach/machine/% $(headers),\
-			    $(mach-src-headers:$(mach-srcdir)/%=%))
-# Rename Mach's sys/version.h to mach/version.h.
-mach-headers := $(patsubst sys/version.h,mach/version.h,$(mach-headers))
-
-# Don't distribute the Mach headers; they are in the Mach distribution.
-dont_distribute = $(mach-headers)
-
-# DO NOT try to remake these in any way!!!
-$(addprefix $(mach-srcdir)/,$(mach-headers)) : ;
-install-others += $(addprefix $(includedir)/,$(mach-headers))
-$(includedir)/%: $(mach-srcdir)/%; $(do-install)
-
-# Make symlinks for machine and mach/machine in the include directory.
-install-others += $(includedir)/mach/machine $(includedir)/machine
-$(includedir)/mach/machine $(includedir)/machine: $(common-objpfx)config.make
-	-rm -f $@
-	cd $(@D); ln -s $(base-machine) $(@F)
-
-# Install Mach's <sys/version.h> as <mach/version.h>.
-install-others += $(includedir)/mach/version.h
-$(includedir)/mach/version.h: $(mach-srcdir)/sys/version.h; $(do-install)
-
 # Define mach-syscalls and sysno-*.
 ifndef no_deps
 ifndef inhibit_mach_syscalls
 include $(objpfx)mach-syscalls.mk
 endif
 endif
-$(objpfx)mach-syscalls.mk: mach/syscall_sw.h syscalls.awk
+$(objpfx)mach-syscalls.mk: syscalls.awk Makefile
 # Go kludges!!!
-	sed -n -e '/Unix server implement them/,$$d' \
-	       -e 's/^kernel_trap(\(.*\),\([-0-9]*\),\([0-9]*\))$$/\1 \2 \3/p'\
-	< $< | awk -f $(word 2,$^) > $@-new
+	echo '#include <mach/syscall_sw.h>' | \
+	DEPENDENCIES_OUTPUT='$@-dep $@' \
+	$(CC) $(CPPFLAGS) -E -x c-header - \
+	      -D_MACH_`echo $(base-machine) | tr a-z A-Z`_SYSCALL_SW_H_=1 | \
+	sed -n -e 's/^kernel_trap(\(.*\),\([-0-9]*\),\([0-9]*\))$$/\1 \2 \3/p'\
+	| awk -f $< > $@-new
+	cat $@-dep >> $@-new; rm -f $@-dep
 	mv $@-new $@
 generated += mach-syscalls.mk
 
@@ -170,22 +134,6 @@ include Machrules
 include ../Rules
 
 
-# There is already a mach.h, so mach.defs generates mach_interface.h.
-$(objpfx)mach/mach_interface.defs: $(mach-srcdir)/mach/mach.defs
-	ln $< $@ || cp $< $@
-# There is already a memory_object.h,
-# so memory_object.defs generates memory_object_user.h.
-$(objpfx)mach/memory_object_user.defs: $(mach-srcdir)/mach/memory_object.defs
-	ln $< $@ || cp $< $@
-
-ifdef objdir
-vpath mach/mach_interface.defs $(objdir)
-vpath mach/memory_object_user.defs $(objdir)
-endif
-
-# Be sure not to make these with implicit rules from foo.defs.
-mach.h mach/memory_object.h: ;
-
 # A gcc bug prevents the generated file from working properly,
 # so we have one in the distribution for the time being.
 generated += errsystems.c
diff --git a/posix/regex.c b/posix/regex.c
index dc831cecd1..c127b01aa5 100644
--- a/posix/regex.c
+++ b/posix/regex.c
@@ -4508,9 +4508,9 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
 #endif
 
                 if ((re_opcode_t) p1[3] == exactn
-		    && ! ((int) p2[1] * BYTEWIDTH > (int) p1[4]
-			  && (p2[1 + p1[4] / BYTEWIDTH]
-			      & (1 << (p1[4] % BYTEWIDTH)))))
+		    && ! ((int) p2[1] * BYTEWIDTH > (int) p1[5]
+			  && (p2[2 + p1[5] / BYTEWIDTH]
+			      & (1 << (p1[5] % BYTEWIDTH)))))
                   {
   		    p[-3] = (unsigned char) pop_failure_jump;
                     DEBUG_PRINT3 ("  %c != %c => pop_failure_jump.\n",
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index cde7496585..6430a924f4 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -103,7 +103,7 @@ ssize_t __wprintf_pad __P ((FILE *, wchar_t pad, size_t n));
     } while (0)
 # define UNBUFFERED_P(S) ((S)->_IO_file_flags & _IO_UNBUFFERED)
 # define flockfile(S) _IO_flockfile (S)
-# define fUNlockfile(S) _IO_funlockfile (S)
+# define funlockfile(S) _IO_funlockfile (S)
 #else /* ! USE_IN_LIBIO */
 /* This code is for use in the GNU C library.  */
 # include <stdio.h>
@@ -125,6 +125,8 @@ ssize_t __wprintf_pad __P ((FILE *, wchar_t pad, size_t n));
     }									      \
    while (0)
 # define UNBUFFERED_P(s) ((s)->__buffer == NULL)
+# define flockfile(S) /* nothing */
+# define funlockfile(S) /* nothing */
 #endif /* USE_IN_LIBIO */
 
 
@@ -805,7 +807,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
 
   /* Lock stream.  */
   flockfile (s);
-  
+
   /* Write the literal text before the first format.  */
   outstring ((const UCHAR_T *) format,
 	     lead_str_end - (const UCHAR_T *) format);
@@ -1001,7 +1003,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
 
   /* Unlock stream.  */
   funlockfile (s);
-  
+
   /* We processed the whole format without any positional parameters.  */
   return done;
 
@@ -1263,7 +1265,7 @@ do_positional:
 
   /* Unlock the stream.  */
   funlockfile (s);
-  
+
   return done;
 }
 
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index 4b4dd119ca..9cdad7bb8b 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -26,7 +26,6 @@ Cambridge, MA 02139, USA.  */
 #include <stdlib.h>
 #include <string.h>
 
-
 #ifdef	__GNUC__
 #define	HAVE_LONGLONG
 #define	LONGLONG	long long
@@ -82,6 +81,8 @@ Cambridge, MA 02139, USA.  */
          return EOF;							      \
        }								      \
     } while (0)
+# define flockfile(S) _IO_flockfile (S)
+# define funlockfile(S) _IO_funlockfile (S)
 #else
 # define inchar()	((c = getc (s)), (void) ++read_in, c)
 # define conv_error()	do {						      \
@@ -108,6 +109,8 @@ Cambridge, MA 02139, USA.  */
 	  return EOF;							      \
 	}								      \
     } while (0)
+# define flockfile(S) /* nothing */
+# define funlockfile(S) /* nothing */
 #endif
 
 
@@ -196,7 +199,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
 
   /* Lock the stream.  */
   flockfile (s);
-  
+
   c = inchar ();
 
   /* Run through the format string.  */
@@ -807,7 +810,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
 
   /* Unlock stream.  */
   funlockfile (s);
-  
+
   return ((void) (c == EOF || ungetc (c, s)), done);
 }
 
diff --git a/sysdeps/mach/Makefile b/sysdeps/mach/Makefile
index fab174c0d6..a179b1f83e 100644
--- a/sysdeps/mach/Makefile
+++ b/sysdeps/mach/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1993, 1994 Free Software Foundation, Inc.
+# Copyright (C) 1993, 1994, 1996 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
 # The GNU C Library is free software; you can redistribute it and/or
@@ -16,38 +16,11 @@
 # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 # Cambridge, MA 02139, USA.
 
-ifndef mach-srcdir-computed
-mach-srcdir-computed := yes
-
-# If we were configured with `--with-mach=DIR', then config.make sets
-# mach-srcdir to DIR.  Otherwise guess we are in a big source tree.
-ifndef mach-srcdir
-mach-srcdir = ../mach
-endif
-
-# mach-srcdir is now set to the logical directory name.  This name might be
-# relative to $(objdir), might be relative to the source directory $(..), or
-# might be absolute.  We choose among these possibilities by looking for a
-# canonical file in each of those places (in that order).
-f := mach/mach.defs # Random file that identifies the Mach source dir.
-f := $(strip $f)
-mach-srcdir := $(firstword $(patsubst %/$f,%,$(wildcard $(addsuffix /$f,\
-	       $(objpfx)$(mach-srcdir) $(..)$(mach-srcdir)))) $(mach-srcdir))
-
-endif	# ! mach-srcdir-computed
-
 ifdef in-Makerules
 
 # Look for header files in mach/ under the top-level library source directory.
 includes += -I$(..)mach
 
-# When compiling, use the Mach header files directly from the kernel sources.
-includes += -I$(mach-srcdir)
-
-# Find Mach header files in the kernel source.
-vpath mach/%.h $(mach-srcdir)
-vpath device/%.h $(mach-srcdir)
-
 ifneq (mach,$(subdir))
 # Subdirectories other than mach/ might use the generated Mach headers.
 # So make sure we get a chance to run in mach/ to make them before all else.
diff --git a/sysdeps/mach/hurd/Makefile b/sysdeps/mach/hurd/Makefile
index 462eb23b0e..14dc1ebc83 100644
--- a/sysdeps/mach/hurd/Makefile
+++ b/sysdeps/mach/hurd/Makefile
@@ -16,33 +16,6 @@
 # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 # Cambridge, MA 02139, USA.
 
-# Get mach-srcdir defined.
-old-in-Makerules := $(in-Makerules)
-in-Makerules :=
-include $(..)sysdeps/mach/Makefile
-in-Makerules := $(old-in-Makerules)
-
-
-ifndef hurd-srcdir-computed
-hurd-srcdir-computed := yes
-
-# If we were configured with `--with-hurd=DIR', then config.make sets
-# hurd-srcdir to DIR.  Otherwise guess we are in a big source tree.
-ifndef hurd-srcdir
-hurd-srcdir = ../hurd
-endif
-
-# hurd-srcdir is now set to the logical directory name.  This name might be
-# relative to $(objdir), might be relative to the source directory $(..), or
-# might be absolute.  We choose among these possibilities by looking for a
-# canonical file in each of those places (in that order).
-f := hurd/hurd_types.defs # Random file that identifies the Hurd source dir.
-f := $(strip $f)
-hurd-srcdir := $(firstword $(patsubst %/$f,%,$(wildcard $(addsuffix /$f,\
-	       $(objpfx)$(hurd-srcdir) $(..)$(hurd-srcdir)))) $(hurd-srcdir))
-
-endif	# ! hurd-srcdir-computed
-
 ifdef in-Makerules
 
 subdirs := $(filter-out sunrpc,$(subdirs)) # XXX skip broken dirs
@@ -50,17 +23,6 @@ subdirs := $(filter-out sunrpc,$(subdirs)) # XXX skip broken dirs
 # Look for header files in hurd/ under the top-level library source directory.
 includes += -I$(..)hurd
 
-# When compiling, use the Hurd header files directly from the sources.
-includes += -I$(hurd-srcdir)
-
-# When compiling, find cthreads.h in the Hurd cthreads source.
-# This directory has some other (private) header file with
-# conflicting names, so we put it last.
-last-includes += -I$(hurd-srcdir)/libthreads
-
-# Find the Hurd header files in the Hurd source.
-vpath hurd/%.h $(hurd-srcdir)
-
 # Do not use any assembly code from sysdeps/unix (and subdirectories).
 # This bypasses all the system call stubs and uses any existing posix or
 # generic C files instead.
@@ -98,19 +60,36 @@ errno.texinfo = $(..)manual/errno.texi
 
 hurd = $(..)sysdeps/mach/hurd
 
-$(hurd)/errnos.h: $(objpfx)stamp-errnos ;
-$(objpfx)stamp-errnos: $(hurd)/errnos.awk $(errno.texinfo) \
-		       $(mach-srcdir)/mach/message.h \
-		       $(mach-srcdir)/mach/kern_return.h \
-		       $(mach-srcdir)/mach/mig_errors.h \
-		       $(mach-srcdir)/device/device_types.h
+define mach-errno-h
+($(foreach h,mach/message.h \
+	     mach/kern_return.h \
+	     mach/mig_errors.h \
+	     device/device_types.h,\
+ echo '#include <$h>';\
+ ))
+endef
+
+# We use the compiler to generate a list of absolute file names for
+# the headers we want to search for Mach error codes, listed above (and
+# incidentally, all other headers those include).
+-include $(common-objpfx)errnos.d
+$(common-objpfx)errnos.d: $(mach-errnos-deps)
+	$(mach-errno-h) | \
+	$(CC) $(CPPFLAGS) -M -x c - | \
+	sed -e 's,- *:,mach-errnos-deps :=,' > $@t
+	mv -f $@t $@
+
+$(hurd)/errnos.h: $(common-objpfx)stamp-errnos ;
+$(common-objpfx)stamp-errnos: $(hurd)/errnos.awk $(errno.texinfo) \
+			      $(mach-errnos-deps)
 	gawk -f $^ > $(hurd)/errnos.h-tmp
 # Make it unwritable so noone will edit it by mistake.
 	-chmod a-w $(hurd)/errnos.h-tmp
 	./$(..)move-if-change $(hurd)/errnos.h-tmp $(hurd)/errnos.h
-	test ! -d CVS || \
-	  (cd $(hurd); cvs commit -m'Regenerated from $^' errnos.h)
+#	test ! -d CVS || \
+#	  (cd $(hurd); cvs commit -m'Regenerated from $^' errnos.h)
 	touch $@
+generated += errnos.d stamp-errnos
 
 $(hurd)/errlist.c: $(hurd)/errlist.awk $(errno.texinfo)
 	gawk -f $^ > $@-tmp
diff --git a/sysdeps/mach/hurd/errnos.awk b/sysdeps/mach/hurd/errnos.awk
index e3ff7a843b..24a01ba935 100644
--- a/sysdeps/mach/hurd/errnos.awk
+++ b/sysdeps/mach/hurd/errnos.awk
@@ -34,7 +34,7 @@ BEGIN {
     print "enum __error_t_codes\n{";
     errnoh = 0;
     maxerrno = 0;
-    in_mach_errors = 0;
+    in_mach_errors = "";
     in_math = 0;
     edom = erange = "";
     print "#undef EDOM\n#undef ERANGE";
@@ -76,22 +76,22 @@ errnoh == 3 && $1 == "@comment" && $2 == "errno" {
 
 NF == 3 && $1 == "#define" && $2 == "MACH_SEND_IN_PROGRESS" \
   {
-    in_mach_errors = 1;
+    in_mach_errors = FILENAME;
     print "\n\t/* Errors from <mach/message.h>.  */";
   }
 NF == 3 && $1 == "#define" && $2 == "KERN_SUCCESS" \
   {
-    in_mach_errors = 1;
+    in_mach_errors = FILENAME;
     print "\n\t/* Errors from <mach/kern_return.h>.  */";
     next;
   }
 
-in_mach_errors && $2 == "MACH_IPC_COMPAT" \
+in_mach_errors != "" && $2 == "MACH_IPC_COMPAT" \
   {
-    in_mach_errors = 0;
+    in_mach_errors = "";
   }
 
-in_mach_errors == 1 && NF == 3 && $1 == "#define" \
+in_mach_errors == FILENAME && NF == 3 && $1 == "#define" \
   {
     printf "\t%-32s= %s,\n", "E" $2, $3;
   }