Makefile revision 1.100
11.100Srillig# $NetBSD: Makefile,v 1.100 2025/04/07 16:07:05 rillig 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.95SbradUSE_SHLIBDIR= yes 111.95Sbrad 121.55Smrg.if defined(PTHREAD_MACHINE_ARCH) && !empty(PTHREAD_MACHINE_ARCH) && \ 131.55Smrg exists(${.CURDIR}/arch/${PTHREAD_MACHINE_ARCH}) 141.55SmrgARCHSUBDIR= ${PTHREAD_MACHINE_ARCH} 151.84Smatt.elif defined(PTHREAD_MACHINE_CPU) && !empty(PTHREAD_MACHINE_CPU) && \ 161.84Smatt exists(${.CURDIR}/arch/${PTHREAD_MACHINE_CPU}) 171.84SmattARCHSUBDIR= ${PTHREAD_MACHINE_CPU} 181.55Smrg.elif exists(${.CURDIR}/arch/${MACHINE_ARCH}) 191.9SthorpejARCHSUBDIR= ${MACHINE_ARCH} 201.98Srin.elif exists(${.CURDIR}/arch/${MACHINE_CPU}) 211.9SthorpejARCHSUBDIR= ${MACHINE_CPU} 221.9Sthorpej.else 231.9Sthorpej.BEGIN: 241.10Sthorpej @echo "WARNING: no ARCHSUBDIR for ${MACHINE_ARCH}/${MACHINE_CPU}; skipping..." 251.9Sthorpej.endif 261.9Sthorpej 271.10SthorpejINCS= pthread.h pthread_types.h pthread_queue.h 281.10SthorpejINCSDIR=/usr/include 291.10Sthorpej 301.9Sthorpej.if defined(ARCHSUBDIR) 311.9Sthorpej 321.9SthorpejARCHDIR= ${.CURDIR}/arch/${ARCHSUBDIR} 331.9Sthorpej.PATH: ${ARCHDIR} 341.9Sthorpej 351.99SriastradEXPSYM_SRCS+= pthread_mi.expsym 361.99Sriastrad. if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "hppa" 371.99Sriastrad# PTHREAD__ASM_RASOPS 381.99SriastradEXPSYM_SRCS+= pthread_md.expsym 391.99Sriastrad. else 401.99Sriastrad# !PTHREAD__ASM_RASOPS 411.99Sriastrad# XXX These really shouldn't be exported. 421.99SriastradEXPSYM_SRCS+= pthread_ras.expsym 431.99Sriastrad. endif 441.99Sriastrad 451.99SriastradLIB_EXPSYM= pthread.expsym 461.99Sriastradpthread.expsym: ${EXPSYM_SRCS} 471.99Sriastrad ${_MKTARGET_CREATE} 481.99Sriastrad LC_ALL=C sort -m ${.ALLSRC} >${.TARGET}.tmp && \ 491.99Sriastrad ${MV} ${.TARGET}.tmp ${.TARGET} 501.99SriastradCLEANFILES+= pthread.expsym pthread.expsym.tmp 511.99Sriastrad 521.80SchristosCPPFLAGS+= -I${ARCHDIR} -I${.CURDIR} -I${.OBJDIR} -D_LIBC -D_REENTRANT 531.80SchristosCPPFLAGS+= -I${.CURDIR}/../libc/include 541.80SchristosCPPFLAGS+= -D__LIBPTHREAD_SOURCE__ -D__LIBC_THREAD_STUBS 551.9Sthorpej 561.96Sjoerg# Since <pthread.h> is not used, allow declaring pthread_create and 571.96Sjoerg# friends locally. 581.96SjoergCWARNFLAGS.clang+= -Wno-builtin-requires-header 591.96Sjoerg 601.35Schristos# XXX: This crappy poke at libc's internals needs to be fixed. 611.35SchristosCPPFLAGS+=-I${NETBSDSRCDIR}/sys -I${.CURDIR}/../libc 621.35Schristos 631.85Spooka# providing alternative MI implementations for creating an lwp is 641.85Spooka# possible by setting PTHREAD_MAKELWP. Currently, alternatives are 651.97Slukem# set by the rumprun software stacks (see https://github.com/rumpkernel/rumprun ) 661.85SpookaPTHREAD_MAKELWP?= pthread_makelwp_netbsd.c 671.9Sthorpej 681.9Sthorpej# 691.9Sthorpej# NOTE: When you create a new file for libpthread, make sure that pthread.c 701.9Sthorpej# gets a reference to a symbol in that file. Otherwise, Unix's stupid static 711.9Sthorpej# library semantics will end up discarding potentially important objects. 721.9Sthorpej# 731.98SrinSRCS= pthread.c 741.18SnathanwSRCS+= pthread_attr.c 751.9SthorpejSRCS+= pthread_barrier.c 761.85Spooka# used by rumprun-posix to work around symbol collisions 771.85Spooka.if ${PTHREAD_CANCELSTUB:Uyes} != "no" 781.9SthorpejSRCS+= pthread_cancelstub.c 791.85Spooka.endif 801.9SthorpejSRCS+= pthread_cond.c 811.86SchristosSRCS+= pthread_getcpuclockid.c 821.98SrinSRCS+= pthread_lock.c 831.85SpookaSRCS+= ${PTHREAD_MAKELWP} 841.40SadSRCS+= pthread_misc.c 851.9SthorpejSRCS+= pthread_mutex.c 861.74SjoergSRCS+= pthread_once.c 871.9SthorpejSRCS+= pthread_rwlock.c 881.9SthorpejSRCS+= pthread_specific.c 891.42SadSRCS+= pthread_spin.c 901.21SnathanwSRCS+= pthread_tsd.c 911.26SchristosSRCS+= res_state.c 921.91Sthorpej.PATH: ${.CURDIR}/../librt 931.11SchristosSRCS+= sem.c 941.9Sthorpej# Architecture-dependent files 951.56Sad.if exists(${ARCHDIR}/pthread_md.S) 961.56SadSRCS+= pthread_md.S 971.9Sthorpej.endif 981.82Smatt.if exists(${ARCHDIR}/Makefile.inc) 991.82Smatt.include "${ARCHDIR}/Makefile.inc" 1001.82Smatt.endif 1011.21Snathanw 1021.79Sapb# The PTHREAD__COMPAT flag builds a libpthread that can be dropped 1031.79Sapb# into a NetBSD 2/3/4 chroot with a NetBSD 5 or later kernel. 1041.79Sapb# This makes threading work in the chroot, no other modifications 1051.79Sapb# required. 1061.79Sapb# 1071.53Sad.if defined(PTHREAD__COMPAT) 1081.53SadSRCS+= pthread_compat.c 1091.53Sad.PATH.c: ${.CURDIR}/../../common/lib/libc/arch/${ARCHSUBDIR}/atomic 1101.53Sad.PATH.S: ${.CURDIR}/../../common/lib/libc/arch/${ARCHSUBDIR}/atomic 1111.53Sad.PATH.c: ${.CURDIR}/../../common/lib/libc/atomic 1121.53Sad.PATH.c: ${.CURDIR}/../libc/misc 1131.53Sad.include "../../common/lib/libc/arch/${ARCHSUBDIR}/atomic/Makefile.inc" 1141.53Sad.endif 1151.53Sad 1161.76SjoergALIGN_FUNCTIONS= ${${ACTIVE_CC} == "gcc":? -falign-functions=32 :} 1171.76Sjoerg 1181.21Snathanw# The TSD routines are used in the implementation of profiling, and so 1191.21Snathanw# can't be profiled themselves. 1201.88SchsCOPTS.pthread_specific.c+= ${ALIGN_FUNCTIONS} 1211.21Snathanwpthread_specific.po: pthread_specific.o 1221.25Slukem ${_MKTARGET_CREATE} 1231.21Snathanw cp pthread_specific.o pthread_specific.po 1241.21Snathanw 1251.72SchristosCOPTS.pthread.c += -Wno-stack-protector -Wno-format-nonliteral 1261.72SchristosCOPTS.pthread_attr.c += -Wno-format-nonliteral 1271.45Sjnemeth 1281.100SrilligLINTFLAGS+= -Ac11 # for _Atomic 1291.100Srillig 1301.52SrmindMAN+= affinity.3 pthread.3 \ 1311.48Syamt pthread_attr.3 \ 1321.58Sjruoho pthread_attr_get_np.3 \ 1331.60Sjruoho pthread_attr_getdetachstate.3 \ 1341.62Sjruoho pthread_attr_getguardsize.3 \ 1351.63Sjruoho pthread_attr_getinheritsched.3 \ 1361.48Syamt pthread_attr_getname_np.3 \ 1371.64Sjruoho pthread_attr_getschedparam.3 \ 1381.59Sjruoho pthread_attr_getscope.3 \ 1391.61Sjruoho pthread_attr_getstack.3 \ 1401.48Syamt pthread_attr_setcreatesuspend_np.3 \ 1411.66Srmind pthread_barrier.3 pthread_barrierattr.3 \ 1421.17Snathanw pthread_cancel.3 pthread_cleanup_push.3 \ 1431.66Srmind pthread_cond.3 pthread_condattr.3 \ 1441.66Srmind pthread_create.3 pthread_detach.3 pthread_equal.3 \ 1451.73Syamt pthread_curcpu_np.3 \ 1461.48Syamt pthread_exit.3 \ 1471.86Schristos pthread_getcpuclockid.3 \ 1481.48Syamt pthread_getname_np.3 \ 1491.48Syamt pthread_getspecific.3 pthread_join.3 \ 1501.69Sjruoho pthread_key_create.3 pthread_kill.3 \ 1511.66Srmind pthread_mutex.3 pthread_mutexattr.3 \ 1521.66Srmind pthread_once.3 pthread_rwlock.3 pthread_rwlockattr.3 \ 1531.17Snathanw pthread_schedparam.3 pthread_self.3 \ 1541.69Sjruoho pthread_sigmask.3 pthread_spin.3 \ 1551.51Srmind pthread_suspend_np.3 pthread_testcancel.3 1561.17Snathanw 1571.70SchristosMLINKS+= pthread_attr_get_np.3 pthread_getattr_np.3 1581.52SrmindMLINKS+= affinity.3 pthread_setaffinity_np.3 1591.52SrmindMLINKS+= affinity.3 pthread_getaffinity_np.3 1601.57Sjruoho 1611.17SnathanwMLINKS+= pthread_attr.3 pthread_attr_init.3 1621.17SnathanwMLINKS+= pthread_attr.3 pthread_attr_destroy.3 1631.59Sjruoho 1641.60SjruohoMLINKS+= pthread_attr_getdetachstate.3 pthread_attr_setdetachstate.3 1651.62SjruohoMLINKS+= pthread_attr_getguardsize.3 pthread_attr_setguardsize.3 1661.63SjruohoMLINKS+= pthread_attr_getinheritsched.3 pthread_attr_setinheritsched.3 1671.68SjruohoMLINKS+= pthread_attr_getname_np.3 pthread_attr_setname_np.3 1681.67Sjruoho 1691.67SjruohoMLINKS+= pthread_attr_getschedparam.3 pthread_attr_setschedparam.3 \ 1701.67Sjruoho pthread_attr_getschedparam.3 pthread_attr_getschedpolicy.3 \ 1711.67Sjruoho pthread_attr_getschedparam.3 pthread_attr_setschedpolicy.3 1721.67Sjruoho 1731.59SjruohoMLINKS+= pthread_attr_getscope.3 pthread_attr_setscope.3 1741.67Sjruoho 1751.61SjruohoMLINKS+= pthread_attr_getstack.3 pthread_attr_setstack.3 \ 1761.61Sjruoho pthread_attr_getstack.3 pthread_attr_getstacksize.3 \ 1771.61Sjruoho pthread_attr_getstack.3 pthread_attr_setstacksize.3 \ 1781.61Sjruoho pthread_attr_getstack.3 pthread_attr_getstackaddr.3 \ 1791.61Sjruoho pthread_attr_getstack.3 pthread_attr_setstackaddr.3 1801.57Sjruoho 1811.66SrmindMLINKS+= pthread_cleanup_push.3 pthread_cleanup_pop.3 1821.66Srmind 1831.66SrmindMLINKS+= pthread_barrier.3 pthread_barrier_init.3 1841.66SrmindMLINKS+= pthread_barrier.3 pthread_barrier_destroy.3 1851.66SrmindMLINKS+= pthread_barrier.3 pthread_barrier_wait.3 1861.66Srmind 1871.32SpeterMLINKS+= pthread_barrierattr.3 pthread_barrierattr_init.3 1881.32SpeterMLINKS+= pthread_barrierattr.3 pthread_barrierattr_destroy.3 1891.87SchristosMLINKS+= pthread_barrierattr.3 pthread_barrierattr_getpshared.3 1901.87SchristosMLINKS+= pthread_barrierattr.3 pthread_barrierattr_setpshared.3 1911.66Srmind 1921.66SrmindMLINKS+= pthread_cond.3 pthread_cond_init.3 1931.66SrmindMLINKS+= pthread_cond.3 pthread_cond_destroy.3 1941.66SrmindMLINKS+= pthread_cond.3 pthread_cond_broadcast.3 1951.66SrmindMLINKS+= pthread_cond.3 pthread_cond_wait.3 1961.66SrmindMLINKS+= pthread_cond.3 pthread_cond_signal.3 1971.66SrmindMLINKS+= pthread_cond.3 pthread_cond_timedwait.3 1981.66Srmind 1991.17SnathanwMLINKS+= pthread_condattr.3 pthread_condattr_init.3 2001.17SnathanwMLINKS+= pthread_condattr.3 pthread_condattr_destroy.3 2011.78SriastradMLINKS+= pthread_condattr.3 pthread_condattr_setclock.3 2021.87SchristosMLINKS+= pthread_condattr.3 pthread_condattr_getclock.3 2031.87SchristosMLINKS+= pthread_condattr.3 pthread_condattr_getpshared.3 2041.87SchristosMLINKS+= pthread_condattr.3 pthread_condattr_setpshared.3 2051.66Srmind 2061.68SjruohoMLINKS+= pthread_getname_np.3 pthread_setname_np.3 2071.69SjruohoMLINKS+= pthread_getspecific.3 pthread_setspecific.3 2081.69SjruohoMLINKS+= pthread_key_create.3 pthread_key_delete.3 2091.68Sjruoho 2101.66SrmindMLINKS+= pthread_mutex.3 pthread_mutex_init.3 2111.66SrmindMLINKS+= pthread_mutex.3 pthread_mutex_destroy.3 2121.66SrmindMLINKS+= pthread_mutex.3 pthread_mutex_lock.3 2131.66SrmindMLINKS+= pthread_mutex.3 pthread_mutex_trylock.3 2141.66SrmindMLINKS+= pthread_mutex.3 pthread_mutex_unlock.3 2151.87SchristosMLINKS+= pthread_mutex.3 pthread_mutex_timedlock.3 2161.87SchristosMLINKS+= pthread_mutex.3 pthread_mutex_getprioceiling.3 2171.98SrinMLINKS+= pthread_mutex.3 pthread_mutex_setprioceiling.3 2181.66Srmind 2191.17SnathanwMLINKS+= pthread_mutexattr.3 pthread_mutexattr_init.3 2201.17SnathanwMLINKS+= pthread_mutexattr.3 pthread_mutexattr_destroy.3 2211.87SchristosMLINKS+= pthread_mutexattr.3 pthread_mutexattr_getpshared.3 2221.87SchristosMLINKS+= pthread_mutexattr.3 pthread_mutexattr_setpshared.3 2231.17SnathanwMLINKS+= pthread_mutexattr.3 pthread_mutexattr_settype.3 2241.17SnathanwMLINKS+= pthread_mutexattr.3 pthread_mutexattr_gettype.3 2251.87SchristosMLINKS+= pthread_mutexattr.3 pthread_mutexattr_getprotocol.3 2261.87SchristosMLINKS+= pthread_mutexattr.3 pthread_mutexattr_setprotocol.3 2271.87SchristosMLINKS+= pthread_mutexattr.3 pthread_mutexattr_getprioceiling.3 2281.98SrinMLINKS+= pthread_mutexattr.3 pthread_mutexattr_setprioceiling.3 2291.66Srmind 2301.66SrmindMLINKS+= pthread_rwlock.3 pthread_rwlock_init.3 2311.66SrmindMLINKS+= pthread_rwlock.3 pthread_rwlock_destroy.3 2321.66SrmindMLINKS+= pthread_rwlock.3 pthread_rwlock_rdlock.3 2331.66SrmindMLINKS+= pthread_rwlock.3 pthread_rwlock_wrlock.3 2341.66SrmindMLINKS+= pthread_rwlock.3 pthread_rwlock_unlock.3 2351.66Srmind 2361.66SrmindMLINKS+= pthread_rwlock.3 pthread_rwlock_timedrdlock.3 2371.66SrmindMLINKS+= pthread_rwlock.3 pthread_rwlock_timedwrlock.3 2381.66SrmindMLINKS+= pthread_rwlock.3 pthread_rwlock_tryrdlock.3 2391.66SrmindMLINKS+= pthread_rwlock.3 pthread_rwlock_trywrlock.3 2401.66Srmind 2411.17SnathanwMLINKS+= pthread_rwlockattr.3 pthread_rwlockattr_init.3 2421.17SnathanwMLINKS+= pthread_rwlockattr.3 pthread_rwlockattr_destroy.3 2431.87SchristosMLINKS+= pthread_rwlockattr.3 pthread_rwlockattr_getpshared.3 2441.87SchristosMLINKS+= pthread_rwlockattr.3 pthread_rwlockattr_setpshared.3 2451.66Srmind 2461.66SrmindMLINKS+= pthread_spin.3 pthread_spin_init.3 2471.66SrmindMLINKS+= pthread_spin.3 pthread_spin_destroy.3 2481.66SrmindMLINKS+= pthread_spin.3 pthread_spin_lock.3 2491.66SrmindMLINKS+= pthread_spin.3 pthread_spin_trylock.3 2501.66SrmindMLINKS+= pthread_spin.3 pthread_spin_unlock.3 2511.66Srmind 2521.17SnathanwMLINKS+= pthread_schedparam.3 pthread_setschedparam.3 2531.17SnathanwMLINKS+= pthread_schedparam.3 pthread_getschedparam.3 2541.23SchristosMLINKS+= pthread_suspend_np.3 pthread_resume_np.3 2551.17SnathanwMLINKS+= pthread_testcancel.3 pthread_setcancelstate.3 2561.17SnathanwMLINKS+= pthread_testcancel.3 pthread_setcanceltype.3 2571.9Sthorpej 2581.92Skamil# ISO C threads (ISO/IEC 9899:2011) 2591.92Skamil 2601.92SkamilSRCS+= call_once.c cnd.c mtx.c thrd.c tss.c 2611.92SkamilMAN+= threads.3 call_once.3 cnd.3 mtx.3 thrd.3 tss.3 2621.92Skamil 2631.92SkamilMLINKS+= call_once.3 ONCE_FLAG_INIT.3 2641.92SkamilMLINKS+= call_once.3 once_flag.3 2651.92Skamil 2661.92SkamilMLINKS+= cnd.3 cnd_broadcast.3 2671.92SkamilMLINKS+= cnd.3 cnd_destroy.3 2681.92SkamilMLINKS+= cnd.3 cnd_init.3 2691.92SkamilMLINKS+= cnd.3 cnd_signal.3 2701.92SkamilMLINKS+= cnd.3 cnd_timedwait.3 2711.92SkamilMLINKS+= cnd.3 cnd_wait.3 2721.92Skamil 2731.92SkamilMLINKS+= mtx.3 mtx_destroy.3 2741.92SkamilMLINKS+= mtx.3 mtx_init.3 2751.92SkamilMLINKS+= mtx.3 mtx_lock.3 2761.92SkamilMLINKS+= mtx.3 mtx_timedlock.3 2771.92SkamilMLINKS+= mtx.3 mtx_trylock.3 2781.92SkamilMLINKS+= mtx.3 mtx_unlock.3 2791.92Skamil 2801.92SkamilMLINKS+= thrd.3 thrd_create.3 2811.92SkamilMLINKS+= thrd.3 thrd_current.3 2821.92SkamilMLINKS+= thrd.3 thrd_detach.3 2831.92SkamilMLINKS+= thrd.3 thrd_equal.3 2841.92SkamilMLINKS+= thrd.3 thrd_exit.3 2851.92SkamilMLINKS+= thrd.3 thrd_join.3 2861.92SkamilMLINKS+= thrd.3 thrd_sleep.3 2871.92SkamilMLINKS+= thrd.3 thrd_yield.3 2881.92Skamil 2891.92SkamilMLINKS+= tss.3 TSS_DTOR_ITERATIONS.3 2901.92SkamilMLINKS+= tss.3 tss_create.3 2911.92SkamilMLINKS+= tss.3 tss_delete.3 2921.92SkamilMLINKS+= tss.3 tss_get.3 2931.92SkamilMLINKS+= tss.3 tss_set.3 2941.92Skamil 2951.92SkamilINCS+= threads.h 2961.92Skamil 2971.93Smaya# PR lib/54001: create libpthread.a as a single large object, with all the 2981.93Smaya# symbols in one section. ensures that if any libpthread function is used, 2991.93Smaya# you get all of them from libpthread, and not the libc stubs. 3001.93Smaya# 3011.93Smaya# This makes -lpthread equivalent to -Wl,--whole-archive -lpthread 3021.93Smaya 3031.93Smaya__archivebuild: .USE 3041.93Smaya ${_MKTARGET_BUILD} 3051.93Smaya @rm -f ${.TARGET} 3061.93Smaya ${LD} -r -o ${.TARGET}.o `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}` 3071.93Smaya ${AR} ${_ARFL} ${.TARGET} ${.TARGET}.o 3081.93Smaya 3091.94SmayaCLEANFILES+= ${_LIBS:=.o} 3101.93Smaya 3111.1Sproven.include <bsd.lib.mk> 3121.1Sproven 3131.9Sthorpej.else 3141.9Sthorpej 3151.9Sthorpej.include <bsd.man.mk> 3161.10Sthorpej.include <bsd.files.mk> 3171.10Sthorpej.include <bsd.inc.mk> 3181.9Sthorpej 3191.9Sthorpej.endif 3201.9Sthorpej 3211.9Sthorpej# WARNS=2 sets -Wcast-qual. This causes problems for one of 3221.9Sthorpej# pthread_setspecific() and pthread_getspecific(), since the constness 3231.9Sthorpej# of the argument to setspecific() has to be discarded *somewhere* 3241.9Sthorpej# before returning it from getspecific(). 3251.77SmattCWARNFLAGS+= -Wno-cast-qual 326