OSDN Git Service

make sure we build against local headers and link against local libs
[uclinux-h8/uClibc.git] / test / Rules.mak
1 # Rules.mak for uClibc test subdirs
2 #
3 # Copyright (C) 2001 by Lineo, inc.
4 # Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
5 #
6 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
7 #
8 # Note: This does not read the top level Rules.mak file
9 #
10
11 top_builddir = ../../
12 TESTDIR=$(top_builddir)test/
13
14 -include $(top_builddir).config
15
16 ifndef UCLIBC_LDSO
17 UCLIBC_LDSO := ld-uClibc.so.0
18 endif
19
20 #--------------------------------------------------------
21 # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc. 
22 LC_ALL:= C
23 export LC_ALL
24
25 ifeq ($(strip $(TARGET_ARCH)),)
26 TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
27         -e 's/i.86/i386/' \
28         -e 's/sparc.*/sparc/' \
29         -e 's/arm.*/arm/g' \
30         -e 's/m68k.*/m68k/' \
31         -e 's/ppc/powerpc/g' \
32         -e 's/v850.*/v850/g' \
33         -e 's/sh[234]/sh/' \
34         -e 's/mips-.*/mips/' \
35         -e 's/mipsel-.*/mipsel/' \
36         -e 's/cris.*/cris/' \
37         )
38 endif
39 export TARGET_ARCH
40
41
42 #--------------------------------------------------------
43 # If you are running a cross compiler, you will want to set 'CROSS'
44 # to something more interesting...  Target architecture is determined
45 # by asking the CC compiler what arch it compiles things for, so unless
46 # your compiler is broken, you should not need to specify TARGET_ARCH
47 #
48 # Most people will set this stuff on the command line, i.e.
49 #        make CROSS=mipsel-linux-
50 # will build uClibc for 'mipsel'.
51
52 CROSS      = $(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
53 CC         = $(CROSS)gcc
54 RM         = rm -f
55
56 # Select the compiler needed to build binaries for your development system
57 HOSTCC     = gcc
58 BUILD_CFLAGS = -O2 -Wall
59
60
61 #--------------------------------------------------------
62 # Check if 'ls -sh' works or not
63 LSFLAGS = -l
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)))
79 XCOMMON_CFLAGS := -D_GNU_SOURCE -I$(top_builddir)test
80 CFLAGS         := $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS) $(XARCH_CFLAGS) -I$(top_builddir)include
81 HOST_CFLAGS    += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS)
82
83 ifeq ($(DODEBUG),y)
84         CFLAGS        += -g
85         HOST_CFLAGS   += -g
86         LDFLAGS       += -g -Wl,-warn-common
87         HOST_LDFLAGS  := -g -Wl,-warn-common
88 else
89         LDFLAGS       += -s -Wl,-warn-common
90         HOST_LDFLAGS  := -s -Wl,-warn-common
91 endif
92
93 ifneq ($(strip $(HAVE_SHARED)),y)
94         LDFLAGS       += -static
95         HOST_LDFLAGS  += -static
96 endif
97 LDFLAGS += -B$(top_builddir)lib -Wl,-rpath,$(top_builddir)lib -Wl,-rpath-link,$(top_builddir)lib
98
99
100 # Filter output
101 MAKEFLAGS += --no-print-directory
102 ifneq ($(findstring s,$(MAKEFLAGS)),)
103 DISP := sil
104 Q    := @
105 SCAT := -@true
106 else
107 ifneq ($(V)$(VERBOSE),)
108 DISP := ver
109 Q    := 
110 SCAT := cat
111 else
112 DISP := pur
113 Q    := @
114 SCAT := -@true
115 endif
116 endif
117
118 banner := ---------------------------------
119 pur_showclean = echo "  "CLEAN $(notdir $(CURDIR))
120 pur_showdiff  = echo "  "TEST_DIFF $(notdir $(CURDIR))/
121 pur_showlink  = echo "  "TEST_LINK $(notdir $(CURDIR))/ $@
122 pur_showtest  = echo "  "TEST_EXEC $(notdir $(CURDIR))/ $@
123 sil_showclean = 
124 sil_showdiff  = true
125 sil_showlink  = true
126 sil_showtest  = true
127 ver_showclean = 
128 ver_showdiff  = true echo
129 ver_showlink  = true echo
130 ver_showtest  = printf "\n$(banner)\nTEST $(notdir $(PWD))/ $@\n$(banner)\n"
131 do_showclean  = $($(DISP)_showclean)
132 do_showdiff   = $($(DISP)_showdiff)
133 do_showlink   = $($(DISP)_showlink)
134 do_showtest   = $($(DISP)_showtest)
135 showclean = @$(do_showclean)
136 showdiff  = @$(do_showdiff)
137 showlink  = @$(do_showlink)
138 showtest  = @$(do_showtest)