summaryrefslogtreecommitdiff
path: root/libpthread/nptl/Makefile.in
blob: 70616a1fefbc87eb47b3e96b10a1286d4f746dc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# Makefile for uClibc NPTL
#
# Copyright (C) 2005-2006 Steven J. Hill <sjhill@realitydiluted.com>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#

subdirs += libpthread/nptl

libpthread_DIR = $(top_srcdir)libpthread/nptl
libpthread_OUT = $(top_builddir)libpthread/nptl

include $(libpthread_DIR)/sysdeps/Makefile.in

libc-shared-routines-y = forward.c libc-cancellation.c
libc-static-routines-y = alloca_cutoff.c libc-cancellation.c
libpthread-shared-only-routines-y = version.c
libpthread-static-only-routines-y = pthread_atfork.c
libpthread-routines- += $(notdir $(wildcard $(libpthread_DIR)/gen_*.c)) # dummy generated files
libpthread-routines- += allocatestack.c # dummy included by pthread_create.c
libpthread-routines- += pthread_mutex_getprioceiling.c pthread_mutex_setprioceiling.c # XXX: delete those or use them!
libpthread-routines-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += res.c
libpthread-routines-$(UCLIBC_SUSV4_LEGACY) += pthread_getconcurrency.c \
	pthread_setconcurrency
