pthread: add to system <pthread.h> instead of replacing it all, for MacOS
[gnulib.git] / modules / pthread
index 51d5dbb..6d06464 100644 (file)
@@ -18,9 +18,18 @@ BUILT_SOURCES += $(PTHREAD_H)
 # We need the following in order to create <pthread.h> when the system
 # doesn't have one that works with the given compiler.
 pthread.h: pthread.in.h
-       $(AM_V_GEN)ln -f $(srcdir)/pthread.in.h $@ \
-          || cp $(srcdir)/pthread.in.h $@
-MOSTLYCLEANFILES += pthread.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''HAVE_PTHREAD_H''@|$(HAVE_PTHREAD_H)|g' \
+             -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''NEXT_PTHREAD_H''@|$(NEXT_PTHREAD_H)|g' \
+             -e 's|@''HAVE_PTHREAD_T''@|$(HAVE_PTHREAD_T)|g' \
+             -e 's|@''HAVE_PTHREAD_SPINLOCK_T''@|$(HAVE_PTHREAD_SPINLOCK_T)|g' \
+             < $(srcdir)/pthread.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += pthread.h pthread.h-t
 
 Include:
 <pthread.h>