OSDN Git Service

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