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