1 # Makefile for uClibc's pthread library
3 # Copyright (C) 2002 Erik Andersen <andersen@uclibc.org>
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
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
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
20 include $(TOPDIR)Rules.mak
22 #Adjust the soname version to avoid namespace collisions with glibc's libpthread
23 LIBPTHREAD=libpthread.a
24 LIBPTHREAD_SHARED=libpthread.so
25 LIBPTHREAD_SHARED_FULLNAME=libpthread-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
27 LIBTHREAD_DB=libthread_db.a
28 LIBTHREAD_DB_SHARED=libthread_db.so
29 LIBTHREAD_DB_SHARED_FULLNAME=libthread_db-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
32 ifeq ($(strip $(INCLUDE_THREADS)),true)
33 DIRS+=linuxthreads linuxthreads_db
36 ALL_SUBDIRS = linuxthreads linuxthreads_db
38 all: $(LIBPTHREAD) $(LIBTHREAD_DB)
40 $(LIBPTHREAD): subdirs
41 @if [ -f $(LIBPTHREAD) ] ; then \
43 install -d $(TOPDIR)lib; \
44 rm -f $(TOPDIR)lib/$(LIBPTHREAD); \
45 install -m 644 $(LIBPTHREAD) $(TOPDIR)lib; \
48 $(LIBTHREAD_DB): subdirs
49 @if [ -f $(LIBTHREAD_DB) ] ; then \
51 install -d $(TOPDIR)lib; \
52 rm -f $(TOPDIR)lib/$(LIBTHREAD_DB); \
53 install -m 644 $(LIBTHREAD_DB) $(TOPDIR)lib; \
58 $(CC) $(CFLAGS) -c $< -o $@
59 $(STRIPTOOL) -x -R .note -R .comment $*.o
64 if [ -f $(LIBPTHREAD) ] ; then \
66 $(LD) $(LDFLAGS) -soname=$(LIBPTHREAD_SHARED).$(MAJOR_VERSION) \
67 -o $(LIBPTHREAD_SHARED_FULLNAME) --whole-archive $(LIBPTHREAD) \
68 --no-whole-archive $(TOPDIR)/libc/misc/internals/interp.o \
69 -L$(TOPDIR)/lib -lc; \
70 install -d $(TOPDIR)lib; \
71 rm -f $(TOPDIR)lib/$(LIBPTHREAD_SHARED_FULLNAME) \
72 $(TOPDIR)lib/$(LIBPTHREAD_SHARED).$(MAJOR_VERSION); \
73 install -m 644 $(LIBPTHREAD_SHARED_FULLNAME) $(TOPDIR)lib; \
74 (cd $(TOPDIR)lib && ln -sf $(LIBPTHREAD_SHARED_FULLNAME) \
75 $(LIBPTHREAD_SHARED)); \
76 (cd $(TOPDIR)lib && ln -sf $(LIBPTHREAD_SHARED_FULLNAME) \
77 $(LIBPTHREAD_SHARED).$(MAJOR_VERSION)); \
79 if [ -f $(LIBTHREAD_DB) ] ; then \
81 $(LD) $(LDFLAGS) -soname=$(LIBTHREAD_DB_SHARED).$(MAJOR_VERSION) \
82 -o $(LIBTHREAD_DB_SHARED_FULLNAME) --whole-archive $(LIBTHREAD_DB) \
83 --no-whole-archive $(TOPDIR)/libc/misc/internals/interp.o \
84 -L$(TOPDIR)/lib -lc; \
85 install -d $(TOPDIR)lib; \
86 rm -f $(TOPDIR)lib/$(LIBTHREAD_DB_SHARED_FULLNAME) \
87 $(TOPDIR)lib/$(LIBTHREAD_DB_SHARED).$(MAJOR_VERSION); \
88 install -m 644 $(LIBTHREAD_DB_SHARED_FULLNAME) $(TOPDIR)lib; \
89 (cd $(TOPDIR)lib && ln -sf $(LIBTHREAD_DB_SHARED_FULLNAME) \
90 $(LIBTHREAD_DB_SHARED)); \
91 (cd $(TOPDIR)lib && ln -sf $(LIBTHREAD_DB_SHARED_FULLNAME) \
92 $(LIBTHREAD_DB_SHARED).$(MAJOR_VERSION)); \
98 subdirs: $(patsubst %, _dir_%, $(DIRS))
99 subdirs_clean: $(patsubst %, _dirclean_%, $(ALL_SUBDIRS))
101 $(patsubst %, _dir_%, $(DIRS)) : dummy
102 $(MAKE) -C $(patsubst _dir_%, %, $@)
104 $(patsubst %, _dirclean_%, $(ALL_SUBDIRS)) : dummy
105 $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
108 rm -f *.[oa] *~ core $(LIBPTHREAD) $(LIBPTHREAD_SHARED_FULLNAME) \
109 $(LIBTHREAD_DB) $(LIBTHREAD_DB_SHARED_FULLNAME)