Rules.mak 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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/sh[234]/sh/' \
  48. -e 's/mips.*/mips/' \
  49. -e 's/cris.*/cris/' \
  50. -e 's/xtensa.*/xtensa/' \
  51. )
  52. endif
  53. export TARGET_ARCH
  54. RM_R = $(Q)$(RM) -r
  55. LN_S = $(Q)$(LN) -fs
  56. ifneq ($(KERNEL_HEADERS),)
  57. ifeq ($(patsubst /%,/,$(KERNEL_HEADERS)),/)
  58. # Absolute path in KERNEL_HEADERS
  59. KERNEL_INCLUDES += -I$(KERNEL_HEADERS)
  60. else
  61. # Relative path in KERNEL_HEADERS
  62. KERNEL_INCLUDES += -I$(top_builddir)$(KERNEL_HEADERS)
  63. endif
  64. endif
  65. XCOMMON_CFLAGS := -I$(top_builddir)test -D_GNU_SOURCE
  66. XWARNINGS += $(CFLAG_-Wstrict-prototypes)
  67. CFLAGS := -nostdinc -I$(top_builddir)$(LOCAL_INSTALL_PATH)/usr/include
  68. CFLAGS += $(XCOMMON_CFLAGS) $(KERNEL_INCLUDES) $(CC_INC)
  69. CFLAGS += $(OPTIMIZATION) $(CPU_CFLAGS) $(XWARNINGS)
  70. $(eval $(call check-gcc-var,-Wno-missing-field-initializers))
  71. CFLAGS += $(CFLAG_-Wno-missing-field-initializers)
  72. # Can't add $(OPTIMIZATION) here, it may be target-specific.
  73. # Just adding -Os for now.
  74. HOST_CFLAGS += $(XCOMMON_CFLAGS) -Os $(XWARNINGS) -std=gnu99
  75. LDFLAGS := $(CPU_LDFLAGS-y) -Wl,-z,now
  76. ifeq ($(DODEBUG),y)
  77. CFLAGS += -g
  78. HOST_CFLAGS += -g
  79. LDFLAGS += -Wl,-g
  80. HOST_LDFLAGS += -Wl,-g
  81. endif
  82. ifeq ($(DOSTRIP),y)
  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 ($(strip $(UCLIBC_EXTRA_CFLAGS)),"")
  102. CFLAGS += $(call qstrip,$(UCLIBC_EXTRA_CFLAGS))
  103. endif
  104. ifneq ($(strip $(UCLIBC_EXTRA_LDFLAGS)),"")
  105. LDFLAGS += $(call qstrip,$(UCLIBC_EXTRA_LDFLAGS))
  106. endif
  107. ifneq ($(findstring -s,$(MAKEFLAGS)),)
  108. DISP := sil
  109. Q := @
  110. SCAT := -@true
  111. else
  112. ifneq ($(V)$(VERBOSE),)
  113. DISP := ver
  114. Q :=
  115. SCAT := cat
  116. else
  117. DISP := pur
  118. Q := @
  119. SCAT := -@true
  120. endif
  121. endif
  122. ifneq ($(Q),)
  123. MAKEFLAGS += --no-print-directory
  124. endif
  125. banner := ---------------------------------
  126. pur_showclean = echo " "CLEAN $(notdir $(CURDIR))
  127. pur_showdiff = echo " "TEST_DIFF $(notdir $(CURDIR))/
  128. pur_showlink = echo " "TEST_LINK $(notdir $(CURDIR))/ $@
  129. pur_showtest = echo " "TEST_EXEC $(notdir $(CURDIR))/ $(@:.exe=)
  130. sil_showclean =
  131. sil_showdiff = true
  132. sil_showlink = true
  133. sil_showtest = true
  134. ver_showclean =
  135. ver_showdiff = true echo
  136. ver_showlink = true echo
  137. ver_showtest = printf "\n$(banner)\nTEST $(notdir $(CURDIR))/ $(@:.exe=)\n$(banner)\n"
  138. do_showclean = $($(DISP)_showclean)
  139. do_showdiff = $($(DISP)_showdiff)
  140. do_showlink = $($(DISP)_showlink)
  141. do_showtest = $($(DISP)_showtest)
  142. showclean = @$(do_showclean)
  143. showdiff = @$(do_showdiff)
  144. showlink = @$(do_showlink)
  145. showtest = @$(do_showtest)