OSDN Git Service

853ac501e62464728f3e1a2f38aac6211d8ca638
[uclinux-h8/uClibc.git] / libpthread / nptl / Makefile.in
1 # Makefile for uClibc NPTL
2 #
3 # Copyright (C) 2005-2006 Steven J. Hill <sjhill@realitydiluted.com>
4 #
5 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6 #
7
8 subdirs += libpthread/nptl/sysdeps/$(TARGET_ARCH) \
9         libpthread/nptl/sysdeps/unix/sysv/linux \
10         libpthread/nptl/sysdeps/pthread
11
12 libpthread-routines-y = init vars events version \
13                       pthread_create pthread_exit pthread_detach \
14                       pthread_join pthread_tryjoin pthread_timedjoin \
15                       pthread_self pthread_equal pthread_yield \
16                       pthread_getconcurrency pthread_setconcurrency \
17                       pthread_getschedparam pthread_setschedparam \
18                       pthread_setschedprio \
19                       pthread_attr_init pthread_attr_destroy \
20                       pthread_attr_getdetachstate pthread_attr_setdetachstate \
21                       pthread_attr_getguardsize pthread_attr_setguardsize \
22                       pthread_attr_getschedparam pthread_attr_setschedparam \
23                       pthread_attr_getschedpolicy pthread_attr_setschedpolicy \
24                       pthread_attr_getinheritsched \
25                       pthread_attr_setinheritsched \
26                       pthread_attr_getscope pthread_attr_setscope \
27                       pthread_attr_getstackaddr pthread_attr_setstackaddr \
28                       pthread_attr_getstacksize pthread_attr_setstacksize \
29                       pthread_attr_getstack pthread_attr_setstack \
30                       pthread_getattr_np \
31                       pthread_mutex_init pthread_mutex_destroy \
32                       pthread_mutex_lock pthread_mutex_trylock \
33                       pthread_mutex_timedlock pthread_mutex_unlock \
34                       pthread_mutex_consistent \
35                       pthread_mutexattr_init pthread_mutexattr_destroy \
36                       pthread_mutexattr_getpshared \
37                       pthread_mutexattr_setpshared \
38                       pthread_mutexattr_getrobust \
39                       pthread_mutexattr_setrobust \
40                       pthread_mutexattr_getprotocol \
41                       pthread_mutexattr_setprotocol \
42                       pthread_mutexattr_getprioceiling \
43                       pthread_mutexattr_setprioceiling \
44                       pthread_mutexattr_gettype pthread_mutexattr_settype \
45                       pthread_rwlock_init pthread_rwlock_destroy \
46                       pthread_rwlock_rdlock pthread_rwlock_timedrdlock \
47                       pthread_rwlock_wrlock pthread_rwlock_timedwrlock \
48                       pthread_rwlock_tryrdlock pthread_rwlock_trywrlock \
49                       pthread_rwlock_unlock \
50                       pthread_rwlockattr_init pthread_rwlockattr_destroy \
51                       pthread_rwlockattr_getpshared \
52                       pthread_rwlockattr_setpshared \
53                       pthread_rwlockattr_getkind_np \
54                       pthread_rwlockattr_setkind_np \
55                       pthread_cond_init pthread_cond_destroy \
56                       pthread_cond_wait pthread_cond_timedwait \
57                       pthread_cond_signal pthread_cond_broadcast \
58                       pthread_condattr_init pthread_condattr_destroy \
59                       pthread_condattr_getpshared pthread_condattr_setpshared \
60                       pthread_condattr_getclock pthread_condattr_setclock \
61                       pthread_spin_init pthread_spin_destroy \
62                       pthread_spin_lock pthread_spin_trylock \
63                       pthread_spin_unlock \
64                       pthread_barrier_init pthread_barrier_destroy \
65                       pthread_barrier_wait \
66                       pthread_barrierattr_init pthread_barrierattr_destroy \
67                       pthread_barrierattr_getpshared \
68                       pthread_barrierattr_setpshared \
69                       pthread_key_create pthread_key_delete \
70                       pthread_getspecific pthread_setspecific \
71                       pthread_sigmask pthread_kill \
72                       pthread_cancel pthread_testcancel \
73                       pthread_setcancelstate pthread_setcanceltype \
74                       pthread_once \
75                       pthread_atfork \
76                       pthread_getcpuclockid \
77                       pthread_clock_gettime pthread_clock_settime \
78                       sem_init sem_destroy \
79                       sem_open sem_close sem_unlink \
80                       sem_getvalue \
81                       sem_wait sem_trywait sem_timedwait sem_post \
82                       cleanup cleanup_defer cleanup_compat \
83                       cleanup_defer_compat unwind \
84                       pt-longjmp pt-cleanup\
85                       cancellation \
86                       lowlevellock \
87                       pt-vfork \
88                       ptw-write ptw-read ptw-close ptw-fcntl ptw-accept \
89                       ptw-connect ptw-recv ptw-recvfrom ptw-recvmsg ptw-send \
90                       ptw-sendmsg ptw-sendto ptw-fsync ptw-lseek ptw-llseek \
91                       ptw-msync ptw-nanosleep ptw-open ptw-open64 ptw-pause \
92                       ptw-pread ptw-pread64 ptw-pwrite ptw-pwrite64 \
93                       ptw-tcdrain ptw-wait ptw-waitpid ptw-msgrcv ptw-msgsnd \
94                       ptw-sigwait \
95                       pt-raise pt-system \
96                       flockfile ftrylockfile funlockfile \
97                       sigaction \
98                       herrno \
99                       pthread_kill_other_threads \
100                       pthread_getaffinity pthread_setaffinity \
101                       pthread_attr_getaffinity pthread_attr_setaffinity \
102                       cleanup_routine unwind-forcedunwind
103 libpthread-routines-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += res
104
105 libpthread-shared-only-routines = version pt-allocrtsig unwind-forcedunwind
106
107 ifeq ($(TARGET_ARCH),x86_64)
108 libpthread-routines-y := $(filter-out cancellation,$(libpthread-routines-y))
109 endif
110
111 CFLAGS-pthread_atfork.c = -DNOT_IN_libc
112
113 # Since cancellation handling is in large parts handled using exceptions
114 # we have to compile some files with exception handling enabled, some
115 # even with asynchronous unwind tables.
116
117 # init.c contains sigcancel_handler().
118 CFLAGS-init.c = -fexceptions -fasynchronous-unwind-tables
119 # The unwind code itself,
120 CFLAGS-unwind.c = -fexceptions
121 CFLAGS-unwind-forcedunwind.c = -fexceptions -fasynchronous-unwind-tables
122
123 # The following three functions must be async-cancel safe.
124 CFLAGS-pthread_cancel.c = -fexceptions -fasynchronous-unwind-tables
125 CFLAGS-pthread_setcancelstate.c = -fexceptions -fasynchronous-unwind-tables
126 CFLAGS-pthread_setcanceltype.c = -fexceptions -fasynchronous-unwind-tables
127
128 # These are internal functions which similar functionality as setcancelstate
129 # and setcanceltype.
130 CFLAGS-cancellation.c = -fasynchronous-unwind-tables
131 CFLAGS-libc-cancellation.c = -fasynchronous-unwind-tables
132
133 # Calling pthread_exit() must cause the registered cancel handlers to
134 # be executed.  Therefore exceptions have to be thrown through this
135 # function.
136 CFLAGS-pthread_exit.c = -fexceptions
137
138 # Among others, __pthread_unwind is forwarded.  This function must handle
139 # exceptions.
140 CFLAGS-forward.c = -fexceptions
141
142 # The following are cancellation points.  Some of the functions can
143 # block and therefore temporarily enable asynchronous cancellation.
144 # Those must be compiled asynchronous unwind tables.
145 CFLAGS-pthread_testcancel.c = -fexceptions
146 CFLAGS-pthread_join.c = -fexceptions -fasynchronous-unwind-tables
147 CFLAGS-pthread_timedjoin.c = -fexceptions -fasynchronous-unwind-tables
148 CFLAGS-pthread_once.c = $(uses-callbacks) -fexceptions \
149                         -fasynchronous-unwind-tables
150 CFLAGS-pthread_cond_wait.c = -fexceptions -fasynchronous-unwind-tables
151 CFLAGS-pthread_cond_timedwait.c = -fexceptions -fasynchronous-unwind-tables
152 CFLAGS-sem_wait.c = -fexceptions -fasynchronous-unwind-tables
153 CFLAGS-sem_timedwait.c = -fexceptions -fasynchronous-unwind-tables
154
155 # These are the function wrappers we have to duplicate here.
156 CFLAGS-fcntl.c = -fexceptions -fasynchronous-unwind-tables
157 CFLAGS-lockf.c = -fexceptions
158 CFLAGS-pread.c = -fexceptions -fasynchronous-unwind-tables
159 CFLAGS-pread64.c = -fexceptions -fasynchronous-unwind-tables
160 CFLAGS-pwrite.c = -fexceptions -fasynchronous-unwind-tables
161 CFLAGS-pwrite64.c = -fexceptions -fasynchronous-unwind-tables
162 CFLAGS-wait.c = -fexceptions -fasynchronous-unwind-tables
163 CFLAGS-waitpid.c = -fexceptions -fasynchronous-unwind-tables
164 CFLAGS-sigwait.c = -fexceptions -fasynchronous-unwind-tables
165 CFLAGS-msgrcv.c = -fexceptions -fasynchronous-unwind-tables
166 CFLAGS-msgsnd.c = -fexceptions -fasynchronous-unwind-tables
167 CFLAGS-tcdrain.c = -fexceptions -fasynchronous-unwind-tables
168
169 CFLAGS-pt-system.c = -fexceptions -I./libc/stdlib
170
171 #
172 # The rest of this file is uClibc specific.
173 #
174 CFLAGS-pthread_barrier_init.c = -D_GNU_SOURCE
175 CFLAGS-pthread_barrier_destroy.c = -D_GNU_SOURCE
176 CFLAGS-pthread_barrierattr_init.c = -D_GNU_SOURCE
177 CFLAGS-pthread_barrierattr_destroy.c = -D_GNU_SOURCE
178 CFLAGS-pthread_barrierattr_getpshared.c = -D_GNU_SOURCE
179 CFLAGS-pthread_barrierattr_setpshared.c = -D_GNU_SOURCE
180 CFLAGS-sem_open.c = -D_GNU_SOURCE
181
182 CFLAGS-nptl = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 $(SSP_ALL_CFLAGS)
183
184 CFLAGS-OMIT-alloca_cutoff.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
185 CFLAGS-OMIT-forward.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
186 CFLAGS-OMIT-libc-lowlevelock.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
187 CFLAGS-OMIT-libc-cancellation.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
188
189 libpthread-os-routines = pthread_yield
190 libpthread-misc-routines = pthread_rwlock_rdlock pthread_rwlock_timedrdlock \
191                            pthread_rwlock_wrlock pthread_rwlock_timedwrlock \
192                            pthread_rwlock_unlock pthread_cond_wait \
193                            pthread_cond_timedwait pthread_cond_signal \
194                            pthread_cond_broadcast pthread_spin_init \
195                            pthread_spin_destroy pthread_spin_lock \
196                            pthread_spin_trylock pthread_spin_unlock \
197                            pthread_barrier_init pthread_barrier_destroy \
198                            pthread_barrier_wait pthread_sigmask \
199                            pthread_kill pthread_once \
200                            pthread_getcpuclockid sem_wait \
201                            sem_trywait sem_timedwait \
202                            sem_post pt-longjmp \
203                            lowlevellock pt-vfork \
204                            ptw-close ptw-read ptw-write \
205                            ptw-fcntl ptw-accept ptw-connect \
206                            ptw-recv ptw-recvfrom ptw-recvmsg \
207                            ptw-send ptw-sendmsg ptw-sendto \
208                            ptw-fsync ptw-lseek ptw-llseek \
209                            ptw-msync ptw-nanosleep ptw-open \
210                            ptw-open64 ptw-pause ptw-pread \
211                            ptw-pread64 ptw-pwrite ptw-pwrite64 \
212                            ptw-tcdrain ptw-wait ptw-waitpid \
213                            ptw-msgrcv ptw-msgsnd ptw-sigwait \
214                            pt-raise flockfile ftrylockfile \
215                            funlockfile sigaction \
216                            pthread_getaffinity \
217                            pthread_setaffinity \
218                            pthread_attr_getaffinity \
219                            pthread_attr_setaffinity \
220                            unwind-forcedunwind
221
222 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
223 LDFLAGS-libpthread.so := $(LDFLAGS_NOSTRIP) -Wl,-z,defs
224 else
225 LDFLAGS-libpthread.so := $(LDFLAGS)
226 endif
227
228 LDFLAGS-libpthread.so += $(top_builddir)lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so $(top_builddir)lib/libdl-$(VERSION).so -Wl,-z,nodelete,-z,initfirst,-init=__pthread_initialize_minimal_internal
229
230 LIBS-libpthread.so := $(LIBS)
231
232 ifneq ($(UCLIBC_CTOR_DTOR),y)
233 START_FILE-libpthread.so := $(top_builddir)/libpthread/nptl/sysdeps/pthread/crti.o $(SHARED_START_FILES)
234 END_FILE-libpthread.so := $(SHARED_END_FILES) $(top_builddir)/libpthread/nptl/sysdeps/pthread/crtn.o
235 endif
236
237 libpthread_FULL_NAME := libpthread-$(VERSION).so
238
239 PTHREAD_DIR := $(top_srcdir)libpthread/nptl
240 PTHREAD_OUT := $(top_builddir)libpthread/nptl
241
242 libpthread_static_SRC := pthread_atfork
243
244 libpthread_a_SRC = $(patsubst %, $(PTHREAD_DIR)/%.c,                    \
245                 $(filter-out $(libpthread-os-routines)                  \
246                         $(libpthread-misc-routines)                     \
247                         $(libpthread-shared-only-routines),             \
248                 $(libpthread-routines-y)))
249 libpthread_so_SRC = $(patsubst %, $(PTHREAD_DIR)/%.c,                   \
250                 $(filter-out $(libpthread-os-routines)                  \
251                         $(libpthread-misc-routines), $(libpthread-routines-y)))
252
253 ifeq ($(TARGET_ARCH),x86_64)
254 libc-static-y += $(patsubst %.c, $(PTHREAD_OUT)/%.o, alloca_cutoff.c)
255 libc-shared-y += $(patsubst %.c, $(PTHREAD_OUT)/%.oS, forward.c)
256 else
257 libc-static-y += $(patsubst %.c, $(PTHREAD_OUT)/%.o, alloca_cutoff.c    \
258         libc-cancellation.c)
259 libc-shared-y += $(patsubst %.c, $(PTHREAD_OUT)/%.oS, forward.c         \
260         libc-cancellation.c)
261 endif
262
263 libpthread-nonshared-y += $(patsubst %,$(PTHREAD_OUT)/%.oS,$(libpthread_static_SRC))
264
265
266 ifeq ($(DOPIC),y)
267 libpthread-a-y := $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.os,$(libpthread_a_SRC))
268 else
269 libpthread-a-y := $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.o,$(libpthread_a_SRC))
270 endif
271
272 libpthread-so-y := $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.oS,$(libpthread_so_SRC))
273 libpthread-static-y += $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.o,$(libpthread_a_SRC) $(libpthread_static_SRC))
274
275 objclean-y += CLEAN_libpthread/nptl
276 headers_clean-y += HEADERCLEAN_libpthread/nptl
277
278 -include $(PTHREAD_DIR)/sysdeps/generic/Makefile.in
279 -include $(PTHREAD_DIR)/sysdeps/pthread/Makefile.in
280 -include $(PTHREAD_DIR)/sysdeps/$(TARGET_ARCH)/Makefile.arch
281 -include $(PTHREAD_DIR)/sysdeps/unix/sysv/linux/Makefile.in
282 -include $(PTHREAD_DIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/Makefile.arch
283
284 lib-a-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.a
285 lib-so-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.so
286
287 $(top_builddir)lib/libpthread.so: $(PTHREAD_OUT)/libpthread_so.a $(libc.depend) $(libdl.depend) $(top_builddir)lib/libpthread_nonshared.a
288         $(call link.so,$(libpthread_FULL_NAME),$(ABI_VERSION))
289         $(Q)cat $(top_srcdir)extra/scripts/format.lds > $@.tmp
290         $(Q)echo "GROUP ( $(notdir $@).$(ABI_VERSION) libpthread_nonshared.a )" >> $@.tmp
291         $(Q)mv $@.tmp $@
292
293 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
294 $(PTHREAD_OUT)/libpthread_so.a: STRIP_FLAGS:=$(STRIP_FLAGS:-x=-X --strip-debug)
295 endif
296 $(PTHREAD_OUT)/libpthread_so.a: $(libpthread-so-y)
297         $(Q)$(RM) $@
298         $(do_ar)
299
300 $(top_builddir)lib/libpthread.a: $(libpthread-a-y)
301         $(Q)$(INSTALL) -d $(dir $@)
302         $(Q)$(RM) $@
303         $(do_ar)
304
305 #
306 # Create 'pthread-errnos.h' header file.
307 #
308 CFLAGS-pthread-errnos.c = -S
309
310 $(PTHREAD_OUT)/pthread-errnos.c: $(PTHREAD_DIR)/pthread-errnos.sym
311         $(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
312
313 $(PTHREAD_OUT)/pthread-errnos.s: $(PTHREAD_OUT)/pthread-errnos.c
314         $(compile.c)
315
316 $(PTHREAD_OUT)/pthread-errnos.h: $(PTHREAD_OUT)/pthread-errnos.s
317         $(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
318
319 pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(PTHREAD_OUT)/pthread-errnos.h
320
321 headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(nptl_headers_bootstrap)
322
323 $(top_builddir)include/pthread.h:
324         $(do_ln) ../$(PTDIR)/sysdeps/pthread/$(@F) $(top_builddir)$@
325 $(top_builddir)include/semaphore.h:
326         $(do_ln) ../$(PTDIR)/$(@F) $(top_builddir)$@
327 $(top_builddir)include/bits/semaphore.h: | include/bits
328         $(do_ln) ../../$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/bits/$(@F) $(top_builddir)$@
329 $(top_builddir)include/bits/pthreadtypes.h: | include/bits
330         $(do_ln) ../../$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/bits/$(@F) $(top_builddir)$@
331 $(top_builddir)include/bits/libc-lock.h: | include/bits
332         $(do_ln) ../../$(PTDIR)/sysdeps/pthread/bits/$(@F) $(top_builddir)$@
333 $(top_builddir)include/bits/stdio-lock.h: | include/bits
334         $(do_ln) ../../$(PTDIR)/sysdeps/pthread/bits/$(@F) $(top_builddir)$@
335
336 nptl_headers_bootstrap := $(top_builddir)include/pthread.h \
337                 $(top_builddir)include/semaphore.h \
338                 $(top_builddir)include/bits/semaphore.h \
339                 $(top_builddir)include/bits/pthreadtypes.h \
340                 $(top_builddir)include/bits/libc-lock.h \
341                 $(top_builddir)include/bits/stdio-lock.h
342
343
344 HEADERCLEAN_libpthread/nptl:
345         $(do_rm) $(nptl_headers_bootstrap) \
346               $(addprefix $(PTHREAD_OUT)/pthread-errnos., c h s)
347
348 CLEAN_libpthread/nptl:
349         $(do_rm) $(addprefix $(PTHREAD_OUT)/*., o os oS a)