Rules.mak 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. # Rules.mak for uClibc test subdirs
  2. #
  3. # Copyright (C) 2001 by Lineo, inc.
  4. # Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
  5. #
  6. # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  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/mipsel-.*/mipsel/' \
  29. -e 's/cris.*/cris/' \
  30. )
  31. endif
  32. export TARGET_ARCH
  33. #--------------------------------------------------------
  34. # If you are running a cross compiler, you will want to set 'CROSS'
  35. # to something more interesting... Target architecture is determined
  36. # by asking the CC compiler what arch it compiles things for, so unless
  37. # your compiler is broken, you should not need to specify TARGET_ARCH
  38. #
  39. # Most people will set this stuff on the command line, i.e.
  40. # make CROSS=mipsel-linux-
  41. # will build uClibc for 'mipsel'.
  42. CROSS = $(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
  43. CC = $(CROSS)gcc
  44. RM = rm -f
  45. # Select the compiler needed to build binaries for your development system
  46. HOSTCC = gcc
  47. #--------------------------------------------------------
  48. # A nifty macro to make testing gcc features easier
  49. check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
  50. then echo "$(1)"; else echo "$(2)"; fi)
  51. # use '-Os' optimization if available, else use -O2, allow Config to override
  52. # Override optimization settings when debugging
  53. ifeq ($(DODEBUG),y)
  54. OPTIMIZATION = -O0
  55. else
  56. OPTIMIZATION += $(call check_gcc,-Os,-O2)
  57. endif
  58. XWARNINGS := $(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes
  59. XARCH_CFLAGS := $(subst ",, $(strip $(ARCH_CFLAGS)))
  60. XCOMMON_CFLAGS := -D_GNU_SOURCE -I$(top_builddir)test
  61. CFLAGS += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS) $(XARCH_CFLAGS) -I$(top_builddir)include
  62. HOST_CFLAGS += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS)
  63. ifeq ($(DODEBUG),y)
  64. CFLAGS += -g
  65. HOST_CFLAGS += -g
  66. LDFLAGS += -g -Wl,-warn-common
  67. HOST_LDFLAGS += -g -Wl,-warn-common
  68. else
  69. LDFLAGS += -s -Wl,-warn-common
  70. HOST_LDFLAGS += -s -Wl,-warn-common
  71. endif
  72. ifneq ($(strip $(HAVE_SHARED)),y)
  73. LDFLAGS += -static
  74. HOST_LDFLAGS += -static
  75. endif
  76. LDFLAGS += -B$(top_builddir)lib -Wl,-rpath,$(top_builddir)lib -Wl,-rpath-link,$(top_builddir)lib
  77. ifeq ($(findstring -static,$(LDFLAGS)),)
  78. LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_LDSO)
  79. endif
  80. # Filter output
  81. MAKEFLAGS += --no-print-directory
  82. ifneq ($(findstring s,$(MAKEFLAGS)),)
  83. DISP := sil
  84. Q := @
  85. SCAT := -@true
  86. else
  87. ifneq ($(V)$(VERBOSE),)
  88. DISP := ver
  89. Q :=
  90. SCAT := cat
  91. else
  92. DISP := pur
  93. Q := @
  94. SCAT := -@true
  95. endif
  96. endif
  97. banner := ---------------------------------
  98. pur_showclean = echo " "CLEAN $(notdir $(CURDIR))
  99. pur_showdiff = echo " "TEST_DIFF $(notdir $(CURDIR))/
  100. pur_showlink = echo " "TEST_LINK $(notdir $(CURDIR))/ $@
  101. pur_showtest = echo " "TEST_EXEC $(notdir $(CURDIR))/ $@
  102. sil_showclean =
  103. sil_showdiff = true
  104. sil_showlink = true
  105. sil_showtest = true
  106. ver_showclean =
  107. ver_showdiff = true echo
  108. ver_showlink = true echo
  109. ver_showtest = printf "\n$(banner)\nTEST $(notdir $(PWD))/ $@\n$(banner)\n"
  110. do_showclean = $($(DISP)_showclean)
  111. do_showdiff = $($(DISP)_showdiff)
  112. do_showlink = $($(DISP)_showlink)
  113. do_showtest = $($(DISP)_showtest)
  114. showclean = @$(do_showclean)
  115. showdiff = @$(do_showdiff)
  116. showlink = @$(do_showlink)
  117. showtest = @$(do_showtest)