Makefile.in 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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. errno_location \
  97. herrno \
  98. pthread_kill_other_threads \
  99. pthread_getaffinity pthread_setaffinity \
  100. pthread_attr_getaffinity pthread_attr_setaffinity \
  101. cleanup_routine unwind-forcedunwind
  102. libpthread-routines-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += res
  103. libpthread-shared-only-routines = version pt-allocrtsig unwind-forcedunwind
  104. ifeq ($(TARGET_ARCH),x86_64)
  105. libpthread-routines-y := $(filter-out cancellation,$(libpthread-routines-y))
  106. endif
  107. CFLAGS-pthread_atfork.c = -DNOT_IN_libc
  108. # Since cancellation handling is in large parts handled using exceptions
  109. # we have to compile some files with exception handling enabled, some
  110. # even with asynchronous unwind tables.
  111. # init.c contains sigcancel_handler().
  112. CFLAGS-init.c = -fexceptions -fasynchronous-unwind-tables
  113. # The unwind code itself,
  114. CFLAGS-unwind.c = -fexceptions
  115. CFLAGS-unwind-forcedunwind.c = -fexceptions -fasynchronous-unwind-tables
  116. # The following three functions must be async-cancel safe.
  117. CFLAGS-pthread_cancel.c = -fexceptions -fasynchronous-unwind-tables
  118. CFLAGS-pthread_setcancelstate.c = -fexceptions -fasynchronous-unwind-tables
  119. CFLAGS-pthread_setcanceltype.c = -fexceptions -fasynchronous-unwind-tables
  120. # These are internal functions which similar functionality as setcancelstate
  121. # and setcanceltype.
  122. CFLAGS-cancellation.c = -fasynchronous-unwind-tables
  123. CFLAGS-libc-cancellation.c = -fasynchronous-unwind-tables
  124. # Calling pthread_exit() must cause the registered cancel handlers to
  125. # be executed. Therefore exceptions have to be thrown through this
  126. # function.
  127. CFLAGS-pthread_exit.c = -fexceptions
  128. # Among others, __pthread_unwind is forwarded. This function must handle
  129. # exceptions.
  130. CFLAGS-forward.c = -fexceptions
  131. # The following are cancellation points. Some of the functions can
  132. # block and therefore temporarily enable asynchronous cancellation.
  133. # Those must be compiled asynchronous unwind tables.
  134. CFLAGS-pthread_testcancel.c = -fexceptions
  135. CFLAGS-pthread_join.c = -fexceptions -fasynchronous-unwind-tables
  136. CFLAGS-pthread_timedjoin.c = -fexceptions -fasynchronous-unwind-tables
  137. CFLAGS-pthread_once.c = $(uses-callbacks) -fexceptions \
  138. -fasynchronous-unwind-tables
  139. CFLAGS-pthread_cond_wait.c = -fexceptions -fasynchronous-unwind-tables
  140. CFLAGS-pthread_cond_timedwait.c = -fexceptions -fasynchronous-unwind-tables
  141. CFLAGS-sem_wait.c = -fexceptions -fasynchronous-unwind-tables
  142. CFLAGS-sem_timedwait.c = -fexceptions -fasynchronous-unwind-tables
  143. # These are the function wrappers we have to duplicate here.
  144. CFLAGS-fcntl.c = -fexceptions -fasynchronous-unwind-tables
  145. CFLAGS-lockf.c = -fexceptions
  146. CFLAGS-pread.c = -fexceptions -fasynchronous-unwind-tables
  147. CFLAGS-pread64.c = -fexceptions -fasynchronous-unwind-tables
  148. CFLAGS-pwrite.c = -fexceptions -fasynchronous-unwind-tables
  149. CFLAGS-pwrite64.c = -fexceptions -fasynchronous-unwind-tables
  150. CFLAGS-wait.c = -fexceptions -fasynchronous-unwind-tables
  151. CFLAGS-waitpid.c = -fexceptions -fasynchronous-unwind-tables
  152. CFLAGS-sigwait.c = -fexceptions -fasynchronous-unwind-tables
  153. CFLAGS-msgrcv.c = -fexceptions -fasynchronous-unwind-tables
  154. CFLAGS-msgsnd.c = -fexceptions -fasynchronous-unwind-tables
  155. CFLAGS-tcdrain.c = -fexceptions -fasynchronous-unwind-tables
  156. CFLAGS-pt-system.c = -fexceptions -I./libc/stdlib
  157. #
  158. # The rest of this file is uClibc specific.
  159. #
  160. CFLAGS-pthread_barrier_init.c = -D_GNU_SOURCE
  161. CFLAGS-pthread_barrier_destroy.c = -D_GNU_SOURCE
  162. CFLAGS-pthread_barrierattr_init.c = -D_GNU_SOURCE
  163. CFLAGS-pthread_barrierattr_destroy.c = -D_GNU_SOURCE
  164. CFLAGS-pthread_barrierattr_getpshared.c = -D_GNU_SOURCE
  165. CFLAGS-pthread_barrierattr_setpshared.c = -D_GNU_SOURCE
  166. CFLAGS-sem_open.c = -D_GNU_SOURCE
  167. CFLAGS-nptl = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 $(SSP_ALL_CFLAGS)
  168. CFLAGS-OMIT-alloca_cutoff.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
  169. CFLAGS-OMIT-forward.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
  170. CFLAGS-OMIT-libc-lowlevelock.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
  171. CFLAGS-OMIT-libc-cancellation.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
  172. libpthread-os-routines = pthread_yield
  173. libpthread-misc-routines = pthread_rwlock_rdlock pthread_rwlock_timedrdlock \
  174. pthread_rwlock_wrlock pthread_rwlock_timedwrlock \
  175. pthread_rwlock_unlock pthread_cond_wait \
  176. pthread_cond_timedwait pthread_cond_signal \
  177. pthread_cond_broadcast pthread_spin_init \
  178. pthread_spin_destroy pthread_spin_lock \
  179. pthread_spin_trylock pthread_spin_unlock \
  180. pthread_barrier_init pthread_barrier_destroy \
  181. pthread_barrier_wait pthread_sigmask \
  182. pthread_kill pthread_once \
  183. pthread_getcpuclockid sem_wait \
  184. sem_trywait sem_timedwait \
  185. sem_post pt-longjmp \
  186. lowlevellock pt-vfork \
  187. ptw-close ptw-read ptw-write \
  188. ptw-fcntl ptw-accept ptw-connect \
  189. ptw-recv ptw-recvfrom ptw-recvmsg \
  190. ptw-send ptw-sendmsg ptw-sendto \
  191. ptw-fsync ptw-lseek ptw-llseek \
  192. ptw-msync ptw-nanosleep ptw-open \
  193. ptw-open64 ptw-pause ptw-pread \
  194. ptw-pread64 ptw-pwrite ptw-pwrite64 \
  195. ptw-tcdrain ptw-wait ptw-waitpid \
  196. ptw-msgrcv ptw-msgsnd ptw-sigwait \
  197. pt-raise flockfile ftrylockfile \
  198. funlockfile sigaction \
  199. pthread_getaffinity \
  200. pthread_setaffinity \
  201. pthread_attr_getaffinity \
  202. pthread_attr_setaffinity \
  203. unwind-forcedunwind
  204. ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
  205. LDFLAGS-libpthread.so := $(LDFLAGS_NOSTRIP) -Wl,-z,defs
  206. else
  207. LDFLAGS-libpthread.so := $(LDFLAGS)
  208. endif
  209. 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
  210. LIBS-libpthread.so := $(LIBS)
  211. ifneq ($(UCLIBC_CTOR_DTOR),y)
  212. START_FILE-libpthread.so := $(top_builddir)/libpthread/nptl/sysdeps/pthread/crti.o $(SHARED_START_FILES)
  213. END_FILE-libpthread.so := $(SHARED_END_FILES) $(top_builddir)/libpthread/nptl/sysdeps/pthread/crtn.o
  214. endif
  215. libpthread_FULL_NAME := libpthread-$(VERSION).so
  216. PTHREAD_DIR := $(top_srcdir)libpthread/nptl
  217. PTHREAD_OUT := $(top_builddir)libpthread/nptl
  218. libpthread_static_SRC := pthread_atfork
  219. libpthread_a_SRC = $(patsubst %, $(PTHREAD_DIR)/%.c, \
  220. $(filter-out $(libpthread-os-routines) \
  221. $(libpthread-misc-routines) \
  222. $(libpthread-shared-only-routines), \
  223. $(libpthread-routines-y)))
  224. libpthread_so_SRC = $(patsubst %, $(PTHREAD_DIR)/%.c, \
  225. $(filter-out $(libpthread-os-routines) \
  226. $(libpthread-misc-routines), $(libpthread-routines-y)))
  227. ifeq ($(TARGET_ARCH),x86_64)
  228. libc-static-y += $(patsubst %.c, $(PTHREAD_OUT)/%.o, alloca_cutoff.c)
  229. libc-shared-y += $(patsubst %.c, $(PTHREAD_OUT)/%.oS, forward.c)
  230. else
  231. libc-static-y += $(patsubst %.c, $(PTHREAD_OUT)/%.o, alloca_cutoff.c \
  232. libc-cancellation.c)
  233. libc-shared-y += $(patsubst %.c, $(PTHREAD_OUT)/%.oS, forward.c \
  234. libc-cancellation.c)
  235. endif
  236. libpthread-nonshared-y += $(patsubst %,$(PTHREAD_OUT)/%.oS,$(libpthread_static_SRC))
  237. ifeq ($(DOPIC),y)
  238. libpthread-a-y := $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.os,$(libpthread_a_SRC))
  239. else
  240. libpthread-a-y := $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.o,$(libpthread_a_SRC))
  241. endif
  242. libpthread-so-y := $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.oS,$(libpthread_so_SRC))
  243. libpthread-static-y += $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.o,$(libpthread_a_SRC) $(libpthread_static_SRC))
  244. objclean-y += CLEAN_libpthread/nptl
  245. headers_clean-y += HEADERCLEAN_libpthread/nptl
  246. -include $(PTHREAD_DIR)/sysdeps/generic/Makefile.in
  247. -include $(PTHREAD_DIR)/sysdeps/pthread/Makefile.in
  248. -include $(PTHREAD_DIR)/sysdeps/$(TARGET_ARCH)/Makefile.arch
  249. -include $(PTHREAD_DIR)/sysdeps/unix/sysv/linux/Makefile.in
  250. -include $(PTHREAD_DIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/Makefile.arch
  251. lib-a-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.a
  252. lib-so-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.so
  253. $(top_builddir)lib/libpthread.so: $(PTHREAD_OUT)/libpthread_so.a $(libc.depend) $(libdl.depend) $(top_builddir)lib/libpthread_nonshared.a
  254. $(call link.so,$(libpthread_FULL_NAME),$(ABI_VERSION))
  255. $(Q)cat $(top_srcdir)extra/scripts/format.lds > $@.tmp
  256. $(Q)echo "GROUP ( $(notdir $@).$(ABI_VERSION) libpthread_nonshared.a )" >> $@.tmp
  257. $(Q)mv $@.tmp $@
  258. ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
  259. $(PTHREAD_OUT)/libpthread_so.a: STRIP_FLAGS:=$(STRIP_FLAGS:-x=-X --strip-debug)
  260. endif
  261. $(PTHREAD_OUT)/libpthread_so.a: $(libpthread-so-y)
  262. $(Q)$(RM) $@
  263. $(do_ar)
  264. $(top_builddir)lib/libpthread.a: $(libpthread-a-y)
  265. $(Q)$(INSTALL) -d $(dir $@)
  266. $(Q)$(RM) $@
  267. $(do_ar)
  268. #
  269. # Create 'pthread-errnos.h' header file.
  270. #
  271. CFLAGS-pthread-errnos.c = -S
  272. $(PTHREAD_OUT)/pthread-errnos.c: $(PTHREAD_DIR)/pthread-errnos.sym
  273. $(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
  274. $(PTHREAD_OUT)/pthread-errnos.s: $(PTHREAD_OUT)/pthread-errnos.c
  275. $(compile.c)
  276. $(PTHREAD_OUT)/pthread-errnos.h: $(PTHREAD_OUT)/pthread-errnos.s
  277. $(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
  278. pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(PTHREAD_OUT)/pthread-errnos.h
  279. headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(nptl_headers_bootstrap)
  280. LIBPTHREAD_H := $(addprefix $(top_builddir)include/,semaphore.h)
  281. LIBPTHREAD_INCLUDE_H := $(addprefix $(top_builddir)include/,pthread.h)
  282. LIBPTHREAD_INCLUDE_BITS_H := $(addprefix $(top_builddir)include/bits/,libc-lock.h stdio-lock.h)
  283. LIBPTHREAD_INCLUDE_STD_IMPL_OS_ARCH_BITS_H := $(addprefix $(top_builddir)include/bits/,pthreadtypes.h semaphore.h)
  284. $(LIBPTHREAD_INCLUDE_STD_IMPL_OS_ARCH_BITS_H): $(top_builddir)include/bits/%: | $(top_builddir)include/bits
  285. $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/bits/$(@F) $@
  286. $(LIBPTHREAD_INCLUDE_BITS_H): $(top_builddir)include/bits/%: | $(top_builddir)include/bits
  287. $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/bits/$(@F) $@
  288. $(LIBPTHREAD_INCLUDE_H): $(top_builddir)include/%: | $(top_builddir)include
  289. $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/$(@F) $@
  290. $(LIBPTHREAD_H): $(top_builddir)include/%: | $(top_builddir)include
  291. $(do_ln) $(call rel_srcdir)$(PTDIR)/$(@F) $@
  292. nptl_headers_bootstrap = $(LIBPTHREAD_H) $(LIBPTHREAD_INCLUDE_H) $(LIBPTHREAD_INCLUDE_BITS_H) $(LIBPTHREAD_INCLUDE_STD_IMPL_OS_ARCH_BITS_H)
  293. HEADERCLEAN_libpthread/nptl:
  294. $(do_rm) $(nptl_headers_bootstrap) \
  295. $(addprefix $(PTHREAD_OUT)/pthread-errnos., c h s)
  296. CLEAN_libpthread/nptl:
  297. $(do_rm) $(addprefix $(PTHREAD_OUT)/*., o os oS a)