Rules.mak 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. RM = rm -f
  47. # Select the compiler needed to build binaries for your development system
  48. HOSTCC = gcc
  49. BUILD_CFLAGS = -O2 -Wall
  50. #--------------------------------------------------------
  51. # Check if 'ls -sh' works or not
  52. LSFLAGS = -l
  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)))
  65. XCOMMON_CFLAGS := -D_GNU_SOURCE -I$(top_builddir)test
  66. CFLAGS := $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS) $(XARCH_CFLAGS) -I$(top_builddir)include
  67. HOST_CFLAGS += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS)
  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. else
  74. LDFLAGS += -s -Wl,-warn-common
  75. HOST_LDFLAGS := -s -Wl,-warn-common
  76. endif
  77. ifneq ($(strip $(HAVE_SHARED)),y)
  78. LDFLAGS += -static
  79. HOST_LDFLAGS += -static
  80. endif
  81. LDFLAGS += -B$(top_builddir)lib -Wl,-rpath,$(top_builddir)lib -Wl,-rpath-link,$(top_builddir)lib
  82. # Filter output
  83. MAKEFLAGS += --no-print-directory
  84. ifneq ($(findstring s,$(MAKEFLAGS)),)
  85. DISP := sil
  86. Q := @
  87. SCAT := -@true
  88. else
  89. ifneq ($(V)$(VERBOSE),)
  90. DISP := ver
  91. Q :=
  92. SCAT := cat
  93. else
  94. DISP := pur
  95. Q := @
  96. SCAT := -@true
  97. endif
  98. endif
  99. banner := ---------------------------------
  100. pur_showclean = echo " "CLEAN $(notdir $(CURDIR))
  101. pur_showdiff = echo " "TEST_DIFF $(notdir $(CURDIR))/
  102. pur_showlink = echo " "TEST_LINK $(notdir $(CURDIR))/ $@
  103. pur_showtest = echo " "TEST_EXEC $(notdir $(CURDIR))/ $@
  104. sil_showclean =
  105. sil_showdiff = true
  106. sil_showlink = true
  107. sil_showtest = true
  108. ver_showclean =
  109. ver_showdiff = true echo
  110. ver_showlink = true echo
  111. ver_showtest = printf "\n$(banner)\nTEST $(notdir $(PWD))/ $@\n$(banner)\n"
  112. do_showclean = $($(DISP)_showclean)
  113. do_showdiff = $($(DISP)_showdiff)
  114. do_showlink = $($(DISP)_showlink)
  115. do_showtest = $($(DISP)_showtest)
  116. showclean = @$(do_showclean)
  117. showdiff = @$(do_showdiff)
  118. showlink = @$(do_showlink)
  119. showtest = @$(do_showtest)