Rules.mak 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # Rules.mak for uClibc test subdirs
  2. #
  3. # Copyright (C) 2001 by Lineo, inc.
  4. #
  5. # Note: This does not read the top level Rules.mak file
  6. #
  7. TOPDIR = ../../
  8. TESTDIR=$(TOPDIR)test/
  9. -include $(TOPDIR).config
  10. #--------------------------------------------------------
  11. # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
  12. LC_ALL:= C
  13. export LC_ALL
  14. ifeq ($(strip $(TARGET_ARCH)),)
  15. TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
  16. -e 's/i.86/i386/' \
  17. -e 's/sparc.*/sparc/' \
  18. -e 's/arm.*/arm/g' \
  19. -e 's/m68k.*/m68k/' \
  20. -e 's/ppc/powerpc/g' \
  21. -e 's/v850.*/v850/g' \
  22. -e 's/sh[234]/sh/' \
  23. -e 's/mips-.*/mips/' \
  24. -e 's/mipsel-.*/mipsel/' \
  25. -e 's/cris.*/cris/' \
  26. )
  27. endif
  28. export TARGET_ARCH
  29. #--------------------------------------------------------
  30. # If you are running a cross compiler, you will want to set 'CROSS'
  31. # to something more interesting... Target architecture is determined
  32. # by asking the CC compiler what arch it compiles things for, so unless
  33. # your compiler is broken, you should not need to specify TARGET_ARCH
  34. #
  35. # Most people will set this stuff on the command line, i.e.
  36. # make CROSS=mipsel-linux-
  37. # will build uClibc for 'mipsel'.
  38. CROSS = $(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
  39. CC = $(CROSS)gcc
  40. STRIPTOOL = strip
  41. RM = rm -f
  42. ifeq ($(LDSO_LDD_SUPPORT),y)
  43. LDD = $(TOPDIR)utils/ldd
  44. else
  45. LDD = @true
  46. endif
  47. # Select the compiler needed to build binaries for your development system
  48. HOSTCC = gcc
  49. HOSTCFLAGS = -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. CFLAGS = $(XWARNINGS) $(OPTIMIZATION) $(XARCH_CFLAGS)
  66. GLIBC_CFLAGS += $(XWARNINGS) $(OPTIMIZATION)
  67. LDFLAGS =
  68. ifeq ($(DODEBUG),y)
  69. CFLAGS += -g
  70. GLIBC_CFLAGS += -g
  71. LDFLAGS += -g -Wl,-warn-common
  72. GLIBC_LDFLAGS = -g -Wl,-warn-common
  73. STRIPTOOL = true -Since_we_are_debugging
  74. else
  75. LDFLAGS += -s -Wl,-warn-common
  76. GLIBC_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. GLIBC_LDFLAGS += -static
  82. endif