xref: /freebsd/lib/libthr/Makefile (revision 1edb7116)
1#
2# All library objects contain FreeBSD revision strings by default; they may be
3# excluded as a space-saving measure.  To produce a library that does
4# not contain these strings, add -DSTRIP_FBSDID (see <sys/cdefs.h>) to CFLAGS
5# below.
6
7PACKAGE=	clibs
8SHLIBDIR?= /lib
9
10LIBADD=	c sys
11.if defined(COMPAT_libcompat)
12# XXX: work around gcc -m32 + bfd ld path issue for DT_NEEDED symbols.
13# https://sourceware.org/bugzilla/show_bug.cgi?id=31395
14LDFLAGS+=	-Wl,--rpath=/usr/lib${COMPAT_libcompat}
15.endif
16
17.include <src.opts.mk>
18MK_SSP=	no
19
20LIB=thr
21SHLIB_MAJOR= 3
22
23NO_WTHREAD_SAFETY=1
24NO_WCAST_ALIGN.gcc=1    # for gcc 4.2
25CFLAGS+=-DPTHREAD_KERNEL
26CFLAGS+=-I${SRCTOP}/lib/libc/include
27CFLAGS+=-I${SRCTOP}/lib/libc/${MACHINE_CPUARCH}
28CFLAGS+=-I${.CURDIR}/thread
29CFLAGS+=-I${.CURDIR}/arch/${MACHINE_CPUARCH}/include
30CFLAGS+=-I${.CURDIR}/sys
31CFLAGS+=-I${SRCTOP}/libexec/rtld-elf
32CFLAGS+=-I${SRCTOP}/libexec/rtld-elf/${MACHINE_CPUARCH}
33CFLAGS+=-I${SRCTOP}/lib/libthread_db
34
35CFLAGS.thr_stack.c+=	-Wno-cast-align
36CFLAGS.rtld_malloc.c+=	-Wno-cast-align
37CFLAGS.thr_symbols.c+=	-Wno-missing-variable-declarations
38.if ${MK_ASAN} != "no"
39# False-positive ASAN error claiming the local "struct sigaction act;" is
40# overflowed by handle_signal() reading from the ucontext_t argument. This
41# could be caused by ASAN not treating this function as a signal handler.
42CFLAGS.thr_sig.c+=	-fno-sanitize=address
43.endif
44
45.if ${MACHINE_CPUARCH} == "arm"
46NO_THREAD_UNWIND_STACK= yes
47.endif
48
49.ifndef NO_THREAD_UNWIND_STACK
50CFLAGS+=-fexceptions
51CFLAGS+=-D_PTHREAD_FORCED_UNWIND
52.endif
53
54LDFLAGS+=-Wl,-znodelete
55LDFLAGS+=-Wl,--auxiliary,libsys.so.7
56
57VERSION_DEF=${SRCTOP}/lib/libc/Versions.def
58SYMBOL_MAPS=${.CURDIR}/pthread.map
59
60MAN=	libthr.3
61
62.if ${MK_PTHREADS_ASSERTIONS} != "no"
63# enable extra internal consistency checks
64CFLAGS+=-D_PTHREADS_INVARIANTS
65.endif
66
67PRECIOUSLIB=
68
69.PATH: ${.CURDIR}/arch/${MACHINE_CPUARCH}/${MACHINE_CPUARCH}
70.PATH: ${SRCTOP}/libexec/rtld-elf
71
72.if exists(${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc)
73.include "${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc"
74.endif
75.include "${.CURDIR}/sys/Makefile.inc"
76.include "${.CURDIR}/thread/Makefile.inc"
77SRCS+= rtld_malloc.c
78
79LIBSYS_SRCTOP=	${.CURDIR:H}/libsys
80.if exists(${LIBSYS_SRCTOP}/${MACHINE_CPUARCH}/_umtx_op_err.S)
81.PATH: ${LIBSYS_SRCTOP}/${MACHINE_CPUARCH}
82.else
83.PATH: ${LIBSYS_SRCTOP}
84.endif
85OBJS+=	_umtx_op_err.o
86
87.if ${MK_INSTALLLIB} != "no"
88SYMLINKS+=lib${LIB}.a ${LIBDIR}/libpthread.a
89.endif
90.if !defined(NO_PIC)
91SYMLINKS+=lib${LIB}.so ${LIBDIR}/libpthread.so
92.endif
93.if ${MK_PROFILE} != "no"
94SYMLINKS+=lib${LIB}_p.a ${LIBDIR}/libpthread_p.a
95.endif
96
97HAS_TESTS=
98SUBDIR.${MK_TESTS}+= tests
99
100.include <bsd.lib.mk>
101