OSDN Git Service

make sure UCLIBC_LDSO can be found via path
[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 TESTDIR=$(top_builddir)test/
14
15 include $(top_builddir)/Rules.mak
16
17 ifdef UCLIBC_LDSO
18 ifeq (,$(findstring /,$(UCLIBC_LDSO)))
19 UCLIBC_LDSO := $(top_builddir)lib/$(UCLIBC_LDSO)
20 endif
21 else
22 UCLIBC_LDSO := $(firstword $(wildcard $(top_builddir)lib/ld*))
23 endif
24
25 #--------------------------------------------------------
26 # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
27 LC_ALL:= C
28 export LC_ALL
29
30 ifeq ($(strip $(TARGET_ARCH)),)
31 TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
32         -e 's/i.86/i386/' \
33         -e 's/sparc.*/sparc/' \
34         -e 's/arm.*/arm/g' \
35         -e 's/m68k.*/m68k/' \
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         )
42 endif
43 export TARGET_ARCH
44
45
46 #--------------------------------------------------------
47 # If you are running a cross compiler, you will want to set 'CROSS'
48 # to something more interesting...  Target architecture is determined
49 # by asking the CC compiler what arch it compiles things for, so unless
50 # your compiler is broken, you should not need to specify TARGET_ARCH
51 #
52 # Most people will set this stuff on the command line, i.e.
53 #        make CROSS=mipsel-linux-
54 # will build uClibc for 'mipsel'.
55
56 CROSS      = $(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
57 CC         = $(CROSS)gcc
58 RM         = rm -f
59
60 # Select the compiler needed to build binaries for your development system
61 HOSTCC     = gcc
62
63
64 #--------------------------------------------------------
65 # A nifty macro to make testing gcc features easier
66 check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
67         then echo "$(1)"; else echo "$(2)"; fi)
68
69 # use '-Os' optimization if available, else use -O2, allow Config to override
70 # Override optimization settings when debugging
71 ifeq ($(DODEBUG),y)
72 OPTIMIZATION    = -O0
73 else
74 OPTIMIZATION   += $(call check_gcc,-Os,-O2)
75 endif
76
77 XWARNINGS      := $(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes
78 XARCH_CFLAGS   := $(subst ",, $(strip $(ARCH_CFLAGS))) $(CPU_CFLAGS)
79 XCOMMON_CFLAGS := -D_GNU_SOURCE -I$(top_builddir)test
80 CFLAGS         += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS) $(XARCH_CFLAGS) -I$(top_builddir)include $(PTINC)
81 HOST_CFLAGS    += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS)
82
83 LDFLAGS        := $(CPU_LDFLAGS)
84 ifeq ($(DODEBUG),y)
85         CFLAGS        += -g
86         HOST_CFLAGS   += -g
87         LDFLAGS       += -g -Wl,-warn-common
88         HOST_LDFLAGS  += -g -Wl,-warn-common
89 else
90         LDFLAGS       += -s -Wl,-warn-common
91         HOST_LDFLAGS  += -s -Wl,-warn-common
92 endif
93
94 ifneq ($(strip $(HAVE_SHARED)),y)
95         LDFLAGS       += -static
96         HOST_LDFLAGS  += -static
97 endif
98 LDFLAGS += -B$(top_builddir)lib -Wl,-rpath,$(top_builddir)lib -Wl,-rpath-link,$(top_builddir)lib
99 ifeq ($(findstring -static,$(LDFLAGS)),)
100 LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_LDSO)
101 endif
102
103
104 # Filter output
105 MAKEFLAGS += --no-print-directory
106 ifneq ($(findstring s,$(MAKEFLAGS)),)
107 DISP := sil
108 Q    := @
109 SCAT := -@true
110 else
111 ifneq ($(V)$(VERBOSE),)
112 DISP := ver
113 Q    :=
114 SCAT := cat
115 else
116 DISP := pur
117 Q    := @
118 SCAT := -@true
119 endif
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))/ $@
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 $(PWD))/ $@\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)