OSDN Git Service

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