Rules.mak 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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
  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. NATIVE_CFLAGS:=-O2 -Wall
  36. # Be sure to update include/features.h when changing this...
  37. MAJOR_VERSION:=0
  38. MINOR_VERSION:=9
  39. SUBLEVEL:=15
  40. VERSION:=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL)
  41. # Ensure consistent filename sort order
  42. LC_COLLATE:= C
  43. export MAJOR_VERSION MINOR_VERSION SUBLEVEL VERSION LC_COLLATE
  44. SHARED_FULLNAME:=libuClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
  45. SHARED_MAJORNAME:=libc.so.$(MAJOR_VERSION)
  46. UCLIBC_LDSO:=ld-uClibc.so.$(MAJOR_VERSION)
  47. LIBNAME:=libc.a
  48. LIBC:=$(TOPDIR)libc/$(LIBNAME)
  49. LIBGCC:=$(shell $(CC) $(LIBGCC_CFLAGS) -print-libgcc-file-name)
  50. LIBGCC_DIR:=$(dir $(LIBGCC))
  51. # Pull in the user's uClibc configuration
  52. ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
  53. include_config := 1
  54. -include $(TOPDIR).config
  55. endif
  56. # A nifty macro to make testing gcc features easier
  57. check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
  58. then echo "$(1)"; else echo "$(2)"; fi)
  59. # check if we have nawk, otherwise user awk
  60. AWK:=$(shell if [ -x /usr/bin/nawk ]; then echo "/usr/bin/nawk"; \
  61. else echo "/usr/bin/awk"; fi)
  62. NATIVE_ARCH:= $(shell uname -m | sed \
  63. -e 's/i.86/i386/' \
  64. -e 's/sparc.*/sparc/' \
  65. -e 's/arm.*/arm/g' \
  66. -e 's/m68k.*/m68k/' \
  67. -e 's/ppc/powerpc/g' \
  68. -e 's/v850.*/v850/g' \
  69. -e 's/sh[234].*/sh/' \
  70. -e 's/mips.*/mips/' \
  71. )
  72. ifeq ($(strip $(TARGET_ARCH)),)
  73. TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
  74. -e 's/i.86/i386/' \
  75. -e 's/sparc.*/sparc/' \
  76. -e 's/arm.*/arm/g' \
  77. -e 's/m68k.*/m68k/' \
  78. -e 's/ppc/powerpc/g' \
  79. -e 's/v850.*/v850/g' \
  80. -e 's/sh[234]/sh/' \
  81. -e 's/mips.*/mips/' \
  82. -e 's/cris.*/cris/' \
  83. )
  84. endif
  85. export TARGET_ARCH
  86. ARFLAGS:=r
  87. # use '-Os' optimization if available, else use -O2, allow Config to override
  88. OPTIMIZATION:=
  89. OPTIMIZATION+=$(call check_gcc,-Os,-O2)
  90. # Some nice CPU specific optimizations
  91. ifeq ($(strip $(TARGET_ARCH)),i386)
  92. OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,)
  93. OPTIMIZATION+=$(call check_gcc,-falign-jumps=0 -falign-loops=0,-malign-jumps=0 -malign-loops=0)
  94. CPU_CFLAGS-$(CONFIG_386):="-march=i386"
  95. CPU_CFLAGS-$(CONFIG_486):="-march=i486"
  96. CPU_CFLAGS-$(CONFIG_586):="-march=i586"
  97. CPU_CFLAGS-$(CONFIG_586MMX):="$(call check_gcc,-march=pentium-mmx,-march=i586)"
  98. CPU_CFLAGS-$(CONFIG_686):="-march=i686"
  99. CPU_CFLAGS-$(CONFIG_PENTIUMIII):="$(call check_gcc,-march=pentium3,-march=i686)"
  100. CPU_CFLAGS-$(CONFIG_PENTIUM4):="$(call check_gcc,-march=pentium4,-march=i686)"
  101. CPU_CFLAGS-$(CONFIG_K6):="$(call check_gcc,-march=k6,-march=i586)"
  102. CPU_CFLAGS-$(CONFIG_K7):="$(call check_gcc,-march=athlon,-malign-functions=4 -march=i686)"
  103. CPU_CFLAGS-$(CONFIG_CRUSOE):="-march=i686 -malign-functions=0 -malign-jumps=0 -malign-loops=0"
  104. CPU_CFLAGS-$(CONFIG_WINCHIPC6):="$(call check_gcc,-march=winchip-c6,-march=i586)"
  105. CPU_CFLAGS-$(CONFIG_WINCHIP2):="$(call check_gcc,-march=winchip2,-march=i586)"
  106. CPU_CFLAGS-$(CONFIG_CYRIXIII):="$(call check_gcc,-march=c3,-march=i586)"
  107. endif
  108. ifeq ($(strip $(TARGET_ARCH)),arm)
  109. OPTIMIZATION+=-fstrict-aliasing
  110. CPU_CFLAGS-$(CONFIG_GENERIC_ARM):=
  111. CPU_CFLAGS-$(CONFIG_ARM7TDMI):="-march=arm7tdmi"
  112. CPU_CFLAGS-$(CONFIG_STRONGARM):="-march=strongarm"
  113. CPU_CFLAGS-$(CONFIG_XSCALE):="$(call check_gcc,-march=xscale,-march=strongarm)"
  114. endif
  115. ifeq ($(strip $(TARGET_ARCH)),sh)
  116. OPTIMIZATION+=-fstrict-aliasing
  117. CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN):="-ml"
  118. CPU_CFLAGS-$(ARCH_BIG_ENDIAN):="-mb"
  119. CPU_CFLAGS-$(CONFIG_SH2)+="-m2"
  120. CPU_CFLAGS-$(CONFIG_SH3)+="-m3"
  121. CPU_CFLAGS-$(CONFIG_SH4)+="-m4"
  122. CPU_CFLAGS-$(CONFIG_SH5)+="-m5"
  123. endif
  124. # Add a bunch of extra pedantic annoyingly strict checks
  125. WARNINGS+=-Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing
  126. # Some nice CFLAGS to work with
  127. CFLAGS:=$(WARNINGS) $(OPTIMIZATION) -fno-builtin -nostdinc $(CPUFLAGS) \
  128. -D_LIBC $(CPU_CFLAGS-y) $(ARCH_CFLAGS) -I$(TOPDIR)include -I.
  129. # Sigh, some stupid versions of gcc can't seem to cope with '-iwithprefix include'
  130. #CFLAGS+=-iwithprefix include
  131. CFLAGS+=$(shell $(CC) -print-search-dirs | sed -ne "s/install: *\(.*\)/-I\1include/gp")
  132. ifeq ($(strip $(DODEBUG)),y)
  133. CFLAGS += -g
  134. LDFLAGS:= -shared --warn-common --warn-once -z combreloc
  135. STRIPTOOL:= true -Since_we_are_debugging
  136. else
  137. CFLAGS += -DNDEBUG #-fomit-frame-pointer
  138. LDFLAGS := -s -shared --warn-common --warn-once -z combreloc
  139. endif
  140. ifeq ($(strip $(HAVE_SHARED)),y)
  141. LIBRARY_CACHE:=#-DUSE_CACHE
  142. ifeq ($(strip $(BUILD_UCLIBC_LDSO)),y)
  143. LDSO:=$(TOPDIR)lib/$(UCLIBC_LDSO)
  144. DYNAMIC_LINKER:=$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO)
  145. BUILD_DYNAMIC_LINKER:=$(shell cd $(TOPDIR) && pwd)/lib/$(UCLIBC_LDSO)
  146. else
  147. LDSO:=$(SYSTEM_LDSO)
  148. DYNAMIC_LINKER:=/lib/$(notdir $(SYSTEM_LDSO))
  149. BUILD_DYNAMIC_LINKER:=/lib/$(notdir $(SYSTEM_LDSO))
  150. endif
  151. endif
  152. ifeq ($(strip $(DOPIC)),y)
  153. CFLAGS += -fPIC
  154. endif
  155. ifeq ($(strip $(HAS_FPU)),n)
  156. CFLAGS += -msoft-float
  157. endif
  158. # TARGET_PREFIX is the directory under which which the uClibc runtime
  159. # environment will be installed and used on the target system. The
  160. # result will look something like the following:
  161. # TARGET_PREFIX/
  162. # lib/ <contains all runtime and static libs>
  163. # usr/lib/ <this directory is searched for runtime libs>
  164. # etc/ <weher the shared library cache and configuration
  165. # information go if you enabled LIBRARY_CACHE above>
  166. # Very few people will need to change this value from the default...
  167. TARGET_PREFIX = /