blob: 1a9a8e8c513fe834c43a2e92860b4df74c06456f [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001# Makefile for uClibc NPTL
2#
3# Copyright (C) 2005-2006 Steven J. Hill <sjhill@uclibc.org>
4#
5# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6#
7
8subdirs += libpthread/nptl/sysdeps/pthread
9#
10# NOTE: glibc puts flockfile.c, ftrylockfile.c, funlockfile.c, and
11# pt-longjmp.c in libc and libpthread. For uClibc, they are
12# in libc only.
13#
14libpthread_pthread_DIR = $(top_srcdir)libpthread/nptl/sysdeps/pthread
15libpthread_pthread_OUT = $(top_builddir)libpthread/nptl/sysdeps/pthread
16
17libpthread_pthread_COBJ = $(patsubst %.c,$(libpthread_pthread_OUT)/%.o,$(libpthread_pthread_CSRC))
18libpthread_pthread_CSRC = \
19 pthread_barrier_destroy.c \
20 pthread_barrier_init.c \
21 pthread_barrier_wait.c \
22 pthread_cond_broadcast.c \
23 pthread_cond_signal.c \
24 pthread_cond_timedwait.c \
25 pthread_cond_wait.c \
26 pthread_rwlock_rdlock.c \
27 pthread_rwlock_timedrdlock.c \
28 pthread_rwlock_timedwrlock.c \
29 pthread_rwlock_unlock.c \
30 pthread_rwlock_wrlock.c \
31 pthread_sigmask.c \
32 pthread_spin_destroy.c \
33 pthread_spin_init.c \
34 pthread_spin_unlock.c \
35 pt-longjmp.c \
36 pt-sigaction.c \
37 tpp.c
38CFLAGS-pthread = $(SSP_ALL_CFLAGS) -DNOT_IN_libc -DIS_IN_libpthread
39CFLAGS-pthread_barrier_wait.c = -D_GNU_SOURCE
40CFLAGS-pthread_spin_destroy.c = -D_GNU_SOURCE
41CFLAGS-pthread_spin_init.c = -D_GNU_SOURCE
42CFLAGS-pthread_spin_unlock.c = -D_GNU_SOURCE
43CFLAGS-unwind-forcedunwind.c = -fexceptions -fasynchronous-unwind-tables
44
45CFLAGS-OMIT-librt-cancellation.c = -DIS_IN_libpthread
46CFLAGS-OMIT-rt-unwind-resume.c = -DIS_IN_libpthread
47CFLAGS-librt-cancellation.c = -DIS_IN_librt \
48 -fexceptions -fasynchronous-unwind-tables
49CFLAGS-rt-unwind-resume.c = -DIS_IN_librt \
50 -fexceptions -fasynchronous-unwind-tables
51
52libpthread-so-y += $(patsubst %,$(libpthread_pthread_OUT)/%.oS, \
53 unwind-forcedunwind)
54
55librt-pt-routines-y = librt-cancellation.c
56librt-pt-shared-only-routines-y = rt-unwind-resume.c
57
58ifeq ($(UCLIBC_CTOR_DTOR),y)
59CFLAGS-OMIT-pt-initfini.c = $(CFLAGS-pthread)
60CFLAGS-pt-initfini.c = -S -g0 $(PICFLAG) -fno-inline-functions \
61 $(call check_gcc,-fno-unit-at-a-time,) \
62 $(SSP_DISABLE_FLAGS) \
63 -finhibit-size-directive \
64 -fno-asynchronous-unwind-tables -fno-unwind-tables \
65 $(patsubst -f%,-fno-%,$(call check_gcc,-fexceptions,))
66
67#ASFLAGS += $(PICFLAG) -I$(top_srcdir)include -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)
68ifneq ($(wildcard $(libpthread_pthread_DIR)/../unix/sysv/linux/$(TARGET_ARCH)/pt-initfini.c),)
69PTHREAD_INITFINI := $(libpthread_pthread_DIR)/../unix/sysv/linux/$(TARGET_ARCH)/pt-initfini.c
70else
71PTHREAD_INITFINI := $(libpthread_pthread_DIR)/pt-initfini.c
72endif
73
74ASFLAGS-pt-crti.S = $(PICFLAG)
75ASFLAGS-pt-crtn.S = $(PICFLAG)
76
77$(libpthread_pthread_OUT)/pt-crti.o: $(libpthread_pthread_OUT)/pt-crti.S
78 $(compile.S)
79
80$(libpthread_pthread_OUT)/pt-crtn.o: $(libpthread_pthread_OUT)/pt-crtn.S
81 $(compile.S)
82
83$(libpthread_pthread_OUT)/pt-initfini.s: $(PTHREAD_INITFINI) | $(top_builddir)include/bits/uClibc_config.h
84 $(compile.c)
85$(libpthread_pthread_OUT)/defs.h: $(PTHREAD_INITFINI)
86 $(do_sed) -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
87 $(AWK) -f $(top_srcdir)extra/scripts/defs.awk > $@.tmp
88 $(Q)mv $@.tmp $@
89
90$(libpthread_pthread_OUT)/pt-crti.S: $(libpthread_pthread_OUT)/pt-initfini.s $(libpthread_pthread_OUT)/defs.h
91 $(do_sed) -n -e '/[ ]*\.file/d' \
92 -e '1,/@HEADER_ENDS/p' \
93 -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
94 -e '/@TRAILER_BEGINS/,$$p' $< > $@.tmp
95 $(Q)mv $@.tmp $@
96$(libpthread_pthread_OUT)/pt-crtn.S: $(libpthread_pthread_OUT)/pt-initfini.s $(libpthread_pthread_OUT)/defs.h
97 $(do_sed) -n -e '/[ ]*\.file/d' \
98 -e '1,/@HEADER_ENDS/p' \
99 -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
100 -e '/@TRAILER_BEGINS/,$$p' $< > $@.tmp
101 $(Q)mv $@.tmp $@
102endif
103
104objclean-y += CLEAN_libpthread/nptl/sysdeps/pthread
105
106CLEAN_libpthread/nptl/sysdeps/pthread:
107 $(do_rm) $(addprefix $(libpthread_pthread_OUT)/*., o os oS s S) \
108 $(libpthread_pthread_OUT)/defs.h