Rules.mak 3.7 KB

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