use a single libc and deduplicate threading code
[uclibc-ng.git] / libpthread / nptl / Makefile.in
blob0fc83e20ed9426640cd5d7cc4c362d24e881985f
1 # Makefile for uClibc NPTL
3 # Copyright (C) 2005-2006 Steven J. Hill <sjhill@realitydiluted.com>
5 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8 subdirs += libpthread/nptl
10 libpthread_DIR = $(top_srcdir)libpthread/nptl
11 libpthread_OUT = $(top_builddir)libpthread/nptl
13 include $(libpthread_DIR)/sysdeps/Makefile.in
15 libc-shared-routines-y = libc-cancellation.c
16 libc-static-routines-y = alloca_cutoff.c libc-cancellation.c
17 libpthread-shared-only-routines-y = version.c
18 libpthread-static-only-routines-y = pthread_atfork.c
19 libpthread-routines- += $(notdir $(wildcard $(libpthread_DIR)/gen_*.c)) # dummy generated files
20 libpthread-routines- += allocatestack.c # dummy included by pthread_create.c
21 libpthread-routines- += pthread_mutex_getprioceiling.c pthread_mutex_setprioceiling.c # XXX: delete those or use them!
22 libpthread-routines-$(UCLIBC_SUSV4_LEGACY) += pthread_getconcurrency.c \
23 pthread_setconcurrency.c
24 libpthread_CSRC = $(filter-out $(libpthread-routines-) \
25 $(libc-shared-routines-y) \
26 $(libc-static-routines-y) \
27 $(libpthread-shared-only-routines-y) \
28 $(libpthread-static-only-routines-y) \
29 $(notdir $(libpthread_OBJS:.o=.c)), \
30 $(notdir $(wildcard $(libpthread_DIR)/*.c)))
32 libpthread_OBJS += $(addprefix $(libpthread_OUT)/,$(libpthread_CSRC:.c=.o))
33 libpthread-so-y += $(addprefix $(libpthread_OUT)/,$(libpthread-shared-only-routines-y:.c=.oS))
34 libpthread-so-y += $(libpthread_OBJS:.o=.oS)
35 libpthread-nonshared-y := $(addprefix $(libpthread_OUT)/,$(libpthread-static-only-routines-y:.c=.oS))
36 libpthread-static-y := $(addprefix $(libpthread_OUT)/,$(libpthread-static-only-routines-y:.c=.o))
37 libpthread-static-y += $(libpthread_OBJS)
38 ifeq ($(DOPIC),y)
39 libpthread-a-y := $(libpthread-static-y:.o=.os)
40 else
41 libpthread-a-y := $(libpthread-static-y)
42 endif
44 libpthread-a-y += $(top_builddir)lib/libpthread_nonshared.a
46 libc-shared-routines-y := $(filter-out $(notdir $(libpthread_libc_OBJS:.o=.c)), $(libc-shared-routines-y))
47 libc-static-routines-y := $(filter-out $(notdir $(libpthread_libc_OBJS:.o=.c)), $(libc-static-routines-y))
48 libc-shared-routines-y := $(addprefix $(libpthread_OUT)/,$(libc-shared-routines-y:.c=.oS))
49 libc-static-routines-y := $(addprefix $(libpthread_OUT)/,$(libc-static-routines-y:.c=.o))
50 libc-shared-y += $(libc-shared-routines-y) $(libpthread_libc_OBJS:.o=.oS)
51 ifeq ($(DOPIC),y)
52 libc-static-y += $(libc-static-routines-y:.o=.os) $(libpthread_libc_a_OBJS:.o=.os) $(libpthread_ld_tls_COBJ:.o=.os)
53 else
54 libc-static-y += $(libc-static-routines-y) $(libpthread_libc_a_OBJS) $(libpthread_ld_tls_COBJ)
55 endif
57 librt-pt-routines-y := $(patsubst %.c,$(libpthread_pthread_OUT)/%.o,$(filter-out $(notdir $(libpthread_librt_OBJS:.o=.c)), $(librt-pt-routines-y)))
58 librt-pt-shared-only-routines-y := $(patsubst %.c,$(libpthread_pthread_OUT)/%.o,$(filter-out $(notdir $(libpthread_librt_OBJS:.o=.c)), $(librt-pt-shared-only-routines-y)))
59 librt_OBJS = $(libpthread_librt_OBJS) $(librt-pt-routines-y)
60 ifeq ($(DOPIC),y)
61 librt-a-y += $(librt_OBJS:.o=.os)
62 else
63 librt-a-y += $(librt_OBJS)
64 endif
65 librt-so-y += $(librt_OBJS:.o=.oS) $(librt-pt-shared-only-routines-y:.o=.oS)
67 $(libpthread_OUT)/pthread-errnos.h: $(top_srcdir)extra/scripts/gen-as-const.awk
68 $(libpthread_OUT)/pthread-errnos.h: $(libpthread_DIR)/pthread-errnos.sym
69 @$(disp_gen)
70 $(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< \
71 | $(CC) $(CFLAGS) -x c - -S -o - \
72 | $(SED) $(PTHREAD_GENERATE_MANGLE) > $@
73 @if test ! -s $@ ; then rm -f $@ ; false ; fi
75 pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(libpthread_OUT)/pthread-errnos.h
77 headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(nptl_headers_bootstrap)
79 libpthread_H := $(addprefix $(top_builddir)include/,semaphore.h)
80 libpthread_include_H := $(addprefix $(top_builddir)include/,pthread.h)
81 libpthread_include_BITS_H := $(addprefix $(top_builddir)include/bits/,libc-lock.h stdio-lock.h)
82 libpthread_include_STD_IMPL_OS_ARCH_BITS_H := $(addprefix $(top_builddir)include/bits/,pthreadtypes.h semaphore.h)
84 $(libpthread_include_STD_IMPL_OS_ARCH_BITS_H): $(top_builddir)include/bits/%:
85 $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/bits/$(@F) $@
86 $(libpthread_include_BITS_H): $(top_builddir)include/bits/%:
87 $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/bits/$(@F) $@
88 $(libpthread_include_H): $(top_builddir)include/%:
89 $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/$(@F) $@
90 $(libpthread_H): $(top_builddir)include/%:
91 $(do_ln) $(call rel_srcdir)$(PTDIR)/$(@F) $@
93 nptl_headers_bootstrap = $(libpthread_H) $(libpthread_include_H) $(libpthread_include_BITS_H) $(libpthread_include_STD_IMPL_OS_ARCH_BITS_H)
95 objclean-y += CLEAN_libpthread/nptl
96 headers_clean-y += HEADERCLEAN_libpthread/nptl
98 HEADERCLEAN_libpthread/nptl:
99 $(do_rm) $(nptl_headers_bootstrap) \
100 $(libpthread_OUT)/pthread-errnos.h
102 CLEAN_libpthread/nptl:
103 $(do_rm) $(addprefix $(libpthread_OUT)/*., o os oS a)
105 CFLAGS-dir_nptl := -DNOT_IN_libc -DIS_IN_libpthread
106 CFLAGS-libpthread/nptl := $(CFLAGS-dir_nptl) $(SSP_ALL_CFLAGS)
108 # Since cancellation handling is in large parts handled using exceptions
109 # we have to compile some files with exception handling enabled, some
110 # even with asynchronous unwind tables.
112 # init.c contains sigcancel_handler().
113 CFLAGS-init.c = -fexceptions -fasynchronous-unwind-tables
114 # The unwind code itself,
115 CFLAGS-unwind.c = -fexceptions
116 CFLAGS-unwind-forcedunwind.c = -fexceptions -fasynchronous-unwind-tables
118 # The following three functions must be async-cancel safe.
119 CFLAGS-pthread_cancel.c = -fexceptions -fasynchronous-unwind-tables
120 CFLAGS-pthread_setcancelstate.c = -fexceptions -fasynchronous-unwind-tables
121 CFLAGS-pthread_setcanceltype.c = -fexceptions -fasynchronous-unwind-tables
123 # These are internal functions which similar functionality as setcancelstate
124 # and setcanceltype.
125 CFLAGS-cancellation.c = -fasynchronous-unwind-tables
126 CFLAGS-libc-cancellation.c = -fasynchronous-unwind-tables
128 # Calling pthread_exit() must cause the registered cancel handlers to
129 # be executed. Therefore exceptions have to be thrown through this
130 # function.
131 CFLAGS-pthread_exit.c = -fexceptions
133 # The following are cancellation points. Some of the functions can
134 # block and therefore temporarily enable asynchronous cancellation.
135 # Those must be compiled asynchronous unwind tables.
136 CFLAGS-pthread_testcancel.c = -fexceptions
137 CFLAGS-pthread_join.c = -fexceptions -fasynchronous-unwind-tables
138 CFLAGS-pthread_timedjoin.c = -fexceptions -fasynchronous-unwind-tables
139 CFLAGS-pthread_once.c = $(uses-callbacks) -fexceptions \
140 -fasynchronous-unwind-tables
141 CFLAGS-pthread_cond_wait.c = -fexceptions -fasynchronous-unwind-tables
142 CFLAGS-pthread_cond_timedwait.c = -fexceptions -fasynchronous-unwind-tables
143 CFLAGS-sem_wait.c = -fexceptions -fasynchronous-unwind-tables
144 CFLAGS-sem_timedwait.c = -fexceptions -fasynchronous-unwind-tables
146 # These are the function wrappers we have to duplicate here.
147 CFLAGS-accept.c = -fexceptions -fasynchronous-unwind-tables
148 CFLAGS-clock_nanosleep.c = -fexceptions -fasynchronous-unwind-tables
149 CFLAGS-close.c = -fexceptions -fasynchronous-unwind-tables
150 CFLAGS-connect.c = -fexceptions -fasynchronous-unwind-tables
151 CFLAGS-creat.c = -fexceptions -fasynchronous-unwind-tables
152 CFLAGS-fdatasync.c = -fexceptions -fasynchronous-unwind-tables
153 CFLAGS-fsync.c = -fexceptions -fasynchronous-unwind-tables
154 CFLAGS-lockf.c = -fexceptions
155 CFLAGS-msgrcv.c = -fexceptions -fasynchronous-unwind-tables
156 CFLAGS-msgsnd.c = -fexceptions -fasynchronous-unwind-tables
157 CFLAGS-msync.c = -fexceptions -fasynchronous-unwind-tables
158 CFLAGS-nanosleep.c = -fexceptions -fasynchronous-unwind-tables
159 CFLAGS-open64.c = -fexceptions -fasynchronous-unwind-tables
160 CFLAGS-open.c = -fexceptions -fasynchronous-unwind-tables
161 CFLAGS-pause.c = -fexceptions -fasynchronous-unwind-tables
162 CFLAGS-poll.c = -fexceptions -fasynchronous-unwind-tables
163 CFLAGS-ppoll.c = -fexceptions -fasynchronous-unwind-tables
164 CFLAGS-pread_write.c = -fexceptions -fasynchronous-unwind-tables
165 CFLAGS-pselect.c = -fexceptions -fasynchronous-unwind-tables
166 CFLAGS-read.c = -fexceptions -fasynchronous-unwind-tables
167 CFLAGS-readv.c = -fexceptions -fasynchronous-unwind-tables
168 CFLAGS-recv.c = -fexceptions -fasynchronous-unwind-tables
169 CFLAGS-recvfrom.c = -fexceptions -fasynchronous-unwind-tables
170 CFLAGS-recvmsg.c = -fexceptions -fasynchronous-unwind-tables
171 CFLAGS-__rt_sigtimedwait.c = -fexceptions -fasynchronous-unwind-tables
172 CFLAGS-__rt_sigwaitinfo.c = -fexceptions -fasynchronous-unwind-tables
173 CFLAGS-select.c = -fexceptions -fasynchronous-unwind-tables
174 CFLAGS-send.c = -fexceptions -fasynchronous-unwind-tables
175 CFLAGS-sendmsg.c = -fexceptions -fasynchronous-unwind-tables
176 CFLAGS-sendto.c = -fexceptions -fasynchronous-unwind-tables
177 CFLAGS-sigpause.c = -fexceptions
178 CFLAGS-sigsuspend.c = -fexceptions -fasynchronous-unwind-tables
179 CFLAGS-sigtimedwait.c = -fexceptions -fasynchronous-unwind-tables
180 CFLAGS-sigwait.c = -fexceptions -fasynchronous-unwind-tables
181 CFLAGS-sigwaitinfo.c = -fexceptions -fasynchronous-unwind-tables
182 CFLAGS-__syscall_fcntl64.c = -fexceptions -fasynchronous-unwind-tables
183 CFLAGS-__syscall_fcntl.c = -fexceptions -fasynchronous-unwind-tables
184 CFLAGS-tcdrain.c = -fexceptions -fasynchronous-unwind-tables
185 CFLAGS-usleep.c = -fexceptions -fasynchronous-unwind-tables
186 CFLAGS-wait4.c = -fexceptions -fasynchronous-unwind-tables
187 CFLAGS-wait.c = -fexceptions -fasynchronous-unwind-tables
188 CFLAGS-waitid.c = -fexceptions -fasynchronous-unwind-tables
189 CFLAGS-waitpid.c = -fexceptions -fasynchronous-unwind-tables
190 CFLAGS-write.c = -fexceptions -fasynchronous-unwind-tables
191 CFLAGS-writev.c = -fexceptions -fasynchronous-unwind-tables
194 # The rest of this file is uClibc specific.
196 CFLAGS-pthread_barrier_init.c = -D_GNU_SOURCE
197 CFLAGS-pthread_barrier_destroy.c = -D_GNU_SOURCE
198 CFLAGS-pthread_barrierattr_init.c = -D_GNU_SOURCE
199 CFLAGS-pthread_barrierattr_destroy.c = -D_GNU_SOURCE
200 CFLAGS-pthread_barrierattr_getpshared.c = -D_GNU_SOURCE
201 CFLAGS-pthread_barrierattr_setpshared.c = -D_GNU_SOURCE
202 CFLAGS-sem_open.c = -D_GNU_SOURCE
204 CFLAGS-OMIT-alloca_cutoff.c = $(CFLAGS-dir_nptl)
205 CFLAGS-OMIT-libc-lowlevelock.c = $(CFLAGS-dir_nptl)
206 CFLAGS-OMIT-libc-cancellation.c = $(CFLAGS-dir_nptl)