Rules.mak 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. ifndef TEST_INSTALLED_UCLIBC
  14. ifdef UCLIBC_LDSO
  15. ifeq (,$(findstring /,$(UCLIBC_LDSO)))
  16. UCLIBC_LDSO := $(top_builddir)lib/$(UCLIBC_LDSO)
  17. endif
  18. else
  19. UCLIBC_LDSO := $(firstword $(wildcard $(top_builddir)lib/ld*))
  20. endif
  21. endif
  22. #--------------------------------------------------------
  23. # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
  24. LC_ALL:= C
  25. export LC_ALL
  26. ifeq ($(strip $(TARGET_ARCH)),)
  27. TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
  28. -e 's/i.86/i386/' \
  29. -e 's/sparc.*/sparc/' \
  30. -e 's/arm.*/arm/g' \
  31. -e 's/m68k.*/m68k/' \
  32. -e 's/ppc/powerpc/g' \
  33. -e 's/v850.*/v850/g' \
  34. -e 's/sh[234]/sh/' \
  35. -e 's/mips.*/mips/' \
  36. -e 's/cris.*/cris/' \
  37. -e 's/xtensa.*/xtensa/' \
  38. )
  39. endif
  40. export TARGET_ARCH
  41. #--------------------------------------------------------
  42. # If you are running a cross compiler, you will want to set 'CROSS'
  43. # to something more interesting... Target architecture is determined
  44. # by asking the CC compiler what arch it compiles things for, so unless
  45. # your compiler is broken, you should not need to specify TARGET_ARCH
  46. #
  47. # Most people will set this stuff on the command line, i.e.
  48. # make CROSS=mipsel-linux-
  49. # will build uClibc for 'mipsel'.
  50. CROSS = $(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
  51. CC = $(CROSS)gcc
  52. RM = rm -f
  53. RM_R = $(RM) -r
  54. # Select the compiler needed to build binaries for your development system
  55. HOSTCC = gcc
  56. #--------------------------------------------------------
  57. # A nifty macro to make testing gcc features easier
  58. check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
  59. then echo "$(1)"; else echo "$(2)"; fi)
  60. # use '-Os' optimization if available, else use -O2, allow Config to override
  61. # Override optimization settings when debugging
  62. ifeq ($(DODEBUG),y)
  63. OPTIMIZATION = -O0
  64. else
  65. OPTIMIZATION += $(call check_gcc,-Os,-O2)
  66. endif
  67. XWARNINGS := $(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes
  68. XARCH_CFLAGS := $(subst ",, $(strip $(ARCH_CFLAGS))) $(CPU_CFLAGS)
  69. XCOMMON_CFLAGS := -D_GNU_SOURCE -I$(top_builddir)test
  70. CFLAGS := $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS) $(XARCH_CFLAGS) -nostdinc -I$(top_builddir)$(LOCAL_INSTALL_PATH)/usr/include
  71. CC_IPREFIX := $(shell $(CC) --print-file-name=include)
  72. CC_INC := -I$(dir $(CC_IPREFIX))include-fixed -I$(CC_IPREFIX)
  73. CFLAGS += $(CC_INC)
  74. ifneq ($(KERNEL_HEADERS),)
  75. ifeq ($(patsubst /%,/,$(KERNEL_HEADERS)),/)
  76. # Absolute path in KERNEL_HEADERS
  77. CFLAGS += -I$(KERNEL_HEADERS)
  78. else
  79. # Relative path in KERNEL_HEADERS
  80. CFLAGS += -I$(top_builddir)$(KERNEL_HEADERS)
  81. endif
  82. endif
  83. # Can't add $(OPTIMIZATION) here, it may be target-specific.
  84. # Just adding -Os for now.
  85. HOST_CFLAGS += $(XWARNINGS) -Os $(XCOMMON_CFLAGS)
  86. LDFLAGS := $(CPU_LDFLAGS)
  87. ifeq ($(DODEBUG),y)
  88. CFLAGS += -g
  89. HOST_CFLAGS += -g
  90. LDFLAGS += -g
  91. HOST_LDFLAGS += -g
  92. else
  93. LDFLAGS += -s
  94. HOST_LDFLAGS += -s
  95. endif
  96. ifeq ($(strip $(UCLIBC_STATIC)),y)
  97. STATIC_LDFLAGS := -static
  98. HOST_LDFLAGS += -static
  99. endif
  100. LDFLAGS += -B$(top_builddir)lib -Wl,-rpath,$(top_builddir)lib -Wl,-rpath-link,$(top_builddir)lib
  101. UCLIBC_LDSO_ABSPATH=$(shell pwd)
  102. ifdef TEST_INSTALLED_UCLIBC
  103. LDFLAGS += -Wl,-rpath,./
  104. UCLIBC_LDSO_ABSPATH=$(SHARED_LIB_LOADER_PREFIX)
  105. endif
  106. ifeq ($(findstring -static,$(LDFLAGS)),)
  107. LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_LDSO_ABSPATH)/$(UCLIBC_LDSO)
  108. endif
  109. ifeq ($(LDSO_GNU_HASH_SUPPORT),y)
  110. # Check for binutils support is done on root Rules.mak
  111. LDFLAGS += -Wl,${LDFLAGS_GNUHASH}
  112. endif
  113. # Filter output
  114. MAKEFLAGS += --no-print-directory
  115. ifneq ($(findstring s,$(MAKEFLAGS)),)
  116. DISP := sil
  117. Q := @
  118. SCAT := -@true
  119. else
  120. ifneq ($(V)$(VERBOSE),)
  121. DISP := ver
  122. Q :=
  123. SCAT := cat
  124. else
  125. DISP := pur
  126. Q := @
  127. SCAT := -@true
  128. endif
  129. endif
  130. banner := ---------------------------------
  131. pur_showclean = echo " "CLEAN $(notdir $(CURDIR))
  132. pur_showdiff = echo " "TEST_DIFF $(notdir $(CURDIR))/
  133. pur_showlink = echo " "TEST_LINK $(notdir $(CURDIR))/ $@
  134. pur_showtest = echo " "TEST_EXEC $(notdir $(CURDIR))/ $(patsubst %.exe,%,$@)
  135. sil_showclean =
  136. sil_showdiff = true
  137. sil_showlink = true
  138. sil_showtest = true
  139. ver_showclean =
  140. ver_showdiff = true echo
  141. ver_showlink = true echo
  142. ver_showtest = printf "\n$(banner)\nTEST $(notdir $(PWD))/ $(patsubst %.exe,%,$@)\n$(banner)\n"
  143. do_showclean = $($(DISP)_showclean)
  144. do_showdiff = $($(DISP)_showdiff)
  145. do_showlink = $($(DISP)_showlink)
  146. do_showtest = $($(DISP)_showtest)
  147. showclean = @$(do_showclean)
  148. showdiff = @$(do_showdiff)
  149. showlink = @$(do_showlink)
  150. showtest = @$(do_showtest)