libpthread_CSRC = $(filter-out $(libpthread-routines-) \
		  		$(libc-shared-routines-y) \
		  		$(libc-static-routines-y) \
				$(libpthread-shared-only-routines-y) \
				$(libpthread-static-only-routines-y) \
				$(notdir $(libpthread_OBJS:.o=.c)), \
		  $(notdir $(wildcard $(libpthread_DIR)/*.c)))

libpthread_OBJS += $(addprefix $(libpthread_OUT)/,$(libpthread_CSRC:.c=.o))
libpthread-so-y += $(addprefix $(libpthread_OUT)/,$(libpthread-shared-only-routines-y:.c=.oS))
libpthread-so-y += $(libpthread_OBJS:.o=.oS)
libpthread-nonshared-y := $(addprefix $(libpthread_OUT)/,$(libpthread-static-only-routines-y:.c=.oS))
libpthread-static-y    := $(addprefix $(libpthread_OUT)/,$(libpthread-static-only-routines-y:.c=.o))
libpthread-static-y    += $(libpthread_OBJS)
ifeq ($(DOPIC),y)
libpthread-a-y := $(libpthread-static-y:.o=.os)
else
libpthread-a-y := $(libpthread-static-y)
endif

libc-shared-routines-y := $(filter-out $(notdir $(libpthread_libc_OBJS:.o=.c)), $(libc-shared-routines-y))
libc-static-routines-y := $(filter-out $(notdir $(libpthread_libc_OBJS:.o=.c)), $(libc-static-routines-y))
libc-shared-routines-y := $(addprefix $(libpthread_OUT)/,$(libc-shared-routines-y:.c=.oS))
libc-static-routines-y := $(addprefix $(libpthread_OUT)/,$(libc-static-routines-y:.c=.o))
libc-shared-y += $(libc-shared-routines-y) $(libpthread_libc_OBJS:.o=.oS)
ifeq ($(DOPIC),y)
libc-static-y += $(libc-static-routines-y:.o=.os) $(libpthread_libc_a_OBJS:.o=.os) $(libpthread_ld_tls_COBJ:.o=.os)
else
libc-static-y += $(libc-static-routines-y) $(libpthread_libc_a_OBJS) $(libpthread_ld_tls_COBJ)
endif

librt-pt-routines-y := $(patsubst %.c,$(libpthread_pthread_OUT)/%.o,$(filter-out $(notdir $(libpthread_librt_OBJS:.o=.c)), $(librt-pt-routines-y)))
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)))
librt_OBJS = $(libpthread_librt_OBJS) $(librt-pt-routines-y)
ifeq ($(DOPIC),y)
librt-a-y += $(librt_OBJS:.o=.os)
else
librt-a-y += $(librt_OBJS)
endif
librt-so-y += $(librt_OBJS:.o=.oS) $(librt-pt-shared-only-routines-y:.o=.oS)

ifeq ($(UCLIBC_CTOR_DTOR),y)
START_FILE-libpthread.so := $(top_builddir)/libpthread/nptl/sysdeps/pthread/crti.o
END_FILE-libpthread.so := $(top_builddir)/libpthread/nptl/sysdeps/pthread/crtn.o
LDFLAGS-libpthread.so += -nostartfiles
$(top_builddir)lib/libpthread.so: | $(START_FILE-libpthread.so) $(END_FILE-libpthread.so)
endif

libpthread_FULL_NAME := libpthread-$(VERSION).so
lib-a-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.a
lib-so-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.so

$(top_builddir)lib/libpthread.so: $(libpthread_OUT)/libpthread_so.a $(libc.depend) $(libdl.depend) $(top_builddir)lib/libpthread_nonshared.a
	$(call link.so,$(libpthread_FULL_NAME),$(ABI_VERSION))
	$(Q)cat $(top_srcdir)extra/scripts/format.lds > $@.tmp
	$(Q)echo "GROUP ( $(notdir $@).$(ABI_VERSION) libpthread_nonshared.a )" >> $@.tmp
	$(Q)mv $@.tmp $@

ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
$(libpthread_OUT)/libpthread_so.a: STRIP_FLAGS:=$(STRIP_FLAGS:-x=-X --strip-debug)
endif
$(libpthread_OUT)/libpthread_so.a: $(libpthread-so-y)
	$(Q)$(RM) $@
	$(do_ar)

$(top_builddir)lib/libpthread.a: $(libpthread-a-y)
	$(Q)$(INSTALL) -d $(dir $@)
	$(Q)$(RM) $@
	$(do_ar)

#
# Create 'pthread-errnos.h' header file.
#
CFLAGS-gen_pthread-errnos.c = -S

$(libpthread_OUT)/gen_pthread-errnos.c: $(libpthread_DIR)/pthread-errnos.sym | $(libpthread_OUT)
	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@

$(libpthread_OUT)/gen_pthread-errnos.s: $(libpthread_OUT)/gen_pthread-errnos.c | headers
	$(compile.c)
libpthread-generated-y += $(libpthread_OUT)/gen_pthread-errnos.s
$(libpthread_OUT)/pthread-errnos.h: $(libpthread_OUT)/gen_pthread-errnos.s
	$(do_sed) $(PTHREAD_GENERATE_MANGLE) $< > $@
	@if test ! -s $@ ; then rm -f $@ ; false ; fi

pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(libpthread_OUT)/pthread-errnos.h

headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(nptl_headers_bootstrap)

libpthread_H := $(addprefix $(top_builddir)include/,semaphore.h)
libpthread_include_H := $(addprefix $(top_builddir)include/,pthread.h)
libpthread_include_BITS_H := $(addprefix $(top_builddir)include/bits/,libc-lock.h stdio-lock.h)
libpthread_include_STD_IMPL_OS_ARCH_BITS_H := $(addprefix $(top_builddir)include/bits/,pthreadtypes.h semaphore.h)

$(libpthread_include_STD_IMPL_OS_ARCH_BITS_H): $(top_builddir)include/bits/%:
	$(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/bits/$(@F) $@
$(libpthread_include_BITS_H): $(top_builddir)include/bits/%:
	$(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/bits/$(@F) $@
$(libpthread_include_H): $(top_builddir)include/%:
	$(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/$(@F) $@
$(libpthread_H): $(top_builddir)include/%:
	$(do_ln) $(call rel_srcdir)$(PTDIR)/$(@F) $@

nptl_headers_bootstrap = $(libpthread_H) $(libpthread_include_H) $(libpthread_include_BITS_H) $(libpthread_include_STD_IMPL_OS_ARCH_BITS_H)

objclean-y += CLEAN_libpthread/nptl
headers_clean-y += HEADERCLEAN_libpthread/nptl

HEADERCLEAN_libpthread/nptl:
	$(do_rm) $(nptl_headers_bootstrap) \
	      $(addprefix $(libpthread_OUT)/gen_pthread-errnos., c s) \
	      $(libpthread_OUT)/pthread-errnos.h

CLEAN_libpthread/nptl:
	$(do_rm) $(addprefix $(libpthread_OUT)/*., o os oS a)

ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
LDFLAGS-libpthread.so += $(LDFLAGS_NOSTRIP) -Wl,-z,defs
else
LDFLAGS-libpthread.so += $(LDFLAGS)
endif

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

LIBS-libpthread.so := $(LIBS)

CFLAGS-nptl = -DNOT_IN_libc -DIS_IN_libpthread $(SSP_ALL_CFLAGS)

# Since cancellation handling is in large parts handled using exceptions
# we have to compile some files with exception handling enabled, some
# even with asynchronous unwind tables.

# init.c contains sigcancel_handler().
CFLAGS-init.c = -fexceptions -fasynchronous-unwind-tables
# The unwind code itself,
CFLAGS-unwind.c = -fexceptions
CFLAGS-unwind-forcedunwind.c = -fexceptions -fasynchronous-unwind-tables

# The following three functions must be async-cancel safe.
CFLAGS-pthread_cancel.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pthread_setcancelstate.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pthread_setcanceltype.c = -fexceptions -fasynchronous-unwind-tables

# These are internal functions which similar functionality as setcancelstate
# and setcanceltype.
CFLAGS-cancellation.c = -fasynchronous-unwind-tables
CFLAGS-libc-cancellation.c = -fasynchronous-unwind-tables

# Calling pthread_exit() must cause the registered cancel handlers to
# be executed.  Therefore exceptions have to be thrown through this
# function.
CFLAGS-pthread_exit.c = -fexceptions

# Among others, __pthread_unwind is forwarded.  This function must handle
# exceptions.
CFLAGS-forward.c = -fexceptions

# The following are cancellation points.  Some of the functions can
# block and therefore temporarily enable asynchronous cancellation.
# Those must be compiled asynchronous unwind tables.
CFLAGS-pthread_testcancel.c = -fexceptions
CFLAGS-pthread_join.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pthread_timedjoin.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pthread_once.c = $(uses-callbacks) -fexceptions \
			-fasynchronous-unwind-tables
CFLAGS-pthread_cond_wait.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pthread_cond_timedwait.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-sem_wait.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-sem_timedwait.c = -fexceptions -fasynchronous-unwind-tables

# These are the function wrappers we have to duplicate here.
CFLAGS-fcntl.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-lockf.c = -fexceptions
CFLAGS-pread.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pread64.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pwrite.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pwrite64.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-wait.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-waitpid.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-sigwait.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-msgrcv.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-msgsnd.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-tcdrain.c = -fexceptions -fasynchronous-unwind-tables

CFLAGS-pt-system.c = -fexceptions -I$(top_srcdir)libc/stdlib

#
# The rest of this file is uClibc specific.
#
CFLAGS-pthread_barrier_init.c = -D_GNU_SOURCE
CFLAGS-pthread_barrier_destroy.c = -D_GNU_SOURCE
CFLAGS-pthread_barrierattr_init.c = -D_GNU_SOURCE
CFLAGS-pthread_barrierattr_destroy.c = -D_GNU_SOURCE
CFLAGS-pthread_barrierattr_getpshared.c = -D_GNU_SOURCE
CFLAGS-pthread_barrierattr_setpshared.c = -D_GNU_SOURCE
CFLAGS-sem_open.c = -D_GNU_SOURCE

CFLAGS-OMIT-alloca_cutoff.c = $(CFLAGS-nptl)
CFLAGS-OMIT-forward.c = $(CFLAGS-nptl)
CFLAGS-OMIT-libc-lowlevelock.c = $(CFLAGS-nptl)
CFLAGS-OMIT-libc-cancellation.c = $(CFLAGS-nptl)