Rules.mak 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. LN_S = $(Q)$(LN) -fs
  42. ifneq ($(KERNEL_HEADERS),)
  43. ifeq ($(patsubst /%,/,$(KERNEL_HEADERS)),/)
  44. # Absolute path in KERNEL_HEADERS
  45. KERNEL_INCLUDES += -I$(KERNEL_HEADERS)
  46. else
  47. # Relative path in KERNEL_HEADERS
  48. KERNEL_INCLUDES += -I$(top_builddir)$(KERNEL_HEADERS)
  49. endif
  50. endif
  51. XCOMMON_CFLAGS := -I$(top_builddir)test -D_GNU_SOURCE
  52. CFLAG_-Wstrict-prototypes ?= $(call check_gcc,-Wstrict-prototypes,)
  53. XWARNINGS += $(CFLAG_-Wstrict-prototypes)
  54. CFLAGS := -nostdinc -I$(top_builddir)$(LOCAL_INSTALL_PATH)/usr/include
  55. CFLAGS += $(XCOMMON_CFLAGS) $(KERNEL_INCLUDES) $(CC_INC)
  56. CFLAGS += $(OPTIMIZATION) $(CPU_CFLAGS) $(XWARNINGS)
  57. # Can't add $(OPTIMIZATION) here, it may be target-specific.
  58. # Just adding -Os for now.
  59. HOST_CFLAGS += $(XCOMMON_CFLAGS) -Os $(XWARNINGS) -std=gnu99
  60. LDFLAGS := $(CPU_LDFLAGS-y) -Wl,-z,now
  61. ifeq ($(DODEBUG),y)
  62. CFLAGS += -g
  63. HOST_CFLAGS += -g
  64. LDFLAGS += -Wl,-g
  65. HOST_LDFLAGS += -Wl,-g
  66. else
  67. LDFLAGS += -Wl,-s
  68. HOST_LDFLAGS += -Wl,-s
  69. endif
  70. ifneq ($(HAVE_SHARED),y)
  71. LDFLAGS += -Wl,-static -static-libgcc
  72. endif
  73. LDFLAGS += -B$(top_builddir)lib -Wl,-rpath,$(top_builddir)lib -Wl,-rpath-link,$(top_builddir)lib
  74. UCLIBC_LDSO_ABSPATH=$(shell pwd)
  75. ifdef TEST_INSTALLED_UCLIBC
  76. LDFLAGS += -Wl,-rpath,./
  77. UCLIBC_LDSO_ABSPATH=$(RUNTIME_PREFIX)$(MULTILIB_DIR)
  78. endif
  79. ifeq ($(findstring -static,$(LDFLAGS)),)
  80. LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_LDSO_ABSPATH)/$(UCLIBC_LDSO)
  81. endif
  82. ifeq ($(LDSO_GNU_HASH_SUPPORT),y)
  83. # Check for binutils support is done on root Rules.mak
  84. LDFLAGS += -Wl,${LDFLAGS_GNUHASH}
  85. endif
  86. ifneq ($(findstring -s,$(MAKEFLAGS)),)
  87. DISP := sil
  88. Q := @
  89. SCAT := -@true
  90. else
  91. ifneq ($(V)$(VERBOSE),)
  92. DISP := ver
  93. Q :=
  94. SCAT := cat
  95. else
  96. DISP := pur
  97. Q := @
  98. SCAT := -@true
  99. endif
  100. endif
  101. ifneq ($(Q),)
  102. MAKEFLAGS += --no-print-directory
  103. endif
  104. banner := ---------------------------------
  105. pur_showclean = echo " "CLEAN $(notdir $(CURDIR))
  106. pur_showdiff = echo " "TEST_DIFF $(notdir $(CURDIR))/
  107. pur_showlink = echo " "TEST_LINK $(notdir $(CURDIR))/ $@
  108. pur_showtest = echo " "TEST_EXEC $(notdir $(CURDIR))/ $(@:.exe=)
  109. sil_showclean =
  110. sil_showdiff = true
  111. sil_showlink = true
  112. sil_showtest = true
  113. ver_showclean =
  114. ver_showdiff = true echo
  115. ver_showlink = true echo
  116. ver_showtest = printf "\n$(banner)\nTEST $(notdir $(CURDIR))/ $(@:.exe=)\n$(banner)\n"
  117. do_showclean = $($(DISP)_showclean)
  118. do_showdiff = $($(DISP)_showdiff)
  119. do_showlink = $($(DISP)_showlink)
  120. do_showtest = $($(DISP)_showtest)
  121. showclean = @$(do_showclean)
  122. showdiff = @$(do_showdiff)
  123. showlink = @$(do_showlink)
  124. showtest = @$(do_showtest)