Rules.mak 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. $(eval $(call check-gcc-var,-Wno-missing-field-initializers))
  72. CFLAGS += $(CFLAG_-Wno-missing-field-initializers)
  73. # Can't add $(OPTIMIZATION) here, it may be target-specific.
  74. # Just adding -Os for now.
  75. HOST_CFLAGS += $(XCOMMON_CFLAGS) -Os $(XWARNINGS) -std=gnu99
  76. LDFLAGS := $(CPU_LDFLAGS-y) -Wl,-z,now
  77. ifeq ($(DODEBUG),y)
  78. CFLAGS += -g
  79. HOST_CFLAGS += -g
  80. LDFLAGS += -Wl,-g
  81. HOST_LDFLAGS += -Wl,-g
  82. endif
  83. ifeq ($(DOSTRIP),y)
  84. LDFLAGS += -Wl,-s
  85. HOST_LDFLAGS += -Wl,-s
  86. endif
  87. ifneq ($(HAVE_SHARED),y)
  88. LDFLAGS += -Wl,-static -static-libgcc
  89. endif
  90. ifndef TEST_INSTALLED_UCLIBC
  91. LDFLAGS += -B$(UCLIBC_PATH) -Wl,-rpath,$(UCLIBC_PATH):$(shell pwd) -Wl,-rpath-link,$(UCLIBC_PATH):$(shell pwd)
  92. else
  93. LDFLAGS += -Wl,-rpath,$(shell pwd)
  94. endif
  95. ifeq ($(findstring -static,$(LDFLAGS)),)
  96. LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_PATH)/$(UCLIBC_LDSO)
  97. endif
  98. ifeq ($(LDSO_GNU_HASH_SUPPORT),y)
  99. # Check for binutils support is done on root Rules.mak
  100. LDFLAGS += $(CFLAG_-Wl--hash-style=gnu)
  101. endif
  102. ifneq ($(strip $(UCLIBC_EXTRA_CFLAGS)),"")
  103. CFLAGS += $(call qstrip,$(UCLIBC_EXTRA_CFLAGS))
  104. endif
  105. ifneq ($(strip $(UCLIBC_EXTRA_LDFLAGS)),"")
  106. LDFLAGS += $(call qstrip,$(UCLIBC_EXTRA_LDFLAGS))
  107. endif
  108. ifneq ($(findstring -s,$(MAKEFLAGS)),)
  109. DISP := sil
  110. Q := @
  111. SCAT := -@true
  112. else
  113. ifneq ($(V)$(VERBOSE),)
  114. DISP := ver
  115. Q :=
  116. SCAT := cat
  117. else
  118. DISP := pur
  119. Q := @
  120. SCAT := -@true
  121. endif
  122. endif
  123. ifneq ($(Q),)
  124. MAKEFLAGS += --no-print-directory
  125. endif
  126. banner := ---------------------------------
  127. pur_showclean = echo " "CLEAN $(notdir $(CURDIR))
  128. pur_showdiff = echo " "TEST_DIFF $(notdir $(CURDIR))/
  129. pur_showlink = echo " "TEST_LINK $(notdir $(CURDIR))/ $@
  130. pur_showtest = echo " "TEST_EXEC $(notdir $(CURDIR))/ $(@:.exe=)
  131. sil_showclean =
  132. sil_showdiff = true
  133. sil_showlink = true
  134. sil_showtest = true
  135. ver_showclean =
  136. ver_showdiff = true echo
  137. ver_showlink = true echo
  138. ver_showtest = printf "\n$(banner)\nTEST $(notdir $(CURDIR))/ $(@:.exe=)\n$(banner)\n"
  139. do_showclean = $($(DISP)_showclean)
  140. do_showdiff = $($(DISP)_showdiff)
  141. do_showlink = $($(DISP)_showlink)
  142. do_showtest = $($(DISP)_showtest)
  143. showclean = @$(do_showclean)
  144. showdiff = @$(do_showdiff)
  145. showlink = @$(do_showlink)
  146. showtest = @$(do_showtest)