Makefile revision 1.94
11.94Smaya#	$NetBSD: Makefile,v 1.94 2019/05/07 18:45:37 maya Exp $
21.9Sthorpej#
31.9Sthorpej
41.90SchristosNOSANITIZER=	# defined
51.75SmattWARNS?=	5
61.85SpookaLIB=	pthread
71.24Scl
81.9Sthorpej.include <bsd.own.mk>
91.9Sthorpej
101.55Smrg.if defined(PTHREAD_MACHINE_ARCH) && !empty(PTHREAD_MACHINE_ARCH) && \
111.55Smrg    exists(${.CURDIR}/arch/${PTHREAD_MACHINE_ARCH})
121.55SmrgARCHSUBDIR=	${PTHREAD_MACHINE_ARCH}
131.84Smatt.elif defined(PTHREAD_MACHINE_CPU) && !empty(PTHREAD_MACHINE_CPU) && \
141.84Smatt    exists(${.CURDIR}/arch/${PTHREAD_MACHINE_CPU})
151.84SmattARCHSUBDIR=	${PTHREAD_MACHINE_CPU}
161.55Smrg.elif exists(${.CURDIR}/arch/${MACHINE_ARCH})
171.9SthorpejARCHSUBDIR=	${MACHINE_ARCH}
181.9Sthorpej.elif exists(${.CURDIR}/arch/${MACHINE_CPU}) 
191.9SthorpejARCHSUBDIR=	${MACHINE_CPU}
201.9Sthorpej.else
211.9Sthorpej.BEGIN:
221.10Sthorpej	@echo "WARNING: no ARCHSUBDIR for ${MACHINE_ARCH}/${MACHINE_CPU}; skipping..."
231.9Sthorpej.endif
241.9Sthorpej
251.10SthorpejINCS=	pthread.h pthread_types.h pthread_queue.h
261.10SthorpejINCSDIR=/usr/include
271.10Sthorpej
281.9Sthorpej.if defined(ARCHSUBDIR)
291.9Sthorpej
301.9SthorpejARCHDIR=	${.CURDIR}/arch/${ARCHSUBDIR}
311.9Sthorpej.PATH:	${ARCHDIR}
321.9Sthorpej
331.80SchristosCPPFLAGS+=	-I${ARCHDIR} -I${.CURDIR} -I${.OBJDIR} -D_LIBC -D_REENTRANT
341.80SchristosCPPFLAGS+=	-I${.CURDIR}/../libc/include
351.80SchristosCPPFLAGS+=	-D__LIBPTHREAD_SOURCE__ -D__LIBC_THREAD_STUBS
361.9Sthorpej
371.35Schristos# XXX: This crappy poke at libc's internals needs to be fixed.
381.35SchristosCPPFLAGS+=-I${NETBSDSRCDIR}/sys -I${.CURDIR}/../libc
391.35Schristos
401.85Spooka# providing alternative MI implementations for creating an lwp is
411.85Spooka# possible by setting PTHREAD_MAKELWP.  Currently, alternatives are
421.85Spooka# set by the rumprun software stacks (see repo.rumpkernel.org)
431.85SpookaPTHREAD_MAKELWP?=	pthread_makelwp_netbsd.c
441.9Sthorpej
451.9Sthorpej#
461.9Sthorpej# NOTE: When you create a new file for libpthread, make sure that pthread.c
471.9Sthorpej# gets a reference to a symbol in that file.  Otherwise, Unix's stupid static
481.9Sthorpej# library semantics will end up discarding potentially important objects.
491.9Sthorpej#
501.9SthorpejSRCS=	pthread.c 
511.18SnathanwSRCS+=	pthread_attr.c
521.9SthorpejSRCS+=	pthread_barrier.c
531.85Spooka# used by rumprun-posix to work around symbol collisions
541.85Spooka.if ${PTHREAD_CANCELSTUB:Uyes} != "no"
551.9SthorpejSRCS+=	pthread_cancelstub.c
561.85Spooka.endif
571.9SthorpejSRCS+=	pthread_cond.c
581.86SchristosSRCS+=	pthread_getcpuclockid.c
591.9SthorpejSRCS+=	pthread_lock.c 
601.85SpookaSRCS+=	${PTHREAD_MAKELWP}
611.40SadSRCS+=	pthread_misc.c
621.9SthorpejSRCS+=	pthread_mutex.c
631.74SjoergSRCS+=	pthread_once.c
641.9SthorpejSRCS+=	pthread_rwlock.c
651.9SthorpejSRCS+=	pthread_specific.c
661.42SadSRCS+=	pthread_spin.c
671.21SnathanwSRCS+=	pthread_tsd.c
681.26SchristosSRCS+=	res_state.c
691.91Sthorpej.PATH: ${.CURDIR}/../librt
701.11SchristosSRCS+=	sem.c
711.9Sthorpej# Architecture-dependent files
721.56Sad.if exists(${ARCHDIR}/pthread_md.S)
731.56SadSRCS+= pthread_md.S
741.9Sthorpej.endif
751.82Smatt.if exists(${ARCHDIR}/Makefile.inc)
761.82Smatt.include "${ARCHDIR}/Makefile.inc"
771.82Smatt.endif
781.21Snathanw
791.79Sapb# The PTHREAD__COMPAT flag builds a libpthread that can be dropped
801.79Sapb# into a NetBSD 2/3/4 chroot with a NetBSD 5 or later kernel.
811.79Sapb# This makes threading work in the chroot, no other modifications
821.79Sapb# required.
831.79Sapb#
841.53Sad.if defined(PTHREAD__COMPAT)
851.53SadSRCS+=		pthread_compat.c
861.53Sad.PATH.c:	${.CURDIR}/../../common/lib/libc/arch/${ARCHSUBDIR}/atomic
871.53Sad.PATH.S:	${.CURDIR}/../../common/lib/libc/arch/${ARCHSUBDIR}/atomic
881.53Sad.PATH.c:	${.CURDIR}/../../common/lib/libc/atomic
891.53Sad.PATH.c:	${.CURDIR}/../libc/misc
901.53Sad.include "../../common/lib/libc/arch/${ARCHSUBDIR}/atomic/Makefile.inc"
911.53Sad.endif
921.53Sad
931.76SjoergALIGN_FUNCTIONS=	${${ACTIVE_CC} == "gcc":? -falign-functions=32 :}
941.76Sjoerg
951.21Snathanw# The TSD routines are used in the implementation of profiling, and so
961.21Snathanw# can't be profiled themselves.
971.88SchsCOPTS.pthread_specific.c+=	${ALIGN_FUNCTIONS}
981.21Snathanwpthread_specific.po: pthread_specific.o
991.25Slukem	${_MKTARGET_CREATE}
1001.21Snathanw	cp pthread_specific.o pthread_specific.po
1011.21Snathanw
1021.72SchristosCOPTS.pthread.c += -Wno-stack-protector -Wno-format-nonliteral
1031.72SchristosCOPTS.pthread_attr.c += -Wno-format-nonliteral
1041.45Sjnemeth
1051.52SrmindMAN+=	affinity.3 pthread.3 \
1061.48Syamt	pthread_attr.3 \
1071.58Sjruoho	pthread_attr_get_np.3 \
1081.60Sjruoho	pthread_attr_getdetachstate.3 \
1091.62Sjruoho	pthread_attr_getguardsize.3 \
1101.63Sjruoho	pthread_attr_getinheritsched.3 \
1111.48Syamt	pthread_attr_getname_np.3 \
1121.64Sjruoho	pthread_attr_getschedparam.3 \
1131.59Sjruoho	pthread_attr_getscope.3 \
1141.61Sjruoho	pthread_attr_getstack.3 \
1151.48Syamt	pthread_attr_setcreatesuspend_np.3 \
1161.66Srmind	pthread_barrier.3 pthread_barrierattr.3 \
1171.17Snathanw	pthread_cancel.3 pthread_cleanup_push.3 \
1181.66Srmind	pthread_cond.3 pthread_condattr.3 \
1191.66Srmind	pthread_create.3 pthread_detach.3 pthread_equal.3 \
1201.73Syamt	pthread_curcpu_np.3 \
1211.48Syamt	pthread_exit.3 \
1221.86Schristos	pthread_getcpuclockid.3 \
1231.48Syamt	pthread_getname_np.3 \
1241.48Syamt	pthread_getspecific.3 pthread_join.3 \
1251.69Sjruoho	pthread_key_create.3 pthread_kill.3 \
1261.66Srmind	pthread_mutex.3 pthread_mutexattr.3 \
1271.66Srmind	pthread_once.3 pthread_rwlock.3 pthread_rwlockattr.3 \
1281.17Snathanw	pthread_schedparam.3 pthread_self.3 \
1291.69Sjruoho	pthread_sigmask.3 pthread_spin.3 \
1301.51Srmind	pthread_suspend_np.3 pthread_testcancel.3
1311.17Snathanw
1321.70SchristosMLINKS+=	pthread_attr_get_np.3 pthread_getattr_np.3
1331.52SrmindMLINKS+=	affinity.3 pthread_setaffinity_np.3
1341.52SrmindMLINKS+=	affinity.3 pthread_getaffinity_np.3
1351.57Sjruoho
1361.17SnathanwMLINKS+=	pthread_attr.3 pthread_attr_init.3
1371.17SnathanwMLINKS+=	pthread_attr.3 pthread_attr_destroy.3
1381.59Sjruoho
1391.60SjruohoMLINKS+=	pthread_attr_getdetachstate.3 pthread_attr_setdetachstate.3
1401.62SjruohoMLINKS+=	pthread_attr_getguardsize.3 pthread_attr_setguardsize.3
1411.63SjruohoMLINKS+=	pthread_attr_getinheritsched.3 pthread_attr_setinheritsched.3
1421.68SjruohoMLINKS+=	pthread_attr_getname_np.3 pthread_attr_setname_np.3
1431.67Sjruoho
1441.67SjruohoMLINKS+=	pthread_attr_getschedparam.3 pthread_attr_setschedparam.3 \
1451.67Sjruoho		pthread_attr_getschedparam.3 pthread_attr_getschedpolicy.3 \
1461.67Sjruoho		pthread_attr_getschedparam.3 pthread_attr_setschedpolicy.3
1471.67Sjruoho
1481.59SjruohoMLINKS+=	pthread_attr_getscope.3 pthread_attr_setscope.3
1491.67Sjruoho
1501.61SjruohoMLINKS+=	pthread_attr_getstack.3 pthread_attr_setstack.3 \
1511.61Sjruoho		pthread_attr_getstack.3 pthread_attr_getstacksize.3 \
1521.61Sjruoho		pthread_attr_getstack.3 pthread_attr_setstacksize.3 \
1531.61Sjruoho		pthread_attr_getstack.3 pthread_attr_getstackaddr.3 \
1541.61Sjruoho		pthread_attr_getstack.3 pthread_attr_setstackaddr.3
1551.57Sjruoho
1561.66SrmindMLINKS+=	pthread_cleanup_push.3 pthread_cleanup_pop.3
1571.66Srmind
1581.66SrmindMLINKS+=	pthread_barrier.3 pthread_barrier_init.3
1591.66SrmindMLINKS+=	pthread_barrier.3 pthread_barrier_destroy.3
1601.66SrmindMLINKS+=	pthread_barrier.3 pthread_barrier_wait.3
1611.66Srmind
1621.32SpeterMLINKS+=	pthread_barrierattr.3 pthread_barrierattr_init.3
1631.32SpeterMLINKS+=	pthread_barrierattr.3 pthread_barrierattr_destroy.3
1641.87SchristosMLINKS+=	pthread_barrierattr.3 pthread_barrierattr_getpshared.3
1651.87SchristosMLINKS+=	pthread_barrierattr.3 pthread_barrierattr_setpshared.3
1661.66Srmind
1671.66SrmindMLINKS+=	pthread_cond.3 pthread_cond_init.3
1681.66SrmindMLINKS+=	pthread_cond.3 pthread_cond_destroy.3
1691.66SrmindMLINKS+=	pthread_cond.3 pthread_cond_broadcast.3
1701.66SrmindMLINKS+=	pthread_cond.3 pthread_cond_wait.3
1711.66SrmindMLINKS+=	pthread_cond.3 pthread_cond_signal.3
1721.66SrmindMLINKS+=	pthread_cond.3 pthread_cond_timedwait.3
1731.66Srmind
1741.17SnathanwMLINKS+=	pthread_condattr.3 pthread_condattr_init.3
1751.17SnathanwMLINKS+=	pthread_condattr.3 pthread_condattr_destroy.3
1761.78SriastradMLINKS+=	pthread_condattr.3 pthread_condattr_setclock.3
1771.87SchristosMLINKS+=	pthread_condattr.3 pthread_condattr_getclock.3
1781.87SchristosMLINKS+=	pthread_condattr.3 pthread_condattr_getpshared.3
1791.87SchristosMLINKS+=	pthread_condattr.3 pthread_condattr_setpshared.3
1801.66Srmind
1811.68SjruohoMLINKS+=	pthread_getname_np.3 pthread_setname_np.3
1821.69SjruohoMLINKS+=	pthread_getspecific.3 pthread_setspecific.3
1831.69SjruohoMLINKS+=	pthread_key_create.3 pthread_key_delete.3
1841.68Sjruoho
1851.66SrmindMLINKS+=	pthread_mutex.3 pthread_mutex_init.3
1861.66SrmindMLINKS+=	pthread_mutex.3 pthread_mutex_destroy.3
1871.66SrmindMLINKS+=	pthread_mutex.3 pthread_mutex_lock.3
1881.66SrmindMLINKS+=	pthread_mutex.3 pthread_mutex_trylock.3
1891.66SrmindMLINKS+=	pthread_mutex.3 pthread_mutex_unlock.3
1901.87SchristosMLINKS+=	pthread_mutex.3 pthread_mutex_timedlock.3
1911.87SchristosMLINKS+=	pthread_mutex.3	pthread_mutex_getprioceiling.3
1921.87SchristosMLINKS+=	pthread_mutex.3	pthread_mutex_setprioceiling.3 
1931.66Srmind
1941.17SnathanwMLINKS+=	pthread_mutexattr.3 pthread_mutexattr_init.3
1951.17SnathanwMLINKS+=	pthread_mutexattr.3 pthread_mutexattr_destroy.3
1961.87SchristosMLINKS+=	pthread_mutexattr.3 pthread_mutexattr_getpshared.3
1971.87SchristosMLINKS+=	pthread_mutexattr.3 pthread_mutexattr_setpshared.3
1981.17SnathanwMLINKS+=	pthread_mutexattr.3 pthread_mutexattr_settype.3
1991.17SnathanwMLINKS+=	pthread_mutexattr.3 pthread_mutexattr_gettype.3
2001.87SchristosMLINKS+=	pthread_mutexattr.3 pthread_mutexattr_getprotocol.3
2011.87SchristosMLINKS+=	pthread_mutexattr.3 pthread_mutexattr_setprotocol.3
2021.87SchristosMLINKS+=	pthread_mutexattr.3 pthread_mutexattr_getprioceiling.3
2031.87SchristosMLINKS+=	pthread_mutexattr.3 pthread_mutexattr_setprioceiling.3	
2041.66Srmind
2051.66SrmindMLINKS+=	pthread_rwlock.3 pthread_rwlock_init.3
2061.66SrmindMLINKS+=	pthread_rwlock.3 pthread_rwlock_destroy.3
2071.66SrmindMLINKS+=	pthread_rwlock.3 pthread_rwlock_rdlock.3
2081.66SrmindMLINKS+=	pthread_rwlock.3 pthread_rwlock_wrlock.3
2091.66SrmindMLINKS+=	pthread_rwlock.3 pthread_rwlock_unlock.3
2101.66Srmind
2111.66SrmindMLINKS+=	pthread_rwlock.3 pthread_rwlock_timedrdlock.3
2121.66SrmindMLINKS+=	pthread_rwlock.3 pthread_rwlock_timedwrlock.3
2131.66SrmindMLINKS+=	pthread_rwlock.3 pthread_rwlock_tryrdlock.3
2141.66SrmindMLINKS+=	pthread_rwlock.3 pthread_rwlock_trywrlock.3
2151.66Srmind
2161.17SnathanwMLINKS+=	pthread_rwlockattr.3 pthread_rwlockattr_init.3
2171.17SnathanwMLINKS+=	pthread_rwlockattr.3 pthread_rwlockattr_destroy.3
2181.87SchristosMLINKS+=	pthread_rwlockattr.3 pthread_rwlockattr_getpshared.3
2191.87SchristosMLINKS+=	pthread_rwlockattr.3 pthread_rwlockattr_setpshared.3
2201.66Srmind
2211.66SrmindMLINKS+=	pthread_spin.3 pthread_spin_init.3
2221.66SrmindMLINKS+=	pthread_spin.3 pthread_spin_destroy.3
2231.66SrmindMLINKS+=	pthread_spin.3 pthread_spin_lock.3
2241.66SrmindMLINKS+=	pthread_spin.3 pthread_spin_trylock.3
2251.66SrmindMLINKS+=	pthread_spin.3 pthread_spin_unlock.3
2261.66Srmind
2271.17SnathanwMLINKS+=	pthread_schedparam.3 pthread_setschedparam.3
2281.17SnathanwMLINKS+=	pthread_schedparam.3 pthread_getschedparam.3
2291.23SchristosMLINKS+=	pthread_suspend_np.3 pthread_resume_np.3
2301.17SnathanwMLINKS+=	pthread_testcancel.3 pthread_setcancelstate.3
2311.17SnathanwMLINKS+=	pthread_testcancel.3 pthread_setcanceltype.3
2321.9Sthorpej
2331.92Skamil# ISO C threads (ISO/IEC 9899:2011)
2341.92Skamil
2351.92SkamilSRCS+=		call_once.c cnd.c mtx.c thrd.c tss.c
2361.92SkamilMAN+=		threads.3 call_once.3 cnd.3 mtx.3 thrd.3 tss.3
2371.92Skamil
2381.92SkamilMLINKS+=	call_once.3 ONCE_FLAG_INIT.3
2391.92SkamilMLINKS+=	call_once.3 once_flag.3
2401.92Skamil
2411.92SkamilMLINKS+=	cnd.3 cnd_broadcast.3
2421.92SkamilMLINKS+=	cnd.3 cnd_destroy.3
2431.92SkamilMLINKS+=	cnd.3 cnd_init.3
2441.92SkamilMLINKS+=	cnd.3 cnd_signal.3
2451.92SkamilMLINKS+=	cnd.3 cnd_timedwait.3
2461.92SkamilMLINKS+=	cnd.3 cnd_wait.3
2471.92Skamil
2481.92SkamilMLINKS+=	mtx.3 mtx_destroy.3
2491.92SkamilMLINKS+=	mtx.3 mtx_init.3
2501.92SkamilMLINKS+=	mtx.3 mtx_lock.3
2511.92SkamilMLINKS+=	mtx.3 mtx_timedlock.3
2521.92SkamilMLINKS+=	mtx.3 mtx_trylock.3
2531.92SkamilMLINKS+=	mtx.3 mtx_unlock.3
2541.92Skamil
2551.92SkamilMLINKS+=	thrd.3 thrd_create.3
2561.92SkamilMLINKS+=	thrd.3 thrd_current.3
2571.92SkamilMLINKS+=	thrd.3 thrd_detach.3
2581.92SkamilMLINKS+=	thrd.3 thrd_equal.3
2591.92SkamilMLINKS+=	thrd.3 thrd_exit.3
2601.92SkamilMLINKS+=	thrd.3 thrd_join.3
2611.92SkamilMLINKS+=	thrd.3 thrd_sleep.3
2621.92SkamilMLINKS+=	thrd.3 thrd_yield.3
2631.92Skamil
2641.92SkamilMLINKS+=	tss.3 TSS_DTOR_ITERATIONS.3
2651.92SkamilMLINKS+=	tss.3 tss_create.3
2661.92SkamilMLINKS+=	tss.3 tss_delete.3
2671.92SkamilMLINKS+=	tss.3 tss_get.3
2681.92SkamilMLINKS+=	tss.3 tss_set.3
2691.92Skamil
2701.92SkamilINCS+=		threads.h
2711.92Skamil
2721.93Smaya# PR lib/54001: create libpthread.a as a single large object, with all the
2731.93Smaya# symbols in one section. ensures that if any libpthread function is used,
2741.93Smaya# you get all of them from libpthread, and not the libc stubs.
2751.93Smaya#
2761.93Smaya# This makes -lpthread equivalent to -Wl,--whole-archive -lpthread
2771.93Smaya
2781.93Smaya__archivebuild: .USE
2791.93Smaya	${_MKTARGET_BUILD}
2801.93Smaya	@rm -f ${.TARGET}
2811.93Smaya	${LD} -r -o ${.TARGET}.o `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
2821.93Smaya	${AR} ${_ARFL} ${.TARGET} ${.TARGET}.o
2831.93Smaya
2841.94SmayaCLEANFILES+=	${_LIBS:=.o}
2851.93Smaya
2861.1Sproven.include <bsd.lib.mk>
2871.1Sproven
2881.9Sthorpej.else
2891.9Sthorpej
2901.9Sthorpej.include <bsd.man.mk>
2911.10Sthorpej.include <bsd.files.mk>
2921.10Sthorpej.include <bsd.inc.mk>
2931.9Sthorpej
2941.9Sthorpej.endif
2951.9Sthorpej
2961.9Sthorpej# WARNS=2 sets -Wcast-qual. This causes problems for one of
2971.9Sthorpej# pthread_setspecific() and pthread_getspecific(), since the constness
2981.9Sthorpej# of the argument to setspecific() has to be discarded *somewhere*
2991.9Sthorpej# before returning it from getspecific().
3001.77SmattCWARNFLAGS+= -Wno-cast-qual
301