* sysdeps/unix/sysv/linux/m68k/sysdep.h: Support inline syscall
[glibc.git] / linuxthreads / Makefile
blobfca0137571b90fc0a30adcaa5af2ade72ab09f8f
1 # Copyright (C) 1996-2001, 2002 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 libc-tsd.c
31 routines := weaks no-tsd
32 shared-only-routines = weaks
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 wrapsyscall rwlock pt-machine \
40 oldsemaphore events getcpuclockid pspinlock barrier \
41 ptclock_gettime ptclock_settime sighandler \
42 pthandles libc-tls-loc
44 nodelete-yes = -Wl,--enable-new-dtags,-z,nodelete
45 initfirst-yes = -Wl,--enable-new-dtags,-z,initfirst
46 LDFLAGS-pthread.so = $(nodelete-$(have-z-nodelete)) \
47 $(initfirst-$(have-z-initfirst))
49 vpath %.c Examples
51 tst-cancel-ARGS = "$(objpfx)"
52 CFLAGS-tst-cancel.c = -fno-inline -fno-inline-functions
54 include ../Makeconfig
56 ifeq ($(build-shared),yes)
57 extra-objs += crti.o crtn.o
58 omit-deps += crti crtn
60 CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions
61 endif
63 librt-tests = ex10 ex11
64 tests = ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 $(librt-tests) ex12 ex13 joinrace \
65 tststack $(tests-nodelete-$(have-z-nodelete)) ecmutex ex14 ex15 ex16 \
66 ex17 ex18 tst-cancel tst-context bug-sleep
67 test-srcs = tst-signal
69 ifeq ($(build-static),yes)
70 tests += tststatic tst-static-locale
71 tests-static += tststatic tst-static-locale
72 endif
74 ifeq (yes,$(build-shared))
75 tests-nodelete-yes = unload
76 endif
78 include ../Rules
80 extra-B-pthread.so = -B$(common-objpfx)linuxthreads/
81 $(objpfx)libpthread.so: $(objpfx)crti.o $(objpfx)crtn.o
82 $(objpfx)libpthread.so: +preinit += $(objpfx)crti.o
83 $(objpfx)libpthread.so: +postinit += $(objpfx)crtn.o
85 znodelete-yes = -DHAVE_Z_NODELETE
86 CFLAGS-mutex.c += -D__NO_WEAK_PTHREAD_ALIASES
87 CFLAGS-specific.c += -D__NO_WEAK_PTHREAD_ALIASES
88 CFLAGS-pthread.c += -D__NO_WEAK_PTHREAD_ALIASES $(znodelete-$(have-z-nodelete))
89 CFLAGS-ptfork.c += -D__NO_WEAK_PTHREAD_ALIASES
90 CFLAGS-cancel.c += -D__NO_WEAK_PTHREAD_ALIASES -D_RPC_THREAD_SAFE_
91 CFLAGS-unload.c += -DPREFIX=\"$(objpfx)\"
92 CFLAGS-sighandler.c += $(exceptions)
94 ifeq (yes,$(versioning))
95 -include $(common-objpfx)tls.make
96 libc-ok-for-link = $(use-thread)
97 else
98 libc-ok-for-link = yes
99 endif
101 ifeq (no,$(libc-ok-for-link))
102 # These hacks are necessary to let us link against a libc.so that exports
103 # the symbols _errno, _h_errno, and _res. Those symbols are accessible
104 # in libc at runtime (dynamic linkable), but are not exported at link time
105 # so that applications cannot link against them. However, libpthread.so
106 # needs to link against them for its __errno_location et al functions to
107 # find the locations that libc's symbols resolve to. We cannot do this
108 # with aliases in libc.so(GLIBC_PRIVATE), because we need to refer to an
109 # executable's symbols when it defines them with copy relocs.
110 libc-link.so = $(objpfx)libc.so
112 $(objpfx)libc_pic_lite.a: $(common-objpfx)libc_pic.a
113 cp $< $@T
114 $(AR) d $@T errno.os herrno.os res_libc.os
115 mv -f $@T $@
117 extra-objs += libc-tsd.os
118 $(objpfx)libc_pic_lite.os: $(objpfx)libc_pic_lite.a $(objpfx)libc-tsd.os
119 $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
120 $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
122 $(objpfx)libc.so: $(elfobjdir)/soinit.os \
123 $(objpfx)libc_pic_lite.os \
124 $(elfobjdir)/sofini.os \
125 $(elfobjdir)/interp.os $(elfobjdir)/ld.so
126 $(build-shlib)
128 generated += libc_pic_lite.a libc_pic_lite.os libc.so
129 else
130 libc-link.so = $(common-objpfx)libc.so
131 endif
133 # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
134 # This ensures they will load libc.so for needed symbols if loaded by
135 # a statically-linked program that hasn't already loaded it.
136 $(objpfx)libpthread.so: $(libc-link.so) $(common-objpfx)libc_nonshared.a
138 # Make sure we link with the thread library.
139 ifeq ($(build-shared),yes)
140 $(addprefix $(objpfx), \
141 $(filter-out $(tests-static) unload, \
142 $(tests) $(test-srcs))): $(objpfx)libpthread.so
143 $(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.so
144 $(objpfx)unload: $(common-objpfx)dlfcn/libdl.so
145 $(objpfx)unload.out: $(objpfx)libpthread.so
146 else
147 $(addprefix $(objpfx),$(tests) $(test-srcs)): $(objpfx)libpthread.a
148 $(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.a
149 endif
150 ifeq ($(build-bounded),yes)
151 $(tests:%=$(objpfx)%-bp): $(objpfx)libpthread_b.a
152 $(librt-tests:%=$(objpfx)%-bp): $(common-objpfx)rt/librt_b.a
153 endif
155 ifeq ($(build-static),yes)
156 $(addprefix $(objpfx), $(tests-static)): $(objpfx)libpthread.a
157 endif
159 ifeq ($(build-shared),yes)
160 vpath pt-initfini.c $(full_config_sysdirs)
162 $(objpfx)pt-initfini.s: pt-initfini.c
163 $(compile.c) -S $(CFLAGS-pt-initfini.s) -finhibit-size-directive \
164 $(patsubst -f%,-fno-%,$(exceptions)) -o $@
166 # We only have one kind of startup code files. Static binaries and
167 # shared libraries are build using the PIC version.
168 $(objpfx)crti.S: $(objpfx)pt-initfini.s
169 sed -n -e '1,/@HEADER_ENDS/p' \
170 -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
171 -e '/@TRAILER_BEGINS/,$$p' $< > $@
172 $(objpfx)crtn.S: $(objpfx)pt-initfini.s
173 sed -n -e '1,/@HEADER_ENDS/p' \
174 -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
175 -e '/@TRAILER_BEGINS/,$$p' $< > $@
177 $(objpfx)defs.h: $(objpfx)pt-initfini.s
178 sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
179 $(AWK) -f ../csu/defs.awk > $@
181 $(objpfx)crti.o: $(objpfx)crti.S $(objpfx)defs.h
182 $(compile.S) -g0 $(ASFLAGS-.os) -o $@
184 $(objpfx)crtn.o: $(objpfx)crtn.S $(objpfx)defs.h
185 $(compile.S) -g0 $(ASFLAGS-.os) -o $@
187 generated += crti.S crtn.S defs.h pt-initfini.s
188 endif
190 ifeq (yes,$(build-static-nss))
191 otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
192 $(resolvobjdir)/libresolv.a
193 endif
195 ifeq (no,$(cross-compiling))
196 ifeq (yes,$(build-shared))
197 tests: $(objpfx)tst-signal.out
198 $(objpfx)tst-signal.out: tst-signal.sh $(objpfx)tst-signal
199 $(SHELL) -e $< $(common-objpfx) > $@
200 endif
201 endif