Rules.mak 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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)/Rules.mak
  13. ifdef UCLIBC_LDSO
  14. ifeq (,$(findstring /,$(UCLIBC_LDSO)))
  15. UCLIBC_LDSO := $(top_builddir)lib/$(UCLIBC_LDSO)
  16. endif
  17. else
  18. UCLIBC_LDSO := $(firstword $(wildcard $(top_builddir)lib/ld*))
  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/sparc.*/sparc/' \
  28. -e 's/arm.*/arm/g' \
  29. -e 's/m68k.*/m68k/' \
  30. -e 's/ppc/powerpc/g' \
  31. -e 's/v850.*/v850/g' \
  32. -e 's/sh[234]/sh/' \
  33. -e 's/mips.*/mips/' \
  34. -e 's/cris.*/cris/' \
  35. )
  36. endif
  37. export TARGET_ARCH
  38. #--------------------------------------------------------
  39. # If you are running a cross compiler, you will want to set 'CROSS'
  40. # to something more interesting... Target architecture is determined
  41. # by asking the CC compiler what arch it compiles things for, so unless
  42. # your compiler is broken, you should not need to specify TARGET_ARCH
  43. #
  44. # Most people will set this stuff on the command line, i.e.
  45. # make CROSS=mipsel-linux-
  46. # will build uClibc for 'mipsel'.
  47. CROSS = $(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
  48. CC = $(CROSS)gcc
  49. RM = rm -f
  50. # Select the compiler needed to build binaries for your development system
  51. HOSTCC = gcc
  52. #--------------------------------------------------------
  53. # A nifty macro to make testing gcc features easier
  54. check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
  55. then echo "$(1)"; else echo "$(2)"; fi)
  56. # use '-Os' optimization if available, else use -O2, allow Config to override
  57. # Override optimization settings when debugging
  58. ifeq ($(DODEBUG),y)
  59. OPTIMIZATION = -O0
  60. else
  61. OPTIMIZATION += $(call check_gcc,-Os,-O2)
  62. endif
  63. XWARNINGS := $(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes
  64. XARCH_CFLAGS := $(subst ",, $(strip $(ARCH_CFLAGS))) $(CPU_CFLAGS)
  65. XCOMMON_CFLAGS := -D_GNU_SOURCE -I$(top_builddir)test
  66. CFLAGS += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS) $(XARCH_CFLAGS) -I$(top_builddir)include $(PTINC)
  67. HOST_CFLAGS += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS)
  68. LDFLAGS := $(CPU_LDFLAGS)
  69. ifeq ($(DODEBUG),y)
  70. CFLAGS += -g
  71. HOST_CFLAGS += -g
  72. LDFLAGS += -g
  73. HOST_LDFLAGS += -g
  74. else
  75. LDFLAGS += -s
  76. HOST_LDFLAGS += -s
  77. endif
  78. ifneq ($(strip $(HAVE_SHARED)),y)
  79. LDFLAGS += -static
  80. HOST_LDFLAGS += -static
  81. endif
  82. LDFLAGS += -B$(top_builddir)lib -Wl,-rpath,$(top_builddir)lib -Wl,-rpath-link,$(top_builddir)lib
  83. ifeq ($(findstring -static,$(LDFLAGS)),)
  84. LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_LDSO)
  85. endif
  86. # Filter output
  87. MAKEFLAGS += --no-print-directory
  88. ifneq ($(findstring s,$(MAKEFLAGS)),)
  89. DISP := sil
  90. Q := @
  91. SCAT := -@true
  92. else
  93. ifneq ($(V)$(VERBOSE),)
  94. DISP := ver
  95. Q :=
  96. SCAT := cat
  97. else
  98. DISP := pur
  99. Q := @
  100. SCAT := -@true
  101. endif
  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))/ $@
  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 $(PWD))/ $@\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)