Makefile 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. #Adjust the soname version to avoid namespace collisions with glibc's libpthread
  21. LIBPTHREAD=libpthread.a
  22. LIBPTHREAD_SHARED=libpthread.so
  23. LIBPTHREAD_SHARED_FULLNAME=libpthread-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
  24. LIBTHREAD_DB=libthread_db.a
  25. LIBTHREAD_DB_SHARED=libthread_db.so
  26. LIBTHREAD_DB_SHARED_FULLNAME=libthread_db-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
  27. DIRS=
  28. ifeq ($(strip $(UCLIBC_HAS_THREADS)),y)
  29. DIRS+=linuxthreads
  30. ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
  31. DIRS+=linuxthreads_db
  32. endif
  33. endif
  34. ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
  35. SHARED_START_FILES = $(TOPDIR)lib/crti.o $(LIBGCC_DIR)crtbeginS.o
  36. SHARED_END_FILES = $(LIBGCC_DIR)crtendS.o $(TOPDIR)lib/crtn.o
  37. endif
  38. ALL_SUBDIRS = linuxthreads linuxthreads_db
  39. # Remove any -z defs since this lib will have undefined symbols
  40. LIBTHREAD_DB_LDFLAGS := $(subst -z defs,,$(LDFLAGS))
  41. all: $(LIBPTHREAD) $(LIBTHREAD_DB)
  42. headers:
  43. ifeq ($(strip $(UCLIBC_HAS_THREADS_NATIVE)),y)
  44. $(LN) -sf $(TOPDIR)libpthread/nptl/sysdeps/pthread/pthread.h $(TOPDIR)include/
  45. $(LN) -sf $(TOPDIR)libpthread/nptl/semaphore.h $(TOPDIR)include/
  46. $(LN) -sf ../$(TOPDIR)libpthread/nptl/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/bits/semaphore.h $(TOPDIR)include/bits/
  47. $(LN) -sf ../$(TOPDIR)libpthread/nptl/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/bits/pthreadtypes.h $(TOPDIR)include/bits/
  48. $(LN) -sf ../$(TOPDIR)libpthread/nptl/sysdeps/pthread/bits/libc-lock.h $(TOPDIR)include/bits/
  49. $(LN) -sf ../$(TOPDIR)libpthread/nptl/sysdeps/pthread/bits/stdio-lock.h $(TOPDIR)include/bits/
  50. else
  51. $(LN) -sf $(TOPDIR)libpthread/linuxthreads/sysdeps/pthread/pthread.h $(TOPDIR)include/
  52. $(LN) -sf $(TOPDIR)libpthread/linuxthreads/semaphore.h $(TOPDIR)include/
  53. $(LN) -sf ../$(TOPDIR)libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h $(TOPDIR)include/bits/
  54. ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
  55. $(LN) -sf $(TOPDIR)libpthread/linuxthreads_db/thread_db.h $(TOPDIR)include/
  56. endif
  57. endif
  58. $(LIBPTHREAD): subdirs
  59. $(INSTALL) -d $(TOPDIR)lib
  60. $(RM) $(TOPDIR)lib/$(LIBPTHREAD)
  61. $(INSTALL) -m 644 $(LIBPTHREAD) $(TOPDIR)lib
  62. $(LIBTHREAD_DB): subdirs
  63. ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
  64. $(INSTALL) -d $(TOPDIR)lib
  65. $(RM) $(TOPDIR)lib/$(LIBTHREAD_DB)
  66. $(INSTALL) -m 644 $(LIBTHREAD_DB) $(TOPDIR)lib
  67. endif
  68. $(OBJS): %.o : %.c
  69. $(CC) $(CFLAGS) -c $< -o $@
  70. $(STRIPTOOL) -x -R .note -R .comment $*.o
  71. shared: all
  72. $(LD) $(LDFLAGS_NOSTRIP) -soname=$(LIBPTHREAD_SHARED).$(MAJOR_VERSION) \
  73. -o $(LIBPTHREAD_SHARED_FULLNAME) $(SHARED_START_FILES) --whole-archive $(LIBPTHREAD) \
  74. --no-whole-archive $(TOPDIR)libc/misc/internals/interp.o \
  75. -L$(TOPDIR)lib -lc $(LDADD_LIBFLOAT) $(LIBGCC) \
  76. $(SHARED_END_FILES)
  77. $(INSTALL) -d $(TOPDIR)lib
  78. $(RM) $(TOPDIR)lib/$(LIBPTHREAD_SHARED_FULLNAME) \
  79. $(TOPDIR)lib/$(LIBPTHREAD_SHARED).$(MAJOR_VERSION)
  80. $(INSTALL) -m 644 $(LIBPTHREAD_SHARED_FULLNAME) $(TOPDIR)lib
  81. $(LN) -sf $(LIBPTHREAD_SHARED_FULLNAME) \
  82. $(TOPDIR)lib/$(LIBPTHREAD_SHARED)
  83. $(LN) -sf $(LIBPTHREAD_SHARED_FULLNAME) \
  84. $(TOPDIR)lib/$(LIBPTHREAD_SHARED).$(MAJOR_VERSION)
  85. ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
  86. $(LD) $(LIBTHREAD_DB_LDFLAGS) --warn-unresolved-symbols -soname=$(LIBTHREAD_DB_SHARED).1 \
  87. -o $(LIBTHREAD_DB_SHARED_FULLNAME) --whole-archive $(LIBTHREAD_DB) \
  88. --no-whole-archive $(TOPDIR)libc/misc/internals/interp.o \
  89. -L$(TOPDIR)lib -lc $(LDADD_LIBFLOAT) $(LIBGCC)
  90. $(INSTALL) -d $(TOPDIR)lib
  91. $(RM) $(TOPDIR)lib/$(LIBTHREAD_DB_SHARED_FULLNAME) \
  92. $(TOPDIR)lib/$(LIBTHREAD_DB_SHARED).1
  93. $(INSTALL) -m 644 $(LIBTHREAD_DB_SHARED_FULLNAME) $(TOPDIR)lib
  94. $(LN) -sf $(LIBTHREAD_DB_SHARED_FULLNAME) \
  95. $(TOPDIR)lib/$(LIBTHREAD_DB_SHARED)
  96. $(LN) -sf $(LIBTHREAD_DB_SHARED_FULLNAME) \
  97. $(TOPDIR)lib/$(LIBTHREAD_DB_SHARED).1
  98. endif
  99. tags:
  100. ctags -R
  101. subdirs: $(patsubst %, _dir_%, $(DIRS))
  102. subdirs_clean: $(patsubst %, _dirclean_%, $(ALL_SUBDIRS))
  103. $(patsubst %, _dir_%, $(DIRS)) : dummy
  104. $(MAKE) -C $(patsubst _dir_%, %, $@)
  105. $(patsubst %, _dirclean_%, $(ALL_SUBDIRS)) : dummy
  106. $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
  107. clean: subdirs_clean
  108. $(RM) *.[oa] *~ core $(LIBPTHREAD) $(LIBPTHREAD_SHARED_FULLNAME) \
  109. $(LIBTHREAD_DB) $(LIBTHREAD_DB_SHARED_FULLNAME) \
  110. $(TOPDIR)include/pthread.h $(TOPDIR)include/semaphore.h \
  111. $(TOPDIR)include/thread_db.h \
  112. $(TOPDIR)include/bits/pthreadtypes.h $(TOPDIR)include/bits/semaphore.h \
  113. $(TOPDIR)include/bits/libc-lock.h $(TOPDIR)include/bits/stdio-lock
  114. .PHONY: dummy