From c06619d7ab2ebbbc93427ca6a49dcc8d479db549 Mon Sep 17 00:00:00 2001
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Date: Sat, 12 Jun 2010 13:29:14 +0200
Subject: nptl: simplify buildsys

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
 libpthread/nptl/Makefile.in                        |   3 +-
 libpthread/nptl/sysdeps/Makefile.commonarch        |  57 +++++
 libpthread/nptl/sysdeps/arm/Makefile.arch          |  47 ----
 libpthread/nptl/sysdeps/generic/Makefile.in        |  18 +-
 libpthread/nptl/sysdeps/i386/Makefile.arch         |  40 ----
 libpthread/nptl/sysdeps/mips/Makefile.arch         |  46 ----
 libpthread/nptl/sysdeps/powerpc/Makefile.arch      |  41 ----
 libpthread/nptl/sysdeps/sh/Makefile.arch           |  39 ----
 libpthread/nptl/sysdeps/sparc/Makefile.arch        |  39 ----
 libpthread/nptl/sysdeps/unix/sysv/linux/Makefile   |   2 +-
 .../sysdeps/unix/sysv/linux/Makefile.commonarch    | 255 ++++++++++++++++++++
 .../nptl/sysdeps/unix/sysv/linux/Makefile.in       | 256 ---------------------
 libpthread/nptl/sysdeps/x86_64/Makefile.arch       |  39 ----
 libpthread/nptl_db/Makefile.in                     |   3 +-
 14 files changed, 322 insertions(+), 563 deletions(-)
 create mode 100644 libpthread/nptl/sysdeps/Makefile.commonarch
 create mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch
 delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.in

(limited to 'libpthread')

diff --git a/libpthread/nptl/Makefile.in b/libpthread/nptl/Makefile.in
index da0568985..b32ee3fe7 100644
--- a/libpthread/nptl/Makefile.in
+++ b/libpthread/nptl/Makefile.in
@@ -279,8 +279,9 @@ headers_clean-y += HEADERCLEAN_libpthread/nptl
 -include $(PTHREAD_DIR)/sysdeps/generic/Makefile.in
 -include $(PTHREAD_DIR)/sysdeps/pthread/Makefile.in
 -include $(PTHREAD_DIR)/sysdeps/$(TARGET_ARCH)/Makefile.arch
