OSDN Git Service

nptl/headers: Convert the makefile targets into variables.
[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 = 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 res \
99                       pthread_kill_other_threads \
100                       pthread_getaffinity pthread_setaffinity \
101                       pthread_attr_getaffinity pthread_attr_setaffinity \
102                       cleanup_routine unwind-forcedunwind
103
104 libpthread-shared-only-routines = version pt-allocrtsig unwind-forcedunwind
105
106 CFLAGS-pthread_atfork.c = -DNOT_IN_libc
107
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.
111
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
117
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
122
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
127
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
132
133 # Among others, __pthread_unwind is forwarded.  This function must handle
134 # exceptions.
135 CFLAGS-forward.c = -fexceptions
136
137 # The following are cancellation points.  Some of the functions can
138 # block and therefore temporarily enable asynchronous cancellation.
139 # Those must be compiled asynchronous unwind tables.
140 CFLAGS-pthread_testcancel.c = -fexceptions
141 CFLAGS-pthread_join.c = -fexceptions -fasynchronous-unwind-tables
142 CFLAGS-pthread_timedjoin.c = -fexceptions -fasynchronous-unwind-tables
143 CFLAGS-pthread_once.c = $(uses-callbacks) -fexceptions \
144                         -fasynchronous-unwind-tables
145 CFLAGS-pthread_cond_wait.c = -fexceptions -fasynchronous-unwind-tables
146 CFLAGS-pthread_cond_timedwait.c = -fexceptions -fasynchronous-unwind-tables
147 CFLAGS-sem_wait.c = -fexceptions -fasynchronous-unwind-tables
148 CFLAGS-sem_timedwait.c = -fexceptions -fasynchronous-unwind-tables
149
150 # These are the function wrappers we have to duplicate here.
151 CFLAGS-fcntl.c = -fexceptions -fasynchronous-unwind-tables
152 CFLAGS-lockf.c = -fexceptions
153 CFLAGS-pread.c = -fexceptions -fasynchronous-unwind-tables
154 CFLAGS-pread64.c = -fexceptions -fasynchronous-unwind-tables
155 CFLAGS-pwrite.c = -fexceptions -fasynchronous-unwind-tables
156 CFLAGS-pwrite64.c = -fexceptions -fasynchronous-unwind-tables
157 CFLAGS-wait.c = -fexceptions -fasynchronous-unwind-tables
158 CFLAGS-waitpid.c = -fexceptions -fasynchronous-unwind-tables
159 CFLAGS-sigwait.c = -fexceptions -fasynchronous-unwind-tables
160 CFLAGS-msgrcv.c = -fexceptions -fasynchronous-unwind-tables
161 CFLAGS-msgsnd.c = -fexceptions -fasynchronous-unwind-tables
162 CFLAGS-tcdrain.c = -fexceptions -fasynchronous-unwind-tables
163
164 CFLAGS-pt-system.c = -fexceptions -I./libc/stdlib
165
166 #
167 # The rest of this file is uClibc specific.
168 #
169 CFLAGS-pthread_barrier_init.c = -D_GNU_SOURCE
170 CFLAGS-pthread_barrier_destroy.c = -D_GNU_SOURCE
171 CFLAGS-pthread_barrierattr_init.c = -D_GNU_SOURCE
172 CFLAGS-pthread_barrierattr_destroy.c = -D_GNU_SOURCE
173 CFLAGS-pthread_barrierattr_getpshared.c = -D_GNU_SOURCE
174 CFLAGS-pthread_barrierattr_setpshared.c = -D_GNU_SOURCE
175 CFLAGS-sem_open.c = -D_GNU_SOURCE
176
177 CFLAGS-nptl = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 $(SSP_ALL_CFLAGS)
178
179 CFLAGS-OMIT-alloca_cutoff.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
180 CFLAGS-OMIT-forward.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
181 CFLAGS-OMIT-libc-lowlevelock.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
182 CFLAGS-OMIT-libc-cancellation.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
183
184 libpthread-os-routines = pthread_yield
185 libpthread-misc-routines = pthread_rwlock_rdlock pthread_rwlock_timedrdlock \
186                            pthread_rwlock_wrlock pthread_rwlock_timedwrlock \
187                            pthread_rwlock_unlock pthread_cond_wait \
188                            pthread_cond_timedwait pthread_cond_signal \
189                            pthread_cond_broadcast pthread_spin_init \
190                            pthread_spin_destroy pthread_spin_lock \
191                            pthread_spin_trylock pthread_spin_unlock \
192                            pthread_barrier_init pthread_barrier_destroy \
193                            pthread_barrier_wait pthread_sigmask \
194                            pthread_kill pthread_once \
195                            pthread_getcpuclockid sem_wait \
196                            sem_trywait sem_timedwait \
197                            sem_post pt-longjmp \
198                            lowlevellock pt-vfork \
199                            ptw-close ptw-read ptw-write \
200                            ptw-fcntl ptw-accept ptw-connect \
201                            ptw-recv ptw-recvfrom ptw-recvmsg \
202                            ptw-send ptw-sendmsg ptw-sendto \
203                            ptw-fsync ptw-lseek ptw-llseek \
204                            ptw-msync ptw-nanosleep ptw-open \
205                            ptw-open64 ptw-pause ptw-pread \
206                            ptw-pread64 ptw-pwrite ptw-pwrite64 \
207                            ptw-tcdrain ptw-wait ptw-waitpid \
208                            ptw-msgrcv ptw-msgsnd ptw-sigwait \
209                            pt-raise flockfile ftrylockfile \
210                            funlockfile sigaction \
211                            pthread_getaffinity \
212                            pthread_setaffinity \
213                            pthread_attr_getaffinity \
214                            pthread_attr_setaffinity \
215                            unwind-forcedunwind
216
217 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
218 LDFLAGS-libpthread.so := $(LDFLAGS_NOSTRIP) -Wl,-z,defs
219 else
220 LDFLAGS-libpthread.so := $(LDFLAGS)
221 endif
222
223 LDFLAGS-libpthread.so += $(top_builddir)lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so $(top_builddir)lib/libdl-$(VERSION).so
224
225 LIBS-libpthread.so := $(LIBS)
226
227 ifneq ($(UCLIBC_CTOR_DTOR),y)
228 START_FILE-libpthread.so := $(top_builddir)/libpthread/nptl/sysdeps/pthread/crti.o $(SHARED_START_FILES)
229 END_FILE-libpthread.so := $(SHARED_END_FILES) $(top_builddir)/libpthread/nptl/sysdeps/pthread/crtn.o
230 endif
231
232 libpthread_FULL_NAME := libpthread-$(VERSION).so
233
234 PTHREAD_DIR := $(top_srcdir)libpthread/nptl
235 PTHREAD_OUT := $(top_builddir)libpthread/nptl
236
237 libpthread_static_SRC := pthread_atfork
238
239 libpthread_a_SRC = $(patsubst %, $(PTHREAD_DIR)/%.c,                    \
240                 $(filter-out $(libpthread-os-routines)                  \
241                         $(libpthread-misc-routines)                     \
242                         $(libpthread-shared-only-routines),             \
243                 $(libpthread-routines)))
244 libpthread_so_SRC = $(patsubst %, $(PTHREAD_DIR)/%.c,                   \
245                 $(filter-out $(libpthread-os-routines)                  \
246                         $(libpthread-misc-routines), $(libpthread-routines)))
247
248 libc-static-y += $(patsubst %.c, $(PTHREAD_OUT)/%.o, alloca_cutoff.c    \
249         libc-cancellation.c)
250 libc-shared-y += $(patsubst %.c, $(PTHREAD_OUT)/%.oS, forward.c         \
251         libc-cancellation.c)
252 libpthread-nonshared-y += $(patsubst %,$(PTHREAD_OUT)/%.oS,$(libpthread_static_SRC))
253
254
255 ifeq ($(DOPIC),y)
256 libpthread-a-y := $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.os,$(libpthread_a_SRC))
257 else
258 libpthread-a-y := $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.o,$(libpthread_a_SRC))
259 endif
260
261 libpthread-so-y := $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.oS,$(libpthread_so_SRC))
262 libpthread-static-y += $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.o,$(libpthread_a_SRC) $(libpthread_static_SRC))
263
264 objclean-y += libpthread_clean
265 headers_clean-y += nptl_headers_clean
266
267 -include $(PTHREAD_DIR)/sysdeps/generic/Makefile.in
268 -include $(PTHREAD_DIR)/sysdeps/pthread/Makefile.in
269 -include $(PTHREAD_DIR)/sysdeps/$(TARGET_ARCH)/Makefile.arch
270 -include $(PTHREAD_DIR)/sysdeps/unix/sysv/linux/Makefile.in
271 -include $(PTHREAD_DIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/Makefile.arch
272
273 pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(nptl_headers) $(nptl_arch_headers) $(nptl_linux_headers)
274
275 lib-a-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.a
276 lib-so-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.so
277
278 $(top_builddir)lib/libpthread.so: $(PTHREAD_OUT)/libpthread_so.a $(libc) $(top_builddir)lib/libpthread_nonshared.a
279         $(call link.so,$(libpthread_FULL_NAME),$(MAJOR_VERSION))
280         $(Q)$(RM) $@
281         $(Q)cp $(top_srcdir)extra/scripts/format.lds $@
282         $(Q)echo "GROUP ( $(notdir $@).$(MAJOR_VERSION) libpthread_nonshared.a )" >> $@
283
284 $(PTHREAD_OUT)/libpthread_so.a: $(libpthread-so-y)
285         $(Q)$(RM) $@
286 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
287         $(do_strip:-x=-X --strip-debug)
288 else
289         $(do_strip)
290 endif
291         $(do_ar)
292
293 $(top_builddir)lib/libpthread.a: $(libpthread-a-y)
294         $(Q)$(INSTALL) -d $(dir $@)
295         $(Q)$(RM) $@
296         $(do_strip)
297         $(do_ar)
298
299 #
300 # Create 'pthread-errnos.h' header file.
301 #
302 CFLAGS-pthread-errnos.c = -S
303
304 $(PTHREAD_OUT)/pthread-errnos.c: $(PTHREAD_DIR)/pthread-errnos.sym
305         $(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
306
307 $(PTHREAD_OUT)/pthread-errnos.s: $(PTHREAD_OUT)/pthread-errnos.c
308         $(compile.c)
309
310 $(PTHREAD_OUT)/pthread-errnos.h: $(PTHREAD_OUT)/pthread-errnos.s
311         $(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
312
313
314 headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(nptl_headers_bootstrap)
315
316 $(top_builddir)include/pthread.h:
317         $(do_ln) ../$(PTDIR)/sysdeps/pthread/$(@F) $(top_builddir)$@
318 $(top_builddir)include/semaphore.h:
319         $(do_ln) ../$(PTDIR)/$(@F) $(top_builddir)$@
320 $(top_builddir)include/bits/semaphore.h: | include/bits
321         $(do_ln) ../../$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/bits/$(@F) $(top_builddir)$@
322 $(top_builddir)include/bits/pthreadtypes.h: | include/bits
323         $(do_ln) ../../$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/bits/$(@F) $(top_builddir)$@
324 $(top_builddir)include/bits/libc-lock.h: | include/bits
325         $(do_ln) ../../$(PTDIR)/sysdeps/pthread/bits/$(@F) $(top_builddir)$@
326 $(top_builddir)include/bits/stdio-lock.h: | include/bits
327         $(do_ln) ../../$(PTDIR)/sysdeps/pthread/bits/$(@F) $(top_builddir)$@
328
329 nptl_headers_bootstrap := $(top_builddir)include/pthread.h \
330                 $(top_builddir)include/semaphore.h \
331                 $(top_builddir)include/bits/semaphore.h \
332                 $(top_builddir)include/bits/pthreadtypes.h \
333                 $(top_builddir)include/bits/libc-lock.h \
334                 $(top_builddir)include/bits/stdio-lock.h
335
336 nptl_headers := $(PTHREAD_OUT)/pthread-errnos.h
337
338 nptl_headers_clean:
339         $(do_rm) $(nptl_headers_bootstrap) \
340               $(addprefix $(PTHREAD_OUT)/pthread-errnos., c h s)
341
342 libpthread_clean:
343         $(do_rm) $(addprefix $(PTHREAD_OUT)/*., o os oS a)