Rules.mak 3.8 KB

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