OSDN Git Service

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