Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. CFLAGS+=$(SSP_ALL_CFLAGS)
  22. # This stuff will not compile without at least -O1
  23. CFLAGS :=$(CFLAGS:-O0=-O1)
  24. # Get the thread include dependencies
  25. CFLAGS += $(PTINC)
  26. ARCH_CFLAGS := $(CFLAGS)
  27. ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
  28. SHARED_START_FILES := $(TOPDIR)lib/crti.o $(LIBGCC_DIR)crtbeginS.o
  29. SHARED_END_FILES := $(LIBGCC_DIR)crtendS.o $(TOPDIR)lib/crtn.o
  30. endif
  31. LIB_NAME := libpthread
  32. AR_LIB_NAME := $(TOPDIR)lib/$(LIB_NAME).a
  33. SO_LIB_NAME = $(TOPDIR)lib/$(LIB_NAME).so
  34. SO_FULL_NAME = $(LIB_NAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
  35. ARCH_CSRC := $(wildcard sysdeps/$(TARGET_ARCH)/*.c)
  36. ARCH_OBJS := $(patsubst %.c,%.o, $(ARCH_CSRC))
  37. -include sysdeps/$(TARGET_ARCH)/Makefile.in
  38. CSRC = $(wildcard *.c)
  39. ifneq ($(strip $(UCLIBC_HAS_XLOCALE)),y)
  40. CSRC := $(filter-out locale.c,$(CSRC))
  41. endif
  42. OBJS := $(patsubst %.c,%.o, $(CSRC))
  43. ifeq ($(strip $(HAVE_SHARED)),y)
  44. all: $(SO_LIB_NAME)
  45. else
  46. all: $(AR_LIB_NAME)
  47. endif
  48. $(AR_LIB_NAME): $(OBJS) $(ARCH_OBJS)
  49. $(INSTALL) -d $(TOPDIR)lib
  50. $(RM) $@
  51. ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
  52. $(STRIPTOOL) -X --strip-debug -R .note -R .comment $^
  53. else
  54. $(STRIPTOOL) -x -R .note -R .comment $^
  55. endif
  56. $(AR) $(ARFLAGS) $@ $(OBJS)
  57. $(AR) $(ARFLAGS) $@ $(ARCH_OBJS)
  58. $(SO_LIB_NAME): $(AR_LIB_NAME)
  59. $(RM) $(TOPDIR)lib/$(SO_FULL_NAME) $(SO_LIB_NAME).$(MAJOR_VERSION) $@
  60. $(LD) $(LDFLAGS_NOSTRIP) -soname=$(LIB_NAME).so.$(MAJOR_VERSION) \
  61. -o $(TOPDIR)lib/$(SO_FULL_NAME) $(SHARED_START_FILES) --whole-archive $< \
  62. --no-whole-archive $(TOPDIR)libc/misc/internals/interp.o \
  63. -L$(TOPDIR)lib -lc $(LDADD_LIBFLOAT) $(LIBGCC) $(SHARED_END_FILES)
  64. $(LN) -sf $(SO_FULL_NAME) $(SO_LIB_NAME).$(MAJOR_VERSION)
  65. $(LN) -sf $(SO_FULL_NAME) $@
  66. $(OBJS): %.o : %.c
  67. $(CC) $(CFLAGS) -c $< -o $@
  68. $(ARCH_OBJS): %.o : %.c
  69. $(CC) $(ARCH_CFLAGS) -c $< -o $@
  70. clean:
  71. $(RM) *.o sysdeps/*/*.o *~ core