OSDN Git Service

support building out-of-tree
[uclinux-h8/uClibc.git] / libpthread / linuxthreads / Makefile.in
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
4 # Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org>
5 #
6 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
7 #
8
9 subdirs += libpthread/linuxthreads/sysdeps/$(TARGET_ARCH)
10 subdirs += libpthread/linuxthreads/sysdeps/unix/sysv/linux
11 subdirs += libpthread/linuxthreads/sysdeps/pthread
12
13 CFLAGS-dir_linuxthreads := -DNOT_IN_libc -DIS_IN_libpthread
14 CFLAGS-linuxthreads := $(CFLAGS-dir_linuxthreads) $(SSP_ALL_CFLAGS)
15
16 CFLAGS-libpthread/linuxthreads/sysdeps/$(TARGET_ARCH)/ := $(CFLAGS-linuxthreads)
17 CFLAGS-libpthread/linuxthreads/sysdeps/unix/sysv/linux/ := $(CFLAGS-linuxthreads)
18 CFLAGS-libpthread/linuxthreads/sysdeps/pthread/         := $(CFLAGS-linuxthreads)
19
20 # This stuff will not compile without at least -O1
21 # psm: can't handle this here, could maybe search for -O0 in CFLAGS
22 # and append -O1 if found
23 #CFLAGS:=$(CFLAGS:-O0=-O1)
24
25 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
26 LDFLAGS-libpthread.so := $(LDFLAGS_NOSTRIP) -Wl,-z,defs
27 else
28 LDFLAGS-libpthread.so := $(LDFLAGS)
29 endif
30
31 LIBS-libpthread.so := $(LIBS) $(ldso)
32
33 START_FILE-libpthread.so := $(SHARED_START_FILES)
34 END_FILE-libpthread.so := $(SHARED_END_FILES)
35
36 libpthread_FULL_NAME := libpthread-$(VERSION).so
37
38 libpthread_DIR := $(top_srcdir)libpthread/linuxthreads
39 libpthread_OUT := $(top_builddir)libpthread/linuxthreads
40
41 -include $(libpthread_DIR)/sysdeps/$(TARGET_ARCH)/Makefile.arch
42
43 pthread_arch_SRC   := pspinlock
44 pthread_arch_SRC   := $(patsubst %,$(libpthread_DIR)/sysdeps/$(TARGET_ARCH)/%.c,$(pthread_arch_SRC))
45 pthread_linux_SRC  := fork pt-sigsuspend register-atfork unregister-atfork
46 pthread_linux_SRC  := $(patsubst %,$(libpthread_DIR)/sysdeps/unix/sysv/linux/%.c,$(pthread_linux_SRC))
47 pthread_sysdep_SRC := errno-loc herrno-loc ptlongjmp
48 pthread_sysdep_SRC := $(patsubst %,$(libpthread_DIR)/sysdeps/pthread/%.c,$(pthread_sysdep_SRC))
49 pthread_SRC := \
50         attr barrier cancel condvar errno events join pthread \
51         lockfile manager mutex pt-machine ptcleanup \
52         ptclock_gettime ptclock_settime ptfork pthandles \
53         pthread_setegid pthread_seteuid pthread_setgid pthread_setregid \
54         pthread_setresgid pthread_setresuid pthread_setreuid pthread_setuid \
55         rwlock semaphore sighandler signals specific spinlock
56 pthread_SRC := $(patsubst %,$(libpthread_DIR)/%.c,$(pthread_SRC))
57
58 libpthread_static_SRC := pthread_atfork
59 libpthread_SRC := $(pthread_arch_SRC) $(pthread_linux_SRC) $(pthread_sysdep_SRC) $(pthread_SRC)
60 libpthread_OBJ := $(patsubst $(libpthread_DIR)/%.c,$(libpthread_OUT)/%.o,$(libpthread_SRC))
61
62 #
63 # Stuff that goes into libc.so, not libpthread.so
64 #
65 #CFLAGS-OMIT-alloca_cutoff.c := $(CFLAGS-dir_linuxthreads)
66 CFLAGS-OMIT-forward.c := $(CFLAGS-dir_linuxthreads)
67 CFLAGS-OMIT-libc-cancellation.c := $(CFLAGS-dir_linuxthreads)
68 CFLAGS-OMIT-libc_pthread_init.c := $(CFLAGS-dir_linuxthreads)
69 libpthread_libc_CSRC := \
70         forward.c libc-cancellation.c libc_pthread_init.c # alloca_cutoff.c
71 libpthread_libc_OBJ  := $(patsubst %.c, $(libpthread_OUT)/%.o,$(libpthread_libc_CSRC))
72 libc-static-y += $(libpthread_OUT)/libc_pthread_init.o
73 libc-shared-y += $(libpthread_libc_OBJ:.o=.oS)
74
75 libpthread-static-y += $(patsubst %,$(libpthread_OUT)/%.o,$(libpthread_static_SRC))
76
77 libpthread-nonshared-y += $(patsubst %,$(libpthread_OUT)/%.oS,$(libpthread_static_SRC))
78
79 ifeq ($(DOPIC),y)
80 libpthread-a-y  += $(libpthread_OBJ:.o=.os) $(libpthread-static-y:.o=.os)
81 else
82 libpthread-a-y  += $(libpthread_OBJ) $(libpthread-static-y)
83 endif
84 libpthread-so-y += $(libpthread_OBJ:.o=.oS)
85
86 lib-a-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.a
87 lib-so-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.so
88
89 #ifeq ($(DOMULTI),n)
90 $(top_builddir)lib/libpthread.so: $(libpthread_OUT)/libpthread_so.a $(libc.depend) $(top_builddir)lib/libpthread_nonshared.a
91         $(call link.so,$(libpthread_FULL_NAME),$(MAJOR_VERSION))
92 #else
93 #$(top_builddir)lib/libpthread.so: $(libpthread_OUT)/libpthread.oS | $(libc.depend) $(top_builddir)lib/libpthread_nonshared.a
94 #       $(call linkm.so,$(libpthread_FULL_NAME),$(MAJOR_VERSION))
95 #endif
96         $(Q)$(RM) $@
97         $(Q)cp $(top_srcdir)extra/scripts/format.lds $@
98         $(Q)echo "GROUP ( $(notdir $@).$(MAJOR_VERSION) libpthread_nonshared.a )" >> $@
99
100 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
101 $(libpthread_OUT)/libpthread_so.a: STRIP_FLAGS:=$(STRIP_FLAGS:-x=-X --strip-debug)
102 endif
103 $(libpthread_OUT)/libpthread_so.a: $(libpthread-so-y)
104         $(Q)$(RM) $@
105         $(do_ar)
106
107 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
108 $(libpthread_OUT)/libpthread.oS: STRIP_FLAGS:=$(STRIP_FLAGS:-x=-X --strip-debug)
109 endif
110 $(libpthread_OUT)/libpthread.oS: $(libpthread_SRC)
111         $(Q)$(RM) $@
112         $(compile-m)
113
114 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
115 $(top_builddir)lib/libpthread.a: STRIP_FLAGS:=$(STRIP_FLAGS:-x=-X --strip-debug)
116 endif
117 $(top_builddir)lib/libpthread.a: $(libpthread-a-y)
118         $(Q)$(INSTALL) -d $(dir $@)
119         $(Q)$(RM) $@
120         $(do_ar)
121
122 $(top_builddir)include/pthread.h:
123         $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/$(@F) $@
124 $(top_builddir)include/semaphore.h:
125         $(do_ln) $(call rel_srcdir)$(PTDIR)/$(@F) $@
126 $(top_builddir)include/bits/pthreadtypes.h: | $(top_builddir)include/bits
127         $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/bits/$(@F) $@
128
129 linuxthreads_headers := $(top_builddir)include/pthread.h \
130                         $(top_builddir)include/semaphore.h \
131                         $(top_builddir)include/bits/pthreadtypes.h
132 $(linuxthreads_headers): $(wildcard $(addprefix $(top_builddir)include/config/linuxthreads/,old.h new.h))
133 headers-$(UCLIBC_HAS_THREADS) += $(linuxthreads_headers)
134
135 objclean-y += libpthread_clean
136 headers_clean-y += linuxthreads_headers_clean
137 linuxthreads_headers_clean:
138         $(do_rm) $(linuxthreads_headers)
139
140 libpthread_clean:
141         $(do_rm) $(addprefix $(libpthread_OUT)/,$(foreach e, o os oS a,$(foreach d, *. */*. */*/*. */*/*/*.,$(d)$(e))))