Makefile.in 14 KB

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