semtimedop implementation for Linux/m68k.
[glibc.git] / linuxthreads / Makefile
blobd832074432ab7bdda74866998ab98afc96170685
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
17 # 02111-1307 USA.
20 # Sub-makefile for linuxthreads portion of the library.
22 subdir := linuxthreads
24 linuxthreads-version := $(shell sed -n 's/^.*$(subdir)-\([0-9.]*\).*$$/\1/p' \
25 Banner)
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)
36 install-lib-ldscripts := libpthread.so
38 libpthread-routines := attr cancel condvar join manager mutex ptfork \
39 ptlongjmp pthread pt-sigsuspend signals specific errno \
40 lockfile semaphore spinlock rwlock pt-machine \
41 oldsemaphore events getcpuclockid pspinlock barrier \
42 ptclock_gettime ptclock_settime sighandler \
43 pthandles libc-tls-loc pt-allocrtsig \
44 ptw-write ptw-read ptw-close ptw-fcntl ptw-accept \
45 ptw-connect ptw-recv ptw-recvfrom ptw-recvmsg \
46 ptw-send ptw-sendmsg ptw-sendto ptw-fsync ptw-lseek \
47 ptw-lseek64 ptw-llseek ptw-msync ptw-nanosleep \
48 ptw-open ptw-open64 ptw-pause ptw-pread ptw-pread64 \
49 ptw-pwrite ptw-pwrite64 ptw-tcdrain ptw-wait \
50 ptw-waitpid pt-system old_pthread_atfork pthread_atfork
51 # Don't generate deps for calls with no sources. See sysdeps/unix/Makefile.
52 omit-deps = $(unix-syscalls:%=ptw-%)
54 libpthread-shared-only-routines = pt-allocrtsig
55 libpthread-static-only-routines = pthread_atfork
57 libpthread-nonshared = pthread_atfork
59 CFLAGS-pthread_atfork.c = -DNOT_IN_libc
61 nodelete-yes = -Wl,--enable-new-dtags,-z,nodelete
62 initfirst-yes = -Wl,--enable-new-dtags,-z,initfirst
63 LDFLAGS-pthread.so = $(nodelete-$(have-z-nodelete)) \
64 $(initfirst-$(have-z-initfirst))
66 vpath %.c Examples
68 tst-cancel-ARGS = "$(objpfx)"
69 CFLAGS-tst-cancel.c = -fno-inline -fno-inline-functions
71 include ../Makeconfig
73 ifeq ($(build-shared),yes)
74 others: $(objpfx)libpthread_nonshared.a
75 endif
77 $(objpfx)libpthread_nonshared.a: $(addprefix $(objpfx),$(addsuffix .os,$(libpthread-nonshared)))
78 $(AR) $(ARFLAGS) $@ $^
80 ifeq ($(build-shared),yes)
82 # Set the `multidir' variable by grabbing the variable from the compiler.
83 # We do it once and save the result in a generated makefile.
84 -include $(objpfx)multidir.mk
85 $(objpfx)multidir.mk: $(common-objpfx)config.make
86 dir=`$(CC) $(CFLAGS) $(CPPFLAGS) -print-multi-directory`; \
87 echo "multidir := $$dir" > $@T
88 mv -f $@T $@
89 generated += multidir.mk
91 crti-objs := crti.o
92 crtn-objs := crtn.o
93 ifneq (,$(patsubst .,,$(multidir)))
94 generated-dirs := $(firstword $(subst /, , $(multidir)))
95 crti-objs += $(multidir)/crti.o
96 crtn-objs += $(multidir)/crtn.o
97 omit-deps += $(multidir)/crti $(multidir)/crtn
98 endif
99 extra-objs += $(crti-objs) $(crtn-objs)
100 omit-deps += crti crtn
102 CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions
103 endif
105 librt-tests = ex10 ex11
106 tests = ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 $(librt-tests) ex12 ex13 joinrace \
107 tststack $(tests-nodelete-$(have-z-nodelete)) ecmutex ex14 ex15 ex16 \
108 ex17 ex18 tst-cancel tst-context bug-sleep \
109 tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel4 tst-cancel5 \
110 tst-cancel6 tst-cancel7 tst-popen tst-popen2
111 test-srcs = tst-signal
112 # These tests are linked with libc before libpthread
113 tests-reverse += tst-cancel5
115 ifeq ($(build-static),yes)
116 tests += tststatic tst-static-locale tst-cancel-static
117 tests-static += tststatic tst-static-locale tst-cancel-static
118 endif
120 ifeq (yes,$(build-shared))
121 tests-nodelete-yes = unload
122 endif
124 include ../Rules
126 # What we install as libpthread.so for programs to link against is in fact a
127 # link script. It contains references for the various libraries we need.
128 # The libpthread.so object is not complete since some functions are only defined
129 # in libpthread_nonshared.a.
130 # We need to use absolute paths since otherwise local copies (if they exist)
131 # of the files are taken by the linker.
132 install: $(inst_libdir)/libpthread.so
133 $(inst_libdir)/libpthread.so: $(common-objpfx)format.lds \
134 $(objpfx)libpthread.so$(libpthread.so-version) \
135 $(inst_libdir)/$(patsubst %,$(libtype.oS),\
136 $(libprefix)pthread) \
137 $(+force)
138 (echo '/* GNU ld script';\
139 echo ' Use the shared library, but some functions are only in';\
140 echo ' the static library, so try that secondarily. */';\
141 cat $<; \
142 echo 'GROUP ( $(slibdir)/libpthread.so$(libpthread.so-version)' \
143 '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)pthread)'\
144 ')' \
145 ) > $@.new
146 mv -f $@.new $@
147 $(inst_libdir)/libpthread_nonshared.a: $(objpfx)libpthread_nonshared.a
148 $(do-install)
151 extra-B-pthread.so = -B$(common-objpfx)linuxthreads/
152 $(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs))
153 $(objpfx)libpthread.so: +preinit += $(addprefix $(objpfx),$(crti-objs))
154 $(objpfx)libpthread.so: +postinit += $(addprefix $(objpfx),$(crtn-objs))
156 znodelete-yes = -DHAVE_Z_NODELETE
157 CFLAGS-mutex.c += -D__NO_WEAK_PTHREAD_ALIASES
158 CFLAGS-specific.c += -D__NO_WEAK_PTHREAD_ALIASES
159 CFLAGS-pthread.c += -D__NO_WEAK_PTHREAD_ALIASES $(znodelete-$(have-z-nodelete))
160 CFLAGS-ptfork.c += -D__NO_WEAK_PTHREAD_ALIASES
161 CFLAGS-cancel.c += -D__NO_WEAK_PTHREAD_ALIASES -D_RPC_THREAD_SAFE_
162 CFLAGS-unload.c += -DPREFIX=\"$(objpfx)\"
163 CFLAGS-sighandler.c += $(exceptions)
165 ifeq (yes,$(versioning))
166 -include $(common-objpfx)tls.make
167 libc-ok-for-link = $(use-thread)
168 else
169 libc-ok-for-link = yes
170 endif
172 ifeq (no,$(libc-ok-for-link))
173 # These hacks are necessary to let us link against a libc.so that exports
174 # the symbols _errno, _h_errno, and _res. Those symbols are accessible
175 # in libc at runtime (dynamic linkable), but are not exported at link time
176 # so that applications cannot link against them. However, libpthread.so
177 # needs to link against them for its __errno_location et al functions to
178 # find the locations that libc's symbols resolve to. We cannot do this
179 # with aliases in libc.so(GLIBC_PRIVATE), because we need to refer to an
180 # executable's symbols when it defines them with copy relocs.
181 libc-link.so = $(objpfx)libc.so
183 $(objpfx)libc_pic_lite.a: $(common-objpfx)libc_pic.a
184 cp $< $@T
185 $(AR) d $@T errno.os herrno.os res_libc.os
186 mv -f $@T $@
188 extra-objs += libc-tsd.os
189 $(objpfx)libc_pic_lite.os: $(objpfx)libc_pic_lite.a $(objpfx)libc-tsd.os
190 $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
191 $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
193 # This trick leaves errno and h_errno undefined.
194 libc.so-no-z-defs = yes
196 $(objpfx)libc.so: $(elfobjdir)/soinit.os \
197 $(objpfx)libc_pic_lite.os \
198 $(elfobjdir)/sofini.os \
199 $(elfobjdir)/interp.os $(elfobjdir)/ld.so
200 $(build-shlib)
202 generated += libc_pic_lite.a libc_pic_lite.os libc.so
203 else
204 libc-link.so = $(common-objpfx)libc.so
205 endif
207 # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
208 # This ensures they will load libc.so for needed symbols if loaded by
209 # a statically-linked program that hasn't already loaded it.
210 # Depend on ld.so too to get proper versions of ld.so symbols.
211 $(objpfx)libpthread.so: $(libc-link.so) $(common-objpfx)libc_nonshared.a \
212 $(if $(filter yes,$(elf)), $(elfobjdir)/ld.so)
214 # Make sure we link with the thread library.
215 ifeq ($(build-shared),yes)
216 $(addprefix $(objpfx), \
217 $(filter-out $(tests-static) $(tests-reverse) unload, \
218 $(tests) $(test-srcs))): $(objpfx)libpthread.so \
219 $(objpfx)libpthread_nonshared.a
220 # $(objpfx)../libc.so is used instead of $(common-objpfx)libc.so,
221 # since otherwise libpthread.so comes before libc.so when linking.
222 $(addprefix $(objpfx), $(tests-reverse)): \
223 $(objpfx)../libc.so $(objpfx)libpthread.so \
224 $(objpfx)libpthread_nonshared.a
225 $(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.so
226 $(objpfx)unload: $(common-objpfx)dlfcn/libdl.so
227 $(objpfx)unload.out: $(objpfx)libpthread.so $(objpfx)libpthread_nonshared.a
228 else
229 $(addprefix $(objpfx),$(tests) $(test-srcs)): $(objpfx)libpthread.a
230 $(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.a
231 endif
232 ifeq ($(build-bounded),yes)
233 $(tests:%=$(objpfx)%-bp): $(objpfx)libpthread_b.a
234 $(librt-tests:%=$(objpfx)%-bp): $(common-objpfx)rt/librt_b.a
235 endif
237 ifeq ($(build-static),yes)
238 $(addprefix $(objpfx), $(tests-static)): $(objpfx)libpthread.a
239 endif
241 ifeq ($(build-shared),yes)
242 vpath pt-initfini.c $(full_config_sysdirs)
244 $(objpfx)pt-initfini.s: pt-initfini.c
245 $(compile.c) -S $(CFLAGS-pt-initfini.s) -finhibit-size-directive \
246 $(patsubst -f%,-fno-%,$(exceptions)) -o $@
248 # We only have one kind of startup code files. Static binaries and
249 # shared libraries are build using the PIC version.
250 $(objpfx)crti.S: $(objpfx)pt-initfini.s
251 sed -n -e '1,/@HEADER_ENDS/p' \
252 -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
253 -e '/@TRAILER_BEGINS/,$$p' $< > $@
254 $(objpfx)crtn.S: $(objpfx)pt-initfini.s
255 sed -n -e '1,/@HEADER_ENDS/p' \
256 -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
257 -e '/@TRAILER_BEGINS/,$$p' $< > $@
259 $(objpfx)defs.h: $(objpfx)pt-initfini.s
260 sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
261 $(AWK) -f ../csu/defs.awk > $@
263 $(objpfx)crti.o: $(objpfx)crti.S $(objpfx)defs.h
264 $(compile.S) -g0 $(ASFLAGS-.os) -o $@
266 $(objpfx)crtn.o: $(objpfx)crtn.S $(objpfx)defs.h
267 $(compile.S) -g0 $(ASFLAGS-.os) -o $@
269 ifneq ($(multidir),.)
270 $(objpfx)$(multidir):
271 @mkdir -p $(objpfx)$(multidir)
273 $(objpfx)$(multidir)/crti.o: $(objpfx)crti.o $(objpfx)$(multidir)
274 ln -f $< $@
276 $(objpfx)$(multidir)/crtn.o: $(objpfx)crtn.o $(objpfx)$(multidir)
277 ln -f $< $@
278 endif
280 generated += crti.S crtn.S defs.h pt-initfini.s
281 endif
283 ifeq (yes,$(build-static-nss))
284 otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
285 $(resolvobjdir)/libresolv.a
286 endif
288 ifeq (no,$(cross-compiling))
289 ifeq (yes,$(build-shared))
290 tests: $(objpfx)tst-signal.out $(objpfx)tst-cancel-wrappers.out
291 $(objpfx)tst-signal.out: tst-signal.sh $(objpfx)tst-signal
292 $(SHELL) -e $< $(common-objpfx) > $@
293 $(objpfx)tst-cancel-wrappers.out: tst-cancel-wrappers.sh
294 $(SHELL) $< $(common-objpfx)/libc_pic.a \
295 $(common-objpfx)/libc.a \
296 $(objpfx)/libpthread_pic.a \
297 $(objpfx)/libpthread.a > $@
298 endif
299 endif