Rules.mak 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # Rules.make for uClibc test apps.
  2. #
  3. # Copyright (C) 2001 by Lineo, inc.
  4. #
  5. #
  6. #Note: This does not read the top level Rules.mak file
  7. #
  8. -include $(TESTDIR)../.config
  9. include $(TESTDIR)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=../$(TESTDIR)extra/gcc-uClibc/$(TARGET_ARCH)-uclibc-
  39. CC= $(CROSS)gcc
  40. STRIPTOOL=strip
  41. LDD=../$(TESTDIR)ldso/util/ldd
  42. # Select the compiler needed to build binaries for your development system
  43. HOSTCC=gcc
  44. HOSTCFLAGS=-O2 -Wall
  45. #--------------------------------------------------------
  46. # Check if 'ls -sh' works or not
  47. LSFLAGS = -l
  48. # A nifty macro to make testing gcc features easier
  49. check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
  50. then echo "$(1)"; else echo "$(2)"; fi)
  51. # use '-Os' optimization if available, else use -O2, allow Config to override
  52. OPTIMIZATION+=$(call check_gcc,-Os,-O2)
  53. # Override optimization settings when debugging
  54. ifeq ($(DODEBUG),true)
  55. OPTIMIZATION=-O0
  56. endif
  57. XWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes
  58. XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS)))
  59. CFLAGS=--uclibc-use-build-dir $(XWARNINGS) $(OPTIMIZATION) $(XARCH_CFLAGS)
  60. GLIBC_CFLAGS+=$(XWARNINGS) $(OPTIMIZATION)
  61. LDFLAGS=--uclibc-use-build-dir
  62. ifeq ($(DODEBUG),true)
  63. CFLAGS+=-g
  64. GLIBC_CFLAGS+=-g
  65. LDFLAGS += -g -Wl,-warn-common
  66. GLIBC_LDFLAGS =-g -Wl,-warn-common
  67. STRIPTOOL =true -Since_we_are_debugging
  68. else
  69. LDFLAGS +=-s -Wl,-warn-common
  70. GLIBC_LDFLAGS =-s -Wl,-warn-common
  71. STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
  72. endif
  73. ifneq ($(DODYNAMIC),true)
  74. LDFLAGS +=-static
  75. GLIBC_LDFLAGS +=-static
  76. endif