Rules.mak 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 =
  39. CC = $(CROSS)gcc
  40. STRIPTOOL = strip
  41. LDD = $(TOPDIR)utils/ldd
  42. RM = rm -f
  43. # Select the compiler needed to build binaries for your development system
  44. HOSTCC = gcc
  45. HOSTCFLAGS = -O2 -Wall
  46. #--------------------------------------------------------
  47. # Check if 'ls -sh' works or not
  48. LSFLAGS = -l
  49. # A nifty macro to make testing gcc features easier
  50. check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
  51. then echo "$(1)"; else echo "$(2)"; fi)
  52. # use '-Os' optimization if available, else use -O2, allow Config to override
  53. # Override optimization settings when debugging
  54. ifeq ($(DODEBUG),y)
  55. OPTIMIZATION = -O0
  56. else
  57. OPTIMIZATION += $(call check_gcc,-Os,-O2)
  58. endif
  59. XWARNINGS = $(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes
  60. XARCH_CFLAGS = $(subst ",, $(strip $(ARCH_CFLAGS)))
  61. CFLAGS = $(XWARNINGS) $(OPTIMIZATION) $(XARCH_CFLAGS)
  62. GLIBC_CFLAGS += $(XWARNINGS) $(OPTIMIZATION)
  63. LDFLAGS =
  64. ifeq ($(DODEBUG),y)
  65. CFLAGS += -g
  66. GLIBC_CFLAGS += -g
  67. LDFLAGS += -g -Wl,-warn-common
  68. GLIBC_LDFLAGS = -g -Wl,-warn-common
  69. STRIPTOOL = true -Since_we_are_debugging
  70. else
  71. LDFLAGS += -s -Wl,-warn-common
  72. GLIBC_LDFLAGS = -s -Wl,-warn-common
  73. STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
  74. endif
  75. ifneq ($(strip $(HAVE_SHARED)),y)
  76. LDFLAGS += -static
  77. GLIBC_LDFLAGS += -static
  78. endif