Makefile revision 1.95
1# $NetBSD: Makefile,v 1.95 2019/09/22 18:45:20 brad Exp $ 2# 3 4NOSANITIZER= # defined 5WARNS?= 5 6LIB= pthread 7 8.include <bsd.own.mk> 9 10USE_SHLIBDIR= yes 11 12.if defined(PTHREAD_MACHINE_ARCH) && !empty(PTHREAD_MACHINE_ARCH) && \ 13 exists(${.CURDIR}/arch/${PTHREAD_MACHINE_ARCH}) 14ARCHSUBDIR= ${PTHREAD_MACHINE_ARCH} 15.elif defined(PTHREAD_MACHINE_CPU) && !empty(PTHREAD_MACHINE_CPU) && \ 16 exists(${.CURDIR}/arch/${PTHREAD_MACHINE_CPU}) 17ARCHSUBDIR= ${PTHREAD_MACHINE_CPU} 18.elif exists(${.CURDIR}/arch/${MACHINE_ARCH}) 19ARCHSUBDIR= ${MACHINE_ARCH} 20.elif exists(${.CURDIR}/arch/${MACHINE_CPU}) 21ARCHSUBDIR= ${MACHINE_CPU} 22.else 23.BEGIN: 24 @echo "WARNING: no ARCHSUBDIR for ${MACHINE_ARCH}/${MACHINE_CPU}; skipping..." 25.endif 26 27INCS= pthread.h pthread_types.h pthread_queue.h 28INCSDIR=/usr/include 29 30.if defined(ARCHSUBDIR) 31 32ARCHDIR= ${.CURDIR}/arch/${ARCHSUBDIR} 33.PATH: ${ARCHDIR} 34 35CPPFLAGS+= -I${ARCHDIR} -I${.CURDIR} -I${.OBJDIR} -D_LIBC -D_REENTRANT 36CPPFLAGS+= -I${.CURDIR}/../libc/include 37CPPFLAGS+= -D__LIBPTHREAD_SOURCE__ -D__LIBC_THREAD_STUBS 38 39# XXX: This crappy poke at libc's internals needs to be fixed. 40CPPFLAGS+=-I${NETBSDSRCDIR}/sys -I${.CURDIR}/../libc 41 42# providing alternative MI implementations for creating an lwp is 43# possible by setting PTHREAD_MAKELWP. Currently, alternatives are 44# set by the rumprun software stacks (see repo.rumpkernel.org) 45PTHREAD_MAKELWP?= pthread_makelwp_netbsd.c 46 47# 48# NOTE: When you create a new file for libpthread, make sure that pthread.c 49# gets a reference to a symbol in that file. Otherwise, Unix's stupid static 50# library semantics will end up discarding potentially important objects. 51# 52SRCS= pthread.c 53SRCS+= pthread_attr.c 54SRCS+= pthread_barrier.c 55# used by rumprun-posix to work around symbol collisions 56.if ${PTHREAD_CANCELSTUB:Uyes} != "no" 57SRCS+= pthread_cancelstub.c 58.endif 59SRCS+= pthread_cond.c 60SRCS+= pthread_getcpuclockid.c 61SRCS+= pthread_lock.c 62SRCS+= ${PTHREAD_MAKELWP} 63SRCS+= pthread_misc.c 64SRCS+= pthread_mutex.c 65SRCS+= pthread_once.c 66SRCS+= pthread_rwlock.c 67SRCS+= pthread_specific.c 68SRCS+= pthread_spin.c 69SRCS+= pthread_tsd.c 70SRCS+= res_state.c 71.PATH: ${.CURDIR}/../librt 72SRCS+= sem.c 73# Architecture-dependent files 74.if exists(${ARCHDIR}/pthread_md.S) 75SRCS+= pthread_md.S 76.endif 77.if exists(${ARCHDIR}/Makefile.inc) 78.include "${ARCHDIR}/Makefile.inc" 79.endif 80 81# The PTHREAD__COMPAT flag builds a libpthread that can be dropped 82# into a NetBSD 2/3/4 chroot with a NetBSD 5 or later kernel. 83# This makes threading work in the chroot, no other modifications 84# required. 85# 86.if defined(PTHREAD__COMPAT) 87SRCS+= pthread_compat.c 88.PATH.c: ${.CURDIR}/../../common/lib/libc/arch/${ARCHSUBDIR}/atomic 89.PATH.S: ${.CURDIR}/../../common/lib/libc/arch/${ARCHSUBDIR}/atomic 90.PATH.c: ${.CURDIR}/../../common/lib/libc/atomic 91.PATH.c: ${.CURDIR}/../libc/misc 92.include "../../common/lib/libc/arch/${ARCHSUBDIR}/atomic/Makefile.inc" 93.endif 94 95ALIGN_FUNCTIONS= ${${ACTIVE_CC} == "gcc":? -falign-functions=32 :} 96 97# The TSD routines are used in the implementation of profiling, and so 98# can't be profiled themselves. 99COPTS.pthread_specific.c+= ${ALIGN_FUNCTIONS} 100pthread_specific.po: pthread_specific.o 101 ${_MKTARGET_CREATE} 102 cp pthread_specific.o pthread_specific.po 103 104COPTS.pthread.c += -Wno-stack-protector -Wno-format-nonliteral 105COPTS.pthread_attr.c += -Wno-format-nonliteral 106 107MAN+= affinity.3 pthread.3 \ 108 pthread_attr.3 \ 109 pthread_attr_get_np.3 \ 110 pthread_attr_getdetachstate.3 \ 111 pthread_attr_getguardsize.3 \ 112 pthread_attr_getinheritsched.3 \ 113 pthread_attr_getname_np.3 \ 114 pthread_attr_getschedparam.3 \ 115 pthread_attr_getscope.3 \ 116 pthread_attr_getstack.3 \ 117 pthread_attr_setcreatesuspend_np.3 \ 118 pthread_barrier.3 pthread_barrierattr.3 \ 119 pthread_cancel.3 pthread_cleanup_push.3 \ 120 pthread_cond.3 pthread_condattr.3 \ 121 pthread_create.3 pthread_detach.3 pthread_equal.3 \ 122 pthread_curcpu_np.3 \ 123 pthread_exit.3 \ 124 pthread_getcpuclockid.3 \ 125 pthread_getname_np.3 \ 126 pthread_getspecific.3 pthread_join.3 \ 127 pthread_key_create.3 pthread_kill.3 \ 128 pthread_mutex.3 pthread_mutexattr.3 \ 129 pthread_once.3 pthread_rwlock.3 pthread_rwlockattr.3 \ 130 pthread_schedparam.3 pthread_self.3 \ 131 pthread_sigmask.3 pthread_spin.3 \ 132 pthread_suspend_np.3 pthread_testcancel.3 133 134MLINKS+= pthread_attr_get_np.3 pthread_getattr_np.3 135MLINKS+= affinity.3 pthread_setaffinity_np.3 136MLINKS+= affinity.3 pthread_getaffinity_np.3 137 138MLINKS+= pthread_attr.3 pthread_attr_init.3 139MLINKS+= pthread_attr.3 pthread_attr_destroy.3 140 141MLINKS+= pthread_attr_getdetachstate.3 pthread_attr_setdetachstate.3 142MLINKS+= pthread_attr_getguardsize.3 pthread_attr_setguardsize.3 143MLINKS+= pthread_attr_getinheritsched.3 pthread_attr_setinheritsched.3 144MLINKS+= pthread_attr_getname_np.3 pthread_attr_setname_np.3 145 146MLINKS+= pthread_attr_getschedparam.3 pthread_attr_setschedparam.3 \ 147 pthread_attr_getschedparam.3 pthread_attr_getschedpolicy.3 \ 148 pthread_attr_getschedparam.3 pthread_attr_setschedpolicy.3 149 150MLINKS+= pthread_attr_getscope.3 pthread_attr_setscope.3 151 152MLINKS+= pthread_attr_getstack.3 pthread_attr_setstack.3 \ 153 pthread_attr_getstack.3 pthread_attr_getstacksize.3 \ 154 pthread_attr_getstack.3 pthread_attr_setstacksize.3 \ 155 pthread_attr_getstack.3 pthread_attr_getstackaddr.3 \ 156 pthread_attr_getstack.3 pthread_attr_setstackaddr.3 157 158MLINKS+= pthread_cleanup_push.3 pthread_cleanup_pop.3 159 160MLINKS+= pthread_barrier.3 pthread_barrier_init.3 161MLINKS+= pthread_barrier.3 pthread_barrier_destroy.3 162MLINKS+= pthread_barrier.3 pthread_barrier_wait.3 163 164MLINKS+= pthread_barrierattr.3 pthread_barrierattr_init.3 165MLINKS+= pthread_barrierattr.3 pthread_barrierattr_destroy.3 166MLINKS+= pthread_barrierattr.3 pthread_barrierattr_getpshared.3 167MLINKS+= pthread_barrierattr.3 pthread_barrierattr_setpshared.3 168 169MLINKS+= pthread_cond.3 pthread_cond_init.3 170MLINKS+= pthread_cond.3 pthread_cond_destroy.3 171MLINKS+= pthread_cond.3 pthread_cond_broadcast.3 172MLINKS+= pthread_cond.3 pthread_cond_wait.3 173MLINKS+= pthread_cond.3 pthread_cond_signal.3 174MLINKS+= pthread_cond.3 pthread_cond_timedwait.3 175 176MLINKS+= pthread_condattr.3 pthread_condattr_init.3 177MLINKS+= pthread_condattr.3 pthread_condattr_destroy.3 178MLINKS+= pthread_condattr.3 pthread_condattr_setclock.3 179MLINKS+= pthread_condattr.3 pthread_condattr_getclock.3 180MLINKS+= pthread_condattr.3 pthread_condattr_getpshared.3 181MLINKS+= pthread_condattr.3 pthread_condattr_setpshared.3 182 183MLINKS+= pthread_getname_np.3 pthread_setname_np.3 184MLINKS+= pthread_getspecific.3 pthread_setspecific.3 185MLINKS+= pthread_key_create.3 pthread_key_delete.3 186 187MLINKS+= pthread_mutex.3 pthread_mutex_init.3 188MLINKS+= pthread_mutex.3 pthread_mutex_destroy.3 189MLINKS+= pthread_mutex.3 pthread_mutex_lock.3 190MLINKS+= pthread_mutex.3 pthread_mutex_trylock.3 191MLINKS+= pthread_mutex.3 pthread_mutex_unlock.3 192MLINKS+= pthread_mutex.3 pthread_mutex_timedlock.3 193MLINKS+= pthread_mutex.3 pthread_mutex_getprioceiling.3 194MLINKS+= pthread_mutex.3 pthread_mutex_setprioceiling.3 195 196MLINKS+= pthread_mutexattr.3 pthread_mutexattr_init.3 197MLINKS+= pthread_mutexattr.3 pthread_mutexattr_destroy.3 198MLINKS+= pthread_mutexattr.3 pthread_mutexattr_getpshared.3 199MLINKS+= pthread_mutexattr.3 pthread_mutexattr_setpshared.3 200MLINKS+= pthread_mutexattr.3 pthread_mutexattr_settype.3 201MLINKS+= pthread_mutexattr.3 pthread_mutexattr_gettype.3 202MLINKS+= pthread_mutexattr.3 pthread_mutexattr_getprotocol.3 203MLINKS+= pthread_mutexattr.3 pthread_mutexattr_setprotocol.3 204MLINKS+= pthread_mutexattr.3 pthread_mutexattr_getprioceiling.3 205MLINKS+= pthread_mutexattr.3 pthread_mutexattr_setprioceiling.3 206 207MLINKS+= pthread_rwlock.3 pthread_rwlock_init.3 208MLINKS+= pthread_rwlock.3 pthread_rwlock_destroy.3 209MLINKS+= pthread_rwlock.3 pthread_rwlock_rdlock.3 210MLINKS+= pthread_rwlock.3 pthread_rwlock_wrlock.3 211MLINKS+= pthread_rwlock.3 pthread_rwlock_unlock.3 212 213MLINKS+= pthread_rwlock.3 pthread_rwlock_timedrdlock.3 214MLINKS+= pthread_rwlock.3 pthread_rwlock_timedwrlock.3 215MLINKS+= pthread_rwlock.3 pthread_rwlock_tryrdlock.3 216MLINKS+= pthread_rwlock.3 pthread_rwlock_trywrlock.3 217 218MLINKS+= pthread_rwlockattr.3 pthread_rwlockattr_init.3 219MLINKS+= pthread_rwlockattr.3 pthread_rwlockattr_destroy.3 220MLINKS+= pthread_rwlockattr.3 pthread_rwlockattr_getpshared.3 221MLINKS+= pthread_rwlockattr.3 pthread_rwlockattr_setpshared.3 222 223MLINKS+= pthread_spin.3 pthread_spin_init.3 224MLINKS+= pthread_spin.3 pthread_spin_destroy.3 225MLINKS+= pthread_spin.3 pthread_spin_lock.3 226MLINKS+= pthread_spin.3 pthread_spin_trylock.3 227MLINKS+= pthread_spin.3 pthread_spin_unlock.3 228 229MLINKS+= pthread_schedparam.3 pthread_setschedparam.3 230MLINKS+= pthread_schedparam.3 pthread_getschedparam.3 231MLINKS+= pthread_suspend_np.3 pthread_resume_np.3 232MLINKS+= pthread_testcancel.3 pthread_setcancelstate.3 233MLINKS+= pthread_testcancel.3 pthread_setcanceltype.3 234 235# ISO C threads (ISO/IEC 9899:2011) 236 237SRCS+= call_once.c cnd.c mtx.c thrd.c tss.c 238MAN+= threads.3 call_once.3 cnd.3 mtx.3 thrd.3 tss.3 239 240MLINKS+= call_once.3 ONCE_FLAG_INIT.3 241MLINKS+= call_once.3 once_flag.3 242 243MLINKS+= cnd.3 cnd_broadcast.3 244MLINKS+= cnd.3 cnd_destroy.3 245MLINKS+= cnd.3 cnd_init.3 246MLINKS+= cnd.3 cnd_signal.3 247MLINKS+= cnd.3 cnd_timedwait.3 248MLINKS+= cnd.3 cnd_wait.3 249 250MLINKS+= mtx.3 mtx_destroy.3 251MLINKS+= mtx.3 mtx_init.3 252MLINKS+= mtx.3 mtx_lock.3 253MLINKS+= mtx.3 mtx_timedlock.3 254MLINKS+= mtx.3 mtx_trylock.3 255MLINKS+= mtx.3 mtx_unlock.3 256 257MLINKS+= thrd.3 thrd_create.3 258MLINKS+= thrd.3 thrd_current.3 259MLINKS+= thrd.3 thrd_detach.3 260MLINKS+= thrd.3 thrd_equal.3 261MLINKS+= thrd.3 thrd_exit.3 262MLINKS+= thrd.3 thrd_join.3 263MLINKS+= thrd.3 thrd_sleep.3 264MLINKS+= thrd.3 thrd_yield.3 265 266MLINKS+= tss.3 TSS_DTOR_ITERATIONS.3 267MLINKS+= tss.3 tss_create.3 268MLINKS+= tss.3 tss_delete.3 269MLINKS+= tss.3 tss_get.3 270MLINKS+= tss.3 tss_set.3 271 272INCS+= threads.h 273 274# PR lib/54001: create libpthread.a as a single large object, with all the 275# symbols in one section. ensures that if any libpthread function is used, 276# you get all of them from libpthread, and not the libc stubs. 277# 278# This makes -lpthread equivalent to -Wl,--whole-archive -lpthread 279 280__archivebuild: .USE 281 ${_MKTARGET_BUILD} 282 @rm -f ${.TARGET} 283 ${LD} -r -o ${.TARGET}.o `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}` 284 ${AR} ${_ARFL} ${.TARGET} ${.TARGET}.o 285 286CLEANFILES+= ${_LIBS:=.o} 287 288.include <bsd.lib.mk> 289 290.else 291 292.include <bsd.man.mk> 293.include <bsd.files.mk> 294.include <bsd.inc.mk> 295 296.endif 297 298# WARNS=2 sets -Wcast-qual. This causes problems for one of 299# pthread_setspecific() and pthread_getspecific(), since the constness 300# of the argument to setspecific() has to be discarded *somewhere* 301# before returning it from getspecific(). 302CWARNFLAGS+= -Wno-cast-qual 303