Rules.mak 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. #
  8. # Note: This does not read the top level Rules.mak file
  9. #
  10. top_builddir = ../../
  11. TESTDIR=$(top_builddir)test/
  12. -include $(top_builddir).config
  13. UCLIBC_LDSO ?= $(firstword $(wildcard $(top_builddir)lib/ld*))
  14. #--------------------------------------------------------
  15. # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
  16. LC_ALL:= C
  17. export LC_ALL
  18. ifeq ($(strip $(TARGET_ARCH)),)
  19. TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
  20. -e 's/i.86/i386/' \
  21. -e 's/sparc.*/sparc/' \
  22. -e 's/arm.*/arm/g' \
  23. -e 's/m68k.*/m68k/' \
  24. -e 's/ppc/powerpc/g' \
  25. -e 's/v850.*/v850/g' \
  26. -e 's/sh[234]/sh/' \
  27. -e 's/mips.*/mips/' \
  28. -e 's/cris.*/cris/' \
  29. )
  30. endif
  31. export TARGET_ARCH
  32. #--------------------------------------------------------
  33. # If you are running a cross compiler, you will want to set 'CROSS'
  34. # to something more interesting... Target architecture is determined
  35. # by asking the CC compiler what arch it compiles things for, so unless
  36. # your compiler is broken, you should not need to specify TARGET_ARCH
  37. #
  38. # Most people will set this stuff on the command line, i.e.
  39. # make CROSS=mipsel-linux-
  40. # will build uClibc for 'mipsel'.
  41. CROSS = $(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
  42. CC = $(CROSS)gcc
  43. RM = rm -f
  44. # Select the compiler needed to build binaries for your development system
  45. HOSTCC = gcc
  46. #--------------------------------------------------------
  47. # A nifty macro to make testing gcc features easier
  48. check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
  49. then echo "$(1)"; else echo "$(2)"; fi)
  50. # use '-Os' optimization if available, else use -O2, allow Config to override
  51. # Override optimization settings when debugging
  52. ifeq ($(DODEBUG),y)
  53. OPTIMIZATION = -O0
  54. else
  55. OPTIMIZATION += $(call check_gcc,-Os,-O2)
  56. endif
  57. XWARNINGS := $(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes
  58. XARCH_CFLAGS := $(subst ",, $(strip $(ARCH_CFLAGS)))
  59. XCOMMON_CFLAGS := -D_GNU_SOURCE -I$(top_builddir)test
  60. CFLAGS += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS) $(XARCH_CFLAGS) -I$(top_builddir)include
  61. HOST_CFLAGS += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS)
  62. ifeq ($(DODEBUG),y)
  63. CFLAGS += -g
  64. HOST_CFLAGS += -g
  65. LDFLAGS += -g -Wl,-warn-common
  66. HOST_LDFLAGS += -g -Wl,-warn-common
  67. else
  68. LDFLAGS += -s -Wl,-warn-common
  69. HOST_LDFLAGS += -s -Wl,-warn-common
  70. endif
  71. ifneq ($(strip $(HAVE_SHARED)),y)
  72. LDFLAGS += -static
  73. HOST_LDFLAGS += -static
  74. endif
  75. LDFLAGS += -B$(top_builddir)lib -Wl,-rpath,$(top_builddir)lib -Wl,-rpath-link,$(top_builddir)lib
  76. ifeq ($(findstring -static,$(LDFLAGS)),)
  77. LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_LDSO)
  78. endif
  79. # Filter output
  80. MAKEFLAGS += --no-print-directory
  81. ifneq ($(findstring s,$(MAKEFLAGS)),)
  82. DISP := sil
  83. Q := @
  84. SCAT := -@true
  85. else
  86. ifneq ($(V)$(VERBOSE),)
  87. DISP := ver
  88. Q :=
  89. SCAT := cat
  90. else
  91. DISP := pur
  92. Q := @
  93. SCAT := -@true
  94. endif
  95. endif
  96. banner := ---------------------------------
  97. pur_showclean = echo " "CLEAN $(notdir $(CURDIR))
  98. pur_showdiff = echo " "TEST_DIFF $(notdir $(CURDIR))/
  99. pur_showlink = echo " "TEST_LINK $(notdir $(CURDIR))/ $@
  100. pur_showtest = echo " "TEST_EXEC $(notdir $(CURDIR))/ $@
  101. sil_showclean =
  102. sil_showdiff = true
  103. sil_showlink = true
  104. sil_showtest = true
  105. ver_showclean =
  106. ver_showdiff = true echo
  107. ver_showlink = true echo
  108. ver_showtest = printf "\n$(banner)\nTEST $(notdir $(PWD))/ $@\n$(banner)\n"
  109. do_showclean = $($(DISP)_showclean)
  110. do_showdiff = $($(DISP)_showdiff)
  111. do_showlink = $($(DISP)_showlink)
  112. do_showtest = $($(DISP)_showtest)
  113. showclean = @$(do_showclean)
  114. showdiff = @$(do_showdiff)
  115. showlink = @$(do_showlink)
  116. showtest = @$(do_showtest)