fix linking for m68k
[uclibc-ng.git] / test / Rules.mak
blobc5d1d636c5238f539e0a353333080a5e4ec40c53
1 # Rules.mak for uClibc test subdirs
3 # Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
5 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8 .SUFFIXES:
10 top_builddir ?= ../
11 abs_top_builddir ?= $(shell cd $(top_builddir); pwd)/
13 TESTDIR=$(top_builddir)test/
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
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
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/v850.*/v850/g' \
54 -e 's/sh[234]/sh/' \
55 -e 's/mips.*/mips/' \
56 -e 's/cris.*/cris/' \
57 -e 's/xtensa.*/xtensa/' \
59 endif
60 export TARGET_ARCH
62 RM_R = $(Q)$(RM) -r
63 LN_S = $(Q)$(LN) -fs
65 ifneq ($(KERNEL_HEADERS),)
66 ifeq ($(patsubst /%,/,$(KERNEL_HEADERS)),/)
67 # Absolute path in KERNEL_HEADERS
68 KERNEL_INCLUDES += -I$(KERNEL_HEADERS)
69 else
70 # Relative path in KERNEL_HEADERS
71 KERNEL_INCLUDES += -I$(top_builddir)$(KERNEL_HEADERS)
72 endif
73 endif
75 XCOMMON_CFLAGS := -I$(top_builddir)test -D_GNU_SOURCE
76 XWARNINGS += $(CFLAG_-Wstrict-prototypes)
77 CFLAGS := -nostdinc -I$(top_builddir)$(LOCAL_INSTALL_PATH)/usr/include
78 CFLAGS += $(XCOMMON_CFLAGS) $(KERNEL_INCLUDES) $(CC_INC)
79 CFLAGS += $(OPTIMIZATION) $(CPU_CFLAGS) $(XWARNINGS)
81 $(eval $(call check-gcc-var,-Wno-missing-field-initializers))
82 CFLAGS += $(CFLAG_-Wno-missing-field-initializers)
84 # Can't add $(OPTIMIZATION) here, it may be target-specific.
85 # Just adding -Os for now.
86 HOST_CFLAGS += $(XCOMMON_CFLAGS) -Os $(XWARNINGS) -std=gnu99
88 LDFLAGS := $(CPU_LDFLAGS-y) -Wl,-z,now
89 ifeq ($(DODEBUG),y)
90 CFLAGS += -g
91 HOST_CFLAGS += -g
92 LDFLAGS += -Wl,-g
93 HOST_LDFLAGS += -Wl,-g
94 else
95 LDFLAGS += -Wl,-s
96 HOST_LDFLAGS += -Wl,-s
97 endif
99 ifneq ($(HAVE_SHARED),y)
100 LDFLAGS += -Wl,-static -static-libgcc
101 endif
103 ifndef TEST_INSTALLED_UCLIBC
104 LDFLAGS += -B$(UCLIBC_PATH) -Wl,-rpath,$(UCLIBC_PATH):$(shell pwd) -Wl,-rpath-link,$(UCLIBC_PATH):$(shell pwd)
105 else
106 LDFLAGS += -Wl,-rpath,$(shell pwd)
107 endif
109 ifeq ($(findstring -static,$(LDFLAGS)),)
110 LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_PATH)/$(UCLIBC_LDSO)
111 endif
113 ifeq ($(LDSO_GNU_HASH_SUPPORT),y)
114 # Check for binutils support is done on root Rules.mak
115 LDFLAGS += $(CFLAG_-Wl--hash-style=gnu)
116 endif
118 ifneq ($(strip $(UCLIBC_EXTRA_CFLAGS)),"")
119 CFLAGS += $(call qstrip,$(UCLIBC_EXTRA_CFLAGS))
120 endif
121 ifneq ($(strip $(UCLIBC_EXTRA_LDFLAGS)),"")
122 LDFLAGS += $(call qstrip,$(UCLIBC_EXTRA_LDFLAGS))
123 endif
125 ifneq ($(findstring -s,$(MAKEFLAGS)),)
126 DISP := sil
127 Q := @
128 SCAT := -@true
129 else
130 ifneq ($(V)$(VERBOSE),)
131 DISP := ver
132 Q :=
133 SCAT := cat
134 else
135 DISP := pur
136 Q := @
137 SCAT := -@true
138 endif
139 endif
140 ifneq ($(Q),)
141 MAKEFLAGS += --no-print-directory
142 endif
144 banner := ---------------------------------
145 pur_showclean = echo " "CLEAN $(notdir $(CURDIR))
146 pur_showdiff = echo " "TEST_DIFF $(notdir $(CURDIR))/
147 pur_showlink = echo " "TEST_LINK $(notdir $(CURDIR))/ $@
148 pur_showtest = echo " "TEST_EXEC $(notdir $(CURDIR))/ $(@:.exe=)
149 sil_showclean =
150 sil_showdiff = true
151 sil_showlink = true
152 sil_showtest = true
153 ver_showclean =
154 ver_showdiff = true echo
155 ver_showlink = true echo
156 ver_showtest = printf "\n$(banner)\nTEST $(notdir $(CURDIR))/ $(@:.exe=)\n$(banner)\n"
157 do_showclean = $($(DISP)_showclean)
158 do_showdiff = $($(DISP)_showdiff)
159 do_showlink = $($(DISP)_showlink)
160 do_showtest = $($(DISP)_showtest)
161 showclean = @$(do_showclean)
162 showdiff = @$(do_showdiff)
163 showlink = @$(do_showlink)
164 showtest = @$(do_showtest)