Rules.mak 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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),y)
  55. OPTIMIZATION=-O0
  56. endif
  57. XWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing
  58. XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS)))
  59. CFLAGS=$(XWARNINGS) $(OPTIMIZATION) $(XARCH_CFLAGS)
  60. GLIBC_CFLAGS+=$(XWARNINGS) $(OPTIMIZATION)
  61. ifeq ($(DODEBUG),true)
  62. CFLAGS+=-g
  63. GLIBC_CFLAGS+=-g
  64. LDFLAGS =-Wl,-warn-common
  65. GLIBC_LDFLAGS =-Wl,-warn-common
  66. STRIPTOOL =true -Since_we_are_debugging
  67. else
  68. LDFLAGS =-s -Wl,-warn-common
  69. GLIBC_LDFLAGS =-s -Wl,-warn-common
  70. STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
  71. endif
  72. ifneq ($(DODYNAMIC),true)
  73. LDFLAGS +=-static
  74. GLIBC_LDFLAGS +=-static
  75. endif
  76. CFLAGS+=--uclibc-use-build-dir
  77. LDFLAGS+=--uclibc-use-build-dir