Makefile 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # Makefile for uClibc's pthread library
  2. #
  3. # Copyright (C) 2002 Erik Andersen <andersen@uclibc.org>
  4. # Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
  5. #
  6. # This program is free software; you can redistribute it and/or modify it under
  7. # the terms of the GNU Library General Public License as published by the Free
  8. # Software Foundation; either version 2 of the License, or (at your option) any
  9. # later version.
  10. #
  11. # This program is distributed in the hope that it will be useful, but WITHOUT
  12. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  13. # FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
  14. # details.
  15. #
  16. # You should have received a copy of the GNU Library General Public License
  17. # along with this program; if not, write to the Free Software Foundation, Inc.,
  18. # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. TOPDIR=../../
  20. include $(TOPDIR)Rules.mak
  21. # As long as there is only one subdir, we don't
  22. # have to worry about race conditions with multiple
  23. # $(AR)'s in subdirs running on linuxthreads.a.
  24. DIRS = sysdeps
  25. CFLAGS+=$(SSP_ALL_CFLAGS)
  26. #This stuff will not compile without at least -O1
  27. CFLAGS :=$(CFLAGS:-O0=-O1)
  28. # set up system dependencies include dirs (NOTE: order matters!)
  29. # psm: don't think that the last include makes sense
  30. # they all should be already linked to $(TOPDIR)include
  31. PTDIR = $(TOPDIR)libpthread/linuxthreads/
  32. SYSDEPINC = -I$(PTDIR)sysdeps/pthread \
  33. -I$(PTDIR)sysdeps/$(TARGET_ARCH) \
  34. -I$(TOPDIR)libc/sysdeps/linux/$(TARGET_ARCH)
  35. CFLAGS += $(SYSDEPINC)
  36. ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
  37. SHARED_START_FILES = $(TOPDIR)lib/crti.o $(LIBGCC_DIR)crtbeginS.o
  38. SHARED_END_FILES = $(LIBGCC_DIR)crtendS.o $(TOPDIR)lib/crtn.o
  39. endif
  40. LIB_NAME=libpthread
  41. AR_LIB_NAME=$(TOPDIR)lib/$(LIB_NAME).a
  42. SO_LIB_NAME=$(TOPDIR)lib/$(LIB_NAME).so
  43. SO_FULL_NAME=$(LIB_NAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
  44. CSRC = $(wildcard *.c)
  45. ifneq ($(strip $(UCLIBC_HAS_XLOCALE)),y)
  46. CSRC := $(filter-out locale.c,$(CSRC))
  47. endif
  48. OBJS=$(patsubst %.c,%.o, $(CSRC))
  49. # We need to make sure that we put all the top-level $(OBJS) into
  50. # our archive before executing subdirs. That way, when $(AR) is
  51. # run in the subdirs, it'll bump the generic top-level objects
  52. # out of our archive in favor of the machine-specific ones.
  53. ifeq ($(strip $(HAVE_SHARED)),y)
  54. all: $(SO_LIB_NAME)
  55. else
  56. all: subdirs
  57. endif
  58. $(AR_LIB_NAME): $(OBJS)
  59. $(INSTALL) -d $(TOPDIR)lib
  60. $(RM) $(AR_LIB_NAME)
  61. $(AR) $(ARFLAGS) $(AR_LIB_NAME) $(OBJS)
  62. $(SO_LIB_NAME): subdirs
  63. $(RM) $(TOPDIR)lib/$(SO_FULL_NAME) $(SO_LIB_NAME).$(MAJOR_VERSION) $(SO_LIB_NAME)
  64. $(LD) $(LDFLAGS_NOSTRIP) -soname=$(LIB_NAME).so.$(MAJOR_VERSION) \
  65. -o $(TOPDIR)lib/$(SO_FULL_NAME) $(SHARED_START_FILES) --whole-archive $(AR_LIB_NAME) \
  66. --no-whole-archive $(TOPDIR)libc/misc/internals/interp.o \
  67. -L$(TOPDIR)lib -lc $(LDADD_LIBFLOAT) $(LIBGCC) $(SHARED_END_FILES)
  68. $(LN) -sf $(SO_FULL_NAME) $(SO_LIB_NAME).$(MAJOR_VERSION)
  69. $(LN) -sf $(SO_FULL_NAME) $(SO_LIB_NAME)
  70. $(OBJS): %.o : %.c
  71. $(CC) $(CFLAGS) -c $< -o $@
  72. ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
  73. $(STRIPTOOL) -X --strip-debug -R .note -R .comment $*.o
  74. else
  75. $(STRIPTOOL) -x -R .note -R .comment $*.o
  76. endif
  77. clean: subdirs_clean
  78. $(RM) *.o *~ core
  79. subdirs: $(patsubst %, _dir_%, $(DIRS))
  80. subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS))
  81. $(patsubst %, _dir_%, $(DIRS)): $(AR_LIB_NAME)
  82. $(MAKE) -C $(patsubst _dir_%, %, $@)
  83. $(patsubst %, _dirclean_%, $(DIRS)): dummy
  84. $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
  85. .PHONY: dummy