Rules.mak 3.5 KB

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