OSDN Git Service

Rehash the PowerPC e500 port to avoid creating symlinks
[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 endif
292
293 ifeq ($(TARGET_ARCH),frv)
294         CPU_LDFLAGS-$(CONFIG_FRV)+=-melf32frvfd
295         # Using -pie causes the program to have an interpreter, which is
296         # forbidden, so we must make do with -shared.  Unfortunately,
297         # -shared by itself would get us global function descriptors
298         # and calls through PLTs, dynamic resolution of symbols, etc,
299         # which would break as well, but -Bsymbolic comes to the rescue.
300         export LDPIEFLAG:=-shared -Bsymbolic
301         UCLIBC_LDSO=ld.so.1
302 endif
303
304 # Keep the check_gcc from being needlessly executed
305 ifndef PIEFLAG
306 ifneq ($(UCLIBC_BUILD_PIE),y)
307 export PIEFLAG:=
308 else
309 export PIEFLAG:=$(call check_gcc,$(PIEFLAG_NAME),$(PICFLAG))
310 endif
311 endif
312 # We need to keep track of both the CC PIE flag (above) as
313 # well as the LD PIE flag (below) because we can't rely on
314 # gcc passing -pie if we used -fPIE
315 ifndef LDPIEFLAG
316 ifneq ($(UCLIBC_BUILD_PIE),y)
317 export LDPIEFLAG:=
318 else
319 export LDPIEFLAG:=$(shell $(LD) --help 2>/dev/null | grep -q -- -pie && echo "-Wl,-pie")
320 endif
321 endif
322
323 # Check for AS_NEEDED support in linker script (binutils>=2.16.1 has it)
324 ifndef ASNEEDED
325 ifneq ($(UCLIBC_HAS_SSP),y)
326 export ASNEEDED:=
327 else
328 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 ) )
329 endif
330 endif
331
332 # Add a bunch of extra pedantic annoyingly strict checks
333 XWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes -fno-strict-aliasing
334 ifeq ($(EXTRA_WARNINGS),y)
335 XWARNINGS+=-Wnested-externs -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wformat=2
336 XWARNINGS+=-Wmissing-prototypes -Wmissing-declarations
337 XWARNINGS+=-Wnonnull -Wundef
338 # works only w/ gcc-3.4 and up, can't be checked for gcc-3.x w/ check_gcc()
339 #XWARNINGS+=-Wdeclaration-after-statement
340 endif
341 XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS)))
342 CPU_CFLAGS=$(subst ",, $(strip $(CPU_CFLAGS-y)))
343
344 SSP_DISABLE_FLAGS ?= $(call check_gcc,-fno-stack-protector,)
345 ifeq ($(UCLIBC_BUILD_SSP),y)
346 SSP_CFLAGS := $(call check_gcc,-fno-stack-protector-all,)
347 SSP_CFLAGS += $(call check_gcc,-fstack-protector,)
348 SSP_ALL_CFLAGS ?= $(call check_gcc,-fstack-protector-all,)
349 else
350 SSP_CFLAGS := $(SSP_DISABLE_FLAGS)
351 endif
352
353 # Some nice CFLAGS to work with
354 CFLAGS := -include $(top_builddir)include/libc-symbols.h \
355         $(XWARNINGS) $(CPU_CFLAGS) $(SSP_CFLAGS) \
356         -fno-builtin -nostdinc -I$(top_builddir)include -I.
357
358 ifneq ($(strip $(UCLIBC_EXTRA_CFLAGS)),"")
359 CFLAGS += $(subst ",, $(UCLIBC_EXTRA_CFLAGS))
360 endif
361
362 LDADD_LIBFLOAT=
363 ifeq ($(UCLIBC_HAS_SOFT_FLOAT),y)
364 # If -msoft-float isn't supported, we want an error anyway.
365 # Hmm... might need to revisit this for arm since it has 2 different
366 # soft float encodings.
367 ifneq ($(TARGET_ARCH),nios)
368 ifneq ($(TARGET_ARCH),nios2)
369 CFLAGS += -msoft-float
370 endif
371 endif
372 ifeq ($(TARGET_ARCH),arm)
373 # No longer needed with current toolchains, but leave it here for now.
374 # If anyone is actually still using gcc 2.95 (say), they can uncomment it.
375 #    LDADD_LIBFLOAT=-lfloat
376 endif
377 endif
378
379 # Make sure "char" behavior is the same everywhere
380 CFLAGS += -fsigned-char
381
382 # We need this to be checked within libc-symbols.h
383 ifneq ($(HAVE_SHARED),y)
384 CFLAGS += -DSTATIC
385 endif
386
387 CFLAGS += $(call check_gcc,-std=gnu99,)
388
389 LDFLAGS_NOSTRIP:=$(CPU_LDFLAGS-y) -shared --warn-common --warn-once -z combreloc
390 # binutils-2.16.1 warns about ignored sections, 2.16.91.0.3 and newer are ok
391 #LDFLAGS_NOSTRIP+=$(call check_ld,--gc-sections)
392
393 ifeq ($(UCLIBC_BUILD_RELRO),y)
394 LDFLAGS_NOSTRIP+=-z relro
395 endif
396
397 ifeq ($(UCLIBC_BUILD_NOW),y)
398 LDFLAGS_NOSTRIP+=-z now
399 endif
400
401 LDFLAGS:=$(LDFLAGS_NOSTRIP) -z defs
402 ifeq ($(DODEBUG),y)
403 #CFLAGS += -g3
404 CFLAGS += -O0 -g3
405 else
406 CFLAGS += $(OPTIMIZATION) $(XARCH_CFLAGS)
407 endif
408 ifeq ($(DOSTRIP),y)
409 LDFLAGS += -s
410 else
411 STRIPTOOL := true -Stripping_disabled
412 endif
413
414 ifeq ($(DOMULTI),y)
415 # we try to compile all sources at once into an object (IMA), but
416 # gcc-3.3.x does not support it
417 # gcc-3.4.x supports it, but does not need and support --combine. though fails on many sources
418 # gcc-4.0.x supports it, supports the --combine flag, but does not need it
419 # gcc-4.1(200506xx) supports it, but needs the --combine flag, else libs are useless
420 ifeq ($(GCC_MAJOR_VER),3)
421 DOMULTI:=n
422 else
423 CFLAGS+=$(call check_gcc,--combine,)
424 endif
425 else
426 DOMULTI:=n
427 endif
428
429 ifeq ($(UCLIBC_HAS_THREADS),y)
430 ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
431         PTNAME := nptl
432 else
433 ifeq ($(LINUXTHREADS_OLD),y)
434         PTNAME := linuxthreads.old
435 else
436         PTNAME := linuxthreads
437 endif
438 endif
439 PTDIR := $(top_builddir)libpthread/$(PTNAME)
440 # set up system dependencies include dirs (NOTE: order matters!)
441 ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
442 PTINC:= -I$(PTDIR)                                              \
443         -I$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)       \
444         -I$(PTDIR)/sysdeps/$(TARGET_ARCH)                       \
445         -I$(PTDIR)/sysdeps/unix/sysv/linux                      \
446         -I$(PTDIR)/sysdeps/pthread                              \
447         -I$(PTDIR)/sysdeps/pthread/bits                         \
448         -I$(PTDIR)/sysdeps/generic                              \
449         -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH)                 \
450         -I$(top_srcdir)ldso/include
451 #
452 # Test for TLS if NPTL support was selected.
453 #
454 GCC_HAS_TLS=$(shell \
455         echo "extern __thread int foo;" | $(CC) -o /dev/null -S -xc - 2>&1)
456 ifneq ($(GCC_HAS_TLS),)
457 gcc_tls_test_fail:
458         @echo "####";
459         @echo "#### Your compiler does not support TLS and you are trying to build uClibc";
460         @echo "#### with NPTL support. Upgrade your binutils and gcc to versions which";
461         @echo "#### support TLS for your architecture. Do not contact uClibc maintainers";
462         @echo "#### about this problem.";
463         @echo "####";
464         @echo "#### Exiting...";
465         @echo "####";
466         @exit 1;
467 endif
468 else
469 PTINC := \
470         -I$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH) \
471         -I$(PTDIR)/sysdeps/$(TARGET_ARCH) \
472         -I$(PTDIR)/sysdeps/unix/sysv/linux \
473         -I$(PTDIR)/sysdeps/pthread \
474         -I$(PTDIR) \
475         -I$(top_builddir)libpthread
476 endif
477 CFLAGS+=$(PTINC)
478 else
479         PTNAME :=
480         PTINC  :=
481 endif
482 CFLAGS += -I$(KERNEL_HEADERS)
483
484 # Sigh, some stupid versions of gcc can't seem to cope with '-iwithprefix include'
485 #CFLAGS+=-iwithprefix include
486 CFLAGS+=-isystem $(shell $(CC) -print-file-name=include)
487
488 ifneq ($(DOASSERTS),y)
489 CFLAGS+=-DNDEBUG
490 endif
491
492 # Keep the check_as from being needlessly executed
493 ifndef ASFLAGS_NOEXEC
494 ifeq ($(UCLIBC_BUILD_NOEXECSTACK),y)
495 export ASFLAGS_NOEXEC := $(call check_as,--noexecstack)
496 else
497 export ASFLAGS_NOEXEC :=
498 endif
499 endif
500 ASFLAGS = $(ASFLAGS_NOEXEC)
501
502 LIBGCC_CFLAGS ?= $(CFLAGS) $(CPU_CFLAGS-y)
503 LIBGCC:=$(shell $(CC) $(LIBGCC_CFLAGS) -print-libgcc-file-name)
504 LIBGCC_DIR:=$(dir $(LIBGCC))
505
506 # moved from libpthread/linuxthreads
507 ifeq ($(UCLIBC_CTOR_DTOR),y)
508 SHARED_START_FILES:=$(top_builddir)lib/crti.o $(LIBGCC_DIR)crtbeginS.o
509 SHARED_END_FILES:=$(LIBGCC_DIR)crtendS.o $(top_builddir)lib/crtn.o
510 endif