OSDN Git Service

ac210a72ed1fdbead94661e68439b362a365eeef
[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/sparc.*/sparc/' \
35         -e 's/arm.*/arm/g' \
36         -e 's/m68k.*/m68k/' \
37         -e 's/ppc/powerpc/g' \
38         -e 's/v850.*/v850/g' \
39         -e 's/sh[234]/sh/' \
40         -e 's/mips.*/mips/' \
41         -e 's/cris.*/cris/' \
42         )
43 endif
44 export TARGET_ARCH
45
46
47 #--------------------------------------------------------
48 # If you are running a cross compiler, you will want to set 'CROSS'
49 # to something more interesting...  Target architecture is determined
50 # by asking the CC compiler what arch it compiles things for, so unless
51 # your compiler is broken, you should not need to specify TARGET_ARCH
52 #
53 # Most people will set this stuff on the command line, i.e.
54 #        make CROSS=mipsel-linux-
55 # will build uClibc for 'mipsel'.
56
57 CROSS      = $(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
58 CC         = $(CROSS)gcc
59 RM         = rm -f
60
61 # Select the compiler needed to build binaries for your development system
62 HOSTCC     = gcc
63
64
65 #--------------------------------------------------------
66 # A nifty macro to make testing gcc features easier
67 check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
68         then echo "$(1)"; else echo "$(2)"; fi)
69
70 # use '-Os' optimization if available, else use -O2, allow Config to override
71 # Override optimization settings when debugging
72 ifeq ($(DODEBUG),y)
73 OPTIMIZATION    = -O0
74 else
75 OPTIMIZATION   += $(call check_gcc,-Os,-O2)
76 endif
77
78 XWARNINGS      := $(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes
79 XARCH_CFLAGS   := $(subst ",, $(strip $(ARCH_CFLAGS))) $(CPU_CFLAGS)
80 XCOMMON_CFLAGS := -D_GNU_SOURCE -I$(top_builddir)test
81 CFLAGS         += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS) $(XARCH_CFLAGS) -I$(top_builddir)include $(PTINC)
82 HOST_CFLAGS    += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS)
83
84 LDFLAGS        := $(CPU_LDFLAGS)
85 ifeq ($(DODEBUG),y)
86         CFLAGS        += -g
87         HOST_CFLAGS   += -g
88         LDFLAGS       += -g
89         HOST_LDFLAGS  += -g
90 else
91         LDFLAGS       += -s
92         HOST_LDFLAGS  += -s
93 endif
94
95 ifneq ($(strip $(HAVE_SHARED)),y)
96         LDFLAGS       += -static
97         HOST_LDFLAGS  += -static
98 endif
99 LDFLAGS += -B$(top_builddir)lib -Wl,-rpath,$(top_builddir)lib -Wl,-rpath-link,$(top_builddir)lib
100 UCLIBC_LDSO_ABSPATH=$(shell pwd)
101 ifdef TEST_INSTALLED_UCLIBC
102 LDFLAGS += -Wl,-rpath,./
103 UCLIBC_LDSO_ABSPATH=/lib
104 endif
105
106 ifeq ($(findstring -static,$(LDFLAGS)),)
107         LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_LDSO_ABSPATH)/$(UCLIBC_LDSO)
108 endif
109
110
111 # Filter output
112 MAKEFLAGS += --no-print-directory
113 ifneq ($(findstring s,$(MAKEFLAGS)),)
114 DISP := sil
115 Q    := @
116 SCAT := -@true
117 else
118 ifneq ($(V)$(VERBOSE),)
119 DISP := ver
120 Q    :=
121 SCAT := cat
122 else
123 DISP := pur
124 Q    := @
125 SCAT := -@true
126 endif
127 endif
128
129 banner := ---------------------------------
130 pur_showclean = echo "  "CLEAN $(notdir $(CURDIR))
131 pur_showdiff  = echo "  "TEST_DIFF $(notdir $(CURDIR))/
132 pur_showlink  = echo "  "TEST_LINK $(notdir $(CURDIR))/ $@
133 pur_showtest  = echo "  "TEST_EXEC $(notdir $(CURDIR))/ $(patsubst %.exe,%,$@)
134 sil_showclean =
135 sil_showdiff  = true
136 sil_showlink  = true
137 sil_showtest  = true
138 ver_showclean =
139 ver_showdiff  = true echo
140 ver_showlink  = true echo
141 ver_showtest  = printf "\n$(banner)\nTEST $(notdir $(PWD))/ $(patsubst %.exe,%,$@)\n$(banner)\n"
142 do_showclean  = $($(DISP)_showclean)
143 do_showdiff   = $($(DISP)_showdiff)
144 do_showlink   = $($(DISP)_showlink)
145 do_showtest   = $($(DISP)_showtest)
146 showclean = @$(do_showclean)
147 showdiff  = @$(do_showdiff)
148 showlink  = @$(do_showlink)
149 showtest  = @$(do_showtest)