summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/Makefile.commonarch
blob: a6842d879aefc088fb11807da14542a83588dc73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Makefile template to be included by sysdeps/linux/<ARCH>/Makefile.arch
#
# Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#

ARCH_DIR  := $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)
ARCH_OUT  := $(top_builddir)libc/sysdeps/linux/$(TARGET_ARCH)

ARCH_CSRC := $(addprefix $(ARCH_DIR)/,$(CSRC-y))
ARCH_COBJ := $(addprefix $(ARCH_OUT)/,$(CSRC-y:.c=.o))
ARCH_SSRC = $(addprefix $(ARCH_DIR)/,$(SSRC-y))
ARCH_SOBJ = $(patsubst %.s,%.o,$(patsubst %.S,%.o,$(addprefix $(ARCH_OUT)/,$(SSRC-y))))

ARCH_OBJS-y = $(ARCH_COBJ) $(ARCH_SOBJ)

crt-y          := FORCE
libc-y         += $(ARCH_OBJS-y)
libc-nomulti-y += $(ARCH_SOBJ)
objclean-y     += CLEAN_$(subst $(top_builddir),,$(ARCH_OUT))

CFLAGS-OMIT-crt1.S := -D_LIBC_REENTRANT
CFLAGS-OMIT-crti.S := -D_LIBC_REENTRANT
CFLAGS-OMIT-crtn.S := -D_LIBC_REENTRANT
CFLAGS-OMIT-crtreloc.c := -D_LIBC_REENTRANT
CFLAGS-crti.S += $(PICFLAG)
CFLAGS-crtn.S += $(PICFLAG)
# Due to a "bug" in make these order_only prereqs inherit per-target flags.
# Attempt to workaround this inconvenient behaviour:
CFLAGS-OMIT-crt1.S += $(CFLAGS-rtld) -DIN_LIB=%
CFLAGS-OMIT-crtreloc.c += $(CFLAGS-rtld) -DIN_LIB=%

CLEAN_$(subst $(top_builddir),,$(ARCH_OUT)):
	$(do_rm) $(addprefix $(ARCH_OUT)/*., o os oS) $(CTOR_TARGETS) $(CRTS)

ifneq ($(ARCH_HEADERS),)

ARCH_HEADERS_OUT := $(patsubst %,$(top_builddir)include/%,$(ARCH_HEADERS))

$(ARCH_HEADERS_OUT):
	$(do_ln) $(call rel_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(@F) $@

headers-y += $(ARCH_HEADERS_OUT)
headers_clean-y += HEADERCLEAN_$(subst $(top_builddir),,$(ARCH_OUT))
HEADERCLEAN_$(subst $(top_builddir),,$(ARCH_OUT)):
	$(do_rm) $(ARCH_HEADERS_OUT)
endif

$(ARCH_OUT)/ucontext_i.h: $(top_srcdir)extra/scripts/gen-as-const.awk
$(ARCH_OUT)/ucontext_i.h: $(ARCH_OUT)/ucontext_i.sym
	@$(disp_gen)
	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< \
	| $(CC) $(CFLAGS) -x c - -S -o - \
	| $(SED) $(PTHREAD_GENERATE_MANGLE) > $@
	@if test ! -s $@ ; then rm -f $@ ; false ; fi

pregen-headers-$(UCLIBC_HAS_CONTEXT_FUNCS) += $(ARCH_OUT)/ucontext_i.h

headers_clean-$(UCLIBC_HAS_CONTEXT_FUNCS) += \
	HEADERCLEAN_$(subst $(top_builddir),,$(ARCH_OUT)/ucontext_i)

HEADERCLEAN_$(subst $(top_builddir),,$(ARCH_OUT)/ucontext_i):
	$(do_rm) $(addprefix $(ARCH_OUT)/ucontext_i., c h s)