1# Makefile for uClibc NPTL 2# 3# Copyright (C) 2005-2006 Steven J. Hill <sjhill@realitydiluted.com> 4# 5# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. 6# 7 8subdirs += libpthread/nptl 9 10libpthread_DIR = $(top_srcdir)libpthread/nptl 11libpthread_OUT = $(top_builddir)libpthread/nptl 12 13include $(libpthread_DIR)/sysdeps/Makefile.in 14 15libc-shared-routines-y = libc-cancellation.c 16libc-static-routines-y = alloca_cutoff.c libc-cancellation.c 17libpthread-shared-only-routines-y = version.c 18libpthread-static-only-routines-y = pthread_atfork.c 19libpthread-routines- += $(notdir $(wildcard $(libpthread_DIR)/gen_*.c)) # dummy generated files 20libpthread-routines- += allocatestack.c # dummy included by pthread_create.c 21libpthread-routines-$(UCLIBC_SUSV4_LEGACY) += pthread_getconcurrency.c \ 22 pthread_setconcurrency.c 23libpthread_CSRC = $(filter-out $(libpthread-routines-) \ 24 $(libc-shared-routines-y) \ 25 $(libc-static-routines-y) \ 26 $(libpthread-shared-only-routines-y) \ 27 $(libpthread-static-only-routines-y) \ 28 $(notdir $(libpthread_OBJS:.o=.c)), \ 29 $(notdir $(wildcard $(libpthread_DIR)/*.c))) 30 31libpthread_OBJS += $(addprefix $(libpthread_OUT)/,$(libpthread_CSRC:.c=.o)) 32libpthread-so-y += $(addprefix $(libpthread_OUT)/,$(libpthread-shared-only-routines-y:.c=.oS)) 33libpthread-so-y += $(libpthread_OBJS:.o=.oS) 34libpthread-nonshared-y := $(addprefix $(libpthread_OUT)/,$(libpthread-static-only-routines-y:.c=.oS)) 35libpthread-static-y := $(addprefix $(libpthread_OUT)/,$(libpthread-static-only-routines-y:.c=.o)) 36libpthread-static-y += $(libpthread_OBJS) 37ifeq ($(DOPIC),y) 38libpthread-a-y := $(libpthread-static-y:.o=.os) 39else 40libpthread-a-y := $(libpthread-static-y) 41endif 42 43libc-shared-routines-y := $(filter-out $(notdir $(libpthread_libc_OBJS:.o=.c)), $(libc-shared-routines-y)) 44libc-static-routines-y := $(filter-out $(notdir $(libpthread_libc_OBJS:.o=.c)), $(libc-static-routines-y)) 45libc-shared-routines-y := $(addprefix $(libpthread_OUT)/,$(libc-shared-routines-y:.c=.oS)) 46libc-static-routines-y := $(addprefix $(libpthread_OUT)/,$(libc-static-routines-y:.c=.o)) 47libc-shared-y += $(libc-shared-routines-y) $(libpthread_libc_OBJS:.o=.oS) 48ifeq ($(DOPIC),y) 49libc-static-y += $(libc-static-routines-y:.o=.os) $(libpthread_libc_a_OBJS:.o=.os) $(libpthread_ld_tls_COBJ:.o=.os) 50else 51libc-static-y += $(libc-static-routines-y) $(libpthread_libc_a_OBJS) $(libpthread_ld_tls_COBJ) 52endif 53 54librt-pt-routines-y := $(patsubst %.c,$(libpthread_pthread_OUT)/%.o,$(filter-out $(notdir $(libpthread_librt_OBJS:.o=.c)), $(librt-pt-routines-y))) 55librt-pt-shared-only-routines-y := $(patsubst %.c,$(libpthread_pthread_OUT)/%.o,$(filter-out $(notdir $(libpthread_librt_OBJS:.o=.c)), $(librt-pt-shared-only-routines-y))) 56librt_OBJS = $(libpthread_librt_OBJS) $(librt-pt-routines-y) 57ifeq ($(DOPIC),y) 58librt-a-y += $(librt_OBJS:.o=.os) 59else 60librt-a-y += $(librt_OBJS) 61endif 62librt-so-y += $(librt_OBJS:.o=.oS) $(librt-pt-shared-only-routines-y:.o=.oS) 63 64$(libpthread_OUT)/pthread-errnos.h: $(top_srcdir)extra/scripts/gen-as-const.awk 65$(libpthread_OUT)/pthread-errnos.h: $(libpthread_DIR)/pthread-errnos.sym 66 @$(disp_gen) 67 $(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< \ 68 | $(CC) $(CFLAGS) -x c - -S -o - \ 69 | $(SED) $(PTHREAD_GENERATE_MANGLE) > $@ 70 @if test ! -s $@ ; then rm -f $@ ; false ; fi 71 72pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(libpthread_OUT)/pthread-errnos.h 73 74headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(nptl_headers_bootstrap) 75 76libpthread_H := $(addprefix $(top_builddir)include/,semaphore.h) 77libpthread_include_H := $(addprefix $(top_builddir)include/,pthread.h) 78libpthread_include_BITS_H := $(addprefix $(top_builddir)include/bits/,libc-lock.h stdio-lock.h) 79libpthread_include_STD_IMPL_OS_ARCH_BITS_H := $(addprefix $(top_builddir)include/bits/,pthreadtypes.h semaphore.h) 80 81$(libpthread_include_STD_IMPL_OS_ARCH_BITS_H): $(top_builddir)include/bits/%: 82 $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/bits/$(@F) $@ 83$(libpthread_include_BITS_H): $(top_builddir)include/bits/%: 84 $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/bits/$(@F) $@ 85$(libpthread_include_H): $(top_builddir)include/%: 86 $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/$(@F) $@ 87$(libpthread_H): $(top_builddir)include/%: 88 $(do_ln) $(call rel_srcdir)$(PTDIR)/$(@F) $@ 89 90nptl_headers_bootstrap = $(libpthread_H) $(libpthread_include_H) $(libpthread_include_BITS_H) $(libpthread_include_STD_IMPL_OS_ARCH_BITS_H) 91 92objclean-y += CLEAN_libpthread/nptl 93headers_clean-y += HEADERCLEAN_libpthread/nptl 94 95HEADERCLEAN_libpthread/nptl: 96 $(do_rm) $(nptl_headers_bootstrap) \ 97 $(libpthread_OUT)/pthread-errnos.h 98 99CLEAN_libpthread/nptl: 100 $(do_rm) $(addprefix $(libpthread_OUT)/*., o os oS a) 101 102CFLAGS-dir_nptl := -DNOT_IN_libc -DIS_IN_libpthread 103CFLAGS-libpthread/nptl := $(CFLAGS-dir_nptl) $(SSP_ALL_CFLAGS) 104 105# Since cancellation handling is in large parts handled using exceptions 106# we have to compile some files with exception handling enabled, some 107# even with asynchronous unwind tables. 108 109# init.c contains sigcancel_handler(). 110CFLAGS-init.c = -fexceptions -fasynchronous-unwind-tables 111# The unwind code itself, 112CFLAGS-unwind.c = -fexceptions 113CFLAGS-unwind-forcedunwind.c = -fexceptions -fasynchronous-unwind-tables 114 115# The following three functions must be async-cancel safe. 116CFLAGS-pthread_cancel.c = -fexceptions -fasynchronous-unwind-tables 117CFLAGS-pthread_setcancelstate.c = -fexceptions -fasynchronous-unwind-tables 118CFLAGS-pthread_setcanceltype.c = -fexceptions -fasynchronous-unwind-tables 119 120# These are internal functions which similar functionality as setcancelstate 121# and setcanceltype. 122CFLAGS-cancellation.c = -fasynchronous-unwind-tables 123CFLAGS-libc-cancellation.c = -fasynchronous-unwind-tables 124 125# Calling pthread_exit() must cause the registered cancel handlers to 126# be executed. Therefore exceptions have to be thrown through this 127# function. 128CFLAGS-pthread_exit.c = -fexceptions 129 130# The following are cancellation points. Some of the functions can 131# block and therefore temporarily enable asynchronous cancellation. 132# Those must be compiled asynchronous unwind tables. 133CFLAGS-pthread_testcancel.c = -fexceptions 134CFLAGS-pthread_join.c = -fexceptions -fasynchronous-unwind-tables 135CFLAGS-pthread_timedjoin.c = -fexceptions -fasynchronous-unwind-tables 136CFLAGS-pthread_once.c = $(uses-callbacks) -fexceptions \ 137 -fasynchronous-unwind-tables 138CFLAGS-pthread_cond_wait.c = -fexceptions -fasynchronous-unwind-tables 139CFLAGS-pthread_cond_timedwait.c = -fexceptions -fasynchronous-unwind-tables 140CFLAGS-sem_wait.c = -fexceptions -fasynchronous-unwind-tables 141CFLAGS-sem_timedwait.c = -fexceptions -fasynchronous-unwind-tables 142 143# These are the function wrappers we have to duplicate here. 144CFLAGS-accept.c = -fexceptions -fasynchronous-unwind-tables 145CFLAGS-clock_nanosleep.c = -fexceptions -fasynchronous-unwind-tables 146CFLAGS-close.c = -fexceptions -fasynchronous-unwind-tables 147CFLAGS-connect.c = -fexceptions -fasynchronous-unwind-tables 148CFLAGS-creat.c = -fexceptions -fasynchronous-unwind-tables 149CFLAGS-creat64.c = -fexceptions -fasynchronous-unwind-tables 150CFLAGS-fdatasync.c = -fexceptions -fasynchronous-unwind-tables 151CFLAGS-fsync.c = -fexceptions -fasynchronous-unwind-tables 152CFLAGS-lockf.c = -fexceptions 153CFLAGS-lockf64.c = -fexceptions 154CFLAGS-msgrcv.c = -fexceptions -fasynchronous-unwind-tables 155CFLAGS-msgsnd.c = -fexceptions -fasynchronous-unwind-tables 156CFLAGS-msync.c = -fexceptions -fasynchronous-unwind-tables 157CFLAGS-nanosleep.c = -fexceptions -fasynchronous-unwind-tables 158CFLAGS-open64.c = -fexceptions -fasynchronous-unwind-tables 159CFLAGS-open.c = -fexceptions -fasynchronous-unwind-tables 160CFLAGS-openat.c = -fexceptions -fasynchronous-unwind-tables 161CFLAGS-pause.c = -fexceptions -fasynchronous-unwind-tables 162CFLAGS-poll.c = -fexceptions -fasynchronous-unwind-tables 163CFLAGS-ppoll.c = -fexceptions -fasynchronous-unwind-tables 164CFLAGS-pread_write.c = -fexceptions -fasynchronous-unwind-tables 165CFLAGS-pselect.c = -fexceptions -fasynchronous-unwind-tables 166CFLAGS-read.c = -fexceptions -fasynchronous-unwind-tables 167CFLAGS-readv.c = -fexceptions -fasynchronous-unwind-tables 168CFLAGS-recv.c = -fexceptions -fasynchronous-unwind-tables 169CFLAGS-recvfrom.c = -fexceptions -fasynchronous-unwind-tables 170CFLAGS-recvmsg.c = -fexceptions -fasynchronous-unwind-tables 171CFLAGS-recvmmsg.c = -fexceptions -fasynchronous-unwind-tables 172CFLAGS-__rt_sigtimedwait.c = -fexceptions -fasynchronous-unwind-tables 173CFLAGS-__rt_sigwaitinfo.c = -fexceptions -fasynchronous-unwind-tables 174CFLAGS-select.c = -fexceptions -fasynchronous-unwind-tables 175CFLAGS-send.c = -fexceptions -fasynchronous-unwind-tables 176CFLAGS-sendmsg.c = -fexceptions -fasynchronous-unwind-tables 177CFLAGS-sendmmsg.c = -fexceptions -fasynchronous-unwind-tables 178CFLAGS-sendto.c = -fexceptions -fasynchronous-unwind-tables 179CFLAGS-sigpause.c = -fexceptions 180CFLAGS-sigsuspend.c = -fexceptions -fasynchronous-unwind-tables 181CFLAGS-sigtimedwait.c = -fexceptions -fasynchronous-unwind-tables 182CFLAGS-sigwait.c = -fexceptions -fasynchronous-unwind-tables 183CFLAGS-sigwaitinfo.c = -fexceptions -fasynchronous-unwind-tables 184CFLAGS-__syscall_fcntl64.c = -fexceptions -fasynchronous-unwind-tables 185CFLAGS-__syscall_fcntl.c = -fexceptions -fasynchronous-unwind-tables 186CFLAGS-tcdrain.c = -fexceptions -fasynchronous-unwind-tables 187CFLAGS-usleep.c = -fexceptions -fasynchronous-unwind-tables 188CFLAGS-wait4.c = -fexceptions -fasynchronous-unwind-tables 189CFLAGS-wait.c = -fexceptions -fasynchronous-unwind-tables 190CFLAGS-waitid.c = -fexceptions -fasynchronous-unwind-tables 191CFLAGS-waitpid.c = -fexceptions -fasynchronous-unwind-tables 192CFLAGS-write.c = -fexceptions -fasynchronous-unwind-tables 193CFLAGS-writev.c = -fexceptions -fasynchronous-unwind-tables 194 195# 196# The rest of this file is uClibc specific. 197# 198CFLAGS-pthread_barrier_init.c = -D_GNU_SOURCE 199CFLAGS-pthread_barrier_destroy.c = -D_GNU_SOURCE 200CFLAGS-pthread_barrierattr_init.c = -D_GNU_SOURCE 201CFLAGS-pthread_barrierattr_destroy.c = -D_GNU_SOURCE 202CFLAGS-pthread_barrierattr_getpshared.c = -D_GNU_SOURCE 203CFLAGS-pthread_barrierattr_setpshared.c = -D_GNU_SOURCE 204CFLAGS-sem_open.c = -D_GNU_SOURCE 205 206CFLAGS-OMIT-alloca_cutoff.c = $(CFLAGS-dir_nptl) 207CFLAGS-OMIT-libc-lowlevelock.c = $(CFLAGS-dir_nptl) 208CFLAGS-OMIT-libc-cancellation.c = $(CFLAGS-dir_nptl) 209