Makefile.in 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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
  8. libpthread_DIR = $(top_srcdir)libpthread/nptl
  9. libpthread_OUT = $(top_builddir)libpthread/nptl
  10. include $(libpthread_DIR)/sysdeps/Makefile.in
  11. libc-shared-routines-y = forward.c libc-cancellation.c
  12. libc-static-routines-y = alloca_cutoff.c libc-cancellation.c
  13. libpthread-shared-only-routines-y = version.c
  14. libpthread-static-only-routines-y = pthread_atfork.c
  15. libpthread-routines- += $(notdir $(wildcard $(libpthread_DIR)/gen_*.c)) # dummy generated files
  16. libpthread-routines- += allocatestack.c # dummy included by pthread_create.c
  17. libpthread-routines- += pthread_mutex_getprioceiling.c pthread_mutex_setprioceiling.c # XXX: delete those or use them!
  18. libpthread-routines-$(UCLIBC_HAS_RESOLVER_SUPPORT) += res.c
  19. libpthread-routines-$(UCLIBC_SUSV4_LEGACY) += pthread_getconcurrency.c \
  20. pthread_setconcurrency.c
  21. libpthread_CSRC = $(filter-out $(libpthread-routines-) \
  22. $(libc-shared-routines-y) \
  23. $(libc-static-routines-y) \
  24. $(libpthread-shared-only-routines-y) \
  25. $(libpthread-static-only-routines-y) \
  26. $(notdir $(libpthread_OBJS:.o=.c)), \
  27. $(notdir $(wildcard $(libpthread_DIR)/*.c)))
  28. libpthread_OBJS += $(addprefix $(libpthread_OUT)/,$(libpthread_CSRC:.c=.o))
  29. libpthread-so-y += $(addprefix $(libpthread_OUT)/,$(libpthread-shared-only-routines-y:.c=.oS))
  30. libpthread-so-y += $(libpthread_OBJS:.o=.oS)
  31. libpthread-nonshared-y := $(addprefix $(libpthread_OUT)/,$(libpthread-static-only-routines-y:.c=.oS))
  32. libpthread-static-y := $(addprefix $(libpthread_OUT)/,$(libpthread-static-only-routines-y:.c=.o))
  33. libpthread-static-y += $(libpthread_OBJS)
  34. ifeq ($(DOPIC),y)
  35. libpthread-a-y := $(libpthread-static-y:.o=.os)
  36. else
  37. libpthread-a-y := $(libpthread-static-y)
  38. endif
  39. libc-shared-routines-y := $(filter-out $(notdir $(libpthread_libc_OBJS:.o=.c)), $(libc-shared-routines-y))
  40. libc-static-routines-y := $(filter-out $(notdir $(libpthread_libc_OBJS:.o=.c)), $(libc-static-routines-y))
  41. libc-shared-routines-y := $(addprefix $(libpthread_OUT)/,$(libc-shared-routines-y:.c=.oS))
  42. libc-static-routines-y := $(addprefix $(libpthread_OUT)/,$(libc-static-routines-y:.c=.o))
  43. libc-shared-y += $(libc-shared-routines-y) $(libpthread_libc_OBJS:.o=.oS)
  44. ifeq ($(DOPIC),y)
  45. libc-static-y += $(libc-static-routines-y:.o=.os) $(libpthread_libc_a_OBJS:.o=.os) $(libpthread_ld_tls_COBJ:.o=.os)
  46. else
  47. libc-static-y += $(libc-static-routines-y) $(libpthread_libc_a_OBJS) $(libpthread_ld_tls_COBJ)
  48. endif
  49. librt-pt-routines-y := $(patsubst %.c,$(libpthread_pthread_OUT)/%.o,$(filter-out $(notdir $(libpthread_librt_OBJS:.o=.c)), $(librt-pt-routines-y)))
  50. librt-pt-shared-only-routines-y := $(patsubst %.c,$(libpthread_pthread_OUT)/%.o,$(filter-out $(notdir $(libpthread_librt_OBJS:.o=.c)), $(librt-pt-shared-only-routines-y)))
  51. librt_OBJS = $(libpthread_librt_OBJS) $(librt-pt-routines-y)
  52. ifeq ($(DOPIC),y)
  53. librt-a-y += $(librt_OBJS:.o=.os)
  54. else
  55. librt-a-y += $(librt_OBJS)
  56. endif
  57. librt-so-y += $(librt_OBJS:.o=.oS) $(librt-pt-shared-only-routines-y:.o=.oS)
  58. ifeq ($(UCLIBC_CTOR_DTOR),y)
  59. START_FILE-libpthread.so := $(top_builddir)libpthread/nptl/sysdeps/pthread/pt-crti.o
  60. END_FILE-libpthread.so := $(top_builddir)libpthread/nptl/sysdeps/pthread/pt-crtn.o
  61. LDFLAGS-libpthread.so += -nostartfiles
  62. $(top_builddir)lib/libpthread.so: | $(START_FILE-libpthread.so) $(END_FILE-libpthread.so)
  63. endif
  64. libpthread_FULL_NAME := libpthread-$(VERSION).so
  65. lib-a-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.a
  66. lib-so-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.so
  67. $(top_builddir)lib/libpthread.so: $(libpthread_OUT)/libpthread_so.a $(libc.depend) $(libdl.depend) $(top_builddir)lib/libpthread_nonshared.a
  68. $(call link.so,$(libpthread_FULL_NAME),$(ABI_VERSION))
  69. $(Q)cat $(top_srcdir)extra/scripts/format.lds > $@.tmp
  70. $(Q)echo "GROUP ( $(notdir $@).$(ABI_VERSION) libpthread_nonshared.a )" >> $@.tmp
  71. $(Q)mv $@.tmp $@
  72. ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
  73. $(libpthread_OUT)/libpthread_so.a: STRIP_FLAGS:=$(STRIP_FLAGS:-x=-X --strip-debug)
  74. endif
  75. $(libpthread_OUT)/libpthread_so.a: $(libpthread-so-y)
  76. $(Q)$(RM) $@
  77. $(do_ar)
  78. $(top_builddir)lib/libpthread.a: $(libpthread-a-y)
  79. $(Q)$(INSTALL) -d $(dir $@)
  80. $(Q)$(RM) $@
  81. $(do_ar)
  82. $(libpthread_OUT)/pthread-errnos.h: $(top_srcdir)extra/scripts/gen-as-const.awk
  83. $(libpthread_OUT)/pthread-errnos.h: $(libpthread_DIR)/pthread-errnos.sym
  84. @$(disp_gen)
  85. $(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< \
  86. | $(CC) $(CFLAGS) -x c - -S -o - \
  87. | $(SED) $(PTHREAD_GENERATE_MANGLE) > $@
  88. @if test ! -s $@ ; then rm -f $@ ; false ; fi
  89. pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(libpthread_OUT)/pthread-errnos.h
  90. headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(nptl_headers_bootstrap)
  91. libpthread_H := $(addprefix $(top_builddir)include/,semaphore.h)
  92. libpthread_include_H := $(addprefix $(top_builddir)include/,pthread.h)
  93. libpthread_include_BITS_H := $(addprefix $(top_builddir)include/bits/,libc-lock.h stdio-lock.h)
  94. libpthread_include_STD_IMPL_OS_ARCH_BITS_H := $(addprefix $(top_builddir)include/bits/,pthreadtypes.h semaphore.h)
  95. $(libpthread_include_STD_IMPL_OS_ARCH_BITS_H): $(top_builddir)include/bits/%:
  96. $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/bits/$(@F) $@
  97. $(libpthread_include_BITS_H): $(top_builddir)include/bits/%:
  98. $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/bits/$(@F) $@
  99. $(libpthread_include_H): $(top_builddir)include/%:
  100. $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/$(@F) $@
  101. $(libpthread_H): $(top_builddir)include/%:
  102. $(do_ln) $(call rel_srcdir)$(PTDIR)/$(@F) $@
  103. nptl_headers_bootstrap = $(libpthread_H) $(libpthread_include_H) $(libpthread_include_BITS_H) $(libpthread_include_STD_IMPL_OS_ARCH_BITS_H)
  104. objclean-y += CLEAN_libpthread/nptl
  105. headers_clean-y += HEADERCLEAN_libpthread/nptl
  106. HEADERCLEAN_libpthread/nptl:
  107. $(do_rm) $(nptl_headers_bootstrap) \
  108. $(libpthread_OUT)/pthread-errnos.h
  109. CLEAN_libpthread/nptl:
  110. $(do_rm) $(addprefix $(libpthread_OUT)/*., o os oS a)
  111. ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
  112. LDFLAGS-libpthread.so += $(LDFLAGS_NOSTRIP) -Wl,-z,defs
  113. else
  114. LDFLAGS-libpthread.so += $(LDFLAGS)
  115. endif
  116. LDFLAGS-libpthread.so += $(top_builddir)lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so $(top_builddir)lib/libdl-$(VERSION).so \
  117. -Wl,-z,nodelete,-z,initfirst,-init=$(SYMBOL_PREFIX)__pthread_initialize_minimal_internal
  118. LIBS-libpthread.so := $(LIBS)
  119. CFLAGS-dir_nptl := -DNOT_IN_libc -DIS_IN_libpthread
  120. CFLAGS-libpthread/nptl := $(CFLAGS-dir_nptl) $(SSP_ALL_CFLAGS)
  121. # Since cancellation handling is in large parts handled using exceptions
  122. # we have to compile some files with exception handling enabled, some
  123. # even with asynchronous unwind tables.
  124. # init.c contains sigcancel_handler().
  125. CFLAGS-init.c = -fexceptions -fasynchronous-unwind-tables
  126. # The unwind code itself,
  127. CFLAGS-unwind.c = -fexceptions
  128. CFLAGS-unwind-forcedunwind.c = -fexceptions -fasynchronous-unwind-tables
  129. # The following three functions must be async-cancel safe.
  130. CFLAGS-pthread_cancel.c = -fexceptions -fasynchronous-unwind-tables
  131. CFLAGS-pthread_setcancelstate.c = -fexceptions -fasynchronous-unwind-tables
  132. CFLAGS-pthread_setcanceltype.c = -fexceptions -fasynchronous-unwind-tables
  133. # These are internal functions which similar functionality as setcancelstate
  134. # and setcanceltype.
  135. CFLAGS-cancellation.c = -fasynchronous-unwind-tables
  136. CFLAGS-libc-cancellation.c = -fasynchronous-unwind-tables
  137. # Calling pthread_exit() must cause the registered cancel handlers to
  138. # be executed. Therefore exceptions have to be thrown through this
  139. # function.
  140. CFLAGS-pthread_exit.c = -fexceptions
  141. # Among others, __pthread_unwind is forwarded. This function must handle
  142. # exceptions.
  143. CFLAGS-forward.c = -fexceptions
  144. # The following are cancellation points. Some of the functions can
  145. # block and therefore temporarily enable asynchronous cancellation.
  146. # Those must be compiled asynchronous unwind tables.
  147. CFLAGS-pthread_testcancel.c = -fexceptions
  148. CFLAGS-pthread_join.c = -fexceptions -fasynchronous-unwind-tables
  149. CFLAGS-pthread_timedjoin.c = -fexceptions -fasynchronous-unwind-tables
  150. CFLAGS-pthread_once.c = $(uses-callbacks) -fexceptions \
  151. -fasynchronous-unwind-tables
  152. CFLAGS-pthread_cond_wait.c = -fexceptions -fasynchronous-unwind-tables
  153. CFLAGS-pthread_cond_timedwait.c = -fexceptions -fasynchronous-unwind-tables
  154. CFLAGS-sem_wait.c = -fexceptions -fasynchronous-unwind-tables
  155. CFLAGS-sem_timedwait.c = -fexceptions -fasynchronous-unwind-tables
  156. # These are the function wrappers we have to duplicate here.
  157. CFLAGS-accept.c = -fexceptions -fasynchronous-unwind-tables
  158. CFLAGS-clock_nanosleep.c = -fexceptions -fasynchronous-unwind-tables
  159. CFLAGS-close.c = -fexceptions -fasynchronous-unwind-tables
  160. CFLAGS-connect.c = -fexceptions -fasynchronous-unwind-tables
  161. CFLAGS-creat.c = -fexceptions -fasynchronous-unwind-tables
  162. CFLAGS-fdatasync.c = -fexceptions -fasynchronous-unwind-tables
  163. CFLAGS-fsync.c = -fexceptions -fasynchronous-unwind-tables
  164. CFLAGS-lockf.c = -fexceptions
  165. CFLAGS-msgrcv.c = -fexceptions -fasynchronous-unwind-tables
  166. CFLAGS-msgsnd.c = -fexceptions -fasynchronous-unwind-tables
  167. CFLAGS-msync.c = -fexceptions -fasynchronous-unwind-tables
  168. CFLAGS-nanosleep.c = -fexceptions -fasynchronous-unwind-tables
  169. CFLAGS-open64.c = -fexceptions -fasynchronous-unwind-tables
  170. CFLAGS-open.c = -fexceptions -fasynchronous-unwind-tables
  171. CFLAGS-pause.c = -fexceptions -fasynchronous-unwind-tables
  172. CFLAGS-poll.c = -fexceptions -fasynchronous-unwind-tables
  173. CFLAGS-ppoll.c = -fexceptions -fasynchronous-unwind-tables
  174. CFLAGS-pread_write.c = -fexceptions -fasynchronous-unwind-tables
  175. CFLAGS-pselect.c = -fexceptions -fasynchronous-unwind-tables
  176. CFLAGS-read.c = -fexceptions -fasynchronous-unwind-tables
  177. CFLAGS-readv.c = -fexceptions -fasynchronous-unwind-tables
  178. CFLAGS-recv.c = -fexceptions -fasynchronous-unwind-tables
  179. CFLAGS-recvfrom.c = -fexceptions -fasynchronous-unwind-tables
  180. CFLAGS-recvmsg.c = -fexceptions -fasynchronous-unwind-tables
  181. CFLAGS-__rt_sigtimedwait.c = -fexceptions -fasynchronous-unwind-tables
  182. CFLAGS-__rt_sigwaitinfo.c = -fexceptions -fasynchronous-unwind-tables
  183. CFLAGS-select.c = -fexceptions -fasynchronous-unwind-tables
  184. CFLAGS-send.c = -fexceptions -fasynchronous-unwind-tables
  185. CFLAGS-sendmsg.c = -fexceptions -fasynchronous-unwind-tables
  186. CFLAGS-sendto.c = -fexceptions -fasynchronous-unwind-tables
  187. CFLAGS-sigpause.c = -fexceptions
  188. CFLAGS-sigsuspend.c = -fexceptions -fasynchronous-unwind-tables
  189. CFLAGS-sigtimedwait.c = -fexceptions -fasynchronous-unwind-tables
  190. CFLAGS-sigwait.c = -fexceptions -fasynchronous-unwind-tables
  191. CFLAGS-sigwaitinfo.c = -fexceptions -fasynchronous-unwind-tables
  192. CFLAGS-__syscall_fcntl64.c = -fexceptions -fasynchronous-unwind-tables
  193. CFLAGS-__syscall_fcntl.c = -fexceptions -fasynchronous-unwind-tables
  194. CFLAGS-tcdrain.c = -fexceptions -fasynchronous-unwind-tables
  195. CFLAGS-usleep.c = -fexceptions -fasynchronous-unwind-tables
  196. CFLAGS-wait4.c = -fexceptions -fasynchronous-unwind-tables
  197. CFLAGS-wait.c = -fexceptions -fasynchronous-unwind-tables
  198. CFLAGS-waitid.c = -fexceptions -fasynchronous-unwind-tables
  199. CFLAGS-waitpid.c = -fexceptions -fasynchronous-unwind-tables
  200. CFLAGS-write.c = -fexceptions -fasynchronous-unwind-tables
  201. CFLAGS-writev.c = -fexceptions -fasynchronous-unwind-tables
  202. CFLAGS-pt-system.c = -fexceptions -I$(top_srcdir)libc/stdlib
  203. #
  204. # The rest of this file is uClibc specific.
  205. #
  206. CFLAGS-pthread_barrier_init.c = -D_GNU_SOURCE
  207. CFLAGS-pthread_barrier_destroy.c = -D_GNU_SOURCE
  208. CFLAGS-pthread_barrierattr_init.c = -D_GNU_SOURCE
  209. CFLAGS-pthread_barrierattr_destroy.c = -D_GNU_SOURCE
  210. CFLAGS-pthread_barrierattr_getpshared.c = -D_GNU_SOURCE
  211. CFLAGS-pthread_barrierattr_setpshared.c = -D_GNU_SOURCE
  212. CFLAGS-sem_open.c = -D_GNU_SOURCE
  213. CFLAGS-OMIT-alloca_cutoff.c = $(CFLAGS-dir_nptl)
  214. CFLAGS-OMIT-forward.c = $(CFLAGS-dir_nptl)
  215. CFLAGS-OMIT-libc-lowlevelock.c = $(CFLAGS-dir_nptl)
  216. CFLAGS-OMIT-libc-cancellation.c = $(CFLAGS-dir_nptl)