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