Rules.mak 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. ifndef UCLIBC_LDSO
  11. UCLIBC_LDSO := ld-uClibc.so.0
  12. endif
  13. #--------------------------------------------------------
  14. # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
  15. LC_ALL:= C
  16. export LC_ALL
  17. ifeq ($(strip $(TARGET_ARCH)),)
  18. TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
  19. -e 's/i.86/i386/' \
  20. -e 's/sparc.*/sparc/' \
  21. -e 's/arm.*/arm/g' \
  22. -e 's/m68k.*/m68k/' \
  23. -e 's/ppc/powerpc/g' \
  24. -e 's/v850.*/v850/g' \
  25. -e 's/sh[234]/sh/' \
  26. -e 's/mips-.*/mips/' \
  27. -e 's/mipsel-.*/mipsel/' \
  28. -e 's/cris.*/cris/' \
  29. )
  30. endif
  31. export TARGET_ARCH
  32. #--------------------------------------------------------
  33. # If you are running a cross compiler, you will want to set 'CROSS'
  34. # to something more interesting... Target architecture is determined
  35. # by asking the CC compiler what arch it compiles things for, so unless
  36. # your compiler is broken, you should not need to specify TARGET_ARCH
  37. #
  38. # Most people will set this stuff on the command line, i.e.
  39. # make CROSS=mipsel-linux-
  40. # will build uClibc for 'mipsel'.
  41. CROSS = $(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
  42. CC = $(CROSS)gcc
  43. STRIPTOOL = strip
  44. RM = rm -f
  45. ifeq ($(LDSO_LDD_SUPPORT),y)
  46. LDD = $(TOPDIR)utils/ldd
  47. else
  48. LDD = @true
  49. endif
  50. # Select the compiler needed to build binaries for your development system
  51. HOSTCC = gcc
  52. HOSTCFLAGS = -O2 -Wall
  53. #--------------------------------------------------------
  54. # Check if 'ls -sh' works or not
  55. LSFLAGS = -l
  56. # A nifty macro to make testing gcc features easier
  57. check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
  58. then echo "$(1)"; else echo "$(2)"; fi)
  59. # use '-Os' optimization if available, else use -O2, allow Config to override
  60. # Override optimization settings when debugging
  61. ifeq ($(DODEBUG),y)
  62. OPTIMIZATION = -O0
  63. else
  64. OPTIMIZATION += $(call check_gcc,-Os,-O2)
  65. endif
  66. XWARNINGS = $(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes
  67. XARCH_CFLAGS = $(subst ",, $(strip $(ARCH_CFLAGS)))
  68. CFLAGS = $(XWARNINGS) $(OPTIMIZATION) $(XARCH_CFLAGS)
  69. GLIBC_CFLAGS += $(XWARNINGS) $(OPTIMIZATION)
  70. LDFLAGS =
  71. ifeq ($(DODEBUG),y)
  72. CFLAGS += -g
  73. GLIBC_CFLAGS += -g
  74. LDFLAGS += -g -Wl,-warn-common
  75. GLIBC_LDFLAGS = -g -Wl,-warn-common
  76. STRIPTOOL = true -Since_we_are_debugging
  77. else
  78. LDFLAGS += -s -Wl,-warn-common
  79. GLIBC_LDFLAGS = -s -Wl,-warn-common
  80. STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
  81. endif
  82. ifneq ($(strip $(HAVE_SHARED)),y)
  83. LDFLAGS += -static
  84. GLIBC_LDFLAGS += -static
  85. else
  86. LDFLAGS += -Wl,-dynamic-linker,$(TOPDIR)lib/$(UCLIBC_LDSO)
  87. endif