Makefile 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 $(INCLUDE_THREADS)),true)
  29. DIRS+=linuxthreads
  30. ifeq ($(strip $(DODEBUG)),true)
  31. DIRS+=linuxthreads_db
  32. endif
  33. endif
  34. GCC_LIB_DIR = $(dir $(shell $(CC) -print-libgcc-file-name ))
  35. ifeq ($(strip $(DOPIC)),true)
  36. START_FILES = $(TOPDIR)lib/crti.o $(GCC_LIB_DIR)crtbeginS.o
  37. END_FILES = $(GCC_LIB_DIR)crtendS.o $(TOPDIR)lib/crtn.o
  38. else
  39. START_FILES = $(TOPDIR)lib/crti.o $(GCC_LIB_DIR)crtbegin.o
  40. END_FILES = $(GCC_LIB_DIR)crtend.o $(TOPDIR)lib/crtn.o
  41. endif
  42. ALL_SUBDIRS = linuxthreads linuxthreads_db
  43. all: $(LIBPTHREAD) $(LIBTHREAD_DB)
  44. $(LIBPTHREAD): subdirs
  45. @if [ -f $(LIBPTHREAD) ] ; then \
  46. set -e; \
  47. install -d $(TOPDIR)lib; \
  48. rm -f $(TOPDIR)lib/$(LIBPTHREAD); \
  49. install -m 644 $(LIBPTHREAD) $(TOPDIR)lib; \
  50. fi;
  51. $(LIBTHREAD_DB): subdirs
  52. @if [ -f $(LIBTHREAD_DB) ] ; then \
  53. set -e; \
  54. install -d $(TOPDIR)lib; \
  55. rm -f $(TOPDIR)lib/$(LIBTHREAD_DB); \
  56. install -m 644 $(LIBTHREAD_DB) $(TOPDIR)lib; \
  57. fi;
  58. $(OBJS): %.o : %.c
  59. $(CC) $(CFLAGS) -c $< -o $@
  60. $(STRIPTOOL) -x -R .note -R .comment $*.o
  61. $(OBJ): Makefile
  62. shared: all
  63. if [ -f $(LIBPTHREAD) ] ; then \
  64. set -e; \
  65. $(LD) $(LDFLAGS) -soname=$(LIBPTHREAD_SHARED).$(MAJOR_VERSION) \
  66. -o $(LIBPTHREAD_SHARED_FULLNAME) $(START_FILES) --whole-archive $(LIBPTHREAD) \
  67. --no-whole-archive $(TOPDIR)/libc/misc/internals/interp.o \
  68. -L$(TOPDIR)/lib -lc $(END_FILES); \
  69. install -d $(TOPDIR)lib; \
  70. rm -f $(TOPDIR)lib/$(LIBPTHREAD_SHARED_FULLNAME) \
  71. $(TOPDIR)lib/$(LIBPTHREAD_SHARED).$(MAJOR_VERSION); \
  72. install -m 644 $(LIBPTHREAD_SHARED_FULLNAME) $(TOPDIR)lib; \
  73. (cd $(TOPDIR)lib && ln -sf $(LIBPTHREAD_SHARED_FULLNAME) \
  74. $(LIBPTHREAD_SHARED)); \
  75. (cd $(TOPDIR)lib && ln -sf $(LIBPTHREAD_SHARED_FULLNAME) \
  76. $(LIBPTHREAD_SHARED).$(MAJOR_VERSION)); \
  77. fi;
  78. if [ -f $(LIBTHREAD_DB) ] ; then \
  79. set -e; \
  80. $(LD) $(LDFLAGS) -soname=$(LIBTHREAD_DB_SHARED).$(MAJOR_VERSION) \
  81. -o $(LIBTHREAD_DB_SHARED_FULLNAME) $(START_FILES) --whole-archive $(LIBTHREAD_DB) \
  82. --no-whole-archive $(TOPDIR)/libc/misc/internals/interp.o \
  83. -L$(TOPDIR)/lib -lc $(END_FILES); \
  84. install -d $(TOPDIR)lib; \
  85. rm -f $(TOPDIR)lib/$(LIBTHREAD_DB_SHARED_FULLNAME) \
  86. $(TOPDIR)lib/$(LIBTHREAD_DB_SHARED).$(MAJOR_VERSION); \
  87. install -m 644 $(LIBTHREAD_DB_SHARED_FULLNAME) $(TOPDIR)lib; \
  88. (cd $(TOPDIR)lib && ln -sf $(LIBTHREAD_DB_SHARED_FULLNAME) \
  89. $(LIBTHREAD_DB_SHARED)); \
  90. (cd $(TOPDIR)lib && ln -sf $(LIBTHREAD_DB_SHARED_FULLNAME) \
  91. $(LIBTHREAD_DB_SHARED).$(MAJOR_VERSION)); \
  92. fi;
  93. tags:
  94. ctags -R
  95. subdirs: $(patsubst %, _dir_%, $(DIRS))
  96. subdirs_clean: $(patsubst %, _dirclean_%, $(ALL_SUBDIRS))
  97. $(patsubst %, _dir_%, $(DIRS)) : dummy
  98. $(MAKE) -C $(patsubst _dir_%, %, $@)
  99. $(patsubst %, _dirclean_%, $(ALL_SUBDIRS)) : dummy
  100. $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
  101. clean: subdirs_clean
  102. rm -f *.[oa] *~ core $(LIBPTHREAD) $(LIBPTHREAD_SHARED_FULLNAME) \
  103. $(LIBTHREAD_DB) $(LIBTHREAD_DB_SHARED_FULLNAME)
  104. .PHONY: dummy