]> Git Repo - uclibc-ng.git/blame - Rules.mak
Do not produce spurious "/bin/sh: [: too many arguments" if
[uclibc-ng.git] / Rules.mak
CommitLineData
2c8e931c 1# Rules.make for uClibc
af1112c8 2#
4b204436 3# Copyright (C) 2000-2006 Erik Andersen <[email protected]>
af1112c8 4#
15870aba 5# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
af1112c8 6#
f149abb8 7
a4d40bdd
MF
8# check for proper make version
9ifneq ($(findstring 3.7,$(MAKE_VERSION)),)
10$(error Your make is too old $(MAKE_VERSION). Go get at least 3.80)
11endif
12
5f9dfa09
MF
13#-----------------------------------------------------------
14# This file contains rules which are shared between multiple
73c81126
EA
15# Makefiles. All normal configuration options live in the
16# file named ".config". Don't mess with this file unless
5f9dfa09 17# you know what you are doing.
f149abb8
EA
18
19
5f9dfa09 20#-----------------------------------------------------------
73c81126
EA
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
5f9dfa09 25# broken, you should not need to specify TARGET_ARCH.
f149abb8
EA
26#
27# Most people will set this stuff on the command line, i.e.
f21f7c41
EA
28# make CROSS=arm-linux-
29# will build uClibc for 'arm'.
f149abb8 30
b2eb218f 31ifndef CROSS
c92bcb00 32CROSS=
b2eb218f 33endif
5f9dfa09
MF
34CC = $(CROSS)gcc
35AR = $(CROSS)ar
36LD = $(CROSS)ld
37NM = $(CROSS)nm
5f9dfa09 38STRIPTOOL = $(CROSS)strip
6737908f 39
5f9dfa09
MF
40INSTALL = install
41LN = ln
42RM = rm -f
3a0333ee 43TAR = tar
49f0dd0f 44
a9d7ad63
MF
45STRIP_FLAGS ?= -x -R .note -R .comment
46
6737908f 47# Select the compiler needed to build binaries for your development system
5f9dfa09 48HOSTCC = gcc
905b94ad 49BUILD_CFLAGS = -O2 -Wall
6737908f 50
af1112c8 51
5f9dfa09
MF
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.
d874cc67
MF
56
57# Pull in the user's uClibc configuration
58ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
59-include $(top_builddir).config
60endif
61
62# Make certain these contain a final "/", but no "//"s.
63TARGET_ARCH:=$(shell grep -s '^TARGET_ARCH' $(top_builddir)/.config | sed -e 's/^TARGET_ARCH=//' -e 's/"//g')
64TARGET_ARCH:=$(strip $(subst ",, $(strip $(TARGET_ARCH))))
dcf24118
JT
65TARGET_SUBARCH:=$(shell grep -s '^TARGET_SUBARCH' $(top_builddir)/.config | sed -e 's/^TARGET_SUBARCH=//' -e 's/"//g')
66TARGET_SUBARCH:=$(strip $(subst ",, $(strip $(TARGET_SUBARCH))))
d874cc67
MF
67RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(RUNTIME_PREFIX))))))
68DEVEL_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(DEVEL_PREFIX))))))
08e377aa
MF
69KERNEL_HEADERS:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(KERNEL_HEADERS))))))
70export RUNTIME_PREFIX DEVEL_PREFIX KERNEL_HEADERS
d874cc67
MF
71
72
73# Now config hard core
5f9dfa09
MF
74MAJOR_VERSION := 0
75MINOR_VERSION := 9
e3c51c27 76SUBLEVEL := 29
5f9dfa09 77VERSION := $(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL)
2c84741c 78# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
5f9dfa09 79LC_ALL := C
f5636fb2 80export MAJOR_VERSION MINOR_VERSION SUBLEVEL VERSION LC_ALL
58bd16ab 81
15870aba
PM
82LIBC := libc
83SHARED_MAJORNAME := $(LIBC).so.$(MAJOR_VERSION)
e9da7cba 84ifneq ($(findstring $(TARGET_ARCH) , hppa64 ia64 mips64 powerpc64 s390x sh64 sparc64 x86_64 ),)
d874cc67 85UCLIBC_LDSO_NAME := ld64-uClibc
e9da7cba
MF
86else
87UCLIBC_LDSO_NAME := ld-uClibc
d874cc67
MF
88endif
89UCLIBC_LDSO := $(UCLIBC_LDSO_NAME).so.$(MAJOR_VERSION)
15870aba 90NONSHARED_LIBNAME := uclibc_nonshared.a
cf5e4b82 91libc := $(top_builddir)lib/$(SHARED_MAJORNAME)
72c0f6a2
PM
92interp := $(top_builddir)lib/interp.os
93ldso := $(top_builddir)lib/$(UCLIBC_LDSO)
3c45ffd2 94headers_dep := $(top_builddir)include/bits/sysnum.h
94c41e72 95sub_headers := $(headers_dep)
15870aba 96
5937c62e 97#LIBS :=$(interp) -L$(top_builddir)lib -lc
cf5e4b82 98LIBS := $(interp) -L$(top_builddir)lib $(libc:.$(MAJOR_VERSION)=)
c75d8083 99
129b1d71
MF
100# Make sure DESTDIR and PREFIX can be used to install
101# PREFIX is a uClibcism while DESTDIR is a common GNUism
102ifndef PREFIX
103PREFIX = $(DESTDIR)
104endif
105
4b204436
MF
106ifneq ($(HAVE_SHARED),y)
107libc :=
c57c6023
PM
108interp :=
109ldso :=
4b204436
MF
110endif
111
05827f4c 112ifndef CROSS
ce23f5cd 113CROSS=$(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
05827f4c
MF
114endif
115
efe79476 116# A nifty macro to make testing gcc features easier
8c9cfb76
MF
117check_gcc=$(shell \
118 if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
efe79476 119 then echo "$(1)"; else echo "$(2)"; fi)
8c9cfb76
MF
120check_as=$(shell \
121 if $(CC) -Wa,$(1) -Wa,-Z -c -o /dev/null -xassembler /dev/null > /dev/null 2>&1; \
75ca73f4 122 then echo "-Wa,$(1)"; fi)
749dbd6e
PK
123check_ld=$(shell \
124 if $(LD) $(1) -o /dev/null -b binary /dev/null > /dev/null 2>&1; \
125 then echo "$(1)"; fi)
efe79476 126
e970fad1 127ARFLAGS:=cr
aa966844 128
efe79476 129OPTIMIZATION:=
f350d5a2
PM
130# Use '-Os' optimization if available, else use -O2, allow Config to override
131OPTIMIZATION+=$(call check_gcc,-Os,-O2)
132# Use the gcc 3.4 -funit-at-a-time optimization when available
133OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,)
134
135GCC_MAJOR_VER?=$(shell $(CC) -dumpversion | cut -d . -f 1)
136#GCC_MINOR_VER?=$(shell $(CC) -dumpversion | cut -d . -f 2)
137
138ifeq ($(GCC_MAJOR_VER),4)
139# shrinks code, results are from 4.0.2
140# 0.36%
141OPTIMIZATION+=$(call check_gcc,-fno-tree-loop-optimize,)
142# 0.34%
143OPTIMIZATION+=$(call check_gcc,-fno-tree-dominator-opts,)
144# 0.1%
145OPTIMIZATION+=$(call check_gcc,-fno-strength-reduce,)
146endif
147
14db067a
MF
148ifeq ($(UCLIBC_FORMAT_FDPIC_ELF),y)
149 PICFLAG:=-mfdpic
150else
151 PICFLAG:=-fPIC
152endif
ce5d0580 153PIEFLAG_NAME:=-fPIE
4efa075c 154
0c6405c1 155# Some nice CPU specific optimizations
15870aba 156ifeq ($(TARGET_ARCH),i386)
efe79476 157 OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,)
0c6405c1 158 OPTIMIZATION+=$(call check_gcc,-falign-jumps=0 -falign-loops=0,-malign-jumps=0 -malign-loops=0)
6a2d1ca4
EA
159 CPU_CFLAGS-$(CONFIG_386)+=-march=i386
160 CPU_CFLAGS-$(CONFIG_486)+=-march=i486
bbab258a 161 CPU_CFLAGS-$(CONFIG_ELAN)+=-march=i486
6a2d1ca4
EA
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
bbab258a 165 CPU_CFLAGS-$(CONFIG_PENTIUMII)+=$(call check_gcc,-march=pentium2,-march=i686)
6a2d1ca4
EA
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)
e1ac781e
MF
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)
6a2d1ca4
EA
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)
e1ac781e 173 CPU_CFLAGS-$(CONFIG_CYRIXIII)+=$(call check_gcc,-march=c3,-march=i486) $(call check_gcc,-falign-functions=0,-malign-functions=0)
bbab258a 174 CPU_CFLAGS-$(CONFIG_NEHEMIAH)+=$(call check_gcc,-march=c3-2,-march=i686)
06d634ea 175endif
0c6405c1 176
15870aba 177ifeq ($(TARGET_ARCH),sparc)
4147ffbc
MF
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)
182endif
183
15870aba 184ifeq ($(TARGET_ARCH),arm)
0c6405c1 185 OPTIMIZATION+=-fstrict-aliasing
6a2d1ca4
EA
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
8c98b925
KR
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
6e7076f0 198 CPU_CFLAGS-$(CONFIG_ARM10T)+=-mtune=arm10tdmi -march=armv5t
fcb56ce4 199 CPU_CFLAGS-$(CONFIG_ARM1136JF_S)+=-mtune=arm1136jf-s -march=armv6
6a2d1ca4
EA
200 CPU_CFLAGS-$(CONFIG_ARM_SA110)+=-mtune=strongarm110 -march=armv4
201 CPU_CFLAGS-$(CONFIG_ARM_SA1100)+=-mtune=strongarm1100 -march=armv4
da19a2df 202 CPU_CFLAGS-$(CONFIG_ARM_XSCALE)+=$(call check_gcc,-mtune=xscale,-mtune=strongarm110)
8c98b925 203 CPU_CFLAGS-$(CONFIG_ARM_XSCALE)+=-march=armv5te -Wa,-mcpu=xscale
6e7076f0 204 CPU_CFLAGS-$(CONFIG_ARM_IWMMXT)+=-march=iwmmxt -Wa,-mcpu=iwmmxt -mabi=iwmmxt
0c6405c1
EA
205endif
206
15870aba 207ifeq ($(TARGET_ARCH),mips)
6f65ac29
MF
208 CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN)+=-EL
209 CPU_LDFLAGS-$(ARCH_BIG_ENDIAN)+=-EB
f6552f74
MNI
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
1da8fd92
EA
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
f6552f74
MNI
227endif
228
40770ac3
MF
229ifeq ($(TARGET_ARCH),nios)
230 CPU_LDFLAGS-y+=-m32
231 CPU_CFLAGS-y+=-m32
232endif
233
15870aba 234ifeq ($(TARGET_ARCH),sh)
0c6405c1 235 OPTIMIZATION+=-fstrict-aliasing
f149abb8 236 OPTIMIZATION+= $(call check_gcc,-mprefergot,)
6a2d1ca4
EA
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
3a7ac9c7 243ifeq ($(UCLIBC_HAS_FLOATS),y)
e8a91ad3 244 CPU_CFLAGS-$(CONFIG_SH2A)+=-m2a
6a2d1ca4 245 CPU_CFLAGS-$(CONFIG_SH4)+=-m4
e8a91ad3
PM
246else
247 CPU_CFLAGS-$(CONFIG_SH2A)+=-m2a-nofpu
248 CPU_CFLAGS-$(CONFIG_SH4)+=-m4-nofpu
249endif
533d76fb
EA
250endif
251
15870aba 252ifeq ($(TARGET_ARCH),sh64)
533d76fb 253 OPTIMIZATION+=-fstrict-aliasing
6a2d1ca4
EA
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
5a2610fb 259endif
163df9f2 260
15870aba 261ifeq ($(TARGET_ARCH),h8300)
6a2d1ca4
EA
262 CPU_LDFLAGS-$(CONFIG_H8300H)+= -ms8300h
263 CPU_LDFLAGS-$(CONFIG_H8S) += -ms8300s
c5598b73
MF
264 CPU_CFLAGS-$(CONFIG_H8300H) += -mh -mint32
265 CPU_CFLAGS-$(CONFIG_H8S) += -ms -mint32
de2abcca
EA
266endif
267
15870aba 268ifeq ($(TARGET_ARCH),cris)
6a2d1ca4 269 CPU_LDFLAGS-$(CONFIG_CRIS)+=-mcrislinux
1583fb7f 270 CPU_LDFLAGS-$(CONFIG_CRISV32)+=-mcrislinux
6a2d1ca4 271 CPU_CFLAGS-$(CONFIG_CRIS)+=-mlinux
783a979b 272 PICFLAG:=-fpic
ce5d0580 273 PIEFLAG_NAME:=-fpie
783a979b
JT
274endif
275
39eff515
MF
276ifeq ($(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
281endif
282
15870aba 283ifeq ($(TARGET_ARCH),powerpc)
783a979b
JT
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
ce5d0580 288 PIEFLAG_NAME:=-fpie
e26ed573
JT
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
afb1cd9b
TA
291endif
292
15870aba 293ifeq ($(TARGET_ARCH),frv)
baa67289 294 CPU_LDFLAGS-$(CONFIG_FRV)+=-melf32frvfd
afd3f33a
MF
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
baa67289
EA
301 UCLIBC_LDSO=ld.so.1
302endif
303
8c9cfb76
MF
304# Keep the check_gcc from being needlessly executed
305ifndef PIEFLAG
ce5d0580 306ifneq ($(UCLIBC_BUILD_PIE),y)
8c9cfb76 307export PIEFLAG:=
ce5d0580 308else
afd3f33a
MF
309export PIEFLAG:=$(call check_gcc,$(PIEFLAG_NAME),$(PICFLAG))
310endif
311endif
73c81126
EA
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
afd3f33a
MF
314# gcc passing -pie if we used -fPIE
315ifndef LDPIEFLAG
316ifneq ($(UCLIBC_BUILD_PIE),y)
317export LDPIEFLAG:=
318else
31248ebd 319export LDPIEFLAG:=$(shell $(LD) --help 2>/dev/null | grep -q -- -pie && echo "-Wl,-pie")
8c9cfb76 320endif
ce5d0580
MF
321endif
322
5eef4411
PM
323# Check for AS_NEEDED support in linker script (binutils>=2.16.1 has it)
324ifndef ASNEEDED
325ifneq ($(UCLIBC_HAS_SSP),y)
326export ASNEEDED:=
327else
01c9aec7 328export 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 ) )
5eef4411
PM
329endif
330endif
331
aa966844 332# Add a bunch of extra pedantic annoyingly strict checks
93de5c42 333XWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes -fno-strict-aliasing
e73b1211 334ifeq ($(EXTRA_WARNINGS),y)
a1b552b0 335XWARNINGS+=-Wnested-externs -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wformat=2
1466eb28 336XWARNINGS+=-Wmissing-prototypes -Wmissing-declarations
d50a7288 337XWARNINGS+=-Wnonnull -Wundef
a1b552b0
PM
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
e73b1211 340endif
b340985b 341XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS)))
c52c2a24 342CPU_CFLAGS=$(subst ",, $(strip $(CPU_CFLAGS-y)))
53d8027c 343
c57c6023
PM
344SSP_DISABLE_FLAGS ?= $(call check_gcc,-fno-stack-protector,)
345ifeq ($(UCLIBC_BUILD_SSP),y)
346SSP_CFLAGS := $(call check_gcc,-fno-stack-protector-all,)
347SSP_CFLAGS += $(call check_gcc,-fstack-protector,)
348SSP_ALL_CFLAGS ?= $(call check_gcc,-fstack-protector-all,)
349else
350SSP_CFLAGS := $(SSP_DISABLE_FLAGS)
351endif
c5598b73 352
c57c6023
PM
353# Some nice CFLAGS to work with
354CFLAGS := -include $(top_builddir)include/libc-symbols.h \
355 $(XWARNINGS) $(CPU_CFLAGS) $(SSP_CFLAGS) \
356 -fno-builtin -nostdinc -I$(top_builddir)include -I.
a1b552b0 357
8ceaf7c7
JT
358ifneq ($(strip $(UCLIBC_EXTRA_CFLAGS)),"")
359CFLAGS += $(subst ",, $(UCLIBC_EXTRA_CFLAGS))
360endif
361
53d8027c 362LDADD_LIBFLOAT=
3a7ac9c7 363ifeq ($(UCLIBC_HAS_SOFT_FLOAT),y)
53d8027c 364# If -msoft-float isn't supported, we want an error anyway.
3c44c596
MNI
365# Hmm... might need to revisit this for arm since it has 2 different
366# soft float encodings.
40770ac3 367ifneq ($(TARGET_ARCH),nios)
d38e11bd 368ifneq ($(TARGET_ARCH),nios2)
c57c6023 369CFLAGS += -msoft-float
5ddfefa4 370endif
40770ac3 371endif
15870aba 372ifeq ($(TARGET_ARCH),arm)
3c44c596
MNI
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
53d8027c
MNI
376endif
377endif
378
c57c6023
PM
379# Make sure "char" behavior is the same everywhere
380CFLAGS += -fsigned-char
381
382# We need this to be checked within libc-symbols.h
383ifneq ($(HAVE_SHARED),y)
384CFLAGS += -DSTATIC
9d7a22d3
MNI
385endif
386
33fa6c8e 387CFLAGS += $(call check_gcc,-std=gnu99,)
aa966844 388
15870aba 389LDFLAGS_NOSTRIP:=$(CPU_LDFLAGS-y) -shared --warn-common --warn-once -z combreloc
89736cf6 390# binutils-2.16.1 warns about ignored sections, 2.16.91.0.3 and newer are ok
e619cc8e 391#LDFLAGS_NOSTRIP+=$(call check_ld,--gc-sections)
15870aba
PM
392
393ifeq ($(UCLIBC_BUILD_RELRO),y)
394LDFLAGS_NOSTRIP+=-z relro
395endif
396
397ifeq ($(UCLIBC_BUILD_NOW),y)
398LDFLAGS_NOSTRIP+=-z now
399endif
400
401LDFLAGS:=$(LDFLAGS_NOSTRIP) -z defs
98fd3d6c 402ifeq ($(DODEBUG),y)
f58f2dda
PK
403#CFLAGS += -g3
404CFLAGS += -O0 -g3
98fd3d6c 405else
f58f2dda
PK
406CFLAGS += $(OPTIMIZATION) $(XARCH_CFLAGS)
407endif
66b01e60 408ifeq ($(DOSTRIP),y)
f58f2dda 409LDFLAGS += -s
66b01e60
EA
410else
411STRIPTOOL := true -Stripping_disabled
98fd3d6c
EA
412endif
413
8789ec41 414ifeq ($(DOMULTI),y)
6e3a0044
PM
415# we try to compile all sources at once into an object (IMA), but
416# gcc-3.3.x does not support it
47d8fab8 417# gcc-3.4.x supports it, but does not need and support --combine. though fails on many sources
6e3a0044
PM
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
f350d5a2 420ifeq ($(GCC_MAJOR_VER),3)
8789ec41 421DOMULTI:=n
6e3a0044
PM
422else
423CFLAGS+=$(call check_gcc,--combine,)
424endif
8789ec41
PM
425else
426DOMULTI:=n
427endif
6e3a0044 428
8c7ac6fc 429ifeq ($(UCLIBC_HAS_THREADS),y)
3a7ac9c7 430ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
c0b31e50 431 PTNAME := nptl
a9f5aa1c
MF
432else
433ifeq ($(LINUXTHREADS_OLD),y)
434 PTNAME := linuxthreads.old
c0b31e50
PM
435else
436 PTNAME := linuxthreads
437endif
a9f5aa1c 438endif
5937c62e 439PTDIR := $(top_builddir)libpthread/$(PTNAME)
8c7ac6fc 440# set up system dependencies include dirs (NOTE: order matters!)
3a7ac9c7 441ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
f9edc7cf 442PTINC:= -I$(PTDIR) \
86553e66
PM
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 \
f9edc7cf 449 -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) \
7fec9f92 450 -I$(top_srcdir)ldso/include
a6487435
SH
451#
452# Test for TLS if NPTL support was selected.
453#
454GCC_HAS_TLS=$(shell \
455 echo "extern __thread int foo;" | $(CC) -o /dev/null -S -xc - 2>&1)
456ifneq ($(GCC_HAS_TLS),)
457gcc_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;
467endif
468else
0f85f257 469PTINC := \
680f8428 470 -I$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH) \
0f85f257 471 -I$(PTDIR)/sysdeps/$(TARGET_ARCH) \
680f8428 472 -I$(PTDIR)/sysdeps/unix/sysv/linux \
0f85f257 473 -I$(PTDIR)/sysdeps/pthread \
680f8428
MF
474 -I$(PTDIR) \
475 -I$(top_builddir)libpthread
a6487435 476endif
a80fc77b 477CFLAGS+=$(PTINC)
0f85f257 478else
73c81126
EA
479 PTNAME :=
480 PTINC :=
8c7ac6fc 481endif
08e377aa 482CFLAGS += -I$(KERNEL_HEADERS)
8c7ac6fc 483
4775ec64
EA
484# Sigh, some stupid versions of gcc can't seem to cope with '-iwithprefix include'
485#CFLAGS+=-iwithprefix include
a56073a2 486CFLAGS+=-isystem $(shell $(CC) -print-file-name=include)
4775ec64 487
98fd3d6c 488ifneq ($(DOASSERTS),y)
86553e66 489CFLAGS+=-DNDEBUG
0dd72555 490endif
c5207a55 491
8c9cfb76 492# Keep the check_as from being needlessly executed
8c9cfb76 493ifndef ASFLAGS_NOEXEC
f8e6aa06 494ifeq ($(UCLIBC_BUILD_NOEXECSTACK),y)
8c9cfb76
MF
495export ASFLAGS_NOEXEC := $(call check_as,--noexecstack)
496else
497export ASFLAGS_NOEXEC :=
498endif
f8e6aa06 499endif
8585cd4d 500ASFLAGS = $(ASFLAGS_NOEXEC)
4a56d69f 501
881e6dca 502LIBGCC_CFLAGS ?= $(CFLAGS) $(CPU_CFLAGS-y)
f149abb8
EA
503LIBGCC:=$(shell $(CC) $(LIBGCC_CFLAGS) -print-libgcc-file-name)
504LIBGCC_DIR:=$(dir $(LIBGCC))
505
0a7b9d5d
PM
506# moved from libpthread/linuxthreads
507ifeq ($(UCLIBC_CTOR_DTOR),y)
5937c62e
PM
508SHARED_START_FILES:=$(top_builddir)lib/crti.o $(LIBGCC_DIR)crtbeginS.o
509SHARED_END_FILES:=$(LIBGCC_DIR)crtendS.o $(top_builddir)lib/crtn.o
0a7b9d5d 510endif
This page took 0.243678 seconds and 4 git commands to generate.