Rules.mak 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. else
  83. LDFLAGS += -Wl,-s
  84. HOST_LDFLAGS += -Wl,-s
  85. endif
  86. ifneq ($(HAVE_SHARED),y)
  87. LDFLAGS += -Wl,-static -static-libgcc
  88. endif
  89. ifndef TEST_INSTALLED_UCLIBC
  90. LDFLAGS += -B$(UCLIBC_PATH) -Wl,-rpath,$(UCLIBC_PATH):$(shell pwd) -Wl,-rpath-link,$(UCLIBC_PATH):$(shell pwd)
  91. else
  92. LDFLAGS += -Wl,-rpath,$(shell pwd)
  93. endif
  94. ifeq ($(findstring -static,$(LDFLAGS)),)
  95. LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_PATH)/$(UCLIBC_LDSO)
  96. endif
  97. ifeq ($(LDSO_GNU_HASH_SUPPORT),y)
  98. # Check for binutils support is done on root Rules.mak
  99. LDFLAGS += $(CFLAG_-Wl--hash-style=gnu)
  100. endif
  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. banner := ---------------------------------
  120. pur_showclean = echo " "CLEAN $(notdir $(CURDIR))
  121. pur_showdiff = echo " "TEST_DIFF $(notdir $(CURDIR))/
  122. pur_showlink = echo " "TEST_LINK $(notdir $(CURDIR))/ $@
  123. pur_showtest = echo " "TEST_EXEC $(notdir $(CURDIR))/ $(@:.exe=)
  124. sil_showclean =
  125. sil_showdiff = true
  126. sil_showlink = true
  127. sil_showtest = true
  128. ver_showclean =
  129. ver_showdiff = true echo
  130. ver_showlink = true echo
  131. ver_showtest = printf "\n$(banner)\nTEST $(notdir $(CURDIR))/ $(@:.exe=)\n$(banner)\n"
  132. do_showclean = $($(DISP)_showclean)
  133. do_showdiff = $($(DISP)_showdiff)
  134. do_showlink = $($(DISP)_showlink)
  135. do_showtest = $($(DISP)_showtest)
  136. showclean = @$(do_showclean)
  137. showdiff = @$(do_showdiff)
  138. showlink = @$(do_showlink)
  139. showtest = @$(do_showtest)