OSDN Git Service

Add necessary Makefile rules for the Blackfin.
[uclinux-h8/uClibc.git] / Rules.mak
1 # Rules.make for uClibc
2 #
3 # Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
4 #
5 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6 #
7
8 # check for proper make version
9 ifneq ($(findstring 3.7,$(MAKE_VERSION)),)
10 $(error Your make is too old $(MAKE_VERSION). Go get at least 3.80)
11 endif
12
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.
18
19
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.
26 #
27 # Most people will set this stuff on the command line, i.e.
28 #        make CROSS=arm-linux-
29 # will build uClibc for 'arm'.
30
31 ifndef CROSS
32 CROSS=
33 endif
34 CC         = $(CROSS)gcc
35 AR         = $(CROSS)ar
36 LD         = $(CROSS)ld
37 NM         = $(CROSS)nm
38 STRIPTOOL  = $(CROSS)strip
39
40 INSTALL    = install
41 LN         = ln
42 RM         = rm -f
43 TAR        = tar
44
45 STRIP_FLAGS ?= -x -R .note -R .comment
46
47 # Select the compiler needed to build binaries for your development system
48 HOSTCC     = gcc
49 BUILD_CFLAGS = -O2 -Wall
50 export ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun.*/sparc/ -e s/sparc.*/sparc/ \
51                                   -e s/arm.*/arm/ -e s/sa110/arm/ -e s/sh.*/sh/ \
52                                   -e s/s390x/s390/ -e s/parisc.*/hppa/ \
53                                   -e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
54
55
56 #---------------------------------------------------------
57 # Nothing beyond this point should ever be touched by mere
58 # mortals.  Unless you hang out with the gods, you should
59 # probably leave all this stuff alone.
60
61 # Pull in the user's uClibc configuration
62 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
63 -include $(top_builddir).config
64 endif
65
66 # Make certain these contain a final "/", but no "//"s.
67 TARGET_ARCH:=$(shell grep -s '^TARGET_ARCH' $(top_builddir)/.config | sed -e 's/^TARGET_ARCH=//' -e 's/"//g')
68 TARGET_ARCH:=$(strip $(subst ",, $(strip $(TARGET_ARCH))))
69 TARGET_SUBARCH:=$(shell grep -s '^TARGET_SUBARCH' $(top_builddir)/.config | sed -e 's/^TARGET_SUBARCH=//' -e 's/"//g')
70 TARGET_SUBARCH:=$(strip $(subst ",, $(strip $(TARGET_SUBARCH))))
71 RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(RUNTIME_PREFIX))))))
72 DEVEL_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(DEVEL_PREFIX))))))
73 KERNEL_HEADERS:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(KERNEL_HEADERS))))))
74 export RUNTIME_PREFIX DEVEL_PREFIX KERNEL_HEADERS
75
76
77 # Now config hard core
78 MAJOR_VERSION := 0
79 MINOR_VERSION := 9
80 SUBLEVEL      := 29
81 EXTRAVERSION  :=
82 VERSION       := $(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL)
83 ifneq ($(EXTRAVERSION),)
84 VERSION       := $(VERSION)$(EXTRAVERSION)
85 endif
86 # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
87 LC_ALL := C
88 export MAJOR_VERSION MINOR_VERSION SUBLEVEL VERSION LC_ALL
89
90 LIBC := libc
91 SHARED_MAJORNAME := $(LIBC).so.$(MAJOR_VERSION)
92 ifneq ($(findstring  $(TARGET_ARCH) , hppa64 ia64 mips64 powerpc64 s390x sh64 sparc64 x86_64 ),)
93 UCLIBC_LDSO_NAME := ld64-uClibc
94 else
95 UCLIBC_LDSO_NAME := ld-uClibc
96 endif
97 UCLIBC_LDSO := $(UCLIBC_LDSO_NAME).so.$(MAJOR_VERSION)
98 NONSHARED_LIBNAME := uclibc_nonshared.a
99 libc := $(top_builddir)lib/$(SHARED_MAJORNAME)
100 interp := $(top_builddir)lib/interp.os
101 ldso := $(top_builddir)lib/$(UCLIBC_LDSO)
102 headers_dep := $(top_builddir)include/bits/sysnum.h
103 sub_headers := $(headers_dep)
104
105 #LIBS :=$(interp) -L$(top_builddir)lib -lc
106 LIBS := $(interp) -L$(top_builddir)lib $(libc:.$(MAJOR_VERSION)=)
107
108 # Make sure DESTDIR and PREFIX can be used to install
109 # PREFIX is a uClibcism while DESTDIR is a common GNUism
110 ifndef PREFIX
111 PREFIX = $(DESTDIR)
112 endif
113
114 ifneq ($(HAVE_SHARED),y)
115 libc :=
116 interp :=
117 ldso :=
118 endif
119
120 comma:=,
121 space:= #
122
123 ifndef CROSS
124 CROSS=$(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
125 endif
126
127 # A nifty macro to make testing gcc features easier
128 check_gcc=$(shell \
129         if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
130         then echo "$(1)"; else echo "$(2)"; fi)
131 check_as=$(shell \
132         if $(CC) -Wa,$(1) -Wa,-Z -c -o /dev/null -xassembler /dev/null > /dev/null 2>&1; \
133         then echo "-Wa,$(1)"; fi)
134 check_ld=$(shell \
135         if $(LD) $(1) -o /dev/null -b binary /dev/null > /dev/null 2>&1; \
136         then echo "$(1)"; fi)
137
138 ARFLAGS:=cr
139
140 OPTIMIZATION:=
141 # Use '-Os' optimization if available, else use -O2, allow Config to override
142 OPTIMIZATION+=$(call check_gcc,-Os,-O2)
143 # Use the gcc 3.4 -funit-at-a-time optimization when available
144 OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,)
145
146 GCC_MAJOR_VER?=$(shell $(CC) -dumpversion | cut -d . -f 1)
147 #GCC_MINOR_VER?=$(shell $(CC) -dumpversion | cut -d . -f 2)
148
149 ifeq ($(GCC_MAJOR_VER),4)
150 # shrinks code, results are from 4.0.2
151 # 0.36%
152 OPTIMIZATION+=$(call check_gcc,-fno-tree-loop-optimize,)
153 # 0.34%
154 OPTIMIZATION+=$(call check_gcc,-fno-tree-dominator-opts,)
155 # 0.1%
156 OPTIMIZATION+=$(call check_gcc,-fno-strength-reduce,)
157 endif
158
159 CPU_CFLAGS-$(UCLIBC_FORMAT_SHARED_FLAT) += -mid-shared-library
160 CPU_CFLAGS-$(UCLIBC_FORMAT_FLAT_SEP_DATA) += -msep-data
161
162 PICFLAG-y := -fPIC
163 PICFLAG-$(UCLIBC_FORMAT_FDPIC_ELF) := -mfdpic
164 PICFLAG := $(PICFLAG-y)
165 PIEFLAG_NAME:=-fPIE
166
167 # Some nice CPU specific optimizations
168 ifeq ($(TARGET_ARCH),i386)
169         OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,)
170         OPTIMIZATION+=$(call check_gcc,-falign-jumps=0 -falign-loops=0,-malign-jumps=0 -malign-loops=0)
171         CPU_CFLAGS-$(CONFIG_386)+=-march=i386
172         CPU_CFLAGS-$(CONFIG_486)+=-march=i486
173         CPU_CFLAGS-$(CONFIG_ELAN)+=-march=i486
174         CPU_CFLAGS-$(CONFIG_586)+=-march=i586
175         CPU_CFLAGS-$(CONFIG_586MMX)+=$(call check_gcc,-march=pentium-mmx,-march=i586)
176         CPU_CFLAGS-$(CONFIG_686)+=-march=i686
177         CPU_CFLAGS-$(CONFIG_PENTIUMII)+=$(call check_gcc,-march=pentium2,-march=i686)
178         CPU_CFLAGS-$(CONFIG_PENTIUMIII)+=$(call check_gcc,-march=pentium3,-march=i686)
179         CPU_CFLAGS-$(CONFIG_PENTIUM4)+=$(call check_gcc,-march=pentium4,-march=i686)
180         CPU_CFLAGS-$(CONFIG_K6)+=$(call check_gcc,-march=k6,-march=i586)
181         CPU_CFLAGS-$(CONFIG_K7)+=$(call check_gcc,-march=athlon,-march=i686) $(call check_gcc,-falign-functions=4,-malign-functions=4)
182         CPU_CFLAGS-$(CONFIG_CRUSOE)+=-march=i686 $(call check_gcc,-falign-functions=0,-malign-functions=0)
183         CPU_CFLAGS-$(CONFIG_WINCHIPC6)+=$(call check_gcc,-march=winchip-c6,-march=i586)
184         CPU_CFLAGS-$(CONFIG_WINCHIP2)+=$(call check_gcc,-march=winchip2,-march=i586)
185         CPU_CFLAGS-$(CONFIG_CYRIXIII)+=$(call check_gcc,-march=c3,-march=i486) $(call check_gcc,-falign-functions=0,-malign-functions=0)
186         CPU_CFLAGS-$(CONFIG_NEHEMIAH)+=$(call check_gcc,-march=c3-2,-march=i686)
187 endif
188
189 ifeq ($(TARGET_ARCH),sparc)
190         CPU_CFLAGS-$(CONFIG_SPARC_V7)+=-mcpu=v7
191         CPU_CFLAGS-$(CONFIG_SPARC_V8)+=-mcpu=v8
192         CPU_CFLAGS-$(CONFIG_SPARC_V9)+=-mcpu=v9
193         CPU_CFLAGS-$(CONFIG_SPARC_V9B)+=$(call check_gcc,-mcpu=v9b,-mcpu=ultrasparc)
194 endif
195
196 ifeq ($(TARGET_ARCH),arm)
197         OPTIMIZATION+=-fstrict-aliasing
198         CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN)+=-Wl,-EL
199         CPU_LDFLAGS-$(ARCH_BIG_ENDIAN)+=-Wl,-EB
200         CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN)+=-mlittle-endian
201         CPU_CFLAGS-$(ARCH_BIG_ENDIAN)+=-mbig-endian
202         CPU_CFLAGS-$(CONFIG_GENERIC_ARM)+=
203         CPU_CFLAGS-$(CONFIG_ARM610)+=-mtune=arm610 -march=armv3
204         CPU_CFLAGS-$(CONFIG_ARM710)+=-mtune=arm710 -march=armv3
205         CPU_CFLAGS-$(CONFIG_ARM7TDMI)+=-mtune=arm7tdmi -march=armv4t
206         CPU_CFLAGS-$(CONFIG_ARM720T)+=-mtune=arm7tdmi -march=armv4t
207         CPU_CFLAGS-$(CONFIG_ARM920T)+=-mtune=arm9tdmi -march=armv4t
208         CPU_CFLAGS-$(CONFIG_ARM922T)+=-mtune=arm9tdmi -march=armv4t
209         CPU_CFLAGS-$(CONFIG_ARM926T)+=-mtune=arm9tdmi -march=armv5t
210         CPU_CFLAGS-$(CONFIG_ARM10T)+=-mtune=arm10tdmi -march=armv5t
211         CPU_CFLAGS-$(CONFIG_ARM1136JF_S)+=-mtune=arm1136jf-s -march=armv6
212         CPU_CFLAGS-$(CONFIG_ARM1176JZ_S)+=-mtune=arm1176jz-s -march=armv6
213         CPU_CFLAGS-$(CONFIG_ARM1176JZF_S)+=-mtune=arm1176jzf-s -march=armv6
214         CPU_CFLAGS-$(CONFIG_ARM_SA110)+=-mtune=strongarm110 -march=armv4
215         CPU_CFLAGS-$(CONFIG_ARM_SA1100)+=-mtune=strongarm1100 -march=armv4
216         CPU_CFLAGS-$(CONFIG_ARM_XSCALE)+=$(call check_gcc,-mtune=xscale,-mtune=strongarm110)
217         CPU_CFLAGS-$(CONFIG_ARM_XSCALE)+=-march=armv5te -Wa,-mcpu=xscale
218         CPU_CFLAGS-$(CONFIG_ARM_IWMMXT)+=-march=iwmmxt -Wa,-mcpu=iwmmxt -mabi=iwmmxt
219 endif
220
221 ifeq ($(TARGET_ARCH),mips)
222         CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN)+=-Wl,-EL
223         CPU_LDFLAGS-$(ARCH_BIG_ENDIAN)+=-Wl,-EB
224         CPU_CFLAGS-$(CONFIG_MIPS_ISA_1)+=-mips1
225         CPU_CFLAGS-$(CONFIG_MIPS_ISA_2)+=-mips2 -mtune=mips2
226         CPU_CFLAGS-$(CONFIG_MIPS_ISA_3)+=-mips3 -mtune=mips3
227         CPU_CFLAGS-$(CONFIG_MIPS_ISA_4)+=-mips4 -mtune=mips4
228         CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS32)+=-mips32 -mtune=mips32
229         CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS64)+=-mips64 -mtune=mips32
230         ifeq ($(strip $(ARCH_BIG_ENDIAN)),y)
231                 CPU_LDFLAGS-$(CONFIG_MIPS_N64_ABI)+=-Wl,-melf64btsmip
232                 CPU_LDFLAGS-$(CONFIG_MIPS_O32_ABI)+=-Wl,-melf32btsmip
233         endif
234         ifeq ($(strip $(ARCH_LITTLE_ENDIAN)),y)
235                 CPU_LDFLAGS-$(CONFIG_MIPS_N64_ABI)+=-Wl,-melf64ltsmip
236                 CPU_LDFLAGS-$(CONFIG_MIPS_O32_ABI)+=-Wl,-melf32ltsmip
237         endif
238         CPU_CFLAGS-$(CONFIG_MIPS_N64_ABI)+=-mabi=64
239         CPU_CFLAGS-$(CONFIG_MIPS_O32_ABI)+=-mabi=32
240         CPU_CFLAGS-$(CONFIG_MIPS_N32_ABI)+=-mabi=n32
241 endif
242
243 ifeq ($(TARGET_ARCH),nios)
244         CPU_LDFLAGS-y+=-Wl,-m32
245         CPU_CFLAGS-y+=-Wl,-m32
246 endif
247
248 ifeq ($(TARGET_ARCH),sh)
249         OPTIMIZATION+=-fstrict-aliasing
250         OPTIMIZATION+= $(call check_gcc,-mprefergot,)
251         CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN)+=-Wl,-EL
252         CPU_LDFLAGS-$(ARCH_BIG_ENDIAN)+=-Wl,-EB
253         CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN)+=-ml
254         CPU_CFLAGS-$(ARCH_BIG_ENDIAN)+=-mb
255         CPU_CFLAGS-$(CONFIG_SH2)+=-m2
256         CPU_CFLAGS-$(CONFIG_SH3)+=-m3
257 ifeq ($(UCLIBC_HAS_FLOATS),y)
258         CPU_CFLAGS-$(CONFIG_SH2A)+=-m2a
259         CPU_CFLAGS-$(CONFIG_SH4)+=-m4
260 else
261         CPU_CFLAGS-$(CONFIG_SH2A)+=-m2a-nofpu
262         CPU_CFLAGS-$(CONFIG_SH4)+=-m4-nofpu
263 endif
264 endif
265
266 ifeq ($(TARGET_ARCH),sh64)
267         OPTIMIZATION+=-fstrict-aliasing
268         CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN):=-Wl,-EL
269         CPU_LDFLAGS-$(ARCH_BIG_ENDIAN):=-Wl,-EB
270         CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN):=-ml
271         CPU_CFLAGS-$(ARCH_BIG_ENDIAN):=-mb
272         CPU_CFLAGS-$(CONFIG_SH5)+=-m5-32media
273 endif
274
275 ifeq ($(TARGET_ARCH),h8300)
276         CPU_LDFLAGS-$(CONFIG_H8300H)+= -Wl,-ms8300h
277         CPU_LDFLAGS-$(CONFIG_H8S)   += -Wl,-ms8300s
278         CPU_CFLAGS-$(CONFIG_H8300H) += -mh -mint32
279         CPU_CFLAGS-$(CONFIG_H8S)    += -ms -mint32
280 endif
281
282 ifeq ($(TARGET_ARCH),cris)
283         CPU_LDFLAGS-$(CONFIG_CRIS)+=-Wl,-mcrislinux
284         CPU_LDFLAGS-$(CONFIG_CRISV32)+=-Wl,-mcrislinux
285         CPU_CFLAGS-$(CONFIG_CRIS)+=-mlinux
286         PICFLAG:=-fpic
287         PIEFLAG_NAME:=-fpie
288 endif
289
290 ifeq ($(TARGET_ARCH),m68k)
291         # -fPIC is only supported for 68020 and above.  It is not supported
292         # for 68000, 68010, or Coldfire.
293         PICFLAG:=-fpic
294         PIEFLAG_NAME:=-fpie
295 endif
296
297 ifeq ($(TARGET_ARCH),powerpc)
298 # PowerPC can hold 8192 entries in its GOT with -fpic which is more than
299 # enough. Therefore use -fpic which will reduce code size and generates
300 # faster code.
301         PICFLAG:=-fpic
302         PIEFLAG_NAME:=-fpie
303         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)
304         CPU_CFLAGS-$(PPC_HAS_REL16)+= -DHAVE_ASM_PPC_REL16
305         CPU_CFLAGS-$(CONFIG_E500) += "-D__NO_MATH_INLINES -D__NO_LONG_DOUBLE_MATH"
306
307 endif
308
309 ifeq ($(TARGET_ARCH),bfin)
310 ifeq ($(UCLIBC_FORMAT_FDPIC_ELF),y)
311         CPU_CFLAGS-y:=-mfdpic
312         CPU_LDFLAGS-y += -Wl,-melf32bfinfd
313         PICFLAG:=-fpic
314         PIEFLAG_NAME:=-fpie
315 endif
316 ifeq ($(UCLIBC_FORMAT_SHARED_FLAT),y)
317         PICFLAG := -mleaf-id-shared-library
318 endif
319 endif
320
321 ifeq ($(TARGET_ARCH),frv)
322         CPU_LDFLAGS-$(CONFIG_FRV)+=-Wl,-melf32frvfd
323         # Using -pie causes the program to have an interpreter, which is
324         # forbidden, so we must make do with -shared.  Unfortunately,
325         # -shared by itself would get us global function descriptors
326         # and calls through PLTs, dynamic resolution of symbols, etc,
327         # which would break as well, but -Bsymbolic comes to the rescue.
328         export LDPIEFLAG:=-Wl,-shared -Wl,-Bsymbolic
329         UCLIBC_LDSO=ld.so.1
330 endif
331
332 ifeq ($(strip $(TARGET_ARCH)),avr32)
333        CPU_CFLAGS-$(CONFIG_AVR32_AP7)  += -march=ap
334        CPU_CFLAGS-$(CONFIG_LINKRELAX)  += -mrelax
335        CPU_LDFLAGS-$(CONFIG_LINKRELAX) += --relax
336 endif
337
338 # Keep the check_gcc from being needlessly executed
339 ifndef PIEFLAG
340 ifneq ($(UCLIBC_BUILD_PIE),y)
341 export PIEFLAG:=
342 else
343 export PIEFLAG:=$(call check_gcc,$(PIEFLAG_NAME),$(PICFLAG))
344 endif
345 endif
346 # We need to keep track of both the CC PIE flag (above) as
347 # well as the LD PIE flag (below) because we can't rely on
348 # gcc passing -pie if we used -fPIE
349 ifndef LDPIEFLAG
350 ifneq ($(UCLIBC_BUILD_PIE),y)
351 export LDPIEFLAG:=
352 else
353 export LDPIEFLAG:=$(shell $(LD) --help 2>/dev/null | grep -q -- -pie && echo "-Wl,-pie")
354 endif
355 endif
356
357 # Check for AS_NEEDED support in linker script (binutils>=2.16.1 has it)
358 ifndef ASNEEDED
359 export ASNEEDED:=$(shell $(LD) --help 2>/dev/null | grep -q -- --as-needed && echo "AS_NEEDED ( $(UCLIBC_LDSO) )" || echo "$(UCLIBC_LDSO)")
360 endif
361
362 # Add a bunch of extra pedantic annoyingly strict checks
363 XWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes -fno-strict-aliasing
364 ifeq ($(EXTRA_WARNINGS),y)
365 XWARNINGS+=-Wnested-externs -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wformat=2
366 XWARNINGS+=-Wmissing-prototypes -Wmissing-declarations
367 XWARNINGS+=-Wnonnull -Wundef
368 # works only w/ gcc-3.4 and up, can't be checked for gcc-3.x w/ check_gcc()
369 #XWARNINGS+=-Wdeclaration-after-statement
370 endif
371 XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS)))
372 CPU_CFLAGS=$(subst ",, $(strip $(CPU_CFLAGS-y)))
373
374 SSP_DISABLE_FLAGS ?= $(call check_gcc,-fno-stack-protector,)
375 ifeq ($(UCLIBC_BUILD_SSP),y)
376 SSP_CFLAGS := $(call check_gcc,-fno-stack-protector-all,)
377 SSP_CFLAGS += $(call check_gcc,-fstack-protector,)
378 SSP_ALL_CFLAGS ?= $(call check_gcc,-fstack-protector-all,)
379 else
380 SSP_CFLAGS := $(SSP_DISABLE_FLAGS)
381 endif
382
383 # Some nice CFLAGS to work with
384 CFLAGS := -include $(top_builddir)include/libc-symbols.h \
385         $(XWARNINGS) $(CPU_CFLAGS) $(SSP_CFLAGS) \
386         -fno-builtin -nostdinc -I$(top_builddir)include -I.
387
388 ifneq ($(strip $(UCLIBC_EXTRA_CFLAGS)),"")
389 CFLAGS += $(subst ",, $(UCLIBC_EXTRA_CFLAGS))
390 endif
391
392 LDADD_LIBFLOAT=
393 ifeq ($(UCLIBC_HAS_SOFT_FLOAT),y)
394 # If -msoft-float isn't supported, we want an error anyway.
395 # Hmm... might need to revisit this for arm since it has 2 different
396 # soft float encodings.
397 ifneq ($(TARGET_ARCH),nios)
398 ifneq ($(TARGET_ARCH),nios2)
399 CFLAGS += -msoft-float
400 endif
401 endif
402 ifeq ($(TARGET_ARCH),arm)
403 # No longer needed with current toolchains, but leave it here for now.
404 # If anyone is actually still using gcc 2.95 (say), they can uncomment it.
405 #    LDADD_LIBFLOAT=-lfloat
406 endif
407 endif
408
409 # We need this to be checked within libc-symbols.h
410 ifneq ($(HAVE_SHARED),y)
411 CFLAGS += -DSTATIC
412 endif
413
414 CFLAGS += $(call check_gcc,-std=gnu99,)
415
416 LDFLAGS_NOSTRIP:=$(CPU_LDFLAGS-y) -Wl,-shared \
417         -Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc
418 # binutils-2.16.1 warns about ignored sections, 2.16.91.0.3 and newer are ok
419 #LDFLAGS_NOSTRIP+=$(call check_ld,--gc-sections)
420
421 ifeq ($(UCLIBC_BUILD_RELRO),y)
422 LDFLAGS_NOSTRIP+=-Wl,-z,relro
423 endif
424
425 ifeq ($(UCLIBC_BUILD_NOW),y)
426 LDFLAGS_NOSTRIP+=-Wl,-z,now
427 endif
428
429 ifeq ($(LDSO_GNU_HASH_SUPPORT),y)
430 # Be sure that binutils support it
431 LDFLAGS_GNUHASH:=$(call check_ld,--hash-style=gnu)
432 ifeq ($(LDFLAGS_GNUHASH),)
433 $(error Your binutils don't support --hash-style option, while you want to use it)
434 else
435 LDFLAGS_NOSTRIP += -Wl,$(LDFLAGS_GNUHASH)
436 endif
437 endif
438
439 LDFLAGS:=$(LDFLAGS_NOSTRIP) -Wl,-z,defs
440 ifeq ($(DODEBUG),y)
441 #CFLAGS += -g3
442 CFLAGS += -O0 -g3
443 else
444 CFLAGS += $(OPTIMIZATION) $(XARCH_CFLAGS)
445 endif
446 ifeq ($(DOSTRIP),y)
447 LDFLAGS += -Wl,-s
448 else
449 STRIPTOOL := true -Stripping_disabled
450 endif
451
452 ifeq ($(DOMULTI),y)
453 # we try to compile all sources at once into an object (IMA), but
454 # gcc-3.3.x does not support it
455 # gcc-3.4.x supports it, but does not need and support --combine. though fails on many sources
456 # gcc-4.0.x supports it, supports the --combine flag, but does not need it
457 # gcc-4.1(200506xx) supports it, but needs the --combine flag, else libs are useless
458 ifeq ($(GCC_MAJOR_VER),3)
459 DOMULTI:=n
460 else
461 CFLAGS+=$(call check_gcc,--combine,)
462 endif
463 else
464 DOMULTI:=n
465 endif
466
467 ifneq ($(strip $(UCLIBC_EXTRA_LDFLAGS)),"")
468 LDFLAGS += $(subst ",, $(UCLIBC_EXTRA_LDFLAGS))
469 endif
470
471 ifeq ($(UCLIBC_HAS_THREADS),y)
472 ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
473         PTNAME := nptl
474 else
475 ifeq ($(LINUXTHREADS_OLD),y)
476         PTNAME := linuxthreads.old
477 else
478         PTNAME := linuxthreads
479 endif
480 endif
481 PTDIR := $(top_builddir)libpthread/$(PTNAME)
482 # set up system dependencies include dirs (NOTE: order matters!)
483 ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
484 PTINC:= -I$(PTDIR)                                              \
485         -I$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)       \
486         -I$(PTDIR)/sysdeps/$(TARGET_ARCH)                       \
487         -I$(PTDIR)/sysdeps/unix/sysv/linux                      \
488         -I$(PTDIR)/sysdeps/pthread                              \
489         -I$(PTDIR)/sysdeps/pthread/bits                         \
490         -I$(PTDIR)/sysdeps/generic                              \
491         -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH)                 \
492         -I$(top_srcdir)ldso/include
493 #
494 # Test for TLS if NPTL support was selected.
495 #
496 GCC_HAS_TLS=$(shell \
497         echo "extern __thread int foo;" | $(CC) -o /dev/null -S -xc - 2>&1)
498 ifneq ($(GCC_HAS_TLS),)
499 gcc_tls_test_fail:
500         @echo "####";
501         @echo "#### Your compiler does not support TLS and you are trying to build uClibc";
502         @echo "#### with NPTL support. Upgrade your binutils and gcc to versions which";
503         @echo "#### support TLS for your architecture. Do not contact uClibc maintainers";
504         @echo "#### about this problem.";
505         @echo "####";
506         @echo "#### Exiting...";
507         @echo "####";
508         @exit 1;
509 endif
510 else
511 PTINC := \
512         -I$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH) \
513         -I$(PTDIR)/sysdeps/$(TARGET_ARCH) \
514         -I$(PTDIR)/sysdeps/unix/sysv/linux \
515         -I$(PTDIR)/sysdeps/pthread \
516         -I$(PTDIR) \
517         -I$(top_builddir)libpthread
518 endif
519 CFLAGS+=$(PTINC)
520 else
521         PTNAME :=
522         PTINC  :=
523 endif
524 CFLAGS += -I$(KERNEL_HEADERS)
525
526 CFLAGS += -iwithprefix include-fixed -iwithprefix include
527
528 ifneq ($(DOASSERTS),y)
529 CFLAGS+=-DNDEBUG
530 endif
531
532 # Keep the check_as from being needlessly executed
533 ifndef ASFLAGS_NOEXEC
534 ifeq ($(UCLIBC_BUILD_NOEXECSTACK),y)
535 export ASFLAGS_NOEXEC := $(call check_as,--noexecstack)
536 else
537 export ASFLAGS_NOEXEC :=
538 endif
539 endif
540 ASFLAGS = $(ASFLAGS_NOEXEC)
541
542 LIBGCC_CFLAGS ?= $(CFLAGS) $(CPU_CFLAGS-y)
543 LIBGCC:=$(shell $(CC) $(LIBGCC_CFLAGS) -print-libgcc-file-name)
544 LIBGCC_DIR:=$(dir $(LIBGCC))
545
546 # moved from libpthread/linuxthreads
547 ifeq ($(UCLIBC_CTOR_DTOR),y)
548 SHARED_START_FILES:=$(top_builddir)lib/crti.o $(LIBGCC_DIR)crtbeginS.o
549 SHARED_END_FILES:=$(LIBGCC_DIR)crtendS.o $(top_builddir)lib/crtn.o
550 endif