1 # Copyright (C) 1996-2002, 2003 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
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.
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.
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
20 # Sub-makefile for linuxthreads portion of the library.
22 subdir
:= linuxthreads
24 linuxthreads-version
:= $(shell sed
-n
's/^.*$(subdir)-\([0-9.]*\).*$$/\1/p' \
27 headers
:= pthread.h semaphore.h
28 distribute
:= internals.h queue.h restart.h spinlock.h smp.h tst-signal.sh \
29 tst-cancel-wrappers.sh libc-tsd.c
31 routines
:= forward alloca_cutoff libc-cancellation libc_pthread_init
32 shared-only-routines
= forward
34 extra-libs
:= libpthread
35 extra-libs-others
:= $(extra-libs
)
37 libpthread-routines
:= attr cancel condvar
join manager mutex ptfork \
38 ptlongjmp pthread signals specific errno lockfile \
39 semaphore spinlock rwlock pt-machine \
40 oldsemaphore events getcpuclockid pspinlock barrier \
41 ptclock_gettime ptclock_settime sighandler \
42 pthandles libc-tls-loc pt-allocrtsig \
43 ptw-write ptw-read ptw-close ptw-fcntl ptw-accept \
44 ptw-connect ptw-recv ptw-recvfrom ptw-recvmsg \
45 ptw-send ptw-sendmsg ptw-sendto ptw-fsync ptw-lseek \
46 ptw-lseek64 ptw-llseek ptw-msync ptw-nanosleep \
47 ptw-open ptw-open64 ptw-pause ptw-pread ptw-pread64 \
48 ptw-pwrite ptw-pwrite64 ptw-tcdrain ptw-wait \
49 ptw-waitpid pt-system old_pthread_atfork
50 # Don't generate deps for calls with no sources. See sysdeps/unix/Makefile.
51 omit-deps
= $(unix-syscalls
:%=ptw-
%)
53 libpthread-shared-only-routines
= pt-allocrtsig
55 libpthread-nonshared
= pthread_atfork
57 CFLAGS-pthread_atfork.c
= -DNOT_IN_libc
59 nodelete-yes
= -Wl
,--enable-new-dtags
,-z
,nodelete
60 initfirst-yes
= -Wl
,--enable-new-dtags
,-z
,initfirst
61 LDFLAGS-pthread.so
= $(nodelete-
$(have-z-nodelete
)) \
62 $(initfirst-
$(have-z-initfirst
))
66 tst-cancel-ARGS
= "$(objpfx)"
67 CFLAGS-tst-cancel.c
= -fno-inline
-fno-inline-functions
71 ifeq ($(build-shared
),yes
)
72 others
: $(objpfx
)libpthread_nonshared.a
75 $(objpfx
)libpthread_nonshared.a
: $(addprefix $(objpfx
),$(addsuffix .os
,$(libpthread-nonshared
)))
76 $(AR
) $(ARFLAGS
) $@
$^
78 ifeq ($(build-shared
),yes
)
80 extra-objs
+= crti.o crtn.o
81 omit-deps
+= crti crtn
83 CFLAGS-pt-initfini.s
= -g0
-fPIC
-fno-inline-functions
86 librt-tests
= ex10 ex11
87 tests
= ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9
$(librt-tests
) ex12 ex13 joinrace \
88 tststack
$(tests-nodelete-
$(have-z-nodelete
)) ecmutex ex14 ex15 ex16 \
89 ex17 ex18 tst-cancel tst-context bug-sleep \
90 tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel4 tst-cancel5 \
92 test-srcs
= tst-signal
93 # These tests are linked with libc before libpthread
94 tests-reverse
+= tst-cancel5
96 ifeq ($(build-static
),yes
)
97 tests
+= tststatic tst-static-locale tst-cancel-static
98 tests-static
+= tststatic tst-static-locale tst-cancel-static
101 ifeq (yes
,$(build-shared
))
102 tests-nodelete-yes
= unload
107 # What we install as libpthread.so for programs to link against is in fact a
108 # link script. It contains references for the various libraries we need.
109 # The libpthread.so object is not complete since some functions are only defined
110 # in libpthread_nonshared.a.
111 # We need to use absolute paths since otherwise local copies (if they exist)
112 # of the files are taken by the linker.
113 install: $(inst_libdir
)/libpthread.so
114 $(inst_libdir
)/libpthread.so
: $(common-objpfx
)format.lds \
115 $(objpfx
)libpthread.so
$(libpthread.so-version
) \
116 $(inst_libdir
)/$(patsubst %,$(libtype.oS
),\
117 $(libprefix
)pthread
) \
119 (echo
'/* GNU ld script';\
120 echo
' Use the shared library, but some functions are only in';\
121 echo
' the static library, so try that secondarily. */';\
123 echo
'GROUP ( $(slibdir)/libpthread.so$(libpthread.so-version)' \
124 '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)pthread)'\
128 $(inst_libdir
)/libpthread_nonshared.a
: $(objpfx
)libpthread_nonshared.a
132 extra-B-pthread.so
= -B
$(common-objpfx
)linuxthreads
/
133 $(objpfx
)libpthread.so
: $(objpfx
)crti.o
$(objpfx
)crtn.o
134 $(objpfx
)libpthread.so
: +preinit
+= $(objpfx
)crti.o
135 $(objpfx
)libpthread.so
: +postinit
+= $(objpfx
)crtn.o
137 znodelete-yes
= -DHAVE_Z_NODELETE
138 CFLAGS-mutex.c
+= -D__NO_WEAK_PTHREAD_ALIASES
139 CFLAGS-specific.c
+= -D__NO_WEAK_PTHREAD_ALIASES
140 CFLAGS-pthread.c
+= -D__NO_WEAK_PTHREAD_ALIASES
$(znodelete-
$(have-z-nodelete
))
141 CFLAGS-ptfork.c
+= -D__NO_WEAK_PTHREAD_ALIASES
142 CFLAGS-cancel.c
+= -D__NO_WEAK_PTHREAD_ALIASES
-D_RPC_THREAD_SAFE_
143 CFLAGS-unload.c
+= -DPREFIX
=\"$(objpfx
)\"
144 CFLAGS-sighandler.c
+= $(exceptions
)
146 ifeq (yes
,$(versioning
))
147 -include $(common-objpfx
)tls.make
148 libc-ok-for-link
= $(use-thread
)
150 libc-ok-for-link
= yes
153 ifeq (no
,$(libc-ok-for-link
))
154 # These hacks are necessary to let us link against a libc.so that exports
155 # the symbols _errno, _h_errno, and _res. Those symbols are accessible
156 # in libc at runtime (dynamic linkable), but are not exported at link time
157 # so that applications cannot link against them. However, libpthread.so
158 # needs to link against them for its __errno_location et al functions to
159 # find the locations that libc's symbols resolve to. We cannot do this
160 # with aliases in libc.so(GLIBC_PRIVATE), because we need to refer to an
161 # executable's symbols when it defines them with copy relocs.
162 libc-link.so
= $(objpfx
)libc.so
164 $(objpfx
)libc_pic_lite.a
: $(common-objpfx
)libc_pic.a
166 $(AR
) d
$@T errno.os herrno.os res_libc.os
169 extra-objs
+= libc-tsd.os
170 $(objpfx
)libc_pic_lite.os
: $(objpfx
)libc_pic_lite.a
$(objpfx
)libc-tsd.os
171 $(LINK.o
) -nostdlib
-nostartfiles
-r
-o
$@ \
172 $(LDFLAGS-c_pic.os
) -Wl
,-d
-Wl
,--whole-archive
$^
174 # This trick leaves errno and h_errno undefined.
175 libc.so-no-z-defs
= yes
177 $(objpfx
)libc.so
: $(elfobjdir
)/soinit.os \
178 $(objpfx
)libc_pic_lite.os \
179 $(elfobjdir
)/sofini.os \
180 $(elfobjdir
)/interp.os
$(elfobjdir
)/ld.so
183 generated
+= libc_pic_lite.a libc_pic_lite.os libc.so
185 libc-link.so
= $(common-objpfx
)libc.so
188 # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
189 # This ensures they will load libc.so for needed symbols if loaded by
190 # a statically-linked program that hasn't already loaded it.
191 # Depend on ld.so too to get proper versions of ld.so symbols.
192 $(objpfx
)libpthread.so
: $(libc-link.so
) $(common-objpfx
)libc_nonshared.a \
193 $(if
$(filter yes
,$(elf
)), $(elfobjdir
)/ld.so
)
195 # Make sure we link with the thread library.
196 ifeq ($(build-shared
),yes
)
197 $(addprefix $(objpfx
), \
198 $(filter-out $(tests-static
) $(tests-reverse
) unload
, \
199 $(tests
) $(test-srcs
))): $(objpfx
)libpthread.so \
200 $(objpfx
)libpthread_nonshared.a
201 # $(objpfx)../libc.so is used instead of $(common-objpfx)libc.so,
202 # since otherwise libpthread.so comes before libc.so when linking.
203 $(addprefix $(objpfx
), $(tests-reverse
)): \
204 $(objpfx
)..
/libc.so
$(objpfx
)libpthread.so \
205 $(objpfx
)libpthread_nonshared.a
206 $(addprefix $(objpfx
),$(librt-tests
)): $(common-objpfx
)rt
/librt.so
207 $(objpfx
)unload
: $(common-objpfx
)dlfcn
/libdl.so
208 $(objpfx
)unload.out
: $(objpfx
)libpthread.so
$(objpfx
)libpthread_nonshared.a
210 $(addprefix $(objpfx
),$(tests
) $(test-srcs
)): $(objpfx
)libpthread.a
211 $(addprefix $(objpfx
),$(librt-tests
)): $(common-objpfx
)rt
/librt.a
213 ifeq ($(build-bounded
),yes
)
214 $(tests
:%=$(objpfx
)%-bp
): $(objpfx
)libpthread_b.a
215 $(librt-tests
:%=$(objpfx
)%-bp
): $(common-objpfx
)rt
/librt_b.a
218 ifeq ($(build-static
),yes
)
219 $(addprefix $(objpfx
), $(tests-static
)): $(objpfx
)libpthread.a
222 ifeq ($(build-shared
),yes
)
223 vpath pt-initfini.c
$(full_config_sysdirs
)
225 $(objpfx
)pt-initfini.s
: pt-initfini.c
226 $(compile.c
) -S
$(CFLAGS-pt-initfini.s
) -finhibit-size-directive \
227 $(patsubst -f
%,-fno-
%,$(exceptions
)) -o
$@
229 # We only have one kind of startup code files. Static binaries and
230 # shared libraries are build using the PIC version.
231 $(objpfx
)crti.S
: $(objpfx
)pt-initfini.s
232 sed
-n
-e
'1,/@HEADER_ENDS/p' \
233 -e
'/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
234 -e
'/@TRAILER_BEGINS/,$$p' $< > $@
235 $(objpfx
)crtn.S
: $(objpfx
)pt-initfini.s
236 sed
-n
-e
'1,/@HEADER_ENDS/p' \
237 -e
'/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
238 -e
'/@TRAILER_BEGINS/,$$p' $< > $@
240 $(objpfx
)defs.h
: $(objpfx
)pt-initfini.s
241 sed
-n
-e
'/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
242 $(AWK
) -f ..
/csu
/defs.awk
> $@
244 $(objpfx
)crti.o
: $(objpfx
)crti.S
$(objpfx
)defs.h
245 $(compile.S
) -g0
$(ASFLAGS-.os
) -o
$@
247 $(objpfx
)crtn.o
: $(objpfx
)crtn.S
$(objpfx
)defs.h
248 $(compile.S
) -g0
$(ASFLAGS-.os
) -o
$@
250 generated
+= crti.S crtn.S defs.h pt-initfini.s
253 ifeq (yes
,$(build-static-nss
))
254 otherlibs
+= $(nssobjdir
)/libnss_files.a
$(resolvobjdir
)/libnss_dns.a \
255 $(resolvobjdir
)/libresolv.a
258 ifeq (no
,$(cross-compiling
))
259 ifeq (yes
,$(build-shared
))
260 tests
: $(objpfx
)tst-signal.out
$(objpfx
)tst-cancel-wrappers.out
261 $(objpfx
)tst-signal.out
: tst-signal.sh
$(objpfx
)tst-signal
262 $(SHELL
) -e
$< $(common-objpfx
) > $@
263 $(objpfx
)tst-cancel-wrappers.out
: tst-cancel-wrappers.sh
264 $(SHELL
) $< $(common-objpfx
)/libc_pic.a \
265 $(common-objpfx
)/libc.a \
266 $(objpfx
)/libpthread_pic.a \
267 $(objpfx
)/libpthread.a
> $@