Makefile.in 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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. subdirs += libpthread/nptl/sysdeps/$(TARGET_ARCH) \
  8. libpthread/nptl/sysdeps/unix/sysv/linux \
  9. libpthread/nptl/sysdeps/pthread
  10. libpthread-routines-y = init vars events version \
  11. pthread_create pthread_exit pthread_detach \
  12. pthread_join pthread_tryjoin pthread_timedjoin \
  13. pthread_self pthread_equal pthread_yield \
  14. pthread_getconcurrency pthread_setconcurrency \
  15. pthread_getschedparam pthread_setschedparam \
  16. pthread_setschedprio \
  17. pthread_attr_init pthread_attr_destroy \
  18. pthread_attr_getdetachstate pthread_attr_setdetachstate \
  19. pthread_attr_getguardsize pthread_attr_setguardsize \
  20. pthread_attr_getschedparam pthread_attr_setschedparam \
  21. pthread_attr_getschedpolicy pthread_attr_setschedpolicy \
  22. pthread_attr_getinheritsched \
  23. pthread_attr_setinheritsched \
  24. pthread_attr_getscope pthread_attr_setscope \
  25. pthread_attr_getstackaddr pthread_attr_setstackaddr \
  26. pthread_attr_getstacksize pthread_attr_setstacksize \
  27. pthread_attr_getstack pthread_attr_setstack \
  28. pthread_getattr_np \
  29. pthread_mutex_init pthread_mutex_destroy \
  30. pthread_mutex_lock pthread_mutex_trylock \
  31. pthread_mutex_timedlock pthread_mutex_unlock \
  32. pthread_mutex_consistent \
  33. pthread_mutexattr_init pthread_mutexattr_destroy \
  34. pthread_mutexattr_getpshared \
  35. pthread_mutexattr_setpshared \
  36. pthread_mutexattr_getrobust \
  37. pthread_mutexattr_setrobust \
  38. pthread_mutexattr_getprotocol \
  39. pthread_mutexattr_setprotocol \
  40. pthread_mutexattr_getprioceiling \
  41. pthread_mutexattr_setprioceiling \
  42. pthread_mutexattr_gettype pthread_mutexattr_settype \
  43. pthread_rwlock_init pthread_rwlock_destroy \
  44. pthread_rwlock_rdlock pthread_rwlock_timedrdlock \
  45. pthread_rwlock_wrlock pthread_rwlock_timedwrlock \
  46. pthread_rwlock_tryrdlock pthread_rwlock_trywrlock \
  47. pthread_rwlock_unlock \
  48. pthread_rwlockattr_init pthread_rwlockattr_destroy \
  49. pthread_rwlockattr_getpshared \
  50. pthread_rwlockattr_setpshared \
  51. pthread_rwlockattr_getkind_np \
  52. pthread_rwlockattr_setkind_np \
  53. pthread_cond_init pthread_cond_destroy \
  54. pthread_cond_wait pthread_cond_timedwait \
  55. pthread_cond_signal pthread_cond_broadcast \
  56. pthread_condattr_init pthread_condattr_destroy \
  57. pthread_condattr_getpshared pthread_condattr_setpshared \
  58. pthread_condattr_getclock pthread_condattr_setclock \
  59. pthread_spin_init pthread_spin_destroy \
  60. pthread_spin_lock pthread_spin_trylock \
  61. pthread_spin_unlock \
  62. pthread_barrier_init pthread_barrier_destroy \
  63. pthread_barrier_wait \
  64. pthread_barrierattr_init pthread_barrierattr_destroy \
  65. pthread_barrierattr_getpshared \
  66. pthread_barrierattr_setpshared \
  67. pthread_key_create pthread_key_delete \
  68. pthread_getspecific pthread_setspecific \
  69. pthread_sigmask pthread_kill \
  70. pthread_cancel pthread_testcancel \
  71. pthread_setcancelstate pthread_setcanceltype \
  72. pthread_once \
  73. pthread_atfork \
  74. pthread_getcpuclockid \
  75. pthread_clock_gettime pthread_clock_settime \
  76. sem_init sem_destroy \
  77. sem_open sem_close sem_unlink \
  78. sem_getvalue \
  79. sem_wait sem_trywait sem_timedwait sem_post \
  80. cleanup cleanup_defer cleanup_compat \
  81. cleanup_defer_compat unwind \
  82. pt-longjmp pt-cleanup\
  83. cancellation \
  84. lowlevellock \
  85. pt-vfork \
  86. ptw-write ptw-read ptw-close ptw-fcntl ptw-accept \
  87. ptw-connect ptw-recv ptw-recvfrom ptw-recvmsg ptw-send \
  88. ptw-sendmsg ptw-sendto ptw-fsync ptw-lseek ptw-llseek \
  89. ptw-msync ptw-nanosleep ptw-open ptw-open64 ptw-pause \
  90. ptw-pread ptw-pread64 ptw-pwrite ptw-pwrite64 \
  91. ptw-tcdrain ptw-wait ptw-waitpid ptw-msgrcv ptw-msgsnd \
  92. ptw-sigwait \
  93. pt-raise pt-system \
  94. flockfile ftrylockfile funlockfile \
  95. sigaction \
  96. herrno \
  97. pthread_kill_other_threads \
  98. pthread_getaffinity pthread_setaffinity \
  99. pthread_attr_getaffinity pthread_attr_setaffinity \
  100. cleanup_routine unwind-forcedunwind
  101. libpthread-routines-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += res
  102. libpthread-shared-only-routines = version pt-allocrtsig unwind-forcedunwind
  103. ifeq ($(TARGET_ARCH),x86_64)
  104. libpthread-routines-y := $(filter-out cancellation,$(libpthread-routines-y))
  105. endif
  106. CFLAGS-pthread_atfork.c = -DNOT_IN_libc
  107. # Since cancellation handling is in large parts handled using exceptions
  108. # we have to compile some files with exception handling enabled, some
  109. # even with asynchronous unwind tables.
  110. # init.c contains sigcancel_handler().
  111. CFLAGS-init.c = -fexceptions -fasynchronous-unwind-tables
  112. # The unwind code itself,
  113. CFLAGS-unwind.c = -fexceptions
  114. CFLAGS-unwind-forcedunwind.c = -fexceptions -fasynchronous-unwind-tables
  115. # The following three functions must be async-cancel safe.
  116. CFLAGS-pthread_cancel.c = -fexceptions -fasynchronous-unwind-tables
  117. CFLAGS-pthread_setcancelstate.c = -fexceptions -fasynchronous-unwind-tables
  118. CFLAGS-pthread_setcanceltype.c = -fexceptions -fasynchronous-unwind-tables
  119. # These are internal functions which similar functionality as setcancelstate
  120. # and setcanceltype.
  121. CFLAGS-cancellation.c = -fasynchronous-unwind-tables
  122. CFLAGS-libc-cancellation.c = -fasynchronous-unwind-tables
  123. # Calling pthread_exit() must cause the registered cancel handlers to
  124. # be executed. Therefore exceptions have to be thrown through this
  125. # function.
  126. CFLAGS-pthread_exit.c = -fexceptions
  127. # Among others, __pthread_unwind is forwarded. This function must handle
  128. # exceptions.
  129. CFLAGS-forward.c = -fexceptions
  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.
  133. CFLAGS-pthread_testcancel.c = -fexceptions
  134. CFLAGS-pthread_join.c = -fexceptions -fasynchronous-unwind-tables
  135. CFLAGS-pthread_timedjoin.c = -fexceptions -fasynchronous-unwind-tables
  136. CFLAGS-pthread_once.c = $(uses-callbacks) -fexceptions \
  137. -fasynchronous-unwind-tables
  138. CFLAGS-pthread_cond_wait.c = -fexceptions -fasynchronous-unwind-tables
  139. CFLAGS-pthread_cond_timedwait.c = -fexceptions -fasynchronous-unwind-tables
  140. CFLAGS-sem_wait.c = -fexceptions -fasynchronous-unwind-tables
  141. CFLAGS-sem_timedwait.c = -fexceptions -fasynchronous-unwind-tables
  142. # These are the function wrappers we have to duplicate here.
  143. CFLAGS-fcntl.c = -fexceptions -fasynchronous-unwind-tables
  144. CFLAGS-lockf.c = -fexceptions
  145. CFLAGS-pread.c = -fexceptions -fasynchronous-unwind-tables
  146. CFLAGS-pread64.c = -fexceptions -fasynchronous-unwind-tables
  147. CFLAGS-pwrite.c = -fexceptions -fasynchronous-unwind-tables
  148. CFLAGS-pwrite64.c = -fexceptions -fasynchronous-unwind-tables
  149. CFLAGS-wait.c = -fexceptions -fasynchronous-unwind-tables
  150. CFLAGS-waitpid.c = -fexceptions -fasynchronous-unwind-tables
  151. CFLAGS-sigwait.c = -fexceptions -fasynchronous-unwind-tables
  152. CFLAGS-msgrcv.c = -fexceptions -fasynchronous-unwind-tables
  153. CFLAGS-msgsnd.c = -fexceptions -fasynchronous-unwind-tables
  154. CFLAGS-tcdrain.c = -fexceptions -fasynchronous-unwind-tables
  155. CFLAGS-pt-system.c = -fexceptions -I./libc/stdlib
  156. #
  157. # The rest of this file is uClibc specific.
  158. #
  159. CFLAGS-pthread_barrier_init.c = -D_GNU_SOURCE
  160. CFLAGS-pthread_barrier_destroy.c = -D_GNU_SOURCE
  161. CFLAGS-pthread_barrierattr_init.c = -D_GNU_SOURCE
  162. CFLAGS-pthread_barrierattr_destroy.c = -D_GNU_SOURCE
  163. CFLAGS-pthread_barrierattr_getpshared.c = -D_GNU_SOURCE
  164. CFLAGS-pthread_barrierattr_setpshared.c = -D_GNU_SOURCE
  165. CFLAGS-sem_open.c = -D_GNU_SOURCE
  166. CFLAGS-nptl = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 $(SSP_ALL_CFLAGS)
  167. CFLAGS-OMIT-alloca_cutoff.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
  168. CFLAGS-OMIT-forward.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
  169. CFLAGS-OMIT-libc-lowlevelock.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
  170. CFLAGS-OMIT-libc-cancellation.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
  171. libpthread-os-routines = pthread_yield
  172. libpthread-misc-routines = pthread_rwlock_rdlock pthread_rwlock_timedrdlock \
  173. pthread_rwlock_wrlock pthread_rwlock_timedwrlock \
  174. pthread_rwlock_unlock pthread_cond_wait \
  175. pthread_cond_timedwait pthread_cond_signal \
  176. pthread_cond_broadcast pthread_spin_init \
  177. pthread_spin_destroy pthread_spin_lock \
  178. pthread_spin_trylock pthread_spin_unlock \
  179. pthread_barrier_init pthread_barrier_destroy \
  180. pthread_barrier_wait pthread_sigmask \
  181. pthread_kill pthread_once \
  182. pthread_getcpuclockid sem_wait \
  183. sem_trywait sem_timedwait \
  184. sem_post pt-longjmp \
  185. lowlevellock pt-vfork \
  186. ptw-close ptw-read ptw-write \
  187. ptw-fcntl ptw-accept ptw-connect \
  188. ptw-recv ptw-recvfrom ptw-recvmsg \
  189. ptw-send ptw-sendmsg ptw-sendto \
  190. ptw-fsync ptw-lseek ptw-llseek \
  191. ptw-msync ptw-nanosleep ptw-open \
  192. ptw-open64 ptw-pause ptw-pread \
  193. ptw-pread64 ptw-pwrite ptw-pwrite64 \
  194. ptw-tcdrain ptw-wait ptw-waitpid \
  195. ptw-msgrcv ptw-msgsnd ptw-sigwait \
  196. pt-raise flockfile ftrylockfile \
  197. funlockfile sigaction \
  198. pthread_getaffinity \
  199. pthread_setaffinity \
  200. pthread_attr_getaffinity \
  201. pthread_attr_setaffinity \
  202. unwind-forcedunwind
  203. ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
  204. LDFLAGS-libpthread.so := $(LDFLAGS_NOSTRIP) -Wl,-z,defs
  205. else
  206. LDFLAGS-libpthread.so := $(LDFLAGS)
  207. endif
  208. LDFLAGS-libpthread.so += $(top_builddir)lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so $(top_builddir)lib/libdl-$(VERSION).so -Wl,-z,nodelete,-z,initfirst,-init=__pthread_initialize_minimal_internal
  209. LIBS-libpthread.so := $(LIBS)
  210. ifneq ($(UCLIBC_CTOR_DTOR),y)
  211. START_FILE-libpthread.so := $(top_builddir)/libpthread/nptl/sysdeps/pthread/crti.o $(SHARED_START_FILES)
  212. END_FILE-libpthread.so := $(SHARED_END_FILES) $(top_builddir)/libpthread/nptl/sysdeps/pthread/crtn.o
  213. endif
  214. libpthread_FULL_NAME := libpthread-$(VERSION).so
  215. PTHREAD_DIR := $(top_srcdir)libpthread/nptl
  216. PTHREAD_OUT := $(top_builddir)libpthread/nptl
  217. libpthread_static_SRC := pthread_atfork
  218. libpthread_a_SRC = $(patsubst %, $(PTHREAD_DIR)/%.c, \
  219. $(filter-out $(libpthread-os-routines) \
  220. $(libpthread-misc-routines) \
  221. $(libpthread-shared-only-routines), \
  222. $(libpthread-routines-y)))
  223. libpthread_so_SRC = $(patsubst %, $(PTHREAD_DIR)/%.c, \
  224. $(filter-out $(libpthread-os-routines) \
  225. $(libpthread-misc-routines), $(libpthread-routines-y)))
  226. ifeq ($(TARGET_ARCH),x86_64)
  227. libc-static-y += $(patsubst %.c, $(PTHREAD_OUT)/%.o, alloca_cutoff.c)
  228. libc-shared-y += $(patsubst %.c, $(PTHREAD_OUT)/%.oS, forward.c)
  229. else
  230. libc-static-y += $(patsubst %.c, $(PTHREAD_OUT)/%.o, alloca_cutoff.c \
  231. libc-cancellation.c)
  232. libc-shared-y += $(patsubst %.c, $(PTHREAD_OUT)/%.oS, forward.c \
  233. libc-cancellation.c)
  234. endif
  235. libpthread-nonshared-y += $(patsubst %,$(PTHREAD_OUT)/%.oS,$(libpthread_static_SRC))
  236. ifeq ($(DOPIC),y)
  237. libpthread-a-y := $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.os,$(libpthread_a_SRC))
  238. else
  239. libpthread-a-y := $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.o,$(libpthread_a_SRC))
  240. endif
  241. libpthread-so-y := $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.oS,$(libpthread_so_SRC))
  242. libpthread-static-y += $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.o,$(libpthread_a_SRC) $(libpthread_static_SRC))
  243. objclean-y += CLEAN_libpthread/nptl
  244. headers_clean-y += HEADERCLEAN_libpthread/nptl
  245. -include $(PTHREAD_DIR)/sysdeps/generic/Makefile.in
  246. -include $(PTHREAD_DIR)/sysdeps/pthread/Makefile.in
  247. -include $(PTHREAD_DIR)/sysdeps/$(TARGET_ARCH)/Makefile.arch
  248. -include $(PTHREAD_DIR)/sysdeps/unix/sysv/linux/Makefile.in
  249. -include $(PTHREAD_DIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/Makefile.arch
  250. lib-a-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.a
  251. lib-so-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.so
  252. $(top_builddir)lib/libpthread.so: $(PTHREAD_OUT)/libpthread_so.a $(libc.depend) $(libdl.depend) $(top_builddir)lib/libpthread_nonshared.a
  253. $(call link.so,$(libpthread_FULL_NAME),$(ABI_VERSION))
  254. $(Q)cat $(top_srcdir)extra/scripts/format.lds > $@.tmp
  255. $(Q)echo "GROUP ( $(notdir $@).$(ABI_VERSION) libpthread_nonshared.a )" >> $@.tmp
  256. $(Q)mv $@.tmp $@
  257. ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
  258. $(PTHREAD_OUT)/libpthread_so.a: STRIP_FLAGS:=$(STRIP_FLAGS:-x=-X --strip-debug)
  259. endif
  260. $(PTHREAD_OUT)/libpthread_so.a: $(libpthread-so-y)
  261. $(Q)$(RM) $@
  262. $(do_ar)
  263. $(top_builddir)lib/libpthread.a: $(libpthread-a-y)
  264. $(Q)$(INSTALL) -d $(dir $@)
  265. $(Q)$(RM) $@
  266. $(do_ar)
  267. #
  268. # Create 'pthread-errnos.h' header file.
  269. #
  270. CFLAGS-pthread-errnos.c = -S
  271. $(PTHREAD_OUT)/pthread-errnos.c: $(PTHREAD_DIR)/pthread-errnos.sym
  272. $(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
  273. $(PTHREAD_OUT)/pthread-errnos.s: $(PTHREAD_OUT)/pthread-errnos.c
  274. $(compile.c)
  275. $(PTHREAD_OUT)/pthread-errnos.h: $(PTHREAD_OUT)/pthread-errnos.s
  276. $(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
  277. pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(PTHREAD_OUT)/pthread-errnos.h
  278. headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(nptl_headers_bootstrap)
  279. LIBPTHREAD_H := $(addprefix $(top_builddir)include/,semaphore.h)
  280. LIBPTHREAD_INCLUDE_H := $(addprefix $(top_builddir)include/,pthread.h)
  281. LIBPTHREAD_INCLUDE_BITS_H := $(addprefix $(top_builddir)include/bits/,libc-lock.h stdio-lock.h)
  282. LIBPTHREAD_INCLUDE_STD_IMPL_OS_ARCH_BITS_H := $(addprefix $(top_builddir)include/bits/,pthreadtypes.h semaphore.h)
  283. $(LIBPTHREAD_INCLUDE_STD_IMPL_OS_ARCH_BITS_H): $(top_builddir)include/bits/%: | $(top_builddir)include/bits
  284. $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/bits/$(@F) $@
  285. $(LIBPTHREAD_INCLUDE_BITS_H): $(top_builddir)include/bits/%: | $(top_builddir)include/bits
  286. $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/bits/$(@F) $@
  287. $(LIBPTHREAD_INCLUDE_H): $(top_builddir)include/%: | $(top_builddir)include
  288. $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/$(@F) $@
  289. $(LIBPTHREAD_H): $(top_builddir)include/%: | $(top_builddir)include
  290. $(do_ln) $(call rel_srcdir)$(PTDIR)/$(@F) $@
  291. nptl_headers_bootstrap = $(LIBPTHREAD_H) $(LIBPTHREAD_INCLUDE_H) $(LIBPTHREAD_INCLUDE_BITS_H) $(LIBPTHREAD_INCLUDE_STD_IMPL_OS_ARCH_BITS_H)
  292. HEADERCLEAN_libpthread/nptl:
  293. $(do_rm) $(nptl_headers_bootstrap) \
  294. $(addprefix $(PTHREAD_OUT)/pthread-errnos., c h s)
  295. CLEAN_libpthread/nptl:
  296. $(do_rm) $(addprefix $(PTHREAD_OUT)/*., o os oS a)