Rules.mak 3.0 KB

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