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