--include $(PTHREAD_DIR)/sysdeps/unix/sysv/linux/Makefile.in
+-include $(PTHREAD_DIR)/sysdeps/Makefile.commonarch
 -include $(PTHREAD_DIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/Makefile.arch
+-include $(PTHREAD_DIR)/sysdeps/unix/sysv/linux/Makefile.commonarch
 
 lib-a-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.a
 lib-so-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.so
diff --git a/libpthread/nptl/sysdeps/Makefile.commonarch b/libpthread/nptl/sysdeps/Makefile.commonarch
new file mode 100644
index 000000000..669e9d318
--- /dev/null
+++ b/libpthread/nptl/sysdeps/Makefile.commonarch
@@ -0,0 +1,57 @@
+# Makefile template to be included by libpthread/nptl/sysdeps/<ARCH>/Makefile.arch
+#
+# Copyright (C) 2010 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+PTHREAD_ARCH_DIR  := $(top_srcdir)libpthread/nptl/sysdeps/$(TARGET_ARCH)
+PTHREAD_ARCH_OUT  := $(top_builddir)libpthread/nptl/sysdeps/$(TARGET_ARCH)
+
+PTHREAD_ARCH_CSRC := $(patsubst %.c,$(PTHREAD_ARCH_DIR)/%.c,$(libpthread_CSRC))
+PTHREAD_ARCH_COBJ := $(patsubst %.c,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_CSRC))
+PTHREAD_ARCH_SSRC := $(patsubst %.s,$(PTHREAD_ARCH_DIR)/%.s,$(patsubst %.S,$(PTHREAD_ARCH_DIR)/%.S,$(libpthread_SSRC)))
+PTHREAD_ARCH_SOBJ := $(patsubst %.s,$(PTHREAD_ARCH_OUT)/%.o,$(patsubst %.S,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_SSRC)))
+PTHREAD_ARCH_OBJS := $(PTHREAD_ARCH_COBJ) $(PTHREAD_ARCH_SOBJ)
+
+LIBRT_ARCH_COBJ := $(patsubst %.c,$(PTHREAD_ARCH_OUT)/%.o,$(librt_CSRC))
+LIBRT_ARCH_SOBJ := $(patsubst %.S,$(PTHREAD_ARCH_OUT)/%.o,$(librt_SSRC))
+LIBRT_ARCH_OBJS := $(LIBRT_ARCH_COBJ) $(LIBRT_ARCH_SOBJ)
+
+LIBC_ARCH_COBJ := $(patsubst %.c,$(PTHREAD_ARCH_OUT)/%.o,$(libc_a_CSRC))
+LIBC_ARCH_SOBJ := $(patsubst %.c,$(PTHREAD_ARCH_OUT)/%.o,$(libc_a_SSRC))
+LIBC_ARCH_OBJS := $(LIBC_ARCH_COBJ) $(LIBC_ARCH_SOBJ)
+
+PTHREAD_LIBC_TLS_CSRC := $(filter-out $(notdir $(PTHREAD_ARCH_OBJS:.o=.c)),$(notdir $(PTHREAD_LIBC_TLS_CSRC)))
+PTHREAD_OBJS := $(PTHREAD_ARCH_OBJS)
+
+libpthread-a-y += $(if $(DOPIC),$(PTHREAD_OBJS:.o=.os),$(PTHREAD_OBJS))
+libpthread-so-y += $(PTHREAD_OBJS:.o=.oS)
+
+librt-a-y += $(LIBRT_ARCH_OBJS)
+librt-so-y += $(LIBRT_ARCH_OBJS:.o=.oS)
+
+libc-static-y += $(LIBC_ARCH_OBJS) $(PTHREAD_LIBC_TLS_OBJS)
+
+CFLAGS-tcb-offsets.c = -S
+$(PTHREAD_ARCH_OUT)/tcb-offsets.c: $(PTHREAD_ARCH_DIR)/tcb-offsets.sym | $(PTHREAD_ARCH_OUT)
+	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
+
+$(PTHREAD_ARCH_OUT)/tcb-offsets.s: $(PTHREAD_ARCH_OUT)/tcb-offsets.c
+	$(compile.c)
+
+PTHREAD_TCB_OFFSET_MANGLE ?= -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*\$$/\#define \1 \2/p"
+$(PTHREAD_ARCH_OUT)/tcb-offsets.h: $(PTHREAD_ARCH_OUT)/tcb-offsets.s
+	$(do_sed) $(PTHREAD_TCB_OFFSET_MANGLE) $< > $@
+	@if test ! -s $@ ; then rm -f $@ ; false ; fi
+
+pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(PTHREAD_ARCH_OUT)/tcb-offsets.h
+
+objclean-y     +=       CLEAN_$(subst $(top_builddir),,$(PTHREAD_ARCH_OUT))
+headers_clean-y+= HEADERCLEAN_$(subst $(top_builddir),,$(PTHREAD_ARCH_OUT))
+
+CLEAN_$(subst $(top_builddir),,$(PTHREAD_ARCH_OUT)):
+	$(do_rm) $(addprefix $(PTHREAD_ARCH_OUT)/*., o os oS)
+HEADERCLEAN_$(subst $(top_builddir),,$(PTHREAD_ARCH_OUT)):
+	$(do_rm) $(addprefix $(PTHREAD_ARCH_OUT)/tcb-offsets., c h s)
+
diff --git a/libpthread/nptl/sysdeps/arm/Makefile.arch b/libpthread/nptl/sysdeps/arm/Makefile.arch
index 8b4ce70e4..87e81896a 100644
--- a/libpthread/nptl/sysdeps/arm/Makefile.arch
+++ b/libpthread/nptl/sysdeps/arm/Makefile.arch
@@ -22,50 +22,3 @@ ASFLAGS-pthread_spin_trylock.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
 ASFLAGS-aeabi_read_tp.S = -DNOT_IN_libc=1
 
 CFLAGS-arm = $(SSP_ALL_CFLAGS)
-
-PTHREAD_ARCH_DIR := $(top_srcdir)libpthread/nptl/sysdeps/arm
-PTHREAD_ARCH_OUT := $(top_builddir)libpthread/nptl/sysdeps/arm
-PTHREAD_ARCH_OBJ := $(patsubst %.S,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_SSRC))
-PTHREAD_ARCH_OBJ += $(patsubst %.c,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_CSRC))
-LIBRT_ARCH_OBJ := $(patsubst %.S,$(PTHREAD_ARCH_OUT)/%.o,$(librt_SSRC))
-LIBRT_ARCH_OBJ += $(patsubst %.c,$(PTHREAD_ARCH_OUT)/%.o,$(librt_CSRC))
-
-
-ifeq ($(DOPIC),y)
-libpthread-a-y += $(PTHREAD_ARCH_OBJ:.o=.os)
-else
-libpthread-a-y += $(PTHREAD_ARCH_OBJ)
-endif
-libpthread-so-y += $(PTHREAD_ARCH_OBJ:.o=.oS)
-
-librt-a-y += $(LIBRT_ARCH_OBJ)
-librt-so-y += $(LIBRT_ARCH_OBJ:.o=.oS)
-
-libpthread-nomulti-y += $(PTHREAD_ARCH_OBJ)
-
-objclean-y += nptl_arch_objclean
-headers_clean-y += nptl_arch_headers_clean
-
-#
-# Create 'tcb-offsets.h' header file.
-#
-CFLAGS-tcb-offsets.c = -S
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.c: $(PTHREAD_ARCH_DIR)/tcb-offsets.sym
-	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.s: $(PTHREAD_ARCH_OUT)/tcb-offsets.c
-	$(compile.c)
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.h: $(PTHREAD_ARCH_OUT)/tcb-offsets.s
-	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
-
-pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(PTHREAD_ARCH_OUT)/tcb-offsets.h
-
-nptl_arch_headers_clean:
-	$(RM) $(PTHREAD_ARCH_OUT)/tcb-offsets.c		\
-	      $(PTHREAD_ARCH_OUT)/tcb-offsets.s		\
-	      $(PTHREAD_ARCH_OUT)/tcb-offsets.h
-
-nptl_arch_objclean:
-	$(RM) $(PTHREAD_ARCH_OUT)/*.{o,os,oS}
diff --git a/libpthread/nptl/sysdeps/generic/Makefile.in b/libpthread/nptl/sysdeps/generic/Makefile.in
index 96bf2ac6d..2091dca0a 100644
--- a/libpthread/nptl/sysdeps/generic/Makefile.in
+++ b/libpthread/nptl/sysdeps/generic/Makefile.in
@@ -10,22 +10,16 @@
 #       their architecture specific directory which will override
 #       the one here.
 #
-ifneq ($(TARGET_ARCH),mips)
-	libc_a_CSRC = libc-tls.c
-endif
 
-CFLAGS-generic = $(SSP_ALL_CFLAGS)
-#CFLAGS:=$(CFLAGS:-O1=-O2)
-
-PTHREAD_GENERIC_OUT:=$(top_builddir)libpthread/nptl/sysdeps/generic
+PTHREAD_LIBC_TLS_DIR := $(top_srcdir)libpthread/nptl/sysdeps/generic
+PTHREAD_LIBC_TLS_OUT := $(top_builddir)libpthread/nptl/sysdeps/generic
 
-LIBC_GENERIC_OBJ:=$(patsubst %.c,$(PTHREAD_GENERIC_OUT)/%.o,$(libc_a_CSRC))
+PTHREAD_LIBC_TLS_CSRC = dl-tls.c libc-tls.c
+PTHREAD_LIBC_TLS_OBJS = $(patsubst %.c,$(PTHREAD_LIBC_TLS_OUT)/%.o,$(PTHREAD_LIBC_TLS_CSRC))
 
-libc-static-y+=$(LIBC_GENERIC_OBJ)
-
-libc-nomulti-y+=$(LIBC_GENERIC_OBJ)
+CFLAGS-generic = $(SSP_ALL_CFLAGS)
 
 objclean-y += CLEAN_libpthread/nptl/sysdeps/generic
 
 CLEAN_libpthread/nptl/sysdeps/generic:
-	$(do_rm) $(addprefix $(PTHREAD_GENERIC_OUT)/*., o os oS)
+	$(do_rm) $(addprefix $(PTHREAD_LIBC_TLS_OUT)/*., o os oS)
diff --git a/libpthread/nptl/sysdeps/i386/Makefile.arch b/libpthread/nptl/sysdeps/i386/Makefile.arch
index bc0117489..03b9972eb 100644
--- a/libpthread/nptl/sysdeps/i386/Makefile.arch
+++ b/libpthread/nptl/sysdeps/i386/Makefile.arch
@@ -11,43 +11,3 @@ libpthread_SSRC = i486/pthread_spin_trylock.S
 CFLAGS-pthread_spin_lock.c += -D_GNU_SOURCE
 
 CFLAGS-i386 = $(SSP_ALL_CFLAGS)
-#CFLAGS:=$(CFLAGS:-O1=-O2)
-
-PTHREAD_ARCH_DIR := $(top_srcdir)libpthread/nptl/sysdeps/i386
-PTHREAD_ARCH_OUT := $(top_builddir)libpthread/nptl/sysdeps/i386
-PTHREAD_ARCH_OBJ := $(patsubst %.S,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_SSRC))
-PTHREAD_ARCH_OBJ += $(patsubst %.c,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_CSRC))
-
-ifeq ($(DOPIC),y)
-libpthread-a-y += $(PTHREAD_ARCH_OBJ:.o=.os)
-else
-libpthread-a-y += $(PTHREAD_ARCH_OBJ)
-endif
-libpthread-so-y += $(PTHREAD_ARCH_OBJ:.o=.oS)
-
-libpthread-nomulti-y += $(PTHREAD_ARCH_OBJ)
-
-objclean-y += CLEAN_libpthread/nptl/sysdeps/i386
-headers_clean-y += HEADERCLEAN_libpthread/nptl/sysdeps/i386
-
-#
-# Create 'tcb-offsets.h' header file.
-#
-CFLAGS-tcb-offsets.c = -S
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.c: $(PTHREAD_ARCH_DIR)/tcb-offsets.sym
-	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.s: $(PTHREAD_ARCH_OUT)/tcb-offsets.c
-	$(compile.c)
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.h: $(PTHREAD_ARCH_OUT)/tcb-offsets.s
-	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
-
-pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(PTHREAD_ARCH_OUT)/tcb-offsets.h
-
-HEADERCLEAN_libpthread/nptl/sysdeps/i386:
-	$(do_rm) $(addprefix $(PTHREAD_ARCH_OUT)/tcb-offsets., c s h)
-
-CLEAN_libpthread/nptl/sysdeps/i386:
-	$(do_rm) $(addprefix $(PTHREAD_ARCH_OUT)/*., o os oS)
diff --git a/libpthread/nptl/sysdeps/mips/Makefile.arch b/libpthread/nptl/sysdeps/mips/Makefile.arch
index 2992f35f1..7b6bfd48e 100644
--- a/libpthread/nptl/sysdeps/mips/Makefile.arch
+++ b/libpthread/nptl/sysdeps/mips/Makefile.arch
@@ -19,50 +19,4 @@ ASFLAGS-nptl-sysdep.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1	\
 		        -I$(top_srcdir)libc/sysdeps/linux/mips
 
 CFLAGS-mips = $(SSP_ALL_CFLAGS)
-#CFLAGS:=$(CFLAGS:-O1=-O2)
 
-PTHREAD_ARCH_DIR := $(top_srcdir)libpthread/nptl/sysdeps/mips
-PTHREAD_ARCH_OUT := $(top_builddir)libpthread/nptl/sysdeps/mips
-PTHREAD_ARCH_OBJ := $(patsubst %.S,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_SSRC))
-
-ifeq ($(DOPIC),y)
-libpthread-a-y += $(PTHREAD_ARCH_OBJ:.o=.os)
-else
-libpthread-a-y += $(PTHREAD_ARCH_OBJ)
-endif
-libpthread-so-y += $(PTHREAD_ARCH_OBJ:.o=.oS)
-
-libpthread-nomulti-y += $(PTHREAD_ARCH_OBJ)
-
-LIBC_ARCH_OBJ := $(patsubst %.c,$(PTHREAD_ARCH_OUT)/%.o,$(libc_a_CSRC))
-
-libc-static-y += $(LIBC_ARCH_OBJ)
-
-libc-nomulti-y += $(LIBC_ARCH_OBJ)
-
-objclean-y += nptl_arch_objclean
-headers_clean-y += nptl_arch_headers_clean
-
-#
-# Create 'tcb-offsets.h' header file.
-#
-CFLAGS-tcb-offsets.c = -S
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.c: $(PTHREAD_ARCH_DIR)/tcb-offsets.sym
-	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.s: $(PTHREAD_ARCH_OUT)/tcb-offsets.c
-	$(compile.c)
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.h: $(PTHREAD_ARCH_OUT)/tcb-offsets.s
-	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
-
-pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(PTHREAD_ARCH_OUT)/tcb-offsets.h
-
-nptl_arch_headers_clean:
-	$(RM) $(PTHREAD_ARCH_OUT)/tcb-offsets.c		\
-	      $(PTHREAD_ARCH_OUT)/tcb-offsets.s		\
-	      $(PTHREAD_ARCH_OUT)/tcb-offsets.h
-
-nptl_arch_objclean:
-	$(RM) $(PTHREAD_ARCH_OUT)/*.{o,os,oS}
diff --git a/libpthread/nptl/sysdeps/powerpc/Makefile.arch b/libpthread/nptl/sysdeps/powerpc/Makefile.arch
index 71695c88b..48a54cc73 100644
--- a/libpthread/nptl/sysdeps/powerpc/Makefile.arch
+++ b/libpthread/nptl/sysdeps/powerpc/Makefile.arch
@@ -5,48 +5,7 @@
 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
 #
 
-PTHREAD_ARCH_DIR := $(top_srcdir)libpthread/nptl/sysdeps/powerpc
-PTHREAD_ARCH_OUT := $(top_builddir)libpthread/nptl/sysdeps/powerpc
-
 libpthread_SSRC =
 libpthread_CSRC = pthread_spin_lock.c pthread_spin_trylock.c
 
-PTHREAD_ARCH_OBJ := $(patsubst %.S,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_SSRC))
-PTHREAD_ARCH_OBJ += $(patsubst %.c,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_CSRC))
-
-ifeq ($(DOPIC),y)
-libpthread-a-y += $(PTHREAD_ARCH_OBJ:.o=.os)
-else
-libpthread-a-y += $(PTHREAD_ARCH_OBJ)
-endif
-libpthread-so-y += $(PTHREAD_ARCH_OBJ:.o=.oS)
-
-libpthread-nomulti-y += $(PTHREAD_ARCH_OBJ)
-
 CFLAGS-powerpc = $(SSP_ALL_CFLAGS)
-objclean-y += nptl_arch_objclean
-headers_clean-y += nptl_arch_headers_clean
-
-#
-# Create 'tcb-offsets.h' header file.
-#
-CFLAGS-tcb-offsets.c = -S
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.c: $(PTHREAD_ARCH_DIR)/tcb-offsets.sym
-	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.s: $(PTHREAD_ARCH_OUT)/tcb-offsets.c
-	$(compile.c)
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.h: $(PTHREAD_ARCH_OUT)/tcb-offsets.s
-	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
-
-pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(PTHREAD_ARCH_OUT)/tcb-offsets.h
-
-nptl_arch_headers_clean:
-	$(RM) $(PTHREAD_ARCH_OUT)/tcb-offsets.c	\
-	$(PTHREAD_ARCH_OUT)/tcb-offsets.s	\
-	$(PTHREAD_ARCH_OUT)/tcb-offsets.h
-
-nptl_arch_objclean:
-	$(RM) $(PTHREAD_ARCH_OUT)/*.{o,os,oS}
diff --git a/libpthread/nptl/sysdeps/sh/Makefile.arch b/libpthread/nptl/sysdeps/sh/Makefile.arch
index 5c36a7992..15830f55c 100644
--- a/libpthread/nptl/sysdeps/sh/Makefile.arch
+++ b/libpthread/nptl/sysdeps/sh/Makefile.arch
@@ -14,43 +14,4 @@ ASFLAGS-pthread_spin_trylock.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
 CFLAGS-pthread_spin_lock.c += -D_GNU_SOURCE
 
 CFLAGS-sh = $(SSP_ALL_CFLAGS)
-#CFLAGS:=$(CFLAGS:-O1=-O2)
 
-PTHREAD_ARCH_DIR := $(top_srcdir)libpthread/nptl/sysdeps/sh
-PTHREAD_ARCH_OUT := $(top_builddir)libpthread/nptl/sysdeps/sh
-PTHREAD_ARCH_OBJ := $(patsubst %.S,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_SSRC))
-PTHREAD_ARCH_OBJ += $(patsubst %.c,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_CSRC))
-
-ifeq ($(DOPIC),y)
-libpthread-a-y += $(PTHREAD_ARCH_OBJ:.o=.os)
-else
-libpthread-a-y += $(PTHREAD_ARCH_OBJ)
-endif
-libpthread-so-y += $(PTHREAD_ARCH_OBJ:.o=.oS)
-
-libpthread-nomulti-y += $(PTHREAD_ARCH_OBJ)
-
-objclean-y += CLEAN_libpthread/nptl/sysdeps/sh
-headers_clean-y += HEADERCLEAN_libpthread/nptl/sysdeps/sh
-
-#
-# Create 'tcb-offsets.h' header file.
-#
-CFLAGS-tcb-offsets.c = -S
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.c: $(PTHREAD_ARCH_DIR)/tcb-offsets.sym
-	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.s: $(PTHREAD_ARCH_OUT)/tcb-offsets.c
-	$(compile.c)
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.h: $(PTHREAD_ARCH_OUT)/tcb-offsets.s
-	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
-
-pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(PTHREAD_ARCH_OUT)/tcb-offsets.h
-
-HEADERCLEAN_libpthread/nptl/sysdeps/sh:
-	$(do_rm) $(addprefix $(PTHREAD_ARCH_OUT)/tcb-offsets., c s h)
-
-CLEAN_libpthread/nptl/sysdeps/sh:
-	$(do_rm) $(addprefix $(PTHREAD_ARCH_OUT)/*., o os oS)
diff --git a/libpthread/nptl/sysdeps/sparc/Makefile.arch b/libpthread/nptl/sysdeps/sparc/Makefile.arch
index b9b1c9cfd..3cd2e67e6 100644
--- a/libpthread/nptl/sysdeps/sparc/Makefile.arch
+++ b/libpthread/nptl/sysdeps/sparc/Makefile.arch
@@ -11,43 +11,4 @@ libpthread_CSRC = sparc32/pthread_spin_lock.c \
 CFLAGS-pthread_spin_lock.c += -D_GNU_SOURCE
 
 CFLAGS-sparc = $(SSP_ALL_CFLAGS)
-#CFLAGS:=$(CFLAGS:-O1=-O2)
 
-PTHREAD_ARCH_DIR := $(top_srcdir)libpthread/nptl/sysdeps/sparc
-PTHREAD_ARCH_OUT := $(top_builddir)libpthread/nptl/sysdeps/sparc
-PTHREAD_ARCH_OBJ := $(patsubst %.S,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_SSRC))
-PTHREAD_ARCH_OBJ += $(patsubst %.c,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_CSRC))
-
-ifeq ($(DOPIC),y)
-libpthread-a-y += $(PTHREAD_ARCH_OBJ:.o=.os)
-else
-libpthread-a-y += $(PTHREAD_ARCH_OBJ)
-endif
-libpthread-so-y += $(PTHREAD_ARCH_OBJ:.o=.oS)
-
-libpthread-nomulti-y += $(PTHREAD_ARCH_OBJ)
-
-objclean-y += CLEAN_libpthread/nptl/sysdeps/sparc
-headers_clean-y += HEADERCLEAN_libpthread/nptl/sysdeps/sparc
-
-#
-# Create 'tcb-offsets.h' header file.
-#
-CFLAGS-tcb-offsets.c = -S
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.c: $(PTHREAD_ARCH_DIR)/tcb-offsets.sym
-	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.s: $(PTHREAD_ARCH_OUT)/tcb-offsets.c
-	$(compile.c)
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.h: $(PTHREAD_ARCH_OUT)/tcb-offsets.s
-	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
-
-pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(PTHREAD_ARCH_OUT)/tcb-offsets.h
-
-nptl_arch_headers_clean:
-	$(do_rm) $(addprefix $(PTHREAD_ARCH_OUT)/tcb-offsets., c s h)
-
-nptl_arch_clean:
-	$(do_rm) $(addprefix $(PTHREAD_ARCH_OUT)/*., o os oS)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile
index 34d647527..930ff5654 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile
@@ -9,5 +9,5 @@ top_srcdir=../../../../../../
 top_builddir=../../../../../../
 all: objs
 include $(top_builddir)Rules.mak
-include Makefile.in
+include Makefile.commonarch
 include $(top_srcdir)Makerules
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch
new file mode 100644
index 000000000..09d967616
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch
@@ -0,0 +1,255 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2006 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+libpthread_CSRC = pthread_attr_getaffinity.c				\
+		  pthread_attr_setaffinity.c pthread_getaffinity.c	\
+		  pthread_getcpuclockid.c pthread_kill.c		\
+		  pthread_mutex_cond_lock.c pthread_setaffinity.c	\
+		  pthread_yield.c sem_post.c sem_timedwait.c		\
+		  pthread_sigqueue.c 					\
+		  sem_trywait.c sem_wait.c pt-fork.c			\
+		  sigtimedwait.c sigwaitinfo.c sigwait.c pt-sleep.c
+
+libpthread_SSRC = #ptw-close.S ptw-open.S ptw-waitid.S ptw-waidpid.S ptw-write.S
+
+libc_CSRC = libc_pthread_init.c libc_multiple_threads.c			\
+	    register-atfork.c unregister-atfork.c getpid.c		\
+	    raise.c sleep.c jmp-unwind.c
+
+# These provide both a cancellable and a not cancellable implementation
+libc_SSRC = close.S open.S write.S read.S waitpid.S
+
+librt_CSRC := mq_notify.c timer_create.c timer_delete.c			 \
+	      timer_getoverr.c timer_gettime.c timer_routines.c		 \
+	      timer_settime.c
+
+
+ifeq ($(TARGET_ARCH),alpha)
+libpthread_CSRC += lowlevellock.c
+libc_CSRC += libc-lowlevellock.c
+librt_CSRC := mq_notify.c
+endif
+
+ifeq ($(TARGET_ARCH),arm)
+libc_SSRC := $(filter-out waitpid.S,$(libc_SSRC))
+libpthread_CSRC += lowlevelrobustlock.c
+endif
+
+ifeq ($(TARGET_ARCH),mips)
+libpthread_CSRC += lowlevellock.c lowlevelrobustlock.c
+libc_CSRC += libc-lowlevellock.c
+endif
+
+ifeq ($(TARGET_ARCH),powerpc)
+libpthread_CSRC += lowlevellock.c lowlevelrobustlock.c
+libc_CSRC += libc-lowlevellock.c
+librt_CSRC += __syscall_error.c
+endif
+
+ifeq ($(TARGET_ARCH),sparc)
+libpthread_CSRC += __syscall_error.c lowlevelrobustlock.c
+librt_CSRC += __syscall_error.c
+endif
+
+ifeq ($(TARGET_ARCH),sh)
+SH_PTHREAD_SPECIFIC := sem_post.c sem_wait.c sem_timedwait.c sem_trywait.c
+libpthread_CSRC := $(filter-out $(SH_PTHREAD_SPECIFIC),$(libpthread_CSRC))
+endif
+
+ifeq ($(TARGET_ARCH),i386)
+X86_PTHREAD_SPECIFIC := sem_post.c sem_wait.c sem_timedwait.c sem_trywait.c
+libpthread_CSRC := $(filter-out $(X86_PTHREAD_SPECIFIC),$(libpthread_CSRC))
+endif
+
+ifeq ($(TARGET_ARCH),x86_64)
+libc_SSRC := $(filter-out waitpid.S,$(libc_SSRC))
+X64_PTHREAD_SPECIFIC := sem_post.c sem_wait.c sem_timedwait.c sem_trywait.c
+libpthread_CSRC := $(filter-out $(X64_PTHREAD_SPECIFIC),$(libpthread_CSRC))
+endif
+
+CFLAGS-pthread_getcpuclockid.c = -I$(top_srcdir)librt
+CFLAGS-pt-pread_pwrite.c = -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH) \
+			    -I$(top_srcdir)libc/sysdeps/linux/common
+CFLAGS-mq_notify.c = -I$(top_srcdir)librt -DIS_IN_librt=1
+CFLAGS-timer_create.c = -I$(top_srcdir)librt -DIS_IN_librt=1
+CFLAGS-timer_delete.c = -I$(top_srcdir)librt -DIS_IN_librt=1
+CFLAGS-timer_getoverr.c = -I$(top_srcdir)librt -DIS_IN_librt=1
+CFLAGS-timer_gettime.c = -I$(top_srcdir)librt -DIS_IN_librt=1
+CFLAGS-timer_routines.c = -I$(top_srcdir)librt -DIS_IN_librt=1
+CFLAGS-timer_settime.c = -I$(top_srcdir)librt -DIS_IN_librt=1
+
+CFLAGS-linux = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 $(SSP_ALL_CFLAGS)
+#CFLAGS:=$(CFLAGS:-O1=-O2)
+
+CFLAGS-OMIT-libc_pthread_init.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
+CFLAGS-OMIT-libc_multiple_threads.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
+CFLAGS-OMIT-register-atfork.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
+CFLAGS-OMIT-unregister-atfork.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
+CFLAGS-OMIT-getpid.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
+CFLAGS-OMIT-raise.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
+CFLAGS-OMIT-sleep.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
+CFLAGS-OMIT-libc-lowlevellock.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
+
+CFLAGS-OMIT-close.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
+CFLAGS-OMIT-open.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
+CFLAGS-OMIT-read.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
+CFLAGS-OMIT-write.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
+CFLAGS-OMIT-waitpid.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
+
+CFLAGS-OMIT-mq_notify.c = -DIS_IN_libpthread=1
+CFLAGS-OMIT-timer_create.c = -DIS_IN_libpthread=1
+CFLAGS-OMIT-timer_delete.c = -DIS_IN_libpthread=1
+CFLAGS-OMIT-timer_getoverr.c = -DIS_IN_libpthread=1
+CFLAGS-OMIT-timer_gettime.c = -DIS_IN_libpthread=1
+CFLAGS-OMIT-timer_routines.c = -DIS_IN_libpthread=1
+CFLAGS-OMIT-timer_settime.c = -DIS_IN_libpthread=1
+
+PTHREAD_LINUX_DIR := $(top_srcdir)libpthread/nptl/sysdeps/unix/sysv/linux
+PTHREAD_LINUX_OUT := $(top_builddir)libpthread/nptl/sysdeps/unix/sysv/linux
+
+PTHREAD_LINUX_OBJ := $(patsubst %.c,$(PTHREAD_LINUX_OUT)/%.o,$(libpthread_CSRC))
+PTHREAD_LINUX_OBJ += $(patsubst %.S,$(PTHREAD_LINUX_OUT)/%.o,$(libpthread_SSRC))
+
+ifeq ($(DOPIC),y)
+libpthread-a-y += $(PTHREAD_LINUX_OBJ:.o=.os)
+else
+libpthread-a-y += $(PTHREAD_LINUX_OBJ)
+endif
+libpthread-so-y += $(PTHREAD_LINUX_OBJ:.o=.oS)
+libpthread-so-y += $(PTHREAD_LINUX_OUT)/pt-raise.oS
+libpthread-nomulti-y += $(PTHREAD_LINUX_OBJ)
+
+ASFLAGS-open.S = -D_LIBC_REENTRANT
+ASFLAGS-close.S = -D_LIBC_REENTRANT
+ASFLAGS-read.S = -D_LIBC_REENTRANT
+ASFLAGS-write.S = -D_LIBC_REENTRANT
+ASFLAGS-waitpid.S = -D_LIBC_REENTRANT
+
+LIBC_LINUX_OBJ := $(patsubst %.c,$(PTHREAD_LINUX_OUT)/%.o,$(libc_CSRC))
+LIBC_LINUX_OBJ += $(patsubst %.S,$(PTHREAD_LINUX_OUT)/%.o,$(libc_SSRC))
+
+libc-static-y += $(LIBC_LINUX_OBJ)
+libc-shared-y += $(LIBC_LINUX_OBJ:.o=.oS)
+libc-nomulti-y += $(LIBC_LINUX_OBJ)
+
+LIBRT_LINUX_OBJ := $(patsubst %.c,$(PTHREAD_LINUX_OUT)/%.o,$(librt_CSRC))
+
+librt-a-y += $(LIBRT_LINUX_OBJ)
+librt-so-y += $(LIBRT_LINUX_OBJ:.o=.oS)
+
+objclean-y += CLEAN_libpthread/nptl/sysdeps/unix/sysv/linux
+headers_clean-y += HEADERCLEAN_libpthread/nptl/sysdeps/unix/sysv/linux
+
+#
+# Create header files.
+#
+CFLAGS-gen_lowlevelbarrier.c = -S
+CFLAGS-gen_lowlevelcond.c = -S
+CFLAGS-gen_lowlevelrwlock.c = -S
+CFLAGS-gen_lowlevelrobustlock.c = -S
+CFLAGS-gen_lunwindbuf.c = -S
+CFLAGS-gen_lstructsem.c = -S
+CFLAGS-gen_lpthread-pi-defines.c = -S
+
+$(PTHREAD_LINUX_OUT)/gen_lowlevelbarrier.c: $(PTHREAD_LINUX_DIR)/lowlevelbarrier.sym
+	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
+
+$(PTHREAD_LINUX_OUT)/gen_lowlevelcond.c: $(PTHREAD_LINUX_DIR)/lowlevelcond.sym
+	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
+
+$(PTHREAD_LINUX_OUT)/gen_lowlevelrwlock.c: $(PTHREAD_LINUX_DIR)/lowlevelrwlock.sym
+	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
+
+$(PTHREAD_LINUX_OUT)/gen_lowlevelrobustlock.c: $(PTHREAD_LINUX_DIR)/lowlevelrobustlock.sym
+	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
+
+$(PTHREAD_LINUX_OUT)/gen_lunwindbuf.c: $(PTHREAD_LINUX_DIR)/unwindbuf.sym
+	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
+
+$(PTHREAD_LINUX_OUT)/gen_lstructsem.c: $(PTHREAD_LINUX_DIR)/structsem.sym
+	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
+
+$(PTHREAD_LINUX_OUT)/gen_lpthread-pi-defines.c: $(PTHREAD_LINUX_DIR)/pthread-pi-defines.sym
+	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
+
+
+$(PTHREAD_LINUX_OUT)/gen_lowlevelbarrier.s: $(PTHREAD_LINUX_OUT)/gen_lowlevelbarrier.c
+	$(compile.c)
+
+$(PTHREAD_LINUX_OUT)/gen_lowlevelcond.s: $(PTHREAD_LINUX_OUT)/gen_lowlevelcond.c
+	$(compile.c)
+
+$(PTHREAD_LINUX_OUT)/gen_lowlevelrwlock.s: $(PTHREAD_LINUX_OUT)/gen_lowlevelrwlock.c
+	$(compile.c)
+
+$(PTHREAD_LINUX_OUT)/gen_lowlevelrobustlock.s: $(PTHREAD_LINUX_OUT)/gen_lowlevelrobustlock.c
+	$(compile.c)
+
+$(PTHREAD_LINUX_OUT)/gen_lunwindbuf.s: $(PTHREAD_LINUX_OUT)/gen_lunwindbuf.c
+	$(compile.c)
+
+$(PTHREAD_LINUX_OUT)/gen_lstructsem.s: $(PTHREAD_LINUX_OUT)/gen_lstructsem.c
+	$(compile.c)
+
+$(PTHREAD_LINUX_OUT)/gen_lpthread-pi-defines.s: $(PTHREAD_LINUX_OUT)/gen_lpthread-pi-defines.c
+	$(compile.c)
+
+
+$(PTHREAD_LINUX_OUT)/lowlevelbarrier.h: $(PTHREAD_LINUX_OUT)/gen_lowlevelbarrier.s
+	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
+
+$(PTHREAD_LINUX_OUT)/lowlevelcond.h: $(PTHREAD_LINUX_OUT)/gen_lowlevelcond.s
+	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
+
+$(PTHREAD_LINUX_OUT)/lowlevelrwlock.h: $(PTHREAD_LINUX_OUT)/gen_lowlevelrwlock.s
+	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
+
+$(PTHREAD_LINUX_OUT)/lowlevelrobustlock.h: $(PTHREAD_LINUX_OUT)/gen_lowlevelrobustlock.s
+	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
+
+$(PTHREAD_LINUX_OUT)/unwindbuf.h: $(PTHREAD_LINUX_OUT)/gen_lunwindbuf.s
+	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
+
+$(PTHREAD_LINUX_OUT)/structsem.h: $(PTHREAD_LINUX_OUT)/gen_lstructsem.s
+	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
+
+$(PTHREAD_LINUX_OUT)/pthread-pi-defines.h: $(PTHREAD_LINUX_OUT)/gen_lpthread-pi-defines.s
+	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
+
+pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += \
+					$(PTHREAD_LINUX_OUT)/lowlevelbarrier.h \
+					$(PTHREAD_LINUX_OUT)/lowlevelcond.h \
+					$(PTHREAD_LINUX_OUT)/lowlevelrwlock.h \
+					$(PTHREAD_LINUX_OUT)/lowlevelrobustlock.h \
+					$(PTHREAD_LINUX_OUT)/unwindbuf.h \
+					$(PTHREAD_LINUX_OUT)/structsem.h \
+					$(PTHREAD_LINUX_OUT)/pthread-pi-defines.h
+
+HEADERS_BITS_PTHREAD     := $(notdir $(wildcard $(PTHREAD_LINUX_DIR)/bits/*.h))
+ALL_HEADERS_BITS_PTHREAD := $(addprefix include/bits/,$(HEADERS_BITS_PTHREAD))
+
+$(ALL_HEADERS_BITS_PTHREAD): $(top_builddir)include/bits/%: | $(top_builddir)include/bits
+	$(do_ln) $(call rel_srcdir)$(PTHREAD_LINUX_DIR)/bits/$(@F) $@
+
+HEADERCLEAN_libpthread/nptl/sysdeps/unix/sysv/linux:
+	$(do_rm) $(addprefix $(PTHREAD_LINUX_OUT)/gen_lowlevelbarrier., c s) \
+	$(addprefix $(PTHREAD_LINUX_OUT)/gen_lowlevelcond., c s) \
+	$(addprefix $(PTHREAD_LINUX_OUT)/gen_lowlevelrwlock., c s) \
+	$(addprefix $(PTHREAD_LINUX_OUT)/gen_lowlevelrobustlock., c s) \
+	$(addprefix $(PTHREAD_LINUX_OUT)/gen_lunwindbuf., c s) \
+	$(addprefix $(PTHREAD_LINUX_OUT)/gen_lstructsem., c s) \
+	$(addprefix $(PTHREAD_LINUX_OUT)/gen_lpthread-pi-defines., c s) \
+	$(PTHREAD_LINUX_OUT)/lowlevelbarrier.h \
+	$(PTHREAD_LINUX_OUT)/lowlevelcond.h \
+	$(PTHREAD_LINUX_OUT)/lowlevelrwlock.h \
+	$(PTHREAD_LINUX_OUT)/lowlevelrobustlock.h \
+	$(PTHREAD_LINUX_OUT)/unwindbuf.h \
+	$(PTHREAD_LINUX_OUT)/structsem.h \
+	$(PTHREAD_LINUX_OUT)/pthread-pi-defines.h
+
+CLEAN_libpthread/nptl/sysdeps/unix/sysv/linux:
+	$(do_rm) $(addprefix $(PTHREAD_LINUX_OUT)/*., o os oS)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.in b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.in
deleted file mode 100644
index b1a35c352..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.in
+++ /dev/null
@@ -1,256 +0,0 @@
-# Makefile for uClibc NPTL
-#
-# Copyright (C) 2006 Steven J. Hill <sjhill@uclibc.org>
-#
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
-
-libpthread_CSRC = pthread_attr_getaffinity.c				\
-		  pthread_attr_setaffinity.c pthread_getaffinity.c	\
-		  pthread_getcpuclockid.c pthread_kill.c		\
-		  pthread_mutex_cond_lock.c pthread_setaffinity.c	\
-		  pthread_yield.c sem_post.c sem_timedwait.c		\
-		  pthread_sigqueue.c 					\
-		  sem_trywait.c sem_wait.c pt-fork.c			\
-		  sigtimedwait.c sigwaitinfo.c sigwait.c pt-sleep.c
-
-libpthread_SSRC = #ptw-close.S ptw-open.S ptw-waitid.S ptw-waidpid.S ptw-write.S
-
-libc_CSRC = libc_pthread_init.c libc_multiple_threads.c			\
-	    register-atfork.c unregister-atfork.c getpid.c		\
-	    raise.c sleep.c jmp-unwind.c
-
-# These provide both a cancellable and a not cancellable implementation
-libc_SSRC = close.S open.S write.S read.S waitpid.S
-
-librt_CSRC := mq_notify.c timer_create.c timer_delete.c			 \
-	      timer_getoverr.c timer_gettime.c timer_routines.c		 \
-	      timer_settime.c
-
-
-ifeq ($(TARGET_ARCH),alpha)
-libpthread_CSRC += lowlevellock.c
-libc_CSRC += libc-lowlevellock.c
-librt_CSRC := mq_notify.c
-endif
-
-ifeq ($(TARGET_ARCH),arm)
-libc_SSRC := $(filter-out waitpid.S,$(libc_SSRC))
-libpthread_CSRC += lowlevelrobustlock.c
-endif
-
-ifeq ($(TARGET_ARCH),mips)
-libpthread_CSRC += lowlevellock.c lowlevelrobustlock.c
-libc_CSRC += libc-lowlevellock.c
-endif
-
-ifeq ($(TARGET_ARCH),powerpc)
-libpthread_CSRC += lowlevellock.c lowlevelrobustlock.c
-libc_CSRC += libc-lowlevellock.c
-librt_CSRC += __syscall_error.c
-endif
-
-ifeq ($(TARGET_ARCH),sparc)
-libpthread_CSRC += __syscall_error.c lowlevelrobustlock.c
-librt_CSRC += __syscall_error.c
-endif
-
-ifeq ($(TARGET_ARCH),sh)
-SH_PTHREAD_SPECIFIC := sem_post.c sem_wait.c sem_timedwait.c sem_trywait.c
-libpthread_CSRC := $(filter-out $(SH_PTHREAD_SPECIFIC),$(libpthread_CSRC))
-endif
-
-ifeq ($(TARGET_ARCH),i386)
-X86_PTHREAD_SPECIFIC := sem_post.c sem_wait.c sem_timedwait.c sem_trywait.c
-libpthread_CSRC := $(filter-out $(X86_PTHREAD_SPECIFIC),$(libpthread_CSRC))
-endif
-
-ifeq ($(TARGET_ARCH),x86_64)
-libc_SSRC := $(filter-out waitpid.S,$(libc_SSRC))
-X64_PTHREAD_SPECIFIC := sem_post.c sem_wait.c sem_timedwait.c sem_trywait.c
-libpthread_CSRC := $(filter-out $(X64_PTHREAD_SPECIFIC),$(libpthread_CSRC))
-endif
-
-CFLAGS-pthread_getcpuclockid.c = -I$(top_srcdir)librt
-CFLAGS-pt-pread_pwrite.c = -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH) \
-			    -I$(top_srcdir)libc/sysdeps/linux/common
-CFLAGS-mq_notify.c = -I$(top_srcdir)librt -DIS_IN_librt=1
-CFLAGS-timer_create.c = -I$(top_srcdir)librt -DIS_IN_librt=1
-CFLAGS-timer_delete.c = -I$(top_srcdir)librt -DIS_IN_librt=1
-CFLAGS-timer_getoverr.c = -I$(top_srcdir)librt -DIS_IN_librt=1
-CFLAGS-timer_gettime.c = -I$(top_srcdir)librt -DIS_IN_librt=1
-CFLAGS-timer_routines.c = -I$(top_srcdir)librt -DIS_IN_librt=1
-CFLAGS-timer_settime.c = -I$(top_srcdir)librt -DIS_IN_librt=1
-
-CFLAGS-linux = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 $(SSP_ALL_CFLAGS)
-#CFLAGS:=$(CFLAGS:-O1=-O2)
-
-CFLAGS-OMIT-libc_pthread_init.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
-CFLAGS-OMIT-libc_multiple_threads.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
-CFLAGS-OMIT-register-atfork.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
-CFLAGS-OMIT-unregister-atfork.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
-CFLAGS-OMIT-getpid.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
-CFLAGS-OMIT-raise.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
-CFLAGS-OMIT-sleep.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
-CFLAGS-OMIT-libc-lowlevellock.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
-
-CFLAGS-OMIT-close.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
-CFLAGS-OMIT-open.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
-CFLAGS-OMIT-read.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
-CFLAGS-OMIT-write.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
-CFLAGS-OMIT-waitpid.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
-
-CFLAGS-OMIT-mq_notify.c = -DIS_IN_libpthread=1
-CFLAGS-OMIT-timer_create.c = -DIS_IN_libpthread=1
-CFLAGS-OMIT-timer_delete.c = -DIS_IN_libpthread=1
-CFLAGS-OMIT-timer_getoverr.c = -DIS_IN_libpthread=1
-CFLAGS-OMIT-timer_gettime.c = -DIS_IN_libpthread=1
-CFLAGS-OMIT-timer_routines.c = -DIS_IN_libpthread=1
-CFLAGS-OMIT-timer_settime.c = -DIS_IN_libpthread=1
-
-PTHREAD_LINUX_DIR := $(top_srcdir)libpthread/nptl/sysdeps/unix/sysv/linux
-PTHREAD_LINUX_OUT := $(top_builddir)libpthread/nptl/sysdeps/unix/sysv/linux
-
-PTHREAD_LINUX_OBJ := $(patsubst %.c,$(PTHREAD_LINUX_OUT)/%.o,$(libpthread_CSRC))
-PTHREAD_LINUX_OBJ += $(patsubst %.S,$(PTHREAD_LINUX_OUT)/%.o,$(libpthread_SSRC))
-
-ifeq ($(DOPIC),y)
-libpthread-a-y += $(PTHREAD_LINUX_OBJ:.o=.os)
-else
-libpthread-a-y += $(PTHREAD_LINUX_OBJ)
-endif
-libpthread-so-y += $(PTHREAD_LINUX_OBJ:.o=.oS)
-libpthread-so-y += $(PTHREAD_LINUX_OUT)/pt-raise.oS
-libpthread-nomulti-y += $(PTHREAD_LINUX_OBJ)
-
-ASFLAGS-open.S = -D_LIBC_REENTRANT
-ASFLAGS-close.S = -D_LIBC_REENTRANT
-ASFLAGS-read.S = -D_LIBC_REENTRANT
-ASFLAGS-write.S = -D_LIBC_REENTRANT
-ASFLAGS-waitpid.S = -D_LIBC_REENTRANT
-
-LIBC_LINUX_OBJ := $(patsubst %.c,$(PTHREAD_LINUX_OUT)/%.o,$(libc_CSRC))
-LIBC_LINUX_OBJ += $(patsubst %.S,$(PTHREAD_LINUX_OUT)/%.o,$(libc_SSRC))
-
-libc-static-y += $(LIBC_LINUX_OBJ)
-libc-shared-y += $(LIBC_LINUX_OBJ:.o=.oS)
-libc-nomulti-y += $(LIBC_LINUX_OBJ)
-
-LIBRT_LINUX_OBJ := $(patsubst %.c,$(PTHREAD_LINUX_OUT)/%.o,$(librt_CSRC))
-
-librt-a-y += $(LIBRT_LINUX_OBJ)
-librt-so-y += $(LIBRT_LINUX_OBJ:.o=.oS)
-
-objclean-y += CLEAN_libpthread/nptl/sysdeps/unix/sysv/linux
-headers_clean-y += HEADERCLEAN_libpthread/nptl/sysdeps/unix/sysv/linux
-
-#
-# Create header files.
-#
-CFLAGS-gen_lowlevelbarrier.c = -S
-CFLAGS-gen_lowlevelcond.c = -S
-CFLAGS-gen_lowlevelrwlock.c = -S
-CFLAGS-gen_lowlevelrobustlock.c = -S
-CFLAGS-gen_lunwindbuf.c = -S
-CFLAGS-gen_lstructsem.c = -S
-CFLAGS-gen_lpthread-pi-defines.c = -S
-
-$(PTHREAD_LINUX_OUT)/gen_lowlevelbarrier.c: $(PTHREAD_LINUX_DIR)/lowlevelbarrier.sym
-	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
-
-$(PTHREAD_LINUX_OUT)/gen_lowlevelcond.c: $(PTHREAD_LINUX_DIR)/lowlevelcond.sym
-	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
-
-$(PTHREAD_LINUX_OUT)/gen_lowlevelrwlock.c: $(PTHREAD_LINUX_DIR)/lowlevelrwlock.sym
-	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
-
-$(PTHREAD_LINUX_OUT)/gen_lowlevelrobustlock.c: $(PTHREAD_LINUX_DIR)/lowlevelrobustlock.sym
-	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
-
-$(PTHREAD_LINUX_OUT)/gen_lunwindbuf.c: $(PTHREAD_LINUX_DIR)/unwindbuf.sym
-	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
-
-$(PTHREAD_LINUX_OUT)/gen_lstructsem.c: $(PTHREAD_LINUX_DIR)/structsem.sym
-	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
-
-$(PTHREAD_LINUX_OUT)/gen_lpthread-pi-defines.c: $(PTHREAD_LINUX_DIR)/pthread-pi-defines.sym
-	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
-
-
-$(PTHREAD_LINUX_OUT)/gen_lowlevelbarrier.s: $(PTHREAD_LINUX_OUT)/gen_lowlevelbarrier.c
-	$(compile.c)
-
-$(PTHREAD_LINUX_OUT)/gen_lowlevelcond.s: $(PTHREAD_LINUX_OUT)/gen_lowlevelcond.c
-	$(compile.c)
-
-$(PTHREAD_LINUX_OUT)/gen_lowlevelrwlock.s: $(PTHREAD_LINUX_OUT)/gen_lowlevelrwlock.c
-	$(compile.c)
-
-$(PTHREAD_LINUX_OUT)/gen_lowlevelrobustlock.s: $(PTHREAD_LINUX_OUT)/gen_lowlevelrobustlock.c
-	$(compile.c)
-
-$(PTHREAD_LINUX_OUT)/gen_lunwindbuf.s: $(PTHREAD_LINUX_OUT)/gen_lunwindbuf.c
-	$(compile.c)
-
-$(PTHREAD_LINUX_OUT)/gen_lstructsem.s: $(PTHREAD_LINUX_OUT)/gen_lstructsem.c
-	$(compile.c)
-
-$(PTHREAD_LINUX_OUT)/gen_lpthread-pi-defines.s: $(PTHREAD_LINUX_OUT)/gen_lpthread-pi-defines.c
-	$(compile.c)
-
-
-$(PTHREAD_LINUX_OUT)/lowlevelbarrier.h: $(PTHREAD_LINUX_OUT)/gen_lowlevelbarrier.s
-	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
-
-$(PTHREAD_LINUX_OUT)/lowlevelcond.h: $(PTHREAD_LINUX_OUT)/gen_lowlevelcond.s
-	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
-
-$(PTHREAD_LINUX_OUT)/lowlevelrwlock.h: $(PTHREAD_LINUX_OUT)/gen_lowlevelrwlock.s
-	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
-
-$(PTHREAD_LINUX_OUT)/lowlevelrobustlock.h: $(PTHREAD_LINUX_OUT)/gen_lowlevelrobustlock.s
-	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
-
-$(PTHREAD_LINUX_OUT)/unwindbuf.h: $(PTHREAD_LINUX_OUT)/gen_lunwindbuf.s
-	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
-
-$(PTHREAD_LINUX_OUT)/structsem.h: $(PTHREAD_LINUX_OUT)/gen_lstructsem.s
-	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
-
-$(PTHREAD_LINUX_OUT)/pthread-pi-defines.h: $(PTHREAD_LINUX_OUT)/gen_lpthread-pi-defines.s
-	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
-
-pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += \
-					$(PTHREAD_LINUX_OUT)/lowlevelbarrier.h \
-					$(PTHREAD_LINUX_OUT)/lowlevelcond.h \
-					$(PTHREAD_LINUX_OUT)/lowlevelrwlock.h \
-					$(PTHREAD_LINUX_OUT)/lowlevelrobustlock.h \
-					$(PTHREAD_LINUX_OUT)/unwindbuf.h \
-					$(PTHREAD_LINUX_OUT)/structsem.h \
-					$(PTHREAD_LINUX_OUT)/pthread-pi-defines.h
-
-HEADERS_BITS_PTHREAD     := $(notdir $(wildcard $(PTHREAD_LINUX_DIR)/bits/*.h))
-ALL_HEADERS_BITS_PTHREAD := $(addprefix include/bits/,$(HEADERS_BITS_PTHREAD))
-
-$(ALL_HEADERS_BITS_PTHREAD): $(top_builddir)include/bits/%: | $(top_builddir)include/bits
-	$(do_ln) $(call rel_srcdir)$(PTHREAD_LINUX_DIR)/bits/$(@F) $@
-
-HEADERCLEAN_libpthread/nptl/sysdeps/unix/sysv/linux:
-	$(do_rm) $(addprefix $(PTHREAD_LINUX_OUT)/gen_lowlevelbarrier., c s) \
-	$(addprefix $(PTHREAD_LINUX_OUT)/gen_lowlevelcond., c s) \
-	$(addprefix $(PTHREAD_LINUX_OUT)/gen_lowlevelrwlock., c s) \
-	$(addprefix $(PTHREAD_LINUX_OUT)/gen_lowlevelrobustlock., c s) \
-	$(addprefix $(PTHREAD_LINUX_OUT)/gen_lunwindbuf., c s) \
-	$(addprefix $(PTHREAD_LINUX_OUT)/gen_lstructsem., c s) \
-	$(addprefix $(PTHREAD_LINUX_OUT)/gen_lpthread-pi-defines., c s) \
-	$(PTHREAD_LINUX_OUT)/lowlevelbarrier.h \
-	$(PTHREAD_LINUX_OUT)/lowlevelcond.h \
-	$(PTHREAD_LINUX_OUT)/lowlevelrwlock.h \
-	$(PTHREAD_LINUX_OUT)/lowlevelrobustlock.h \
-	$(PTHREAD_LINUX_OUT)/unwindbuf.h \
-	$(PTHREAD_LINUX_OUT)/structsem.h \
-	$(PTHREAD_LINUX_OUT)/pthread-pi-defines.h
-
-
-CLEAN_libpthread/nptl/sysdeps/unix/sysv/linux:
-	$(do_rm) $(addprefix $(PTHREAD_LINUX_OUT)/*., o os oS)
diff --git a/libpthread/nptl/sysdeps/x86_64/Makefile.arch b/libpthread/nptl/sysdeps/x86_64/Makefile.arch
index dc7e484e5..5a3c4a2fc 100644
--- a/libpthread/nptl/sysdeps/x86_64/Makefile.arch
+++ b/libpthread/nptl/sysdeps/x86_64/Makefile.arch
@@ -11,43 +11,4 @@ libpthread_SSRC = pthread_spin_trylock.S
 CFLAGS-pthread_spin_lock.c += -D_GNU_SOURCE
 
 CFLAGS-x86_64 = $(SSP_ALL_CFLAGS)
-#CFLAGS:=$(CFLAGS:-O1=-O2)
 
-PTHREAD_ARCH_DIR := $(top_srcdir)libpthread/nptl/sysdeps/x86_64
-PTHREAD_ARCH_OUT := $(top_builddir)libpthread/nptl/sysdeps/x86_64
-PTHREAD_ARCH_OBJ := $(patsubst %.S,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_SSRC))
-PTHREAD_ARCH_OBJ += $(patsubst %.c,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_CSRC))
-
-ifeq ($(DOPIC),y)
-libpthread-a-y += $(PTHREAD_ARCH_OBJ:.o=.os)
-else
-libpthread-a-y += $(PTHREAD_ARCH_OBJ)
-endif
-libpthread-so-y += $(PTHREAD_ARCH_OBJ:.o=.oS)
-
-libpthread-nomulti-y += $(PTHREAD_ARCH_OBJ)
-
-objclean-y += CLEAN_libpthread/nptl/sysdeps/x86_64
-headers_clean-y += HEADERCLEAN_libpthread/nptl/sysdeps/x86_64
-
-#
-# Create 'tcb-offsets.h' header file.
-#
-CFLAGS-tcb-offsets.c = -S
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.c: $(PTHREAD_ARCH_DIR)/tcb-offsets.sym
-	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.s: $(PTHREAD_ARCH_OUT)/tcb-offsets.c
-	$(compile.c)
-
-$(PTHREAD_ARCH_OUT)/tcb-offsets.h: $(PTHREAD_ARCH_OUT)/tcb-offsets.s
-	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
-
-pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(PTHREAD_ARCH_OUT)/tcb-offsets.h
-
-HEADERCLEAN_libpthread/nptl/sysdeps/x86_64:
-	$(do_rm) $(addprefix $(PTHREAD_ARCH_OUT)/tcb-offsets., c s h)
-
-CLEAN_libpthread/nptl/sysdeps/x86_64:
-	$(do_rm) $(addprefix $(PTHREAD_ARCH_OUT)/*., o os oS)
diff --git a/libpthread/nptl_db/Makefile.in b/libpthread/nptl_db/Makefile.in
index cc6db8d7d..644ec5552 100644
--- a/libpthread/nptl_db/Makefile.in
+++ b/libpthread/nptl_db/Makefile.in
@@ -53,8 +53,7 @@ $(libthread_db_OUT)/libthread_db_so.a: $(libthread_db-so-y)
 	$(do_strip)
 	$(do_ar)
 
-$(top_builddir)lib/libthread_db.a: $(libthread_db-a-y)
-	$(Q)$(INSTALL) -d $(dir $@)
+$(top_builddir)lib/libthread_db.a: $(libthread_db-a-y) | $(top_builddir)lib
 	$(Q)$(RM) $@
 	$(do_strip)
 	$(do_ar)
-- 
cgit v1.2.3