blob: b5eb20b1025b2ad5d8e023faec7d2d14299f8db1 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001# Rules.mak for uClibc test subdirs
2#
3# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
4#
5# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6#
7
8.SUFFIXES:
9
10top_builddir ?= ../
11
12TESTDIR=$(top_builddir)test/
13
14include $(top_builddir)/Rules.mak
15ifndef TEST_INSTALLED_UCLIBC
16ifdef UCLIBC_LDSO
17ifeq (,$(findstring /,$(UCLIBC_LDSO)))
18UCLIBC_LDSO := $(top_builddir)lib/$(UCLIBC_LDSO)
19endif
20else
21UCLIBC_LDSO := $(firstword $(wildcard $(top_builddir)lib/ld*))
22endif
23endif
24#--------------------------------------------------------
25# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
26LC_ALL:= C
27export LC_ALL
28
29ifeq ($(strip $(TARGET_ARCH)),)
30TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
31 -e 's/i.86/i386/' \
32 -e 's/sun.*/sparc/' -e 's/sparc.*/sparc/' \
33 -e 's/sa110/arm/' -e 's/arm.*/arm/g' \
34 -e 's/m68k.*/m68k/' \
35 -e 's/parisc.*/hppa/' \
36 -e 's/ppc/powerpc/g' \
37 -e 's/v850.*/v850/g' \
38 -e 's/sh[234]/sh/' \
39 -e 's/mips.*/mips/' \
40 -e 's/cris.*/cris/' \
41 -e 's/xtensa.*/xtensa/' \
42 )
43endif
44export TARGET_ARCH
45
46RM_R = $(Q)$(RM) -r
47LN_S = $(Q)$(LN) -fs
48
49ifneq ($(KERNEL_HEADERS),)
50ifeq ($(patsubst /%,/,$(KERNEL_HEADERS)),/)
51# Absolute path in KERNEL_HEADERS
52KERNEL_INCLUDES += -I$(KERNEL_HEADERS)
53else
54# Relative path in KERNEL_HEADERS
55KERNEL_INCLUDES += -I$(top_builddir)$(KERNEL_HEADERS)
56endif
57endif
58
59XCOMMON_CFLAGS := -I$(top_builddir)test -D_GNU_SOURCE
60XWARNINGS += $(CFLAG_-Wstrict-prototypes)
61CFLAGS := -nostdinc -I$(top_builddir)$(LOCAL_INSTALL_PATH)/usr/include
62CFLAGS += $(XCOMMON_CFLAGS) $(KERNEL_INCLUDES) $(CC_INC)
63CFLAGS += $(OPTIMIZATION) $(CPU_CFLAGS) $(XWARNINGS)
64
65# Can't add $(OPTIMIZATION) here, it may be target-specific.
66# Just adding -Os for now.
67HOST_CFLAGS += $(XCOMMON_CFLAGS) -Os $(XWARNINGS) -std=gnu99
68
69LDFLAGS := $(CPU_LDFLAGS-y) -Wl,-z,now
70ifeq ($(DODEBUG),y)
71 CFLAGS += -g
72 HOST_CFLAGS += -g
73 LDFLAGS += -Wl,-g
74 HOST_LDFLAGS += -Wl,-g
75else
76 LDFLAGS += -Wl,-s
77 HOST_LDFLAGS += -Wl,-s
78endif
79
80ifneq ($(HAVE_SHARED),y)
81 LDFLAGS += -Wl,-static -static-libgcc
82endif
83
84LDFLAGS += -B$(top_builddir)lib -Wl,-rpath,$(top_builddir)lib -Wl,-rpath-link,$(top_builddir)lib
85UCLIBC_LDSO_ABSPATH=$(shell pwd)
86ifdef TEST_INSTALLED_UCLIBC
87LDFLAGS += -Wl,-rpath,./
88UCLIBC_LDSO_ABSPATH=$(RUNTIME_PREFIX)$(MULTILIB_DIR)
89endif
90
91ifeq ($(findstring -static,$(LDFLAGS)),)
92LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_LDSO_ABSPATH)/$(UCLIBC_LDSO)
93endif
94
95ifeq ($(LDSO_GNU_HASH_SUPPORT),y)
96# Check for binutils support is done on root Rules.mak
97LDFLAGS += $(CFLAG_-Wl--hash-style=gnu)
98endif
99
100
101ifneq ($(findstring -s,$(MAKEFLAGS)),)
102DISP := sil
103Q := @
104SCAT := -@true
105else
106ifneq ($(V)$(VERBOSE),)
107DISP := ver
108Q :=
109SCAT := cat
110else
111DISP := pur
112Q := @
113SCAT := -@true
114endif
115endif
116ifneq ($(Q),)
117MAKEFLAGS += --no-print-directory
118endif
119
120banner := ---------------------------------
121pur_showclean = echo " "CLEAN $(notdir $(CURDIR))
122pur_showdiff = echo " "TEST_DIFF $(notdir $(CURDIR))/
123pur_showlink = echo " "TEST_LINK $(notdir $(CURDIR))/ $@
124pur_showtest = echo " "TEST_EXEC $(notdir $(CURDIR))/ $(@:.exe=)
125sil_showclean =
126sil_showdiff = true
127sil_showlink = true
128sil_showtest = true
129ver_showclean =
130ver_showdiff = true echo
131ver_showlink = true echo
132ver_showtest = printf "\n$(banner)\nTEST $(notdir $(CURDIR))/ $(@:.exe=)\n$(banner)\n"
133do_showclean = $($(DISP)_showclean)
134do_showdiff = $($(DISP)_showdiff)
135do_showlink = $($(DISP)_showlink)
136do_showtest = $($(DISP)_showtest)
137showclean = @$(do_showclean)
138showdiff = @$(do_showdiff)
139showlink = @$(do_showlink)
140showtest = @$(do_showtest)