OSDN Git Service

bdd097d38bb961ac04a2730b5a60910e2bc62b12
[uclinux-h8/uClibc.git] / libpthread / Makefile
1 # Makefile for uClibc's pthread library
2 #
3 # Copyright (C) 2002 Erik Andersen <andersen@uclibc.org>
4 #
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
8 # later version.
9 #
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
13 # details.
14 #
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
18
19 TOPDIR=../
20 include $(TOPDIR)Rules.mak
21
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
26
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
30
31 DIRS=
32 ifeq ($(strip $(INCLUDE_THREADS)),true)
33         DIRS+=linuxthreads
34 endif
35 ifeq ($(strip $(DODEBUG)),true)
36         DIRS+=linuxthreads_db
37 endif
38
39 ALL_SUBDIRS = linuxthreads linuxthreads_db
40
41 all: $(LIBPTHREAD) $(LIBTHREAD_DB)
42
43 $(LIBPTHREAD): subdirs
44         @if [ -f $(LIBPTHREAD) ] ; then \
45                 set -e; \
46                 install -d $(TOPDIR)lib; \
47                 rm -f $(TOPDIR)lib/$(LIBPTHREAD); \
48                 install -m 644 $(LIBPTHREAD) $(TOPDIR)lib; \
49         fi;
50
51 $(LIBTHREAD_DB): subdirs
52         @if [ -f $(LIBTHREAD_DB) ] ; then \
53                 set -e; \
54                 install -d $(TOPDIR)lib; \
55                 rm -f $(TOPDIR)lib/$(LIBTHREAD_DB); \
56                 install -m 644 $(LIBTHREAD_DB) $(TOPDIR)lib; \
57         fi;
58
59
60 $(OBJS): %.o : %.c
61         $(CC) $(CFLAGS) -c $< -o $@
62         $(STRIPTOOL) -x -R .note -R .comment $*.o
63
64 $(OBJ): Makefile
65
66 shared: all
67         if [ -f $(LIBPTHREAD) ] ; then \
68                 set -e; \
69                 $(LD) $(LDFLAGS) -soname=$(LIBPTHREAD_SHARED).$(MAJOR_VERSION) \
70                         -o $(LIBPTHREAD_SHARED_FULLNAME) --whole-archive $(LIBPTHREAD) \
71                         --no-whole-archive $(TOPDIR)/libc/misc/internals/interp.o \
72                         -L$(TOPDIR)/lib -lc; \
73                 install -d $(TOPDIR)lib; \
74                 rm -f $(TOPDIR)lib/$(LIBPTHREAD_SHARED_FULLNAME) \
75                         $(TOPDIR)lib/$(LIBPTHREAD_SHARED).$(MAJOR_VERSION); \
76                 install -m 644 $(LIBPTHREAD_SHARED_FULLNAME) $(TOPDIR)lib; \
77                 (cd $(TOPDIR)lib && ln -sf $(LIBPTHREAD_SHARED_FULLNAME) \
78                         $(LIBPTHREAD_SHARED)); \
79                 (cd $(TOPDIR)lib && ln -sf $(LIBPTHREAD_SHARED_FULLNAME) \
80                         $(LIBPTHREAD_SHARED).$(MAJOR_VERSION)); \
81         fi;
82         if [ -f $(LIBTHREAD_DB) ] ; then \
83                 set -e; \
84                 $(LD) $(LDFLAGS) -soname=$(LIBTHREAD_DB_SHARED).$(MAJOR_VERSION) \
85                         -o $(LIBTHREAD_DB_SHARED_FULLNAME) --whole-archive $(LIBTHREAD_DB) \
86                         --no-whole-archive $(TOPDIR)/libc/misc/internals/interp.o \
87                         -L$(TOPDIR)/lib -lc; \
88                 install -d $(TOPDIR)lib; \
89                 rm -f $(TOPDIR)lib/$(LIBTHREAD_DB_SHARED_FULLNAME) \
90                         $(TOPDIR)lib/$(LIBTHREAD_DB_SHARED).$(MAJOR_VERSION); \
91                 install -m 644 $(LIBTHREAD_DB_SHARED_FULLNAME) $(TOPDIR)lib; \
92                 (cd $(TOPDIR)lib && ln -sf $(LIBTHREAD_DB_SHARED_FULLNAME) \
93                         $(LIBTHREAD_DB_SHARED)); \
94                 (cd $(TOPDIR)lib && ln -sf $(LIBTHREAD_DB_SHARED_FULLNAME) \
95                         $(LIBTHREAD_DB_SHARED).$(MAJOR_VERSION)); \
96         fi;
97
98 tags:
99         ctags -R
100         
101 subdirs: $(patsubst %, _dir_%, $(DIRS))
102 subdirs_clean: $(patsubst %, _dirclean_%, $(ALL_SUBDIRS))
103
104 $(patsubst %, _dir_%, $(DIRS)) : dummy
105         $(MAKE) -C $(patsubst _dir_%, %, $@)
106
107 $(patsubst %, _dirclean_%, $(ALL_SUBDIRS)) : dummy
108         $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
109
110 clean: subdirs_clean
111         rm -f *.[oa] *~ core $(LIBPTHREAD) $(LIBPTHREAD_SHARED_FULLNAME) \
112                 $(LIBTHREAD_DB) $(LIBTHREAD_DB_SHARED_FULLNAME)
113
114 .PHONY: dummy
115
116