1 # Makefile for uClibc NPTL
3 # Copyright (C) 2005-2006 Steven J. Hill <sjhill@uclibc.org>
5 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8 subdirs += libpthread/nptl/sysdeps/pthread
10 # NOTE: glibc puts flockfile.c, ftrylockfile.c, funlockfile.c, and
11 # pt-longjmp.c in libc and libpthread. For uClibc, they are
14 libpthread_pthread_DIR = $(top_srcdir)libpthread/nptl/sysdeps/pthread
15 libpthread_pthread_OUT = $(top_builddir)libpthread/nptl/sysdeps/pthread
17 libpthread_pthread_COBJ = $(patsubst %.c,$(libpthread_pthread_OUT)/%.o,$(libpthread_pthread_CSRC))
18 libpthread_pthread_CSRC = \
19 pthread_barrier_destroy.c \
20 pthread_barrier_init.c \
21 pthread_barrier_wait.c \
22 pthread_cond_broadcast.c \
23 pthread_cond_signal.c \
24 pthread_cond_timedwait.c \
26 pthread_rwlock_rdlock.c \
27 pthread_rwlock_timedrdlock.c \
28 pthread_rwlock_timedwrlock.c \
29 pthread_rwlock_unlock.c \
30 pthread_rwlock_wrlock.c \
32 pthread_spin_destroy.c \
34 pthread_spin_unlock.c \
40 CFLAGS-pthread = $(SSP_ALL_CFLAGS) -DNOT_IN_libc -DIS_IN_libpthread
41 CFLAGS-pthread_barrier_wait.c = -D_GNU_SOURCE
42 CFLAGS-pthread_spin_destroy.c = -D_GNU_SOURCE
43 CFLAGS-pthread_spin_init.c = -D_GNU_SOURCE
44 CFLAGS-pthread_spin_unlock.c = -D_GNU_SOURCE
45 CFLAGS-pt-sigaction.c = -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH) \
46 -I$(top_srcdir)libc/signal
47 CFLAGS-pt-sigfillset.c = -I$(top_srcdir)libc/signal
48 CFLAGS-pt-sigprocmask.c = -I$(top_srcdir)libc/sysdeps/linux/common
49 CFLAGS-unwind-forcedunwind.c = -fexceptions -fasynchronous-unwind-tables
51 CFLAGS-OMIT-librt-cancellation.c = -DIS_IN_libpthread
52 CFLAGS-OMIT-rt-unwind-resume.c = -DIS_IN_libpthread
53 CFLAGS-librt-cancellation.c = -DIS_IN_librt \
54 -fexceptions -fasynchronous-unwind-tables
55 CFLAGS-rt-unwind-resume.c = -DIS_IN_librt \
56 -fexceptions -fasynchronous-unwind-tables
58 libpthread-so-y += $(patsubst %,$(libpthread_pthread_OUT)/%.oS, \
59 pt-sigaction pt-sigprocmask unwind-forcedunwind)
61 CFLAGS-OMIT-sigaction.c = $(CFLAGS-pthread)
62 CFLAGS-sigaction.c = -I$(top_srcdir)libc/signal
63 libc-y += $(libpthread_pthread_OUT)/sigaction.o
65 librt-pt-routines-y = librt-cancellation.c
66 librt-pt-shared-only-routines-y = rt-unwind-resume.c
68 ifeq ($(UCLIBC_CTOR_DTOR),y)
69 CFLAGS-OMIT-pt-initfini.c = $(CFLAGS-pthread)
70 CFLAGS-pt-initfini.c = -S -g0 $(PICFLAG) -fno-inline-functions \
71 $(call check_gcc,-fno-unit-at-a-time,) \
72 $(SSP_DISABLE_FLAGS) \
73 -finhibit-size-directive \
74 -fno-asynchronous-unwind-tables -fno-unwind-tables \
75 $(patsubst -f%,-fno-%,$(call check_gcc,-fexceptions,))
77 #ASFLAGS += $(PICFLAG) -I$(top_srcdir)include -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)
78 ifneq ($(wildcard $(libpthread_pthread_DIR)/../unix/sysv/linux/$(TARGET_ARCH)/pt-initfini.c),)
79 PTHREAD_INITFINI := $(libpthread_pthread_DIR)/../unix/sysv/linux/$(TARGET_ARCH)/pt-initfini.c
81 PTHREAD_INITFINI := $(libpthread_pthread_DIR)/pt-initfini.c
84 ASFLAGS-pt-crti.S = $(PICFLAG)
85 ASFLAGS-pt-crtn.S = $(PICFLAG)
87 $(libpthread_pthread_OUT)/pt-crti.o: $(libpthread_pthread_OUT)/pt-crti.S
90 $(libpthread_pthread_OUT)/pt-crtn.o: $(libpthread_pthread_OUT)/pt-crtn.S
93 $(libpthread_pthread_OUT)/pt-initfini.s: $(PTHREAD_INITFINI)
95 $(libpthread_pthread_OUT)/defs.h: $(PTHREAD_INITFINI)
96 $(do_sed) -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
97 $(AWK) -f $(top_srcdir)extra/scripts/defs.awk > $@.tmp
100 $(libpthread_pthread_OUT)/pt-crti.S: $(libpthread_pthread_OUT)/pt-initfini.s $(libpthread_pthread_OUT)/defs.h
101 $(do_sed) -n -e '/[ ]*\.file/d' \
102 -e '1,/@HEADER_ENDS/p' \
103 -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
104 -e '/@TRAILER_BEGINS/,$$p' $< > $@.tmp
106 $(libpthread_pthread_OUT)/pt-crtn.S: $(libpthread_pthread_OUT)/pt-initfini.s $(libpthread_pthread_OUT)/defs.h
107 $(do_sed) -n -e '/[ ]*\.file/d' \
108 -e '1,/@HEADER_ENDS/p' \
109 -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
110 -e '/@TRAILER_BEGINS/,$$p' $< > $@.tmp
113 # It would have been easier to just add dummy files that include the real
115 # Special rules needed since we do objdir->objdir compilation for these 3.
116 # First symlink them, then build them. Rob would freak out on these. Sheesh! ;)
117 pthread-lc-fwd = sigaction sigfillset sigprocmask
118 $(patsubst %,$(libpthread_pthread_OUT)/pt-%.c,$(pthread-lc-fwd)): | $(libpthread_pthread_OUT)
119 $(do_ln) $(call rel_srcdir)$(patsubst pt-%,$(libpthread_pthread_DIR)/%,$(@F)) $@
120 $(patsubst %,$(libpthread_pthread_OUT)/pt-%.oS,$(pthread-lc-fwd)): $(libpthread_pthread_OUT)/pt-%.oS: $(libpthread_pthread_OUT)/pt-%.c
122 $(patsubst %,$(libpthread_pthread_OUT)/pt-%.o,$(pthread-lc-fwd)): $(libpthread_pthread_OUT)/pt-%.o: $(libpthread_pthread_OUT)/pt-%.c
125 $(patsubst %,$(libpthread_pthread_OUT)/pt-%.os,$(pthread-lc-fwd)): $(libpthread_pthread_OUT)/pt-%.os: $(libpthread_pthread_OUT)/pt-%.c
129 objclean-y += CLEAN_libpthread/nptl/sysdeps/pthread
131 CLEAN_libpthread/nptl/sysdeps/pthread:
132 $(do_rm) $(addprefix $(libpthread_pthread_OUT)/*., o os oS s S) \
133 $(libpthread_pthread_OUT)/defs.h \
134 $(addprefix $(libpthread_pthread_DIR)/,pt-sigaction.c \
135 pt-sigfillset.c pt-sigprocmask.c)