blob: 8a4b0812316a15883042ba5a9c0c9733d8a5046c [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001# Makefile for uClibc (libubacktrace)
2#
3# Copyright (C) 2010 STMicroelectronics Ltd
4# Author: Carmelo Amoroso <carmelo.amoroso@st.com>
5
6# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
7#
8
9subdirs += libubacktrace libubacktrace/$(TARGET_ARCH)
10
11CFLAGS-libubacktrace := -DNOT_IN_libc -DIS_IN_libubacktrace $(SSP_ALL_CFLAGS)
12
13LDFLAGS-libubacktrace.so := $(LDFLAGS) $(top_builddir)lib/libdl-$(VERSION).so
14
15LIBS-libubacktrace.so := $(LIBS)
16
17libubacktrace_FULL_NAME := libubacktrace-$(VERSION).so
18
19libubacktrace_DIR := $(top_srcdir)libubacktrace
20libubacktrace_OUT := $(top_builddir)libubacktrace
21
22libubacktrace_ARCH_DIR:=$(libubacktrace_DIR)/$(TARGET_ARCH)
23libubacktrace_ARCH_OUT:=$(libubacktrace_OUT)/$(TARGET_ARCH)
24
25-include $(libubacktrace_ARCH_DIR)/Makefile.arch
26
27libubacktrace_SRC-y :=
28libubacktrace_SRC-$(UCLIBC_HAS_BACKTRACE) := backtrace.c backtracesyms.c backtracesymsfd.c
29
30# remove generic sources, if arch specific version is present
31ifneq ($(strip $(libubacktrace_ARCH_SRC-y)),)
32libubacktrace_SRC-y := $(filter-out $(notdir $(libubacktrace_ARCH_SRC-y)),$(libubacktrace_SRC-y))
33endif
34
35# -fasynchronous-unwind-tables is required for backtrace to work using dwarf2
36CFLAGS-backtrace.c := -fasynchronous-unwind-tables
37
38# pass common flags to arch dirs
39ifneq ($(strip $(libubacktrace_ARCH_OBJS)),)
40CFLAGS-libubacktrace/$(TARGET_ARCH)/ := $(CFLAGS-libubacktrace)
41endif
42
43libubacktrace_SRCS := $(patsubst %.c,$(libubacktrace_DIR)/%.c,$(libubacktrace_SRC-y))
44libubacktrace_OBJS := $(patsubst $(libubacktrace_DIR)/%.c,$(libubacktrace_OUT)/%.o,$(libubacktrace_SRCS))
45
46ifeq ($(DOPIC),y)
47libubacktrace-a-y += $(libubacktrace_OBJS:.o=.os)
48else
49libubacktrace-a-y += $(libubacktrace_OBJS)
50endif
51libubacktrace-so-y += $(libubacktrace_OBJS:.o=.os)
52
53lib-a-$(UCLIBC_HAS_BACKTRACE) += $(top_builddir)lib/libubacktrace.a
54lib-so-$(UCLIBC_HAS_BACKTRACE) += $(top_builddir)lib/libubacktrace.so
55
56objclean-y += CLEAN_libubacktrace
57
58ifeq ($(DOMULTI),n)
59ifeq ($(DOPIC),y)
60$(top_builddir)lib/libubacktrace.so: $(top_builddir)lib/libubacktrace.a $(libdl.depend)
61else
62$(top_builddir)lib/libubacktrace.so: $(libubacktrace_OUT)/libubacktrace_so.a $(libdl.depend)
63endif
64 $(call link.so,$(libubacktrace_FULL_NAME),$(ABI_VERSION))
65else
66$(top_builddir)lib/libubacktrace.so: $(libubacktrace_OUT)/libubacktrace.oS | $(libdl.depend)
67 $(call linkm.so,$(libubacktrace_FULL_NAME),$(ABI_VERSION))
68endif
69
70$(libubacktrace_OUT)/libubacktrace_so.a: $(libubacktrace-so-y)
71 $(Q)$(RM) $@
72 $(do_ar)
73
74$(libubacktrace_OUT)/libubacktrace.oS: $(libubacktrace_SRCS) $(libubacktrace_ARCH_SRCS)
75 $(Q)$(RM) $@
76 $(compile-m)
77
78$(top_builddir)lib/libubacktrace.a: $(libubacktrace-a-y)
79 $(Q)$(INSTALL) -d $(dir $@)
80 $(Q)$(RM) $@
81 $(do_ar)
82
83CLEAN_libubacktrace:
84 $(do_rm) $(addprefix $(libubacktrace_OUT)/*., o os oS a)