Rules.mak 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. BUILD_CFLAGS = -O2 -Wall
  48. #--------------------------------------------------------
  49. # Check if 'ls -sh' works or not
  50. LSFLAGS = -l
  51. # A nifty macro to make testing gcc features easier
  52. check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
  53. then echo "$(1)"; else echo "$(2)"; fi)
  54. # use '-Os' optimization if available, else use -O2, allow Config to override
  55. # Override optimization settings when debugging
  56. ifeq ($(DODEBUG),y)
  57. OPTIMIZATION = -O0
  58. else
  59. OPTIMIZATION += $(call check_gcc,-Os,-O2)
  60. endif
  61. XWARNINGS := $(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes
  62. XARCH_CFLAGS := $(subst ",, $(strip $(ARCH_CFLAGS)))
  63. XCOMMON_CFLAGS := -D_GNU_SOURCE -I$(top_builddir)test
  64. CFLAGS := $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS) $(XARCH_CFLAGS) -I$(top_builddir)include
  65. HOST_CFLAGS += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS)
  66. ifeq ($(DODEBUG),y)
  67. CFLAGS += -g
  68. HOST_CFLAGS += -g
  69. LDFLAGS += -g -Wl,-warn-common
  70. HOST_LDFLAGS := -g -Wl,-warn-common
  71. else
  72. LDFLAGS += -s -Wl,-warn-common
  73. HOST_LDFLAGS := -s -Wl,-warn-common
  74. endif
  75. ifneq ($(strip $(HAVE_SHARED)),y)
  76. LDFLAGS += -static
  77. HOST_LDFLAGS += -static
  78. endif
  79. LDFLAGS += -B$(top_builddir)lib -Wl,-rpath,$(top_builddir)lib -Wl,-rpath-link,$(top_builddir)lib
  80. ifeq ($(findstring -static,$(LDFLAGS)),)
  81. LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_LDSO)
  82. endif
  83. # Filter output
  84. MAKEFLAGS += --no-print-directory
  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. banner := ---------------------------------
  101. pur_showclean = echo " "CLEAN $(notdir $(CURDIR))
  102. pur_showdiff = echo " "TEST_DIFF $(notdir $(CURDIR))/
  103. pur_showlink = echo " "TEST_LINK $(notdir $(CURDIR))/ $@
  104. pur_showtest = echo " "TEST_EXEC $(notdir $(CURDIR))/ $@
  105. sil_showclean =
  106. sil_showdiff = true
  107. sil_showlink = true
  108. sil_showtest = true
  109. ver_showclean =
  110. ver_showdiff = true echo
  111. ver_showlink = true echo
  112. ver_showtest = printf "\n$(banner)\nTEST $(notdir $(PWD))/ $@\n$(banner)\n"
  113. do_showclean = $($(DISP)_showclean)
  114. do_showdiff = $($(DISP)_showdiff)
  115. do_showlink = $($(DISP)_showlink)
  116. do_showtest = $($(DISP)_showtest)
  117. showclean = @$(do_showclean)
  118. showdiff = @$(do_showdiff)
  119. showlink = @$(do_showlink)
  120. showtest = @$(do_showtest)