3 # Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
4 # Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org>
6 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
9 subdirs += libpthread/linuxthreads/sysdeps/$(TARGET_ARCH)
10 subdirs += libpthread/linuxthreads/sysdeps/unix/sysv/linux
11 subdirs += libpthread/linuxthreads/sysdeps/pthread
13 CFLAGS-dir_linuxthreads := -DNOT_IN_libc -DIS_IN_libpthread
14 CFLAGS-libpthread/linuxthreads := $(CFLAGS-dir_linuxthreads) $(SSP_ALL_CFLAGS)
16 # This stuff will not compile without at least -O1
17 # psm: can't handle this here, could maybe search for -O0 in CFLAGS
18 # and append -O1 if found
19 #CFLAGS:=$(CFLAGS:-O0=-O1)
21 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
22 LDFLAGS-libpthread.so := $(LDFLAGS_NOSTRIP) -Wl,-z,defs
24 LDFLAGS-libpthread.so := $(LDFLAGS)
27 LIBS-libpthread.so := $(LIBS) $(ldso)
29 START_FILE-libpthread.so := $(SHARED_START_FILES)
30 END_FILE-libpthread.so := $(SHARED_END_FILES)
32 libpthread_FULL_NAME := libpthread-$(VERSION).so
34 libpthread_DIR := $(top_srcdir)libpthread/linuxthreads
35 libpthread_OUT := $(top_builddir)libpthread/linuxthreads
37 -include $(libpthread_DIR)/sysdeps/$(TARGET_ARCH)/Makefile.arch
39 pthread_arch_SRC := pspinlock
40 pthread_arch_SRC := $(patsubst %,$(libpthread_DIR)/sysdeps/$(TARGET_ARCH)/%.c,$(pthread_arch_SRC))
41 pthread_linux_SRC := fork pt-sigsuspend register-atfork unregister-atfork
42 pthread_linux_SRC := $(patsubst %,$(libpthread_DIR)/sysdeps/unix/sysv/linux/%.c,$(pthread_linux_SRC))
43 pthread_sysdep_SRC := errno-loc herrno-loc ptlongjmp
44 pthread_sysdep_SRC := $(patsubst %,$(libpthread_DIR)/sysdeps/pthread/%.c,$(pthread_sysdep_SRC))
46 attr barrier cancel condvar errno events join pthread \
47 lockfile manager mutex pt-machine ptcleanup \
48 ptclock_gettime ptclock_settime ptfork pthandles \
49 pthread_setegid pthread_seteuid pthread_setgid pthread_setregid \
50 pthread_setresgid pthread_setresuid pthread_setreuid pthread_setuid \
51 rwlock semaphore sighandler signals specific spinlock
52 pthread_SRC := $(patsubst %,$(libpthread_DIR)/%.c,$(pthread_SRC))
54 libpthread_static_SRC := pthread_atfork
55 libpthread_SRC := $(pthread_arch_SRC) $(pthread_linux_SRC) $(pthread_sysdep_SRC) $(pthread_SRC)
56 libpthread_OBJ := $(patsubst $(libpthread_DIR)/%.c,$(libpthread_OUT)/%.o,$(libpthread_SRC))
59 # Stuff that goes into libc.so, not libpthread.so
61 #CFLAGS-OMIT-alloca_cutoff.c := $(CFLAGS-dir_linuxthreads)
62 CFLAGS-OMIT-forward.c := $(CFLAGS-dir_linuxthreads)
63 CFLAGS-OMIT-libc-cancellation.c := $(CFLAGS-dir_linuxthreads)
64 CFLAGS-OMIT-libc_pthread_init.c := $(CFLAGS-dir_linuxthreads)
65 libpthread_libc_CSRC := \
66 forward.c libc-cancellation.c libc_pthread_init.c # alloca_cutoff.c
67 libpthread_libc_OBJ := $(patsubst %.c, $(libpthread_OUT)/%.o,$(libpthread_libc_CSRC))
68 libc-static-y += $(libpthread_OUT)/libc_pthread_init.o
69 libc-shared-y += $(libpthread_libc_OBJ:.o=.oS)
71 libpthread-static-y += $(patsubst %,$(libpthread_OUT)/%.o,$(libpthread_static_SRC))
73 libpthread-nonshared-y += $(patsubst %,$(libpthread_OUT)/%.oS,$(libpthread_static_SRC))
76 libpthread-a-y += $(libpthread_OBJ:.o=.os) $(libpthread-static-y:.o=.os)
78 libpthread-a-y += $(libpthread_OBJ) $(libpthread-static-y)
80 libpthread-so-y += $(libpthread_OBJ:.o=.oS)
82 lib-a-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.a
83 lib-so-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.so
86 $(top_builddir)lib/libpthread.so: $(libpthread_OUT)/libpthread_so.a $(libc.depend) $(top_builddir)lib/libpthread_nonshared.a
87 $(call link.so,$(libpthread_FULL_NAME),$(ABI_VERSION))
89 #$(top_builddir)lib/libpthread.so: $(libpthread_OUT)/libpthread.oS | $(libc.depend) $(top_builddir)lib/libpthread_nonshared.a
90 # $(call linkm.so,$(libpthread_FULL_NAME),$(ABI_VERSION))
93 $(Q)cat $(top_srcdir)extra/scripts/format.lds > $@.tmp
94 $(Q)echo "GROUP ( $(notdir $@).$(ABI_VERSION) libpthread_nonshared.a )" >> $@.tmp
97 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
98 $(libpthread_OUT)/libpthread_so.a: STRIP_FLAGS:=$(STRIP_FLAGS:-x=-X --strip-debug)
100 $(libpthread_OUT)/libpthread_so.a: $(libpthread-so-y)
104 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
105 $(libpthread_OUT)/libpthread.oS: STRIP_FLAGS:=$(STRIP_FLAGS:-x=-X --strip-debug)
107 $(libpthread_OUT)/libpthread.oS: $(libpthread_SRC)
111 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
112 $(top_builddir)lib/libpthread.a: STRIP_FLAGS:=$(STRIP_FLAGS:-x=-X --strip-debug)
114 $(top_builddir)lib/libpthread.a: $(libpthread-a-y)
115 $(Q)$(INSTALL) -d $(dir $@)
119 $(top_builddir)include/pthread.h:
120 $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/$(@F) $@
121 $(top_builddir)include/semaphore.h:
122 $(do_ln) $(call rel_srcdir)$(PTDIR)/$(@F) $@
123 $(top_builddir)include/bits/pthreadtypes.h: | $(top_builddir)include/bits
124 $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/bits/$(@F) $@
126 linuxthreads_headers := $(top_builddir)include/pthread.h \
127 $(top_builddir)include/semaphore.h \
128 $(top_builddir)include/bits/pthreadtypes.h
129 $(linuxthreads_headers): $(wildcard $(addprefix $(top_builddir)include/config/linuxthreads/,old.h new.h))
130 headers-$(UCLIBC_HAS_THREADS) += $(linuxthreads_headers)
132 objclean-y += CLEAN_libpthread/linuxthreads
133 headers_clean-y += HEADERCLEAN_libpthread/linuxthreads
134 HEADERCLEAN_libpthread/linuxthreads:
135 $(do_rm) $(linuxthreads_headers)
137 CLEAN_libpthread/linuxthreads:
138 $(do_rm) $(addprefix $(libpthread_OUT)/,$(foreach e, o os oS a,$(foreach d, *. */*. */*/*. */*/*/*.,$(d)$(e))))