Makefile 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. # Makefile for uClibc's pthread library
  2. #
  3. # Copyright (C) 2002 Erik Andersen <andersen@uclibc.org>
  4. #
  5. # This program is free software; you can redistribute it and/or modify it under
  6. # the terms of the GNU Library General Public License as published by the Free
  7. # Software Foundation; either version 2 of the License, or (at your option) any
  8. # later version.
  9. #
  10. # This program is distributed in the hope that it will be useful, but WITHOUT
  11. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. # FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
  13. # details.
  14. #
  15. # You should have received a copy of the GNU Library General Public License
  16. # along with this program; if not, write to the Free Software Foundation, Inc.,
  17. # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. TOPDIR=../
  19. include $(TOPDIR)Rules.mak
  20. CFLAGS+=$(SSP_ALL_CFLAGS)
  21. #Adjust the soname version to avoid namespace collisions with glibc's libpthread
  22. LIBPTHREAD=libpthread.a
  23. LIBPTHREAD_SHARED=libpthread.so
  24. LIBPTHREAD_SHARED_FULLNAME=libpthread-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
  25. LIBTHREAD_DB=libthread_db.a
  26. LIBTHREAD_DB_SHARED=libthread_db.so
  27. LIBTHREAD_DB_SHARED_FULLNAME=libthread_db-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
  28. DIRS=
  29. ifeq ($(strip $(UCLIBC_HAS_THREADS)),y)
  30. ifeq ($(strip $(PTHREADS_NATIVE)),y)
  31. DIRS+=nptl
  32. else
  33. DIRS+=linuxthreads
  34. endif
  35. LDFLAGS_THREAD:= $(CPU_LDFLAGS-y) -shared --warn-common --warn-once -z combreloc -z defs
  36. ifeq ($(UCLIBC_BUILD_RELRO),y)
  37. LDFLAGS_THREAD+=-z relro
  38. endif
  39. ifeq ($(UCLIBC_BUILD_NOW),y)
  40. LDFLAGS_THREAD+=-z now
  41. endif
  42. ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
  43. ifeq ($(strip $(PTHREADS_NATIVE)),y)
  44. DIRS+=nptl_db
  45. else
  46. DIRS+=linuxthreads_db
  47. endif
  48. LDFLAGS_THREAD_DB:= $(CPU_LDFLAGS-y) -shared --warn-common --warn-once -z combreloc
  49. endif
  50. ifeq ($(DODEBUG),n)
  51. LDFLAGS_THREAD_DB+=-s
  52. ifeq ($(UCLIBC_BUILD_RELRO),y)
  53. LDFLAGS_THREAD_DB+=-z relro
  54. endif
  55. ifeq ($(UCLIBC_BUILD_NOW),y)
  56. LDFLAGS_THREAD_DB+=-z now
  57. endif
  58. endif
  59. endif
  60. ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
  61. SHARED_START_FILES = $(TOPDIR)lib/crti.o $(LIBGCC_DIR)crtbeginS.o
  62. SHARED_END_FILES = $(LIBGCC_DIR)crtendS.o $(TOPDIR)lib/crtn.o
  63. endif
  64. ALL_SUBDIRS = linuxthreads linuxthreads_db nptl nptl_db
  65. all: $(LIBPTHREAD) $(LIBTHREAD_DB)
  66. $(LIBPTHREAD): subdirs
  67. ifeq ($(strip $(UCLIBC_HAS_THREADS)),y)
  68. $(INSTALL) -d $(TOPDIR)lib
  69. $(RM) $(TOPDIR)lib/$(LIBPTHREAD)
  70. $(INSTALL) -m 644 $(LIBPTHREAD) $(TOPDIR)lib
  71. endif
  72. $(LIBTHREAD_DB): subdirs
  73. ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
  74. $(INSTALL) -d $(TOPDIR)lib
  75. $(RM) $(TOPDIR)lib/$(LIBTHREAD_DB)
  76. $(INSTALL) -m 644 $(LIBTHREAD_DB) $(TOPDIR)lib
  77. endif
  78. $(OBJS): %.o : %.c
  79. $(CC) $(CFLAGS) -c $< -o $@
  80. $(STRIPTOOL) -x -R .note -R .comment $*.o
  81. $(OBJ): Makefile
  82. shared: all
  83. ifeq ($(strip $(UCLIBC_HAS_THREADS)),y)
  84. $(LD) $(LDFLAGS_THREAD) -soname=$(LIBPTHREAD_SHARED).$(MAJOR_VERSION) \
  85. -o $(LIBPTHREAD_SHARED_FULLNAME) $(SHARED_START_FILES) --whole-archive $(LIBPTHREAD) \
  86. --no-whole-archive $(TOPDIR)libc/misc/internals/interp.o \
  87. -L$(TOPDIR)lib -lc $(LDADD_LIBFLOAT) $(LIBGCC) \
  88. $(SHARED_END_FILES)
  89. $(INSTALL) -d $(TOPDIR)lib
  90. $(RM) $(TOPDIR)lib/$(LIBPTHREAD_SHARED_FULLNAME) \
  91. $(TOPDIR)lib/$(LIBPTHREAD_SHARED).$(MAJOR_VERSION)
  92. $(INSTALL) -m 644 $(LIBPTHREAD_SHARED_FULLNAME) $(TOPDIR)lib
  93. $(LN) -sf $(LIBPTHREAD_SHARED_FULLNAME) \
  94. $(TOPDIR)lib/$(LIBPTHREAD_SHARED)
  95. $(LN) -sf $(LIBPTHREAD_SHARED_FULLNAME) \
  96. $(TOPDIR)lib/$(LIBPTHREAD_SHARED).$(MAJOR_VERSION)
  97. endif
  98. ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
  99. $(LD) $(LDFLAGS_THREAD_DB) -soname=$(LIBTHREAD_DB_SHARED).1 \
  100. -o $(LIBTHREAD_DB_SHARED_FULLNAME) --whole-archive $(LIBTHREAD_DB) \
  101. --no-whole-archive $(TOPDIR)libc/misc/internals/interp.o \
  102. -L$(TOPDIR)lib -lc $(LDADD_LIBFLOAT) $(LIBGCC)
  103. $(INSTALL) -d $(TOPDIR)lib
  104. $(RM) $(TOPDIR)lib/$(LIBTHREAD_DB_SHARED_FULLNAME) \
  105. $(TOPDIR)lib/$(LIBTHREAD_DB_SHARED).1
  106. $(INSTALL) -m 644 $(LIBTHREAD_DB_SHARED_FULLNAME) $(TOPDIR)lib
  107. $(LN) -sf $(LIBTHREAD_DB_SHARED_FULLNAME) \
  108. $(TOPDIR)lib/$(LIBTHREAD_DB_SHARED)
  109. $(LN) -sf $(LIBTHREAD_DB_SHARED_FULLNAME) \
  110. $(TOPDIR)lib/$(LIBTHREAD_DB_SHARED).1
  111. endif
  112. tags:
  113. ctags -R
  114. subdirs: $(patsubst %, _dir_%, $(DIRS))
  115. subdirs_clean: $(patsubst %, _dirclean_%, $(ALL_SUBDIRS))
  116. $(patsubst %, _dir_%, $(DIRS)) : dummy
  117. $(MAKE) -C $(patsubst _dir_%, %, $@)
  118. $(patsubst %, _dirclean_%, $(ALL_SUBDIRS)) : dummy
  119. $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
  120. clean: subdirs_clean
  121. $(RM) *.[oa] *~ core $(LIBPTHREAD) $(LIBPTHREAD_SHARED_FULLNAME) \
  122. $(LIBTHREAD_DB) $(LIBTHREAD_DB_SHARED_FULLNAME)
  123. .PHONY: dummy