1 | # Copyright (C) 1996-2003, 2004, 2005 Free Software Foundation, Inc.
|
---|
2 | # This file is part of the GNU C Library.
|
---|
3 |
|
---|
4 | # The GNU C Library is free software; you can redistribute it and/or
|
---|
5 | # modify it under the terms of the GNU Lesser General Public
|
---|
6 | # License as published by the Free Software Foundation; either
|
---|
7 | # version 2.1 of the License, or (at your option) any later version.
|
---|
8 |
|
---|
9 | # The GNU C Library is distributed in the hope that it will be useful,
|
---|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
12 | # Lesser General Public License for more details.
|
---|
13 |
|
---|
14 | # You should have received a copy of the GNU Lesser General Public
|
---|
15 | # License along with the GNU C Library; if not, write to the Free
|
---|
16 | # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
---|
17 | # 02111-1307 USA.
|
---|
18 |
|
---|
19 | #
|
---|
20 | # Sub-makefile for linuxthreads portion of the library.
|
---|
21 | #
|
---|
22 | subdir := linuxthreads
|
---|
23 |
|
---|
24 | all: # Make this the default target; it will be defined in Rules.
|
---|
25 |
|
---|
26 | linuxthreads-version := $(shell sed -n 's/^.*$(subdir)-\([0-9.]*\).*$$/\1/p' \
|
---|
27 | Banner)
|
---|
28 | libpthread-abi-frozen := GLIBC_2.3.2
|
---|
29 |
|
---|
30 | headers := pthread.h semaphore.h
|
---|
31 | distribute := internals.h queue.h restart.h spinlock.h smp.h tst-signal.sh \
|
---|
32 | tst-cancel-wrappers.sh libc-tsd.c
|
---|
33 |
|
---|
34 | routines := forward alloca_cutoff libc-cancellation libc_pthread_init
|
---|
35 | shared-only-routines = forward
|
---|
36 |
|
---|
37 | extra-libs := libpthread
|
---|
38 | extra-libs-others := $(extra-libs)
|
---|
39 | install-lib-ldscripts := libpthread.so
|
---|
40 |
|
---|
41 | libpthread-routines := attr cancel condvar join manager mutex ptfork \
|
---|
42 | ptlongjmp pthread pt-sigsuspend signals specific errno \
|
---|
43 | lockfile semaphore spinlock rwlock pt-machine \
|
---|
44 | oldsemaphore events getcpuclockid pspinlock barrier \
|
---|
45 | ptclock_gettime ptclock_settime sighandler \
|
---|
46 | pthandles libc-tls-loc pt-allocrtsig \
|
---|
47 | ptw-write ptw-read ptw-close ptw-fcntl ptw-accept \
|
---|
48 | ptw-connect ptw-recv ptw-recvfrom ptw-recvmsg \
|
---|
49 | ptw-send ptw-sendmsg ptw-sendto ptw-fsync ptw-lseek \
|
---|
50 | ptw-lseek64 ptw-llseek ptw-msync ptw-nanosleep \
|
---|
51 | ptw-open ptw-open64 ptw-pause ptw-pread ptw-pread64 \
|
---|
52 | ptw-pwrite ptw-pwrite64 ptw-tcdrain ptw-wait \
|
---|
53 | ptw-waitpid pt-system old_pthread_atfork pthread_atfork \
|
---|
54 | ptcleanup
|
---|
55 | # pthread_setuid pthread_seteuid pthread_setreuid \
|
---|
56 | # pthread_setresuid \
|
---|
57 | # pthread_setgid pthread_setegid pthread_setregid \
|
---|
58 | # pthread_setresgid
|
---|
59 |
|
---|
60 | # Don't generate deps for calls with no sources. See sysdeps/unix/Makefile.
|
---|
61 | omit-deps = $(unix-syscalls:%=ptw-%)
|
---|
62 |
|
---|
63 | libpthread-shared-only-routines = pt-allocrtsig
|
---|
64 | libpthread-static-only-routines = pthread_atfork
|
---|
65 |
|
---|
66 | linuxthreads-CPPFLAGS = -DIS_IN_linuxthreads=1
|
---|
67 |
|
---|
68 | CFLAGS-pthread_atfork.c = -DNOT_IN_libc
|
---|
69 |
|
---|
70 | nodelete-yes = -Wl,--enable-new-dtags,-z,nodelete
|
---|
71 | initfirst-yes = -Wl,--enable-new-dtags,-z,initfirst
|
---|
72 | LDFLAGS-pthread.so = $(nodelete-$(have-z-nodelete)) \
|
---|
73 | $(initfirst-$(have-z-initfirst))
|
---|
74 |
|
---|
75 | vpath %.c Examples
|
---|
76 |
|
---|
77 | tst-cancel-ARGS = "$(objpfx)"
|
---|
78 | CFLAGS-tst-cancel.c = -fno-inline -fno-inline-functions
|
---|
79 |
|
---|
80 | include ../Makeconfig
|
---|
81 |
|
---|
82 | ifeq ($(build-shared),yes)
|
---|
83 |
|
---|
84 | # Set the `multidir' variable by grabbing the variable from the compiler.
|
---|
85 | # We do it once and save the result in a generated makefile.
|
---|
86 | -include $(objpfx)multidir.mk
|
---|
87 | $(objpfx)multidir.mk: $(common-objpfx)config.make
|
---|
88 | $(make-target-directory)
|
---|
89 | dir=`$(CC) $(CFLAGS) $(CPPFLAGS) -print-multi-directory`; \
|
---|
90 | echo "multidir := $$dir" > $@T
|
---|
91 | mv -f $@T $@
|
---|
92 | generated += multidir.mk
|
---|
93 |
|
---|
94 | crti-objs := crti.o
|
---|
95 | crtn-objs := crtn.o
|
---|
96 | ifneq (,$(patsubst .,,$(multidir)))
|
---|
97 | generated-dirs := $(firstword $(subst /, , $(multidir)))
|
---|
98 | crti-objs += $(multidir)/crti.o
|
---|
99 | crtn-objs += $(multidir)/crtn.o
|
---|
100 | omit-deps += $(multidir)/crti $(multidir)/crtn
|
---|
101 | endif
|
---|
102 | extra-objs += $(crti-objs) $(crtn-objs)
|
---|
103 | omit-deps += crti crtn
|
---|
104 |
|
---|
105 | CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions $(fno-unit-at-a-time)
|
---|
106 | endif
|
---|
107 |
|
---|
108 | librt-tests = ex10 ex11 tst-clock1
|
---|
109 | tests = ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 $(librt-tests) ex12 ex13 joinrace \
|
---|
110 | tststack $(tests-nodelete-$(have-z-nodelete)) ecmutex ex14 ex15 ex16 \
|
---|
111 | ex17 ex18 tst-cancel tst-context bug-sleep \
|
---|
112 | tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel4 tst-cancel5 \
|
---|
113 | tst-cancel6 tst-cancel7 tst-cancel8 tst-popen tst-popen2 tst-attr1 \
|
---|
114 | tst-stack1 tst-align tst-tsd1
|
---|
115 | test-srcs = tst-signal
|
---|
116 | # These tests are linked with libc before libpthread
|
---|
117 | tests-reverse += tst-cancel5
|
---|
118 |
|
---|
119 | ifeq ($(build-static),yes)
|
---|
120 | tests += tststatic tst-static-locale tst-cancel-static
|
---|
121 | tests-static += tststatic tst-static-locale tst-cancel-static
|
---|
122 | endif
|
---|
123 |
|
---|
124 | ifeq (yes,$(build-shared))
|
---|
125 | tests-nodelete-yes = unload
|
---|
126 | tests += tst-tls1 tst-_res1
|
---|
127 | endif
|
---|
128 |
|
---|
129 | modules-names = tst-_res1mod1 tst-_res1mod2 \
|
---|
130 | tst-tls1mod tst-tls1moda tst-tls1modb tst-tls1modc \
|
---|
131 | tst-tls1modd tst-tls1mode tst-tls1modf
|
---|
132 | extra-objs += $(addsuffix .os,$(strip $(modules-names)))
|
---|
133 | generated += $(addsuffix .so,$(strip $(modules-names)))
|
---|
134 | test-extras += $(modules-names)
|
---|
135 | test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))
|
---|
136 |
|
---|
137 | tst-tls1mod.so-no-z-defs = yes
|
---|
138 | tst-tls1moda.so-no-z-defs = yes
|
---|
139 | tst-tls1modb.so-no-z-defs = yes
|
---|
140 | tst-tls1modc.so-no-z-defs = yes
|
---|
141 | tst-tls1modd.so-no-z-defs = yes
|
---|
142 | tst-tls1mode.so-no-z-defs = yes
|
---|
143 | tst-tls1modf.so-no-z-defs = yes
|
---|
144 |
|
---|
145 | $(test-modules): $(objpfx)%.so: $(objpfx)%.os $(common-objpfx)shlib.lds
|
---|
146 | $(build-module)
|
---|
147 |
|
---|
148 | ifeq ($(build-shared),yes)
|
---|
149 | # Build all the modules even when not actually running test programs.
|
---|
150 | tests: $(test-modules)
|
---|
151 | endif
|
---|
152 |
|
---|
153 | # What we install as libpthread.so for programs to link against is in fact a
|
---|
154 | # link script. It contains references for the various libraries we need.
|
---|
155 | # The libpthread.so object is not complete since some functions are only defined
|
---|
156 | # in libpthread_nonshared.a.
|
---|
157 | # We need to use absolute paths since otherwise local copies (if they exist)
|
---|
158 | # of the files are taken by the linker.
|
---|
159 | install: $(inst_libdir)/libpthread.so
|
---|
160 | $(inst_libdir)/libpthread.so: $(common-objpfx)format.lds \
|
---|
161 | $(objpfx)libpthread.so$(libpthread.so-version) \
|
---|
162 | $(inst_libdir)/$(patsubst %,$(libtype.oS),\
|
---|
163 | $(libprefix)pthread) \
|
---|
164 | $(+force)
|
---|
165 | (echo '/* GNU ld script';\
|
---|
166 | echo ' Use the shared library, but some functions are only in';\
|
---|
167 | echo ' the static library, so try that secondarily. */';\
|
---|
168 | cat $<; \
|
---|
169 | echo 'GROUP ( $(slibdir)/libpthread.so$(libpthread.so-version)' \
|
---|
170 | '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)pthread)'\
|
---|
171 | ')' \
|
---|
172 | ) > $@.new
|
---|
173 | mv -f $@.new $@
|
---|
174 |
|
---|
175 |
|
---|
176 | extra-B-pthread.so = -B$(common-objpfx)linuxthreads/
|
---|
177 | $(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs))
|
---|
178 | $(objpfx)libpthread.so: +preinit += $(addprefix $(objpfx),$(crti-objs))
|
---|
179 | $(objpfx)libpthread.so: +postinit += $(addprefix $(objpfx),$(crtn-objs))
|
---|
180 |
|
---|
181 | znodelete-yes = -DHAVE_Z_NODELETE
|
---|
182 | CFLAGS-mutex.c += -D__NO_WEAK_PTHREAD_ALIASES
|
---|
183 | CFLAGS-specific.c += -D__NO_WEAK_PTHREAD_ALIASES
|
---|
184 | CFLAGS-pthread.c += -D__NO_WEAK_PTHREAD_ALIASES $(znodelete-$(have-z-nodelete))
|
---|
185 | CFLAGS-ptfork.c += -D__NO_WEAK_PTHREAD_ALIASES
|
---|
186 | CFLAGS-cancel.c += -D__NO_WEAK_PTHREAD_ALIASES -D_RPC_THREAD_SAFE_
|
---|
187 | CFLAGS-unload.c += -DPREFIX=\"$(objpfx)\"
|
---|
188 | CFLAGS-mutex.c += $(uses-callbacks)
|
---|
189 | CFLAGS-sighandler.c += $(uses-callbacks)
|
---|
190 |
|
---|
191 | ifeq (yes,$(versioning))
|
---|
192 | -include $(common-objpfx)tls.make
|
---|
193 | libc-ok-for-link = $(use-thread)
|
---|
194 | else
|
---|
195 | libc-ok-for-link = yes
|
---|
196 | endif
|
---|
197 |
|
---|
198 | ifeq (no,$(libc-ok-for-link))
|
---|
199 | # These hacks are necessary to let us link against a libc.so that exports
|
---|
200 | # the symbols _errno, _h_errno, and _res. Those symbols are accessible
|
---|
201 | # in libc at runtime (dynamic linkable), but are not exported at link time
|
---|
202 | # so that applications cannot link against them. However, libpthread.so
|
---|
203 | # needs to link against them for its __errno_location et al functions to
|
---|
204 | # find the locations that libc's symbols resolve to. We cannot do this
|
---|
205 | # with aliases in libc.so(GLIBC_PRIVATE), because we need to refer to an
|
---|
206 | # executable's symbols when it defines them with copy relocs.
|
---|
207 | libc-link.so = $(objpfx)libc.so
|
---|
208 |
|
---|
209 | $(objpfx)libc_pic_lite.a: $(common-objpfx)libc_pic.a
|
---|
210 | cp $< $@T
|
---|
211 | $(AR) d $@T errno.os herrno.os res_libc.os
|
---|
212 | mv -f $@T $@
|
---|
213 |
|
---|
214 | extra-objs += libc-tsd.os
|
---|
215 | $(objpfx)libc_pic_lite.os: $(objpfx)libc_pic_lite.a $(objpfx)libc-tsd.os
|
---|
216 | $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
|
---|
217 | $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
|
---|
218 |
|
---|
219 | # This trick leaves errno and h_errno undefined.
|
---|
220 | libc.so-no-z-defs = yes
|
---|
221 |
|
---|
222 | $(objpfx)libc.so: $(elfobjdir)/soinit.os \
|
---|
223 | $(objpfx)libc_pic_lite.os \
|
---|
224 | $(elfobjdir)/sofini.os \
|
---|
225 | $(elfobjdir)/interp.os $(elfobjdir)/ld.so
|
---|
226 | $(build-shlib)
|
---|
227 |
|
---|
228 | generated += libc_pic_lite.a libc_pic_lite.os libc.so libc-tsd.os
|
---|
229 | else
|
---|
230 | libc-link.so = $(common-objpfx)libc.so
|
---|
231 | endif
|
---|
232 |
|
---|
233 | include ../Rules
|
---|
234 |
|
---|
235 | # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
|
---|
236 | # This ensures they will load libc.so for needed symbols if loaded by
|
---|
237 | # a statically-linked program that hasn't already loaded it.
|
---|
238 | # Depend on ld.so too to get proper versions of ld.so symbols.
|
---|
239 | $(objpfx)libpthread.so: $(libc-link.so) $(common-objpfx)libc_nonshared.a \
|
---|
240 | $(if $(filter yes,$(elf)), $(elfobjdir)/ld.so)
|
---|
241 |
|
---|
242 | # Make sure we link with the thread library.
|
---|
243 | ifeq ($(build-shared),yes)
|
---|
244 | $(addprefix $(objpfx), \
|
---|
245 | $(filter-out $(tests-static) $(tests-reverse) unload, \
|
---|
246 | $(tests) $(test-srcs))): $(objpfx)libpthread.so \
|
---|
247 | $(objpfx)libpthread_nonshared.a
|
---|
248 | # $(objpfx)../libc.so is used instead of $(common-objpfx)libc.so,
|
---|
249 | # since otherwise libpthread.so comes before libc.so when linking.
|
---|
250 | $(addprefix $(objpfx), $(tests-reverse)): \
|
---|
251 | $(objpfx)../libc.so $(objpfx)libpthread.so \
|
---|
252 | $(objpfx)libpthread_nonshared.a
|
---|
253 | $(objpfx)../libc.so: $(common-objpfx)libc.so ;
|
---|
254 | $(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.so
|
---|
255 | $(objpfx)unload: $(common-objpfx)dlfcn/libdl.so
|
---|
256 | $(objpfx)unload.out: $(objpfx)libpthread.so $(objpfx)libpthread_nonshared.a
|
---|
257 | else
|
---|
258 | $(addprefix $(objpfx),$(tests) $(test-srcs)): $(objpfx)libpthread.a
|
---|
259 | $(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.a
|
---|
260 | endif
|
---|
261 | ifeq ($(build-bounded),yes)
|
---|
262 | $(tests:%=$(objpfx)%-bp): $(objpfx)libpthread_b.a
|
---|
263 | $(librt-tests:%=$(objpfx)%-bp): $(common-objpfx)rt/librt_b.a
|
---|
264 | endif
|
---|
265 |
|
---|
266 | ifeq ($(build-static),yes)
|
---|
267 | $(addprefix $(objpfx), $(tests-static)): $(objpfx)libpthread.a
|
---|
268 | endif
|
---|
269 |
|
---|
270 | ifeq ($(build-shared),yes)
|
---|
271 | vpath pt-initfini.c $(full_config_sysdirs)
|
---|
272 |
|
---|
273 | $(objpfx)pt-initfini.s: pt-initfini.c
|
---|
274 | $(compile.c) -S $(CFLAGS-pt-initfini.s) -finhibit-size-directive \
|
---|
275 | $(patsubst -f%,-fno-%,$(exceptions)) -o $@
|
---|
276 |
|
---|
277 | # We only have one kind of startup code files. Static binaries and
|
---|
278 | # shared libraries are build using the PIC version.
|
---|
279 | $(objpfx)crti.S: $(objpfx)pt-initfini.s
|
---|
280 | sed -n -e '1,/@HEADER_ENDS/p' \
|
---|
281 | -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
|
---|
282 | -e '/@TRAILER_BEGINS/,$$p' $< > $@
|
---|
283 | $(objpfx)crtn.S: $(objpfx)pt-initfini.s
|
---|
284 | sed -n -e '1,/@HEADER_ENDS/p' \
|
---|
285 | -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
|
---|
286 | -e '/@TRAILER_BEGINS/,$$p' $< > $@
|
---|
287 |
|
---|
288 | $(objpfx)defs.h: $(objpfx)pt-initfini.s
|
---|
289 | sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
|
---|
290 | $(AWK) -f ../csu/defs.awk > $@
|
---|
291 |
|
---|
292 | $(objpfx)crti.o: $(objpfx)crti.S $(objpfx)defs.h
|
---|
293 | $(compile.S) -g0 $(ASFLAGS-.os) -o $@
|
---|
294 |
|
---|
295 | $(objpfx)crtn.o: $(objpfx)crtn.S $(objpfx)defs.h
|
---|
296 | $(compile.S) -g0 $(ASFLAGS-.os) -o $@
|
---|
297 |
|
---|
298 | ifneq ($(multidir),.)
|
---|
299 | $(objpfx)$(multidir):
|
---|
300 | @mkdir -p $(objpfx)$(multidir)
|
---|
301 |
|
---|
302 | $(objpfx)$(multidir)/crti.o: $(objpfx)crti.o $(objpfx)$(multidir)
|
---|
303 | ln -f $< $@
|
---|
304 |
|
---|
305 | $(objpfx)$(multidir)/crtn.o: $(objpfx)crtn.o $(objpfx)$(multidir)
|
---|
306 | ln -f $< $@
|
---|
307 | endif
|
---|
308 |
|
---|
309 | generated += crti.S crtn.S defs.h pt-initfini.s libpthread_nonshared.a
|
---|
310 | endif
|
---|
311 |
|
---|
312 | ifeq (yes,$(build-static-nss))
|
---|
313 | otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
|
---|
314 | $(resolvobjdir)/libresolv.a
|
---|
315 | endif
|
---|
316 |
|
---|
317 | ifeq (yes,$(build-shared))
|
---|
318 | $(objpfx)tst-_res1mod2.so: $(objpfx)tst-_res1mod1.so
|
---|
319 | $(objpfx)tst-_res1: $(objpfx)tst-_res1mod2.so $(shared-thread-library)
|
---|
320 |
|
---|
321 | $(objpfx)tst-tls1: $(objpfx)tst-tls1mod.so $(shared-thread-library)
|
---|
322 |
|
---|
323 | tests: $(objpfx)tst-tls2.out
|
---|
324 | $(objpfx)tst-tls2.out: tst-tls2.sh $(objpfx)tst-tls1 \
|
---|
325 | $(objpfx)tst-tls1moda.so $(objpfx)tst-tls1modb.so \
|
---|
326 | $(objpfx)tst-tls1modc.so $(objpfx)tst-tls1modd.so \
|
---|
327 | $(objpfx)tst-tls1mode.so $(objpfx)tst-tls1modf.so
|
---|
328 | $(SHELL) -e tst-tls2.sh $(common-objpfx) $(elf-objpfx) \
|
---|
329 | $(rtld-installed-name)
|
---|
330 | generated += tst-tls2.out
|
---|
331 | endif
|
---|
332 |
|
---|
333 | ifeq (no,$(cross-compiling))
|
---|
334 | ifeq (yes,$(build-shared))
|
---|
335 | tests: $(objpfx)tst-signal.out $(objpfx)tst-cancel-wrappers.out
|
---|
336 | $(objpfx)tst-signal.out: tst-signal.sh $(objpfx)tst-signal
|
---|
337 | $(SHELL) -e $< $(common-objpfx) > $@
|
---|
338 | $(objpfx)tst-cancel-wrappers.out: tst-cancel-wrappers.sh
|
---|
339 | $(SHELL) $< $(common-objpfx)/libc_pic.a \
|
---|
340 | $(common-objpfx)/libc.a \
|
---|
341 | $(objpfx)/libpthread_pic.a \
|
---|
342 | $(objpfx)/libpthread.a > $@
|
---|
343 | generated += tst-signal.out tst-cancel-wrappers.out
|
---|
344 | endif
|
---|
345 | endif
|
---|