1 # Rules.make for uClibc
3 # Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org>
5 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8 # check for proper make version
9 ifneq ($(findstring x3.7
,x
$(MAKE_VERSION
)),)
10 $(error Your make is too old
$(MAKE_VERSION
). Go
get at least
3.80)
13 #-----------------------------------------------------------
14 # This file contains rules which are shared between multiple
15 # Makefiles. All normal configuration options live in the
16 # file named ".config". Don't mess with this file unless
17 # you know what you are doing.
20 #-----------------------------------------------------------
21 # If you are running a cross compiler, you will want to set
22 # 'CROSS' to something more interesting ... Target
23 # architecture is determined by asking the CC compiler what
24 # arch it compiles things for, so unless your compiler is
25 # broken, you should not need to specify TARGET_ARCH.
27 # Most people will set this stuff on the command line, i.e.
28 # make CROSS=arm-linux-
29 # will build uClibc for 'arm'.
38 STRIPTOOL
= $(CROSS
)strip
47 STRIP_FLAGS ?
= -x
-R .note
-R .comment
49 UNIFDEF
:= $(top_builddir
)extra
/scripts
/unifdef
-UUCLIBC_INTERNAL
51 # Select the compiler needed to build binaries for your development system
53 BUILD_CFLAGS
= -O2
-Wall
54 export ARCH
:= $(shell uname
-m |
$(SED
) -e s
/i
.86/i386
/ \
55 -e s
/sun.
*/sparc
/ -e s
/sparc.
*/sparc
/ \
56 -e s
/arm.
*/arm
/ -e s
/sa110
/arm
/ \
58 -e s
/s390x
/s390
/ -e s
/parisc.
*/hppa
/ \
59 -e s
/ppc.
*/powerpc
/ -e s
/mips.
*/mips
/ \
60 -e s
/xtensa.
*/xtensa
/ )
63 #---------------------------------------------------------
64 # Nothing beyond this point should ever be touched by mere
65 # mortals. Unless you hang out with the gods, you should
66 # probably leave all this stuff alone.
68 # Pull in the user's uClibc configuration
69 ifeq ($(filter $(noconfig_targets
),$(MAKECMDGOALS
)),)
70 -include $(top_builddir
).config
73 # Make certain these contain a final "/", but no "//"s.
74 TARGET_ARCH
:=$(shell grep
-s
'^TARGET_ARCH' $(top_builddir
)/.config |
$(SED
) -e
's/^TARGET_ARCH=//' -e
's/"//g')
75 TARGET_ARCH
:=$(strip $(subst ",, $(strip $(TARGET_ARCH))))
76 TARGET_SUBARCH:=$(shell grep -s '^TARGET_SUBARCH' $(top_builddir)/.config | $(SED) -e 's/^TARGET_SUBARCH=//' -e 's/"//g
')
77 TARGET_SUBARCH:=$(strip $(subst ",, $(strip $(TARGET_SUBARCH))))
78 RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(RUNTIME_PREFIX))))))
79 DEVEL_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(DEVEL_PREFIX))))))
80 KERNEL_HEADERS:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(KERNEL_HEADERS))))))
81 export RUNTIME_PREFIX DEVEL_PREFIX KERNEL_HEADERS
84 # Now config hard core
89 VERSION := $(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL)
90 ifneq ($(EXTRAVERSION),)
91 VERSION := $(VERSION)$(EXTRAVERSION)
93 # Ensure consistent sort order, 'gcc
-print-search-dirs
' behavior, etc.
95 export MAJOR_VERSION MINOR_VERSION SUBLEVEL VERSION LC_ALL
98 SHARED_MAJORNAME := $(LIBC).so.$(MAJOR_VERSION)
99 ifneq ($(findstring $(TARGET_ARCH) , hppa64 ia64 mips64 powerpc64 s390x sparc64 x86_64 ),)
100 UCLIBC_LDSO_NAME := ld64-uClibc
101 ARCH_NATIVE_BIT := 64
103 UCLIBC_LDSO_NAME := ld-uClibc
104 ARCH_NATIVE_BIT := 32
106 UCLIBC_LDSO := $(UCLIBC_LDSO_NAME).so.$(MAJOR_VERSION)
107 NONSHARED_LIBNAME := uclibc_nonshared.a
108 libc := $(top_builddir)lib/$(SHARED_MAJORNAME)
109 libc.depend := $(top_builddir)lib/$(SHARED_MAJORNAME:.$(MAJOR_VERSION)=)
110 interp := $(top_builddir)lib/interp.os
111 ldso := $(top_builddir)lib/$(UCLIBC_LDSO)
112 headers_dep := $(top_builddir)include/bits/sysnum.h
113 sub_headers := $(headers_dep)
115 #LIBS :=$(interp) -L$(top_builddir)lib -lc
116 LIBS := $(interp) -L$(top_builddir)lib $(libc:.$(MAJOR_VERSION)=)
118 # Make sure DESTDIR and PREFIX can be used to install
119 # PREFIX is a uClibcism while DESTDIR is a common GNUism
124 ifneq ($(HAVE_SHARED),y)
134 CROSS=$(strip $(subst ",, $(CROSS_COMPILER_PREFIX)))
137 # A nifty macro to make testing gcc features easier
139 if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
140 then echo "$(1)"; else echo "$(2)"; fi)
142 if $(CC) -Wa,$(1) -Wa,-Z -c -o /dev/null -xassembler /dev/null > /dev/null 2>&1; \
143 then echo "-Wa,$(1)"; fi)
145 if $(LD) $(1) -o /dev/null -b binary /dev/null > /dev/null 2>&1; \
146 then echo "$(1)"; fi)
150 # Flags in OPTIMIZATION are used only for non-debug builds
152 # Use '-Os
' optimization if available, else use -O2, allow Config to override
153 OPTIMIZATION+=$(call check_gcc,-Os,-O2)
154 # Use the gcc 3.4 -funit-at-a-time optimization when available
155 OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,)
157 GCC_MAJOR_VER?=$(shell $(CC) -dumpversion | cut -d . -f 1)
158 #GCC_MINOR_VER?=$(shell $(CC) -dumpversion | cut -d . -f 2)
160 ifeq ($(GCC_MAJOR_VER),4)
161 # shrinks code, results are from 4.0.2
163 OPTIMIZATION+=$(call check_gcc,-fno-tree-loop-optimize,)
165 OPTIMIZATION+=$(call check_gcc,-fno-tree-dominator-opts,)
167 OPTIMIZATION+=$(call check_gcc,-fno-strength-reduce,)
170 CPU_CFLAGS-$(UCLIBC_FORMAT_SHARED_FLAT) += -mid-shared-library
171 CPU_CFLAGS-$(UCLIBC_FORMAT_FLAT_SEP_DATA) += -msep-data
174 PICFLAG-$(UCLIBC_FORMAT_FDPIC_ELF) := -mfdpic
175 PICFLAG := $(PICFLAG-y)
178 # Some nice CPU specific optimizations
179 ifeq ($(TARGET_ARCH),i386)
180 OPTIMIZATION+=$(call check_gcc,-fomit-frame-pointer,)
182 # NB: this may make SSE insns segfault!
183 # -O1 -march=pentium3, -Os -msse etc are known to be affected.
184 # TODO: conditionally bump to 4
185 # (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13685)
186 OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=4,)
188 # Choice of alignment (please document why!)
189 # -falign-labels: in-line labels
190 # (reachable by normal code flow, aligning will insert nops
191 # which will be executed - may even make things slower)
192 # -falign-jumps: reachable only by a jump
193 # Generic: no alignment at all (smallest code)
194 GCC_FALIGN=$(call check_gcc,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,-malign-jumps=1 -malign-loops=1)
195 ifeq ($(CONFIG_K7),y)
196 # Align functions to four bytes, use default for jumps and loops (why?)
197 GCC_FALIGN=$(call check_gcc,-falign-functions=4 -falign-labels=1,-malign-functions=4)
199 ifeq ($(CONFIG_CRUSOE),y)
200 # Use compiler's default for functions
, jumps and loops
(why?
)
201 GCC_FALIGN
=$(call check_gcc
,-falign-functions
=0 -falign-labels
=1,-malign-functions
=0)
203 ifeq ($(CONFIG_CYRIXIII
),y
)
204 # Use compiler's default for functions, jumps and loops (why?)
205 GCC_FALIGN
=$(call check_gcc
,-falign-functions
=0 -falign-labels
=1,-malign-functions
=0)
207 OPTIMIZATION
+=$(GCC_FALIGN
)
209 # Putting each function and data object into its own section
210 # allows for kbytes of less text if users link against static uclibc
211 # using ld --gc-sections.
212 # ld 2.18 can't do that (yet?) for shared libraries, so we itself
213 # do not use --gc-sections at shared lib link time.
214 # However, in combination with sections being sorted by alignment
215 # it does result in much reduced padding:
216 # text data bss dec hex
217 # 235319 1472 5992 242783 3b45f old.so
218 # 234104 1472 5980 241556 3af94 new.so
219 # Without -ffunction-sections, all functions will get aligned
220 # to 4 byte boundary by as/ld. This is arguably a bug in as.
221 # It specifies 4 byte align for .text even if not told to do so:
222 # Idx Name Size VMA LMA File off Algn
223 # 0 .text xxxxxxxx 00000000 00000000 xxxxxxxx 2**2 <===!
224 CPU_CFLAGS-y
+= $(call check_gcc
,-ffunction-sections
-fdata-sections
,)
225 ifneq ($(call check_ld
,--sort-common
,),)
226 CPU_LDFLAGS-y
+= -Wl
,--sort-common
228 ifneq ($(call check_ld
,--sort-section alignment
),)
229 CPU_LDFLAGS-y
+= -Wl
,--sort-section
,alignment
234 CPU_CFLAGS-
$(CONFIG_386
)+=-march
=i386
235 CPU_CFLAGS-
$(CONFIG_486
)+=-march
=i486
236 CPU_CFLAGS-
$(CONFIG_ELAN
)+=-march
=i486
237 CPU_CFLAGS-
$(CONFIG_586
)+=-march
=i586
238 CPU_CFLAGS-
$(CONFIG_586MMX
)+=$(call check_gcc
,-march
=pentium-mmx
,-march
=i586
)
239 CPU_CFLAGS-
$(CONFIG_686
)+=-march
=i686
240 CPU_CFLAGS-
$(CONFIG_PENTIUMII
)+=$(call check_gcc
,-march
=pentium2
,-march
=i686
)
241 CPU_CFLAGS-
$(CONFIG_PENTIUMIII
)+=$(call check_gcc
,-march
=pentium3
,-march
=i686
)
242 CPU_CFLAGS-
$(CONFIG_PENTIUM4
)+=$(call check_gcc
,-march
=pentium4
,-march
=i686
)
243 CPU_CFLAGS-
$(CONFIG_K6
)+=$(call check_gcc
,-march
=k6
,-march
=i586
)
244 CPU_CFLAGS-
$(CONFIG_K7
)+=$(call check_gcc
,-march
=athlon
,-march
=i686
)
245 CPU_CFLAGS-
$(CONFIG_CRUSOE
)+=-march
=i686
246 CPU_CFLAGS-
$(CONFIG_WINCHIPC6
)+=$(call check_gcc
,-march
=winchip-c6
,-march
=i586
)
247 CPU_CFLAGS-
$(CONFIG_WINCHIP2
)+=$(call check_gcc
,-march
=winchip2
,-march
=i586
)
248 CPU_CFLAGS-
$(CONFIG_CYRIXIII
)+=$(call check_gcc
,-march
=c3
,-march
=i486
)
249 CPU_CFLAGS-
$(CONFIG_NEHEMIAH
)+=$(call check_gcc
,-march
=c3-2
,-march
=i686
)
252 ifeq ($(TARGET_ARCH
),sparc
)
253 CPU_CFLAGS-
$(CONFIG_SPARC_V7
)+=-mcpu
=v7
254 CPU_CFLAGS-
$(CONFIG_SPARC_V8
)+=-mcpu
=v8
255 CPU_CFLAGS-
$(CONFIG_SPARC_V9
)+=-mcpu
=v9
256 CPU_CFLAGS-
$(CONFIG_SPARC_V9B
)+=$(call check_gcc
,-mcpu
=v9b
,-mcpu
=ultrasparc
)
259 ifeq ($(TARGET_ARCH
),arm
)
260 OPTIMIZATION
+=-fstrict-aliasing
261 CPU_LDFLAGS-
$(ARCH_LITTLE_ENDIAN
)+=-Wl
,-EL
262 CPU_LDFLAGS-
$(ARCH_BIG_ENDIAN
)+=-Wl
,-EB
263 CPU_CFLAGS-
$(ARCH_LITTLE_ENDIAN
)+=-mlittle-endian
264 CPU_CFLAGS-
$(ARCH_BIG_ENDIAN
)+=-mbig-endian
265 CPU_CFLAGS-
$(CONFIG_GENERIC_ARM
)+=
266 CPU_CFLAGS-
$(CONFIG_ARM610
)+=-mtune
=arm610
-march
=armv3
267 CPU_CFLAGS-
$(CONFIG_ARM710
)+=-mtune
=arm710
-march
=armv3
268 CPU_CFLAGS-
$(CONFIG_ARM7TDMI
)+=-mtune
=arm7tdmi
-march
=armv4t
269 CPU_CFLAGS-
$(CONFIG_ARM720T
)+=-mtune
=arm7tdmi
-march
=armv4t
270 CPU_CFLAGS-
$(CONFIG_ARM920T
)+=-mtune
=arm9tdmi
-march
=armv4t
271 CPU_CFLAGS-
$(CONFIG_ARM922T
)+=-mtune
=arm9tdmi
-march
=armv4t
272 CPU_CFLAGS-
$(CONFIG_ARM926T
)+=-mtune
=arm9tdmi
-march
=armv5t
273 CPU_CFLAGS-
$(CONFIG_ARM10T
)+=-mtune
=arm10tdmi
-march
=armv5t
274 CPU_CFLAGS-
$(CONFIG_ARM1136JF_S
)+=-mtune
=arm1136jf-s
-march
=armv6
275 CPU_CFLAGS-
$(CONFIG_ARM1176JZ_S
)+=-mtune
=arm1176jz-s
-march
=armv6
276 CPU_CFLAGS-
$(CONFIG_ARM1176JZF_S
)+=-mtune
=arm1176jzf-s
-march
=armv6
277 CPU_CFLAGS-
$(CONFIG_ARM_SA110
)+=-mtune
=strongarm110
-march
=armv4
278 CPU_CFLAGS-
$(CONFIG_ARM_SA1100
)+=-mtune
=strongarm1100
-march
=armv4
279 CPU_CFLAGS-
$(CONFIG_ARM_XSCALE
)+=$(call check_gcc
,-mtune
=xscale
,-mtune
=strongarm110
)
280 CPU_CFLAGS-
$(CONFIG_ARM_XSCALE
)+=-march
=armv5te
-Wa
,-mcpu
=xscale
281 CPU_CFLAGS-
$(CONFIG_ARM_IWMMXT
)+=-march
=iwmmxt
-Wa
,-mcpu
=iwmmxt
-mabi
=iwmmxt
282 CPU_CFLAGS-
$(CONFIG_ARM_CORTEX_M3
)+=-mcpu
=cortex-m3
-mthumb
283 CPU_CFLAGS-
$(CONFIG_ARM_CORTEX_M1
)+=-mcpu
=cortex-m1
-mthumb
286 ifeq ($(TARGET_ARCH
),mips
)
287 CPU_LDFLAGS-
$(ARCH_LITTLE_ENDIAN
)+=-Wl
,-EL
288 CPU_LDFLAGS-
$(ARCH_BIG_ENDIAN
)+=-Wl
,-EB
289 CPU_CFLAGS-
$(CONFIG_MIPS_ISA_1
)+=-mips1
290 CPU_CFLAGS-
$(CONFIG_MIPS_ISA_2
)+=-mips2
-mtune
=mips2
291 CPU_CFLAGS-
$(CONFIG_MIPS_ISA_3
)+=-mips3
-mtune
=mips3
292 CPU_CFLAGS-
$(CONFIG_MIPS_ISA_4
)+=-mips4
-mtune
=mips4
293 CPU_CFLAGS-
$(CONFIG_MIPS_ISA_MIPS32
)+=-mips32
-mtune
=mips32
294 CPU_CFLAGS-
$(CONFIG_MIPS_ISA_MIPS32R2
)+=-march
=mips32r2
-mtune
=mips32r2
295 CPU_CFLAGS-
$(CONFIG_MIPS_ISA_MIPS64
)+=-mips64
-mtune
=mips32
296 ifeq ($(strip $(ARCH_BIG_ENDIAN
)),y
)
297 CPU_LDFLAGS-
$(CONFIG_MIPS_N64_ABI
)+=-Wl
,-melf64btsmip
298 CPU_LDFLAGS-
$(CONFIG_MIPS_O32_ABI
)+=-Wl
,-melf32btsmip
300 ifeq ($(strip $(ARCH_LITTLE_ENDIAN
)),y
)
301 CPU_LDFLAGS-
$(CONFIG_MIPS_N64_ABI
)+=-Wl
,-melf64ltsmip
302 CPU_LDFLAGS-
$(CONFIG_MIPS_O32_ABI
)+=-Wl
,-melf32ltsmip
304 CPU_CFLAGS-
$(CONFIG_MIPS_N64_ABI
)+=-mabi
=64
305 CPU_CFLAGS-
$(CONFIG_MIPS_O32_ABI
)+=-mabi
=32
306 CPU_CFLAGS-
$(CONFIG_MIPS_N32_ABI
)+=-mabi
=n32
309 ifeq ($(TARGET_ARCH
),nios
)
310 CPU_LDFLAGS-y
+=-Wl
,-m32
311 CPU_CFLAGS-y
+=-Wl
,-m32
314 ifeq ($(TARGET_ARCH
),sh
)
315 OPTIMIZATION
+=-fstrict-aliasing
316 OPTIMIZATION
+= $(call check_gcc
,-mprefergot
,)
317 CPU_LDFLAGS-
$(ARCH_LITTLE_ENDIAN
)+=-Wl
,-EL
318 CPU_LDFLAGS-
$(ARCH_BIG_ENDIAN
)+=-Wl
,-EB
319 CPU_CFLAGS-
$(ARCH_LITTLE_ENDIAN
)+=-ml
320 CPU_CFLAGS-
$(ARCH_BIG_ENDIAN
)+=-mb
321 CPU_CFLAGS-
$(CONFIG_SH2
)+=-m2
322 CPU_CFLAGS-
$(CONFIG_SH3
)+=-m3
323 ifeq ($(UCLIBC_HAS_FLOATS
),y
)
324 CPU_CFLAGS-
$(CONFIG_SH2A
)+=-m2a
325 CPU_CFLAGS-
$(CONFIG_SH4
)+=-m4
327 CPU_CFLAGS-
$(CONFIG_SH2A
)+=-m2a-nofpu
328 CPU_CFLAGS-
$(CONFIG_SH4
)+=-m4-nofpu
332 ifeq ($(TARGET_ARCH
),sh64
)
333 OPTIMIZATION
+=-fstrict-aliasing
334 CPU_LDFLAGS-
$(ARCH_LITTLE_ENDIAN
):=-Wl
,-EL
335 CPU_LDFLAGS-
$(ARCH_BIG_ENDIAN
):=-Wl
,-EB
336 CPU_CFLAGS-
$(ARCH_LITTLE_ENDIAN
):=-ml
337 CPU_CFLAGS-
$(ARCH_BIG_ENDIAN
):=-mb
338 CPU_CFLAGS-
$(CONFIG_SH5
)+=-m5-32media
341 ifeq ($(TARGET_ARCH
),h8300
)
343 CPU_LDFLAGS-
$(CONFIG_H8300H
)+= -Wl
,-ms8300h
344 CPU_LDFLAGS-
$(CONFIG_H8S
) += -Wl
,-ms8300s
345 CPU_CFLAGS-
$(CONFIG_H8300H
) += -mh
-mint32
346 CPU_CFLAGS-
$(CONFIG_H8S
) += -ms
-mint32
349 ifeq ($(TARGET_ARCH
),cris
)
350 CPU_LDFLAGS-
$(CONFIG_CRIS
)+=-Wl
,-mcrislinux
351 CPU_LDFLAGS-
$(CONFIG_CRISV32
)+=-Wl
,-mcrislinux
352 CPU_CFLAGS-
$(CONFIG_CRIS
)+=-mlinux
357 ifeq ($(TARGET_ARCH
),m68k
)
358 # -fPIC is only supported for 68020 and above. It is not supported
359 # for 68000, 68010, or Coldfire.
364 ifeq ($(TARGET_ARCH
),powerpc
)
365 # PowerPC can hold 8192 entries in its GOT with -fpic which is more than
366 # enough. Therefore use -fpic which will reduce code size and generates
370 PPC_HAS_REL16
:=$(shell echo
-e
"\t.text\n\taddis 11,30,_GLOBAL_OFFSET_TABLE_-.@ha" |
$(CC
) -c
-x assembler
-o
/dev
/null
- 2> /dev
/null
&& echo
-n y || echo
-n n
)
371 CPU_CFLAGS-
$(PPC_HAS_REL16
)+= -DHAVE_ASM_PPC_REL16
372 CPU_CFLAGS-
$(CONFIG_E500
) += "-D__NO_MATH_INLINES"
376 ifeq ($(TARGET_ARCH
),bfin
)
378 ifeq ($(UCLIBC_FORMAT_FDPIC_ELF
),y
)
379 CPU_CFLAGS-y
:=-mfdpic
380 CPU_LDFLAGS-y
+= -Wl
,-melf32bfinfd
384 ifeq ($(UCLIBC_FORMAT_SHARED_FLAT
),y
)
385 PICFLAG
:= -mleaf-id-shared-library
389 ifeq ($(TARGET_ARCH
),frv
)
390 CPU_LDFLAGS-
$(CONFIG_FRV
)+=-Wl
,-melf32frvfd
391 # Using -pie causes the program to have an interpreter, which is
392 # forbidden, so we must make do with -shared. Unfortunately,
393 # -shared by itself would get us global function descriptors
394 # and calls through PLTs, dynamic resolution of symbols, etc,
395 # which would break as well, but -Bsymbolic comes to the rescue.
396 export LDPIEFLAG
:=-Wl
,-shared
-Wl
,-Bsymbolic
400 ifeq ($(strip $(TARGET_ARCH
)),avr32
)
401 CPU_CFLAGS-
$(CONFIG_AVR32_AP7
) += -march
=ap
402 CPU_CFLAGS-
$(CONFIG_LINKRELAX
) += -mrelax
403 CPU_LDFLAGS-
$(CONFIG_LINKRELAX
) += --relax
406 ifeq ($(TARGET_ARCH
),i960
)
410 ifeq ($(TARGET_ARCH
),microblaze
)
414 ifeq ($(TARGET_ARCH
),v850
)
418 # Keep the check_gcc from being needlessly executed
420 ifneq ($(UCLIBC_BUILD_PIE
),y
)
423 export PIEFLAG
:=$(call check_gcc
,$(PIEFLAG_NAME
),$(PICFLAG
))
426 # We need to keep track of both the CC PIE flag (above) as
427 # well as the LD PIE flag (below) because we can't rely on
428 # gcc passing -pie if we used -fPIE
430 ifneq ($(UCLIBC_BUILD_PIE
),y
)
433 export LDPIEFLAG
:=$(shell $(LD
) --help
2>/dev
/null | grep
-q
-- -pie
&& echo
"-Wl,-pie")
437 # Check for AS_NEEDED support in linker script (binutils>=2.16.1 has it)
439 export ASNEEDED
:=$(shell $(LD
) --help
2>/dev
/null | grep
-q
-- --as-needed
&& echo
"AS_NEEDED ( $(UCLIBC_LDSO) )" || echo
"$(UCLIBC_LDSO)")
442 # Add a bunch of extra pedantic annoyingly strict checks
443 XWARNINGS
=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes -fno-strict-aliasing
444 ifeq ($(EXTRA_WARNINGS),y)
445 XWARNINGS+=-Wnested-externs -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wformat=2
446 XWARNINGS+=-Wmissing-prototypes -Wmissing-declarations
447 XWARNINGS+=-Wnonnull -Wundef
448 # works only w/ gcc-3.4 and up, can't be checked for gcc-3.x w/ check_gcc()
449 #XWARNINGS+=-Wdeclaration-after-statement
451 XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS
)))
452 CPU_CFLAGS
=$(subst ",, $(strip $(CPU_CFLAGS-y)))
454 SSP_DISABLE_FLAGS ?= $(call check_gcc,-fno-stack-protector,)
455 ifeq ($(UCLIBC_BUILD_SSP),y)
456 SSP_CFLAGS := $(call check_gcc,-fno-stack-protector-all,)
457 SSP_CFLAGS += $(call check_gcc,-fstack-protector,)
458 SSP_ALL_CFLAGS ?= $(call check_gcc,-fstack-protector-all,)
460 SSP_CFLAGS := $(SSP_DISABLE_FLAGS)
463 NOSTDLIB_CFLAGS:=$(call check_gcc,-nostdlib,)
464 # Some nice CFLAGS to work with
465 CFLAGS := -include $(top_builddir)include/libc-symbols.h \
466 $(XWARNINGS) $(CPU_CFLAGS) $(SSP_CFLAGS) \
467 -fno-builtin -nostdinc -I$(top_builddir)include -I. \
468 -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)
470 # Make sure that we can be built with non-C99 compilers, too.
471 # Use __\1__ instead.
472 CFLAGS += $(call check_gcc,-fno-asm,)
473 ifneq ($(strip $(UCLIBC_EXTRA_CFLAGS)),"")
474 CFLAGS += $(subst ",, $(UCLIBC_EXTRA_CFLAGS
))
478 ifeq ($(UCLIBC_HAS_SOFT_FLOAT
),y
)
479 # If -msoft-float isn't supported, we want an error anyway.
480 # Hmm... might need to revisit this for arm since it has 2 different
481 # soft float encodings.
482 ifneq ($(TARGET_ARCH
),nios
)
483 ifneq ($(TARGET_ARCH
),nios2
)
484 ifneq ($(TARGET_ARCH
),sh
)
485 CFLAGS
+= -msoft-float
489 ifeq ($(TARGET_ARCH
),arm
)
490 # No longer needed with current toolchains, but leave it here for now.
491 # If anyone is actually still using gcc 2.95 (say), they can uncomment it.
492 # LDADD_LIBFLOAT=-lfloat
496 # Please let us see private headers' parts
497 CFLAGS
+= -DUCLIBC_INTERNAL
499 # We need this to be checked within libc-symbols.h
500 ifneq ($(HAVE_SHARED
),y
)
504 CFLAGS
+= $(call check_gcc
,-std
=gnu99
,)
506 LDFLAGS_NOSTRIP
:=$(CPU_LDFLAGS-y
) -Wl
,-shared \
507 -Wl
,--warn-common
-Wl
,--warn-once
-Wl
,-z
,combreloc
508 # binutils-2.16.1 warns about ignored sections, 2.16.91.0.3 and newer are ok
509 #LDFLAGS_NOSTRIP+=$(call check_ld,--gc-sections)
511 ifeq ($(UCLIBC_BUILD_RELRO
),y
)
512 LDFLAGS_NOSTRIP
+=-Wl
,-z
,relro
515 ifeq ($(UCLIBC_BUILD_NOW
),y
)
516 LDFLAGS_NOSTRIP
+=-Wl
,-z
,now
519 ifeq ($(LDSO_GNU_HASH_SUPPORT
),y
)
520 # Be sure that binutils support it
521 LDFLAGS_GNUHASH
:=$(call check_ld
,--hash-style
=gnu
)
522 ifeq ($(LDFLAGS_GNUHASH
),)
523 $(error Your binutils don
't support --hash-style option, while you want to use it)
525 LDFLAGS_NOSTRIP += -Wl,$(LDFLAGS_GNUHASH)
529 LDFLAGS:=$(LDFLAGS_NOSTRIP) -Wl,-z,defs
533 CFLAGS += $(OPTIMIZATION) $(XARCH_CFLAGS)
538 STRIPTOOL := true -Stripping_disabled
542 # we try to compile all sources at once into an object (IMA), but
543 # gcc-3.3.x does not support it
544 # gcc-3.4.x supports it, but does not need and support --combine. though fails on many sources
545 # gcc-4.0.x supports it, supports the --combine flag, but does not need it
546 # gcc-4.1(200506xx) supports it, but needs the --combine flag, else libs are useless
547 ifeq ($(GCC_MAJOR_VER),3)
550 CFLAGS+=$(call check_gcc,--combine,)
556 ifneq ($(strip $(UCLIBC_EXTRA_LDFLAGS)),"")
557 LDFLAGS += $(subst ",, $(UCLIBC_EXTRA_LDFLAGS))
560 ifeq ($(UCLIBC_HAS_THREADS),y)
561 ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
564 ifeq ($(LINUXTHREADS_OLD),y)
565 PTNAME := linuxthreads.old
567 PTNAME := linuxthreads
570 PTDIR := $(top_builddir)libpthread/$(PTNAME)
571 # set up system dependencies include dirs (NOTE: order matters!)
572 ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
574 -I$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH) \
575 -I$(PTDIR)/sysdeps/$(TARGET_ARCH) \
576 -I$(PTDIR)/sysdeps/unix/sysv/linux \
577 -I$(PTDIR)/sysdeps/pthread \
578 -I$(PTDIR)/sysdeps/pthread/bits \
579 -I$(PTDIR)/sysdeps/generic \
580 -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) \
581 -I$(top_srcdir)ldso/include
583 # Test for TLS if NPTL support was selected.
585 GCC_HAS_TLS=$(shell \
586 echo "extern __thread int foo;" | $(CC) -o /dev/null -S -xc - 2>&1)
587 ifneq ($(GCC_HAS_TLS),)
590 @echo "#### Your compiler does not support TLS and you are trying to build uClibc";
591 @echo "#### with NPTL support. Upgrade your binutils and gcc to versions which";
592 @echo "#### support TLS for your architecture. Do not contact uClibc maintainers";
593 @echo "#### about this problem.";
595 @echo "#### Exiting...";
601 -I$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH) \
602 -I$(PTDIR)/sysdeps/$(TARGET_ARCH) \
603 -I$(PTDIR)/sysdeps/unix/sysv/linux \
604 -I$(PTDIR)/sysdeps/pthread \
606 -I$(top_builddir)libpthread
613 CFLAGS += -I$(KERNEL_HEADERS)
615 #CFLAGS += -iwithprefix include-fixed -iwithprefix include
616 CC_IPREFIX:=$(shell $(CC) --print-file-name=include)
617 CFLAGS += -I$(dir $(CC_IPREFIX))/include-fixed -I$(CC_IPREFIX)
619 ifneq ($(DOASSERTS),y)
623 ifeq ($(SYMBOL_PREFIX),_)
624 CFLAGS+=-D__UCLIBC_UNDERSCORES__
627 # Keep the check_as from being needlessly executed
628 ifndef ASFLAGS_NOEXEC
629 ifeq ($(UCLIBC_BUILD_NOEXECSTACK),y)
630 export ASFLAGS_NOEXEC := $(call check_as,--noexecstack)
632 export ASFLAGS_NOEXEC :=
635 ASFLAGS = $(ASFLAGS_NOEXEC)
637 LIBGCC_CFLAGS ?= $(CFLAGS) $(CPU_CFLAGS-y)
638 LIBGCC:=$(shell $(CC) $(LIBGCC_CFLAGS) -print-libgcc-file-name)
639 LIBGCC_DIR:=$(dir $(LIBGCC))
641 # moved from libpthread/linuxthreads
642 ifeq ($(UCLIBC_CTOR_DTOR),y)
643 SHARED_START_FILES:=$(top_builddir)lib/crti.o $(LIBGCC_DIR)crtbeginS.o
644 SHARED_END_FILES:=$(LIBGCC_DIR)crtendS.o $(top_builddir)lib/crtn.o
647 LOCAL_INSTALL_PATH := install_dir