Rules.mak 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. # 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. # use '-Os' optimization if available, else use -O2, allow Config to override
  86. OPTIMIZATION:=
  87. OPTIMIZATION+=$(call check_gcc,-Os,-O2)
  88. # Some nice CPU specific optimizations
  89. ifeq ($(strip $(TARGET_ARCH)),i386)
  90. OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,)
  91. OPTIMIZATION+=$(call check_gcc,-falign-jumps=0 -falign-loops=0,-malign-jumps=0 -malign-loops=0)
  92. CPU_CFLAGS-$(CONFIG_386):="-march=i386"
  93. CPU_CFLAGS-$(CONFIG_486):="-march=i486"
  94. CPU_CFLAGS-$(CONFIG_586):="-march=i586"
  95. CPU_CFLAGS-$(CONFIG_586MMX):="$(call check_gcc,-march=pentium-mmx,-march=i586)"
  96. CPU_CFLAGS-$(CONFIG_686):="-march=i686"
  97. CPU_CFLAGS-$(CONFIG_PENTIUMIII):="$(call check_gcc,-march=pentium3,-march=i686)"
  98. CPU_CFLAGS-$(CONFIG_PENTIUM4):="$(call check_gcc,-march=pentium4,-march=i686)"
  99. CPU_CFLAGS-$(CONFIG_K6):="$(call check_gcc,-march=k6,-march=i586)"
  100. CPU_CFLAGS-$(CONFIG_K7):="$(call check_gcc,-march=athlon,-malign-functions=4 -march=i686)"
  101. CPU_CFLAGS-$(CONFIG_CRUSOE):="-march=i686 -malign-functions=0 -malign-jumps=0 -malign-loops=0"
  102. CPU_CFLAGS-$(CONFIG_WINCHIPC6):="$(call check_gcc,-march=winchip-c6,-march=i586)"
  103. CPU_CFLAGS-$(CONFIG_WINCHIP2):="$(call check_gcc,-march=winchip2,-march=i586)"
  104. CPU_CFLAGS-$(CONFIG_CYRIXIII):="$(call check_gcc,-march=c3,-march=i586)"
  105. endif
  106. ifeq ($(strip $(TARGET_ARCH)),arm)
  107. OPTIMIZATION+=-fstrict-aliasing
  108. CPU_CFLAGS-$(CONFIG_GENERIC_ARM):=
  109. CPU_CFLAGS-$(CONFIG_ARM7TDMI):="-march=arm7tdmi"
  110. CPU_CFLAGS-$(CONFIG_STRONGARM):="-march=strongarm"
  111. CPU_CFLAGS-$(CONFIG_XSCALE):="$(call check_gcc,-march=xscale,-march=strongarm)"
  112. endif
  113. ifeq ($(strip $(TARGET_ARCH)),sh)
  114. OPTIMIZATION+=-fstrict-aliasing
  115. CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN):="-ml"
  116. CPU_CFLAGS-$(ARCH_BIG_ENDIAN):="-mb"
  117. CPU_CFLAGS-$(CONFIG_SH2)+="-m2"
  118. CPU_CFLAGS-$(CONFIG_SH3)+="-m3"
  119. CPU_CFLAGS-$(CONFIG_SH4)+="-m4"
  120. CPU_CFLAGS-$(CONFIG_SH5)+="-m5"
  121. endif
  122. # Add a bunch of extra pedantic annoyingly strict checks
  123. WARNINGS+=-Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing
  124. CFLAGS:=$(WARNINGS) $(OPTIMIZATION) -fno-builtin -nostdinc $(CPUFLAGS) \
  125. -I$(TOPDIR)include -iwithprefix include -I. -D_LIBC $(CPU_CFLAGS-y) $(ARCH_CFLAGS)
  126. NATIVE_CFLAGS:=-O2 -Wall
  127. ifeq ($(strip $(DODEBUG)),y)
  128. CFLAGS += -g
  129. LDFLAGS:= -shared --warn-common --warn-once -z combreloc
  130. STRIPTOOL:= true -Since_we_are_debugging
  131. else
  132. CFLAGS += -DNDEBUG #-fomit-frame-pointer
  133. LDFLAGS := -s -shared --warn-common --warn-once -z combreloc
  134. endif
  135. ifeq ($(strip $(HAVE_SHARED)),y)
  136. LIBRARY_CACHE:=#-DUSE_CACHE
  137. ifeq ($(strip $(BUILD_UCLIBC_LDSO)),y)
  138. LDSO:=$(TOPDIR)lib/$(UCLIBC_LDSO)
  139. DYNAMIC_LINKER:=$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO)
  140. BUILD_DYNAMIC_LINKER:=$(shell cd $(TOPDIR) && pwd)/lib/$(UCLIBC_LDSO)
  141. else
  142. LDSO:=$(SYSTEM_LDSO)
  143. DYNAMIC_LINKER:=/lib/$(notdir $(SYSTEM_LDSO))
  144. BUILD_DYNAMIC_LINKER:=/lib/$(notdir $(SYSTEM_LDSO))
  145. endif
  146. endif
  147. ifeq ($(strip $(DOPIC)),y)
  148. CFLAGS += -fPIC
  149. endif
  150. # TARGET_PREFIX is the directory under which which the uClibc runtime
  151. # environment will be installed and used on the target system. The
  152. # result will look something like the following:
  153. # TARGET_PREFIX/
  154. # lib/ <contains all runtime and static libs>
  155. # usr/lib/ <this directory is searched for runtime libs>
  156. # etc/ <weher the shared library cache and configuration
  157. # information go if you enabled LIBRARY_CACHE above>
  158. # Very few people will need to change this value from the default...
  159. TARGET_PREFIX = /