OSDN Git Service

h8300: O_DIRECT and O_DIRECTIRY swapping.
[uclinux-h8/uclibc-ng.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 .SUFFIXES:
9
10 top_builddir ?= ../
11 abs_top_builddir ?= $(shell cd $(top_builddir); pwd)/
12
13 TESTDIR=$(top_builddir)test/
14
15 include $(top_srcdir)Rules.mak
16 ifeq ($(filter $(clean_targets) CLEAN_%,$(MAKECMDGOALS)),)
17 ifeq ($(HAVE_DOT_CONFIG),)
18 $(error no HAVE_DOT_CONFIG, failed to read .config)
19 endif
20 endif
21
22 ifdef UCLIBC_LDSO
23 ifeq (,$(findstring /,$(UCLIBC_LDSO)))
24 UCLIBC_LDSO := $(UCLIBC_LDSO)
25 else
26 UCLIBC_LDSO := $(notdir $(UCLIBC_LDSO))
27 endif
28 else
29 UCLIBC_LDSO := $(notdir $(firstword $(wildcard $(top_builddir)lib/ld*)))
30 endif
31 ifndef TEST_INSTALLED_UCLIBC
32 ifeq ($(LDSO_SAFE_RUNPATH),y)
33 UCLIBC_PATH := $(abs_top_builddir)lib
34 else
35 UCLIBC_PATH := $(top_builddir)lib
36 endif
37 else
38 UCLIBC_PATH := $(RUNTIME_PREFIX)$(MULTILIB_DIR)
39 endif
40 #--------------------------------------------------------
41 # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
42 LC_ALL:= C
43 export LC_ALL
44
45 ifeq ($(strip $(TARGET_ARCH)),)
46 TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
47         -e 's/i.86/i386/' \
48         -e 's/sun.*/sparc/' -e 's/sparc.*/sparc/' \
49         -e 's/sa110/arm/' -e 's/arm.*/arm/g' \
50         -e 's/m68k.*/m68k/' \
51         -e 's/parisc.*/hppa/' \
52         -e 's/ppc/powerpc/g' \
53         -e 's/sh[234]/sh/' \
54         -e 's/mips.*/mips/' \
55         -e 's/cris.*/cris/' \
56         -e 's/xtensa.*/xtensa/' \
57         )
58 endif
59 export TARGET_ARCH
60
61 RM_R = $(Q)$(RM) -r
62 LN_S = $(Q)$(LN) -fs
63
64 ifneq ($(KERNEL_HEADERS),)
65 ifeq ($(patsubst /%,/,$(KERNEL_HEADERS)),/)
66 # Absolute path in KERNEL_HEADERS
67 KERNEL_INCLUDES += -I$(KERNEL_HEADERS)
68 else
69 # Relative path in KERNEL_HEADERS
70 KERNEL_INCLUDES += -I$(top_builddir)$(KERNEL_HEADERS)
71 endif
72 endif
73
74 XCOMMON_CFLAGS := -I$(top_builddir)test -D_GNU_SOURCE
75 XWARNINGS      += $(CFLAG_-Wstrict-prototypes)
76 CFLAGS         := -nostdinc -I$(top_builddir)$(LOCAL_INSTALL_PATH)/usr/include
77 CFLAGS         += $(XCOMMON_CFLAGS) $(KERNEL_INCLUDES) $(CC_INC)
78 CFLAGS         += $(OPTIMIZATION) $(CPU_CFLAGS) $(XWARNINGS)
79
80 $(eval $(call check-gcc-var,-Wno-missing-field-initializers))
81 CFLAGS         += $(CFLAG_-Wno-missing-field-initializers)
82
83 # Can't add $(OPTIMIZATION) here, it may be target-specific.
84 # Just adding -Os for now.
85 HOST_CFLAGS    += $(XCOMMON_CFLAGS) -Os $(XWARNINGS) -std=gnu99
86
87 LDFLAGS        := $(CPU_LDFLAGS-y) -Wl,-z,now
88 ifeq ($(DODEBUG),y)
89         CFLAGS        += -g
90         HOST_CFLAGS   += -g
91         LDFLAGS       += -Wl,-g
92         HOST_LDFLAGS  += -Wl,-g
93 endif
94
95 ifeq ($(DOSTRIP),y)
96         LDFLAGS       += -Wl,-s
97         HOST_LDFLAGS  += -Wl,-s
98 endif
99
100 ifneq ($(HAVE_SHARED),y)
101         LDFLAGS       += -Wl,-static -static-libgcc
102 endif
103
104 ifndef TEST_INSTALLED_UCLIBC
105 LDFLAGS += -B$(UCLIBC_PATH) -Wl,-rpath,$(UCLIBC_PATH):$(shell pwd) -Wl,-rpath-link,$(UCLIBC_PATH):$(shell pwd)
106 else
107 LDFLAGS += -Wl,-rpath,$(shell pwd)
108 endif
109
110 ifeq ($(findstring -static,$(LDFLAGS)),)
111 LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_PATH)/$(UCLIBC_LDSO)
112 endif
113
114 ifeq ($(LDSO_GNU_HASH_SUPPORT),y)
115 # Check for binutils support is done on root Rules.mak
116 LDFLAGS += $(CFLAG_-Wl--hash-style=gnu)
117 endif
118
119 ifneq ($(strip $(UCLIBC_EXTRA_CFLAGS)),"")
120 CFLAGS += $(call qstrip,$(UCLIBC_EXTRA_CFLAGS))
121 endif
122 ifneq ($(strip $(UCLIBC_EXTRA_LDFLAGS)),"")
123 LDFLAGS += $(call qstrip,$(UCLIBC_EXTRA_LDFLAGS))
124 endif
125
126 ifneq ($(findstring -s,$(MAKEFLAGS)),)
127 DISP := sil
128 Q    := @
129 SCAT := -@true
130 else
131 ifneq ($(V)$(VERBOSE),)
132 DISP := ver
133 Q    :=
134 SCAT := cat
135 else
136 DISP := pur
137 Q    := @
138 SCAT := -@true
139 endif
140 endif
141 ifneq ($(Q),)
142 MAKEFLAGS += --no-print-directory
143 endif
144
145 banner := ---------------------------------
146 pur_showclean = echo "  "CLEAN $(notdir $(CURDIR))
147 pur_showdiff  = echo "  "TEST_DIFF $(notdir $(CURDIR))/
148 pur_showlink  = echo "  "TEST_LINK $(notdir $(CURDIR))/ $@
149 pur_showtest  = echo "  "TEST_EXEC $(notdir $(CURDIR))/ $(@:.exe=)
150 sil_showclean =
151 sil_showdiff  = true
152 sil_showlink  = true
153 sil_showtest  = true
154 ver_showclean =
155 ver_showdiff  = true echo
156 ver_showlink  = true echo
157 ver_showtest  = printf "\n$(banner)\nTEST $(notdir $(CURDIR))/ $(@:.exe=)\n$(banner)\n"
158 do_showclean  = $($(DISP)_showclean)
159 do_showdiff   = $($(DISP)_showdiff)
160 do_showlink   = $($(DISP)_showlink)
161 do_showtest   = $($(DISP)_showtest)
162 showclean = @$(do_showclean)
163 showdiff  = @$(do_showdiff)
164 showlink  = @$(do_showlink)
165 showtest  = @$(do_showtest)