Rules.mak 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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=
  39. CC= $(CROSS)gcc
  40. STRIPTOOL=strip
  41. LDD=../$(TESTDIR)ldso/util/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. OPTIMIZATION+=$(call check_gcc,-Os,-O2)
  54. # Override optimization settings when debugging
  55. ifeq ($(DODEBUG),true)
  56. OPTIMIZATION=-O0
  57. endif
  58. XWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes
  59. XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS)))
  60. CFLAGS=$(XWARNINGS) $(OPTIMIZATION) $(XARCH_CFLAGS)
  61. GLIBC_CFLAGS+=$(XWARNINGS) $(OPTIMIZATION)
  62. LDFLAGS=
  63. ifeq ($(DODEBUG),true)
  64. CFLAGS+=-g
  65. GLIBC_CFLAGS+=-g
  66. LDFLAGS += -g -Wl,-warn-common
  67. GLIBC_LDFLAGS =-g -Wl,-warn-common
  68. STRIPTOOL =true -Since_we_are_debugging
  69. else
  70. LDFLAGS +=-s -Wl,-warn-common
  71. GLIBC_LDFLAGS =-s -Wl,-warn-common
  72. STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
  73. endif
  74. ifneq ($(DODYNAMIC),true)
  75. LDFLAGS +=-static
  76. GLIBC_LDFLAGS +=-static
  77. endif