OSDN Git Service

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