blob: f599b1697a345fd7fa3ffc04fd804a9207d068b3 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001# 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
9subdirs += libpthread/linuxthreads.old
10
11CFLAGS-dir_linuxthreads.old := -DNOT_IN_libc -DIS_IN_libpthread
12CFLAGS-linuxthreads.old := $(CFLAGS-dir_linuxthreads.old) $(SSP_ALL_CFLAGS)
13
14CFLAGS-libpthread/linuxthreads.old/sysdeps/$(TARGET_ARCH)/ := $(CFLAGS-linuxthreads.old)
15
16ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
17LDFLAGS-libpthread.so := $(LDFLAGS_NOSTRIP) -Wl,-z,defs
18else
19LDFLAGS-libpthread.so := $(LDFLAGS)
20endif
21LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libpthread.so := -Wl,--dsbt-index=10
22
23LIBS-libpthread.so := $(LIBS) $(ldso)
24
25START_FILE-libpthread.so := $(SHARED_START_FILES)
26END_FILE-libpthread.so := $(SHARED_END_FILES)
27
28libpthread_FULL_NAME := libpthread-$(VERSION).so
29
30libpthread_DIR := $(top_srcdir)libpthread/linuxthreads.old
31libpthread_OUT := $(top_builddir)libpthread/linuxthreads.old
32
33-include $(libpthread_DIR)/sysdeps/$(TARGET_ARCH)/Makefile.arch
34
35libpthread_SRC := \
36 attr.c cancel.c condvar.c errno.c events.c join.c lockfile.c manager.c \
37 mutex.c oldsemaphore.c pt-machine.c ptfork.c ptlongjmp.c \
38 rwlock.c semaphore.c signals.c specific.c spinlock.c wrapsyscall.c
39ifeq ($(UCLIBC_HAS_XLOCALE),y)
40libpthread_SRC += locale.c
41endif
42
43libpthread_SPEC_SRC := pthread.c
44libpthread_SPEC_SRC := $(patsubst %.c,$(libpthread_DIR)/%.c,$(libpthread_SPEC_SRC))
45
46# remove generic sources, if arch specific version is present
47ifneq ($(strip $(libpthread_ARCH_SRC)),)
48libpthread_SRC := $(filter-out $(patsubst %.c,$(libpthread_DIR)/%.c,$(notdir $(libpthread_ARCH_SRC))),$(libpthread_SRC))
49endif
50
51libpthread_SRC := $(patsubst %,$(libpthread_DIR)/%,$(libpthread_SRC))
52
53libpthread_OBJ := $(patsubst $(libpthread_DIR)/%.c,$(libpthread_OUT)/%.o,$(libpthread_SRC))
54
55#
56# Stuff that goes into libc.so, not libpthread.so
57#
58CFLAGS-OMIT-forward.c := $(CFLAGS-dir_linuxthreads.old)
59CFLAGS-OMIT-libc_pthread_init.c := $(CFLAGS-dir_linuxthreads.old)
60libpthread_libc_CSRC := forward.c libc_pthread_init.c
61libpthread_libc_OBJ := $(patsubst %.c, $(libpthread_OUT)/%.o,$(libpthread_libc_CSRC))
62libc-static-y += $(libpthread_OUT)/libc_pthread_init.o
63libc-shared-y += $(libpthread_libc_OBJ:.o=.oS)
64
65libpthread-static-y += $(patsubst $(libpthread_DIR)/%.c,$(libpthread_OUT)/%.o,$(libpthread_SPEC_SRC))
66libpthread-shared-y += $(patsubst $(libpthread_DIR)/%.c,$(libpthread_OUT)/%.oS,$(libpthread_SPEC_SRC))
67
68ifeq ($(DOPIC),y)
69libpthread-a-y += $(libpthread_OBJ:.o=.os) $(libpthread-static-y:.o=.os)
70else
71libpthread-a-y += $(libpthread_OBJ) $(libpthread-static-y)
72endif
73libpthread-so-y += $(libpthread_OBJ:.o=.os) $(libpthread-shared-y)
74
75lib-a-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.a
76lib-so-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.so
77
78#ifeq ($(DOMULTI),n)
79$(top_builddir)lib/libpthread.so: $(libpthread_OUT)/libpthread_so.a $(libc.depend)
80 $(call link.so,$(libpthread_FULL_NAME),$(ABI_VERSION))
81#else
82#$(top_builddir)lib/libpthread.so: $(libpthread_OUT)/libpthread.oS | $(libc.depend)
83# $(call linkm.so,$(libpthread_FULL_NAME),$(ABI_VERSION))
84#endif
85
86ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
87$(libpthread_OUT)/libpthread_so.a: STRIP_FLAGS:=$(STRIP_FLAGS:-x=-X --strip-debug)
88endif
89$(libpthread_OUT)/libpthread_so.a: $(libpthread-so-y)
90 $(Q)$(RM) $@
91 $(do_ar)
92
93ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
94$(libpthread_OUT)/libpthread.oS: STRIP_FLAGS:=$(STRIP_FLAGS:-x=-X --strip-debug)
95endif
96$(libpthread_OUT)/libpthread.oS: $(libpthread_SRC) $(libpthread_SPEC_SRC)
97 $(Q)$(RM) $@
98 $(compile-m)
99
100ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
101$(top_builddir)lib/libpthread.a: STRIP_FLAGS:=$(STRIP_FLAGS:-x=-X --strip-debug)
102endif
103$(top_builddir)lib/libpthread.a: $(libpthread-a-y)
104 $(Q)$(INSTALL) -d $(dir $@)
105 $(Q)$(RM) $@
106 $(do_ar)
107
108$(top_builddir)include/pthread.h:
109 $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/$(@F) $@
110$(top_builddir)include/semaphore.h:
111 $(do_ln) $(call rel_srcdir)$(PTDIR)/$(@F) $@
112$(top_builddir)include/bits/pthreadtypes.h: | $(top_builddir)include/bits
113 $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/bits/$(@F) $@
114
115linuxthreads_headers := $(top_builddir)include/pthread.h \
116 $(top_builddir)include/semaphore.h \
117 $(top_builddir)include/bits/pthreadtypes.h
118$(linuxthreads_headers): $(wildcard $(addprefix $(top_builddir)include/config/linuxthreads/,old.h new.h))
119headers-$(UCLIBC_HAS_THREADS) += $(linuxthreads_headers)
120
121objclean-y += CLEAN_libpthread/linuxthreads.old
122headers_clean-y += HEADERCLEAN_libpthread/linuxthreads.old
123HEADERCLEAN_libpthread/linuxthreads.old:
124 $(do_rm) $(linuxthreads_headers)
125
126CLEAN_libpthread/linuxthreads.old:
127 $(do_rm) $(addprefix $(libpthread_OUT)/*., o os oS a)