Makefile 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 $(UCLIBC_CTOR_DTOR)),y)
  34. SHARED_START_FILES = $(TOPDIR)lib/crti.o $(LIBGCC_DIR)crtbeginS.o
  35. SHARED_END_FILES = $(LIBGCC_DIR)crtendS.o $(TOPDIR)lib/crtn.o
  36. endif
  37. LIB_NAME=libpthread
  38. AR_LIB_NAME=$(TOPDIR)lib/$(LIB_NAME).a
  39. SO_LIB_NAME=$(TOPDIR)lib/$(LIB_NAME).so
  40. SO_FULL_NAME=$(LIB_NAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
  41. ARCH_CSRC=$(wildcard sysdeps/$(TARGET_ARCH)/*.c)
  42. ARCH_OBJS=$(patsubst %.c,%.o, $(ARCH_CSRC))
  43. -include sysdeps/$(TARGET_ARCH)/Makefile.in
  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. ifeq ($(strip $(HAVE_SHARED)),y)
  50. all: $(SO_LIB_NAME)
  51. else
  52. all: $(AR_LIB_NAME)
  53. endif
  54. $(AR_LIB_NAME): $(OBJS) $(ARCH_OBJS)
  55. $(INSTALL) -d $(TOPDIR)lib
  56. $(RM) $(AR_LIB_NAME)
  57. $(AR) $(ARFLAGS) $(AR_LIB_NAME) $(OBJS)
  58. $(AR) $(ARFLAGS) $(AR_LIB_NAME) $(ARCH_OBJS)
  59. $(SO_LIB_NAME): $(AR_LIB_NAME)
  60. $(RM) $(TOPDIR)lib/$(SO_FULL_NAME) $(SO_LIB_NAME).$(MAJOR_VERSION) $(SO_LIB_NAME)
  61. $(LD) $(LDFLAGS_NOSTRIP) -soname=$(LIB_NAME).so.$(MAJOR_VERSION) \
  62. -o $(TOPDIR)lib/$(SO_FULL_NAME) $(SHARED_START_FILES) --whole-archive $(AR_LIB_NAME) \
  63. --no-whole-archive $(TOPDIR)libc/misc/internals/interp.o \
  64. -L$(TOPDIR)lib -lc $(LDADD_LIBFLOAT) $(LIBGCC) $(SHARED_END_FILES)
  65. $(LN) -sf $(SO_FULL_NAME) $(SO_LIB_NAME).$(MAJOR_VERSION)
  66. $(LN) -sf $(SO_FULL_NAME) $(SO_LIB_NAME)
  67. $(OBJS): %.o : %.c
  68. $(CC) $(CFLAGS) -c $< -o $@
  69. ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
  70. $(STRIPTOOL) -X --strip-debug -R .note -R .comment $*.o
  71. else
  72. $(STRIPTOOL) -x -R .note -R .comment $*.o
  73. endif
  74. $(ARCH_OBJS): %.o : %.c
  75. $(CC) $(ARCH_CFLAGS) -c $< -o $@
  76. ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
  77. $(STRIPTOOL) -X --strip-debug -R .note -R .comment $*.o
  78. else
  79. $(STRIPTOOL) -x -R .note -R .comment $*.o
  80. endif
  81. clean:
  82. $(RM) *.o sysdeps/*/*.o *~ core