Rules.mak 3.9 KB

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