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