Makefile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. # set up system dependencies include dirs (NOTE: order matters!)
  25. # psm: don't think that the last include makes sense
  26. # they all should be already linked to $(TOPDIR)include
  27. PTDIR = $(TOPDIR)libpthread/linuxthreads/
  28. SYSDEPINC = -I$(PTDIR)sysdeps/pthread \
  29. -I$(PTDIR)sysdeps/$(TARGET_ARCH) \
  30. -I$(TOPDIR)libc/sysdeps/linux/$(TARGET_ARCH)
  31. CFLAGS += $(SYSDEPINC)
  32. ARCH_CFLAGS = $(CFLAGS)
  33. ifeq ($(strip $(TARGET_ARCH)),sh64)
  34. # We need to build as SHcompact for tas..
  35. ARCH_CFLAGS := $(subst 32media,compact,$(ARCH_CFLAGS))
  36. endif
  37. ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
  38. SHARED_START_FILES = $(TOPDIR)lib/crti.o $(LIBGCC_DIR)crtbeginS.o
  39. SHARED_END_FILES = $(LIBGCC_DIR)crtendS.o $(TOPDIR)lib/crtn.o
  40. endif
  41. LIB_NAME=libpthread
  42. AR_LIB_NAME=$(TOPDIR)lib/$(LIB_NAME).a
  43. SO_LIB_NAME=$(TOPDIR)lib/$(LIB_NAME).so
  44. SO_FULL_NAME=$(LIB_NAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
  45. ARCH_CSRC=$(wildcard sysdeps/$(TARGET_ARCH)/*.c)
  46. ARCH_OBJS=$(patsubst %.c,%.o, $(ARCH_CSRC))
  47. CSRC = $(wildcard *.c)
  48. ifneq ($(strip $(UCLIBC_HAS_XLOCALE)),y)
  49. CSRC := $(filter-out locale.c,$(CSRC))
  50. endif
  51. OBJS=$(patsubst %.c,%.o, $(CSRC))
  52. ifeq ($(strip $(HAVE_SHARED)),y)
  53. all: $(SO_LIB_NAME)
  54. else
  55. all: $(AR_LIB_NAME)
  56. endif
  57. $(AR_LIB_NAME): $(OBJS) $(ARCH_OBJS)
  58. $(INSTALL) -d $(TOPDIR)lib
  59. $(RM) $(AR_LIB_NAME)
  60. $(AR) $(ARFLAGS) $(AR_LIB_NAME) $(OBJS)
  61. $(AR) $(ARFLAGS) $(AR_LIB_NAME) $(ARCH_OBJS)
  62. $(SO_LIB_NAME): $(AR_LIB_NAME)
  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. $(ARCH_OBJS): %.o : %.c
  78. $(CC) $(ARCH_CFLAGS) -c $< -o $@
  79. ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
  80. $(STRIPTOOL) -X --strip-debug -R .note -R .comment $*.o
  81. else
  82. $(STRIPTOOL) -x -R .note -R .comment $*.o
  83. endif
  84. clean:
  85. $(RM) *.o sysdeps/*/*.o *~ core