OSDN Git Service

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