Rules.mak 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. # Rules.make for uClibc
  2. #
  3. # This file contains rules which are shared between multiple Makefiles. All
  4. # normal configuration options live in the file named "Config". You probably
  5. # should not mess with this file unless you know what you are doing...
  6. #
  7. # Copyright (C) 2000 by Lineo, inc.
  8. # Copyright (C) 2000-2002 Erik Andersen <andersen@uclibc.org>
  9. #
  10. # This program is free software; you can redistribute it and/or modify it under
  11. # the terms of the GNU Library General Public License as published by the Free
  12. # Software Foundation; either version 2 of the License, or (at your option) any
  13. # later version.
  14. #
  15. # This program is distributed in the hope that it will be useful, but WITHOUT
  16. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  17. # FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
  18. # details.
  19. #
  20. # You should have received a copy of the GNU Library General Public License
  21. # along with this program; if not, write to the Free Software Foundation, Inc.,
  22. # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. # If you are running a cross compiler, you may want to set this
  24. # to something more interesting... Target architecture is determined
  25. # by asking this compiler what arch it compiles stuff for.
  26. CROSS=
  27. CC = $(CROSS)gcc-3.2
  28. AR = $(CROSS)ar
  29. LD = $(CROSS)ld
  30. NM = $(CROSS)nm
  31. STRIPTOOL = $(CROSS)strip
  32. #STRIPTOOL = /bin/true
  33. # Select the compiler needed to build binaries for your development system
  34. NATIVE_CC = gcc
  35. # Be sure to update include/features.h when changing this...
  36. MAJOR_VERSION:=0
  37. MINOR_VERSION:=9
  38. SUBLEVEL:=15
  39. VERSION:=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL)
  40. export MAJOR_VERSION MINOR_VERSION SUBLEVEL VERSION
  41. SHARED_FULLNAME:=libuClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
  42. SHARED_MAJORNAME:=libc.so.$(MAJOR_VERSION)
  43. UCLIBC_LDSO:=ld-uClibc.so.$(MAJOR_VERSION)
  44. LIBNAME:=libc.a
  45. LIBC:=$(TOPDIR)libc/$(LIBNAME)
  46. LIBGCC:=$(shell $(CC) $(LIBGCC_CFLAGS) -print-libgcc-file-name)
  47. # Pull in the user's uClibc configuration
  48. ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
  49. include-config := 1
  50. -include $(TOPDIR).config
  51. endif
  52. # A nifty macro to make testing gcc features easier
  53. check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
  54. then echo "$(1)"; else echo "$(2)"; fi)
  55. # check if we have nawk, otherwise user awk
  56. AWK:=$(shell if [ -x /usr/bin/nawk ]; then echo "/usr/bin/nawk"; \
  57. else echo "/usr/bin/awk"; fi)
  58. NATIVE_ARCH:= $(shell uname -m | sed \
  59. -e 's/i.86/i386/' \
  60. -e 's/sparc.*/sparc/' \
  61. -e 's/arm.*/arm/g' \
  62. -e 's/m68k.*/m68k/' \
  63. -e 's/ppc/powerpc/g' \
  64. -e 's/v850.*/v850/g' \
  65. -e 's/sh[234].*/sh/' \
  66. -e 's/mips.*/mips/' \
  67. )
  68. ifeq ($(strip $(TARGET_ARCH)),)
  69. TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
  70. -e 's/i.86/i386/' \
  71. -e 's/sparc.*/sparc/' \
  72. -e 's/arm.*/arm/g' \
  73. -e 's/m68k.*/m68k/' \
  74. -e 's/ppc/powerpc/g' \
  75. -e 's/v850.*/v850/g' \
  76. -e 's/sh[234]/sh/' \
  77. -e 's/mips.*/mips/' \
  78. -e 's/cris.*/cris/' \
  79. )
  80. endif
  81. # Ensure consistent filename sort order
  82. LC_COLLATE := C
  83. export LC_COLLATE
  84. ARFLAGS:=r
  85. # Some nice architecture specific optimizations
  86. ifndef OPTIMIZATION
  87. # use '-Os' optimization if available, else use -O2, allow Config to override
  88. OPTIMIZATION:=
  89. OPTIMIZATION+=$(call check_gcc,-Os,-O2)
  90. ifeq ($(strip $(TARGET_ARCH)),arm)
  91. OPTIMIZATION+=-fstrict-aliasing
  92. endif
  93. ifeq ($(strip $(TARGET_ARCH)),i386)
  94. OPTIMIZATION+=-march=i386
  95. OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,)
  96. OPTIMIZATION+=$(call check_gcc,-falign-functions=0 -falign-jumps=0 -falign-loops=0,\
  97. -malign-functions=0 -malign-jumps=0 -malign-loops=0)
  98. endif
  99. endif
  100. # Add a bunch of extra pedantic annoyingly strict checks
  101. WARNINGS+=-Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing
  102. CFLAGS:=$(WARNINGS) $(OPTIMIZATION) -fno-builtin -nostdinc $(CPUFLAGS) \
  103. -I$(TOPDIR)include -iwithprefix include -I. -D_LIBC $(ARCH_CFLAGS)
  104. NATIVE_CFLAGS:=-O2 -Wall
  105. ifeq ($(strip $(DODEBUG)),y)
  106. CFLAGS += -g
  107. LDFLAGS:= -shared --warn-common --warn-once -z combreloc
  108. STRIPTOOL:= true -Since_we_are_debugging
  109. else
  110. CFLAGS += -DNDEBUG #-fomit-frame-pointer
  111. LDFLAGS := -s -shared --warn-common --warn-once -z combreloc
  112. endif
  113. ifeq ($(strip $(HAVE_SHARED)),y)
  114. LIBRARY_CACHE:=#-DUSE_CACHE
  115. ifeq ($(strip $(BUILD_UCLIBC_LDSO)),y)
  116. LDSO:=$(TOPDIR)lib/$(UCLIBC_LDSO)
  117. DYNAMIC_LINKER:=$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO)
  118. BUILD_DYNAMIC_LINKER:=$(shell cd $(TOPDIR) && pwd)/lib/$(UCLIBC_LDSO)
  119. else
  120. LDSO:=$(SYSTEM_LDSO)
  121. DYNAMIC_LINKER:=/lib/$(notdir $(SYSTEM_LDSO))
  122. BUILD_DYNAMIC_LINKER:=/lib/$(notdir $(SYSTEM_LDSO))
  123. endif
  124. endif
  125. ifeq ($(strip $(DOPIC)),y)
  126. CFLAGS += -fPIC
  127. endif
  128. # TARGET_PREFIX is the directory under which which the uClibc runtime
  129. # environment will be installed and used on the target system. The
  130. # result will look something like the following:
  131. # TARGET_PREFIX/
  132. # lib/ <contains all runtime and static libs>
  133. # usr/lib/ <this directory is searched for runtime libs>
  134. # etc/ <weher the shared library cache and configuration
  135. # information go if you enabled LIBRARY_CACHE above>
  136. # Very few people will need to change this value from the default...
  137. TARGET_PREFIX = /