Makefile.in 14 KB

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