Makefile.in 14 KB

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