OSDN Git Service

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