]> Git Repo - uclibc-ng.git/blame - Rules.mak
Remove __libc_posix_fadvise[64] alias. It existed on i386 and arm only,
[uclibc-ng.git] / Rules.mak
CommitLineData
2c8e931c 1# Rules.make for uClibc
af1112c8 2#
b74c3aa1 3# Copyright (C) 2000-2008 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 8# check for proper make version
9c2d269c 9ifneq ($(findstring x3.7,x$(MAKE_VERSION)),)
a4d40bdd
MF
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
4e885757
BRF
44SED = sed
45AWK = awk
49f0dd0f 46
a9d7ad63
MF
47STRIP_FLAGS ?= -x -R .note -R .comment
48
f2420be7
BRF
49UNIFDEF := $(top_builddir)extra/scripts/unifdef -UUCLIBC_INTERNAL
50
6737908f 51# Select the compiler needed to build binaries for your development system
5f9dfa09 52HOSTCC = gcc
905b94ad 53BUILD_CFLAGS = -O2 -Wall
4e885757
BRF
54export ARCH := $(shell uname -m | $(SED) -e s/i.86/i386/ \
55 -e s/sun.*/sparc/ -e s/sparc.*/sparc/ \
56 -e s/arm.*/arm/ -e s/sa110/arm/ \
57 -e s/sh.*/sh/ \
4e736021 58 -e s/s390x/s390/ -e s/parisc.*/hppa/ \
124ec188
MF
59 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
60 -e s/xtensa.*/xtensa/ )
6737908f 61
af1112c8 62
5f9dfa09
MF
63#---------------------------------------------------------
64# Nothing beyond this point should ever be touched by mere
65# mortals. Unless you hang out with the gods, you should
66# probably leave all this stuff alone.
d874cc67
MF
67
68# Pull in the user's uClibc configuration
69ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
70-include $(top_builddir).config
71endif
72
73# Make certain these contain a final "/", but no "//"s.
4e885757 74TARGET_ARCH:=$(shell grep -s '^TARGET_ARCH' $(top_builddir)/.config | $(SED) -e 's/^TARGET_ARCH=//' -e 's/"//g')
d874cc67 75TARGET_ARCH:=$(strip $(subst ",, $(strip $(TARGET_ARCH))))
4e885757 76TARGET_SUBARCH:=$(shell grep -s '^TARGET_SUBARCH' $(top_builddir)/.config | $(SED) -e 's/^TARGET_SUBARCH=//' -e 's/"//g')
dcf24118 77TARGET_SUBARCH:=$(strip $(subst ",, $(strip $(TARGET_SUBARCH))))
d874cc67
MF
78RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(RUNTIME_PREFIX))))))
79DEVEL_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(DEVEL_PREFIX))))))
08e377aa
MF
80KERNEL_HEADERS:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(KERNEL_HEADERS))))))
81export RUNTIME_PREFIX DEVEL_PREFIX KERNEL_HEADERS
d874cc67
MF
82
83
84# Now config hard core
5f9dfa09
MF
85MAJOR_VERSION := 0
86MINOR_VERSION := 9
c50c578d 87SUBLEVEL := 30
9d6b62ec 88EXTRAVERSION :=-svn
5f9dfa09 89VERSION := $(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL)
6bc45b2d 90ifneq ($(EXTRAVERSION),)
76a888be 91VERSION := $(VERSION)$(EXTRAVERSION)
6bc45b2d 92endif
2c84741c 93# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
5f9dfa09 94LC_ALL := C
f5636fb2 95export MAJOR_VERSION MINOR_VERSION SUBLEVEL VERSION LC_ALL
58bd16ab 96
15870aba
PM
97LIBC := libc
98SHARED_MAJORNAME := $(LIBC).so.$(MAJOR_VERSION)
44784f8a 99ifneq ($(findstring $(TARGET_ARCH) , hppa64 ia64 mips64 powerpc64 s390x sparc64 x86_64 ),)
d874cc67 100UCLIBC_LDSO_NAME := ld64-uClibc
ab600d2a 101ARCH_NATIVE_BIT := 64
e9da7cba
MF
102else
103UCLIBC_LDSO_NAME := ld-uClibc
ab600d2a 104ARCH_NATIVE_BIT := 32
d874cc67
MF
105endif
106UCLIBC_LDSO := $(UCLIBC_LDSO_NAME).so.$(MAJOR_VERSION)
15870aba 107NONSHARED_LIBNAME := uclibc_nonshared.a
cf5e4b82 108libc := $(top_builddir)lib/$(SHARED_MAJORNAME)
68d02d64 109libc.depend := $(top_builddir)lib/$(SHARED_MAJORNAME:.$(MAJOR_VERSION)=)
72c0f6a2
PM
110interp := $(top_builddir)lib/interp.os
111ldso := $(top_builddir)lib/$(UCLIBC_LDSO)
3c45ffd2 112headers_dep := $(top_builddir)include/bits/sysnum.h
94c41e72 113sub_headers := $(headers_dep)
15870aba 114
5937c62e 115#LIBS :=$(interp) -L$(top_builddir)lib -lc
cf5e4b82 116LIBS := $(interp) -L$(top_builddir)lib $(libc:.$(MAJOR_VERSION)=)
c75d8083 117
129b1d71
MF
118# Make sure DESTDIR and PREFIX can be used to install
119# PREFIX is a uClibcism while DESTDIR is a common GNUism
120ifndef PREFIX
121PREFIX = $(DESTDIR)
122endif
123
4b204436
MF
124ifneq ($(HAVE_SHARED),y)
125libc :=
c57c6023
PM
126interp :=
127ldso :=
4b204436
MF
128endif
129
51ce75b5
BRF
130comma:=,
131space:= #
132
05827f4c 133ifndef CROSS
b74c3aa1 134CROSS=$(strip $(subst ",, $(CROSS_COMPILER_PREFIX)))
05827f4c
MF
135endif
136
efe79476 137# A nifty macro to make testing gcc features easier
8c9cfb76
MF
138check_gcc=$(shell \
139 if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
efe79476 140 then echo "$(1)"; else echo "$(2)"; fi)
8c9cfb76
MF
141check_as=$(shell \
142 if $(CC) -Wa,$(1) -Wa,-Z -c -o /dev/null -xassembler /dev/null > /dev/null 2>&1; \
75ca73f4 143 then echo "-Wa,$(1)"; fi)
749dbd6e
PK
144check_ld=$(shell \
145 if $(LD) $(1) -o /dev/null -b binary /dev/null > /dev/null 2>&1; \
146 then echo "$(1)"; fi)
efe79476 147
e970fad1 148ARFLAGS:=cr
aa966844 149
e348b8f7 150# Flags in OPTIMIZATION are used only for non-debug builds
efe79476 151OPTIMIZATION:=
f350d5a2
PM
152# Use '-Os' optimization if available, else use -O2, allow Config to override
153OPTIMIZATION+=$(call check_gcc,-Os,-O2)
154# Use the gcc 3.4 -funit-at-a-time optimization when available
155OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,)
156
157GCC_MAJOR_VER?=$(shell $(CC) -dumpversion | cut -d . -f 1)
158#GCC_MINOR_VER?=$(shell $(CC) -dumpversion | cut -d . -f 2)
159
160ifeq ($(GCC_MAJOR_VER),4)
161# shrinks code, results are from 4.0.2
162# 0.36%
163OPTIMIZATION+=$(call check_gcc,-fno-tree-loop-optimize,)
164# 0.34%
165OPTIMIZATION+=$(call check_gcc,-fno-tree-dominator-opts,)
166# 0.1%
167OPTIMIZATION+=$(call check_gcc,-fno-strength-reduce,)
168endif
169
dcad31e6
MF
170CPU_CFLAGS-$(UCLIBC_FORMAT_SHARED_FLAT) += -mid-shared-library
171CPU_CFLAGS-$(UCLIBC_FORMAT_FLAT_SEP_DATA) += -msep-data
172
173PICFLAG-y := -fPIC
174PICFLAG-$(UCLIBC_FORMAT_FDPIC_ELF) := -mfdpic
f2410a17 175PICFLAG := $(PICFLAG-y)
ce5d0580 176PIEFLAG_NAME:=-fPIE
4efa075c 177
0c6405c1 178# Some nice CPU specific optimizations
15870aba 179ifeq ($(TARGET_ARCH),i386)
e348b8f7
DV
180 OPTIMIZATION+=$(call check_gcc,-fomit-frame-pointer,)
181
5196e42e
DV
182ifeq ($(CONFIG_386)$(CONFIG_486)$(CONFIG_586)$(CONFIG_586MMX),y)
183 # Non-SSE capable processor.
e348b8f7
DV
184 # NB: this may make SSE insns segfault!
185 # -O1 -march=pentium3, -Os -msse etc are known to be affected.
5196e42e
DV
186 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13685
187 OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,)
188else
f2420be7 189 OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=4,)
5196e42e 190endif
e348b8f7
DV
191
192 # Choice of alignment (please document why!)
193 # -falign-labels: in-line labels
194 # (reachable by normal code flow, aligning will insert nops
195 # which will be executed - may even make things slower)
196 # -falign-jumps: reachable only by a jump
197 # Generic: no alignment at all (smallest code)
198 GCC_FALIGN=$(call check_gcc,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,-malign-jumps=1 -malign-loops=1)
199ifeq ($(CONFIG_K7),y)
9f59aad1
DV
200 # Align functions to four bytes, use default for jumps and loops (why?)
201 GCC_FALIGN=$(call check_gcc,-falign-functions=4 -falign-labels=1,-malign-functions=4)
e348b8f7
DV
202endif
203ifeq ($(CONFIG_CRUSOE),y)
9f59aad1
DV
204 # Use compiler's default for functions, jumps and loops (why?)
205 GCC_FALIGN=$(call check_gcc,-falign-functions=0 -falign-labels=1,-malign-functions=0)
e348b8f7
DV
206endif
207ifeq ($(CONFIG_CYRIXIII),y)
9f59aad1
DV
208 # Use compiler's default for functions, jumps and loops (why?)
209 GCC_FALIGN=$(call check_gcc,-falign-functions=0 -falign-labels=1,-malign-functions=0)
e348b8f7
DV
210endif
211 OPTIMIZATION+=$(GCC_FALIGN)
212
213 # Putting each function and data object into its own section
214 # allows for kbytes of less text if users link against static uclibc
215 # using ld --gc-sections.
216 # ld 2.18 can't do that (yet?) for shared libraries, so we itself
217 # do not use --gc-sections at shared lib link time.
218 # However, in combination with sections being sorted by alignment
219 # it does result in much reduced padding:
220 # text data bss dec hex
221 # 235319 1472 5992 242783 3b45f old.so
222 # 234104 1472 5980 241556 3af94 new.so
223 # Without -ffunction-sections, all functions will get aligned
224 # to 4 byte boundary by as/ld. This is arguably a bug in as.
225 # It specifies 4 byte align for .text even if not told to do so:
226 # Idx Name Size VMA LMA File off Algn
227 # 0 .text xxxxxxxx 00000000 00000000 xxxxxxxx 2**2 <===!
228 CPU_CFLAGS-y += $(call check_gcc,-ffunction-sections -fdata-sections,)
9e886c48
DV
229ifneq ($(call check_ld,--sort-common,),)
230 CPU_LDFLAGS-y += -Wl,--sort-common
231endif
232ifneq ($(call check_ld,--sort-section alignment),)
233 CPU_LDFLAGS-y += -Wl,--sort-section,alignment
234endif
e348b8f7 235
29c5e0ad
MF
236 CPU_LDFLAGS-y+=-m32
237 CPU_CFLAGS-y+=-m32
6a2d1ca4
EA
238 CPU_CFLAGS-$(CONFIG_386)+=-march=i386
239 CPU_CFLAGS-$(CONFIG_486)+=-march=i486
bbab258a 240 CPU_CFLAGS-$(CONFIG_ELAN)+=-march=i486
6a2d1ca4
EA
241 CPU_CFLAGS-$(CONFIG_586)+=-march=i586
242 CPU_CFLAGS-$(CONFIG_586MMX)+=$(call check_gcc,-march=pentium-mmx,-march=i586)
243 CPU_CFLAGS-$(CONFIG_686)+=-march=i686
bbab258a 244 CPU_CFLAGS-$(CONFIG_PENTIUMII)+=$(call check_gcc,-march=pentium2,-march=i686)
6a2d1ca4
EA
245 CPU_CFLAGS-$(CONFIG_PENTIUMIII)+=$(call check_gcc,-march=pentium3,-march=i686)
246 CPU_CFLAGS-$(CONFIG_PENTIUM4)+=$(call check_gcc,-march=pentium4,-march=i686)
247 CPU_CFLAGS-$(CONFIG_K6)+=$(call check_gcc,-march=k6,-march=i586)
e348b8f7
DV
248 CPU_CFLAGS-$(CONFIG_K7)+=$(call check_gcc,-march=athlon,-march=i686)
249 CPU_CFLAGS-$(CONFIG_CRUSOE)+=-march=i686
6a2d1ca4
EA
250 CPU_CFLAGS-$(CONFIG_WINCHIPC6)+=$(call check_gcc,-march=winchip-c6,-march=i586)
251 CPU_CFLAGS-$(CONFIG_WINCHIP2)+=$(call check_gcc,-march=winchip2,-march=i586)
e348b8f7 252 CPU_CFLAGS-$(CONFIG_CYRIXIII)+=$(call check_gcc,-march=c3,-march=i486)
bbab258a 253 CPU_CFLAGS-$(CONFIG_NEHEMIAH)+=$(call check_gcc,-march=c3-2,-march=i686)
06d634ea 254endif
0c6405c1 255
15870aba 256ifeq ($(TARGET_ARCH),sparc)
4147ffbc
MF
257 CPU_CFLAGS-$(CONFIG_SPARC_V7)+=-mcpu=v7
258 CPU_CFLAGS-$(CONFIG_SPARC_V8)+=-mcpu=v8
259 CPU_CFLAGS-$(CONFIG_SPARC_V9)+=-mcpu=v9
260 CPU_CFLAGS-$(CONFIG_SPARC_V9B)+=$(call check_gcc,-mcpu=v9b,-mcpu=ultrasparc)
261endif
262
15870aba 263ifeq ($(TARGET_ARCH),arm)
0c6405c1 264 OPTIMIZATION+=-fstrict-aliasing
51ce75b5
BRF
265 CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN)+=-Wl,-EL
266 CPU_LDFLAGS-$(ARCH_BIG_ENDIAN)+=-Wl,-EB
6a2d1ca4
EA
267 CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN)+=-mlittle-endian
268 CPU_CFLAGS-$(ARCH_BIG_ENDIAN)+=-mbig-endian
269 CPU_CFLAGS-$(CONFIG_GENERIC_ARM)+=
270 CPU_CFLAGS-$(CONFIG_ARM610)+=-mtune=arm610 -march=armv3
271 CPU_CFLAGS-$(CONFIG_ARM710)+=-mtune=arm710 -march=armv3
8c98b925
KR
272 CPU_CFLAGS-$(CONFIG_ARM7TDMI)+=-mtune=arm7tdmi -march=armv4t
273 CPU_CFLAGS-$(CONFIG_ARM720T)+=-mtune=arm7tdmi -march=armv4t
274 CPU_CFLAGS-$(CONFIG_ARM920T)+=-mtune=arm9tdmi -march=armv4t
275 CPU_CFLAGS-$(CONFIG_ARM922T)+=-mtune=arm9tdmi -march=armv4t
276 CPU_CFLAGS-$(CONFIG_ARM926T)+=-mtune=arm9tdmi -march=armv5t
6e7076f0 277 CPU_CFLAGS-$(CONFIG_ARM10T)+=-mtune=arm10tdmi -march=armv5t
fcb56ce4 278 CPU_CFLAGS-$(CONFIG_ARM1136JF_S)+=-mtune=arm1136jf-s -march=armv6
520e102e
BRF
279 CPU_CFLAGS-$(CONFIG_ARM1176JZ_S)+=-mtune=arm1176jz-s -march=armv6
280 CPU_CFLAGS-$(CONFIG_ARM1176JZF_S)+=-mtune=arm1176jzf-s -march=armv6
6a2d1ca4
EA
281 CPU_CFLAGS-$(CONFIG_ARM_SA110)+=-mtune=strongarm110 -march=armv4
282 CPU_CFLAGS-$(CONFIG_ARM_SA1100)+=-mtune=strongarm1100 -march=armv4
da19a2df 283 CPU_CFLAGS-$(CONFIG_ARM_XSCALE)+=$(call check_gcc,-mtune=xscale,-mtune=strongarm110)
8c98b925 284 CPU_CFLAGS-$(CONFIG_ARM_XSCALE)+=-march=armv5te -Wa,-mcpu=xscale
6e7076f0 285 CPU_CFLAGS-$(CONFIG_ARM_IWMMXT)+=-march=iwmmxt -Wa,-mcpu=iwmmxt -mabi=iwmmxt
efce79f0
BRF
286 CPU_CFLAGS-$(CONFIG_ARM_CORTEX_M3)+=-mcpu=cortex-m3 -mthumb
287 CPU_CFLAGS-$(CONFIG_ARM_CORTEX_M1)+=-mcpu=cortex-m1 -mthumb
0c6405c1
EA
288endif
289
15870aba 290ifeq ($(TARGET_ARCH),mips)
51ce75b5
BRF
291 CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN)+=-Wl,-EL
292 CPU_LDFLAGS-$(ARCH_BIG_ENDIAN)+=-Wl,-EB
f6552f74
MNI
293 CPU_CFLAGS-$(CONFIG_MIPS_ISA_1)+=-mips1
294 CPU_CFLAGS-$(CONFIG_MIPS_ISA_2)+=-mips2 -mtune=mips2
295 CPU_CFLAGS-$(CONFIG_MIPS_ISA_3)+=-mips3 -mtune=mips3
296 CPU_CFLAGS-$(CONFIG_MIPS_ISA_4)+=-mips4 -mtune=mips4
297 CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS32)+=-mips32 -mtune=mips32
959cac18 298 CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS32R2)+=-march=mips32r2 -mtune=mips32r2
f6552f74 299 CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS64)+=-mips64 -mtune=mips32
1da8fd92 300 ifeq ($(strip $(ARCH_BIG_ENDIAN)),y)
51ce75b5
BRF
301 CPU_LDFLAGS-$(CONFIG_MIPS_N64_ABI)+=-Wl,-melf64btsmip
302 CPU_LDFLAGS-$(CONFIG_MIPS_O32_ABI)+=-Wl,-melf32btsmip
1da8fd92
EA
303 endif
304 ifeq ($(strip $(ARCH_LITTLE_ENDIAN)),y)
51ce75b5
BRF
305 CPU_LDFLAGS-$(CONFIG_MIPS_N64_ABI)+=-Wl,-melf64ltsmip
306 CPU_LDFLAGS-$(CONFIG_MIPS_O32_ABI)+=-Wl,-melf32ltsmip
1da8fd92
EA
307 endif
308 CPU_CFLAGS-$(CONFIG_MIPS_N64_ABI)+=-mabi=64
309 CPU_CFLAGS-$(CONFIG_MIPS_O32_ABI)+=-mabi=32
310 CPU_CFLAGS-$(CONFIG_MIPS_N32_ABI)+=-mabi=n32
f6552f74
MNI
311endif
312
40770ac3 313ifeq ($(TARGET_ARCH),nios)
51ce75b5
BRF
314 CPU_LDFLAGS-y+=-Wl,-m32
315 CPU_CFLAGS-y+=-Wl,-m32
40770ac3
MF
316endif
317
15870aba 318ifeq ($(TARGET_ARCH),sh)
0c6405c1 319 OPTIMIZATION+=-fstrict-aliasing
f149abb8 320 OPTIMIZATION+= $(call check_gcc,-mprefergot,)
51ce75b5
BRF
321 CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN)+=-Wl,-EL
322 CPU_LDFLAGS-$(ARCH_BIG_ENDIAN)+=-Wl,-EB
6a2d1ca4
EA
323 CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN)+=-ml
324 CPU_CFLAGS-$(ARCH_BIG_ENDIAN)+=-mb
325 CPU_CFLAGS-$(CONFIG_SH2)+=-m2
326 CPU_CFLAGS-$(CONFIG_SH3)+=-m3
3a7ac9c7 327ifeq ($(UCLIBC_HAS_FLOATS),y)
e8a91ad3 328 CPU_CFLAGS-$(CONFIG_SH2A)+=-m2a
6a2d1ca4 329 CPU_CFLAGS-$(CONFIG_SH4)+=-m4
e8a91ad3
PM
330else
331 CPU_CFLAGS-$(CONFIG_SH2A)+=-m2a-nofpu
332 CPU_CFLAGS-$(CONFIG_SH4)+=-m4-nofpu
333endif
533d76fb
EA
334endif
335
15870aba 336ifeq ($(TARGET_ARCH),sh64)
533d76fb 337 OPTIMIZATION+=-fstrict-aliasing
51ce75b5
BRF
338 CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN):=-Wl,-EL
339 CPU_LDFLAGS-$(ARCH_BIG_ENDIAN):=-Wl,-EB
6a2d1ca4
EA
340 CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN):=-ml
341 CPU_CFLAGS-$(ARCH_BIG_ENDIAN):=-mb
342 CPU_CFLAGS-$(CONFIG_SH5)+=-m5-32media
5a2610fb 343endif
163df9f2 344
15870aba 345ifeq ($(TARGET_ARCH),h8300)
23656d08 346 SYMBOL_PREFIX=_
51ce75b5
BRF
347 CPU_LDFLAGS-$(CONFIG_H8300H)+= -Wl,-ms8300h
348 CPU_LDFLAGS-$(CONFIG_H8S) += -Wl,-ms8300s
c5598b73
MF
349 CPU_CFLAGS-$(CONFIG_H8300H) += -mh -mint32
350 CPU_CFLAGS-$(CONFIG_H8S) += -ms -mint32
de2abcca
EA
351endif
352
15870aba 353ifeq ($(TARGET_ARCH),cris)
51ce75b5
BRF
354 CPU_LDFLAGS-$(CONFIG_CRIS)+=-Wl,-mcrislinux
355 CPU_LDFLAGS-$(CONFIG_CRISV32)+=-Wl,-mcrislinux
6a2d1ca4 356 CPU_CFLAGS-$(CONFIG_CRIS)+=-mlinux
783a979b 357 PICFLAG:=-fpic
ce5d0580 358 PIEFLAG_NAME:=-fpie
783a979b
JT
359endif
360
39eff515
MF
361ifeq ($(TARGET_ARCH),m68k)
362 # -fPIC is only supported for 68020 and above. It is not supported
363 # for 68000, 68010, or Coldfire.
364 PICFLAG:=-fpic
365 PIEFLAG_NAME:=-fpie
366endif
367
15870aba 368ifeq ($(TARGET_ARCH),powerpc)
783a979b
JT
369# PowerPC can hold 8192 entries in its GOT with -fpic which is more than
370# enough. Therefore use -fpic which will reduce code size and generates
371# faster code.
372 PICFLAG:=-fpic
ce5d0580 373 PIEFLAG_NAME:=-fpie
e26ed573
JT
374 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)
375 CPU_CFLAGS-$(PPC_HAS_REL16)+= -DHAVE_ASM_PPC_REL16
feeb0301 376 CPU_CFLAGS-$(CONFIG_E500) += "-D__NO_MATH_INLINES"
e04c4c3c 377
afb1cd9b
TA
378endif
379
f1e85d44 380ifeq ($(TARGET_ARCH),bfin)
23656d08 381 SYMBOL_PREFIX=_
f1e85d44
BS
382ifeq ($(UCLIBC_FORMAT_FDPIC_ELF),y)
383 CPU_CFLAGS-y:=-mfdpic
384 CPU_LDFLAGS-y += -Wl,-melf32bfinfd
385 PICFLAG:=-fpic
386 PIEFLAG_NAME:=-fpie
387endif
388ifeq ($(UCLIBC_FORMAT_SHARED_FLAT),y)
389 PICFLAG := -mleaf-id-shared-library
390endif
391endif
392
15870aba 393ifeq ($(TARGET_ARCH),frv)
51ce75b5 394 CPU_LDFLAGS-$(CONFIG_FRV)+=-Wl,-melf32frvfd
afd3f33a
MF
395 # Using -pie causes the program to have an interpreter, which is
396 # forbidden, so we must make do with -shared. Unfortunately,
397 # -shared by itself would get us global function descriptors
398 # and calls through PLTs, dynamic resolution of symbols, etc,
399 # which would break as well, but -Bsymbolic comes to the rescue.
51ce75b5 400 export LDPIEFLAG:=-Wl,-shared -Wl,-Bsymbolic
baa67289
EA
401 UCLIBC_LDSO=ld.so.1
402endif
403
e130b681
CA
404ifeq ($(strip $(TARGET_ARCH)),avr32)
405 CPU_CFLAGS-$(CONFIG_AVR32_AP7) += -march=ap
406 CPU_CFLAGS-$(CONFIG_LINKRELAX) += -mrelax
407 CPU_LDFLAGS-$(CONFIG_LINKRELAX) += --relax
408endif
409
23656d08
BS
410ifeq ($(TARGET_ARCH),i960)
411 SYMBOL_PREFIX=_
412endif
413
414ifeq ($(TARGET_ARCH),microblaze)
415 SYMBOL_PREFIX=_
416endif
417
418ifeq ($(TARGET_ARCH),v850)
419 SYMBOL_PREFIX=_
420endif
421
8c9cfb76
MF
422# Keep the check_gcc from being needlessly executed
423ifndef PIEFLAG
ce5d0580 424ifneq ($(UCLIBC_BUILD_PIE),y)
8c9cfb76 425export PIEFLAG:=
ce5d0580 426else
afd3f33a
MF
427export PIEFLAG:=$(call check_gcc,$(PIEFLAG_NAME),$(PICFLAG))
428endif
429endif
73c81126
EA
430# We need to keep track of both the CC PIE flag (above) as
431# well as the LD PIE flag (below) because we can't rely on
afd3f33a
MF
432# gcc passing -pie if we used -fPIE
433ifndef LDPIEFLAG
434ifneq ($(UCLIBC_BUILD_PIE),y)
435export LDPIEFLAG:=
436else
31248ebd 437export LDPIEFLAG:=$(shell $(LD) --help 2>/dev/null | grep -q -- -pie && echo "-Wl,-pie")
8c9cfb76 438endif
ce5d0580
MF
439endif
440
5eef4411
PM
441# Check for AS_NEEDED support in linker script (binutils>=2.16.1 has it)
442ifndef ASNEEDED
d9ec8005 443export ASNEEDED:=$(shell $(LD) --help 2>/dev/null | grep -q -- --as-needed && echo "AS_NEEDED ( $(UCLIBC_LDSO) )" || echo "$(UCLIBC_LDSO)")
5eef4411
PM
444endif
445
aa966844 446# Add a bunch of extra pedantic annoyingly strict checks
93de5c42 447XWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes -fno-strict-aliasing
e73b1211 448ifeq ($(EXTRA_WARNINGS),y)
a1b552b0 449XWARNINGS+=-Wnested-externs -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wformat=2
1466eb28 450XWARNINGS+=-Wmissing-prototypes -Wmissing-declarations
d50a7288 451XWARNINGS+=-Wnonnull -Wundef
a1b552b0
PM
452# works only w/ gcc-3.4 and up, can't be checked for gcc-3.x w/ check_gcc()
453#XWARNINGS+=-Wdeclaration-after-statement
e73b1211 454endif
b340985b 455XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS)))
c52c2a24 456CPU_CFLAGS=$(subst ",, $(strip $(CPU_CFLAGS-y)))
53d8027c 457
c57c6023
PM
458SSP_DISABLE_FLAGS ?= $(call check_gcc,-fno-stack-protector,)
459ifeq ($(UCLIBC_BUILD_SSP),y)
460SSP_CFLAGS := $(call check_gcc,-fno-stack-protector-all,)
461SSP_CFLAGS += $(call check_gcc,-fstack-protector,)
462SSP_ALL_CFLAGS ?= $(call check_gcc,-fstack-protector-all,)
463else
464SSP_CFLAGS := $(SSP_DISABLE_FLAGS)
465endif
c5598b73 466
bcfe4064 467NOSTDLIB_CFLAGS:=$(call check_gcc,-nostdlib,)
c57c6023
PM
468# Some nice CFLAGS to work with
469CFLAGS := -include $(top_builddir)include/libc-symbols.h \
470 $(XWARNINGS) $(CPU_CFLAGS) $(SSP_CFLAGS) \
1030faf5
BS
471 -fno-builtin -nostdinc -I$(top_builddir)include -I. \
472 -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)
a1b552b0 473
21c9dcf8
BRF
474# Make sure that we can be built with non-C99 compilers, too.
475# Use __\1__ instead.
476CFLAGS += $(call check_gcc,-fno-asm,)
8ceaf7c7
JT
477ifneq ($(strip $(UCLIBC_EXTRA_CFLAGS)),"")
478CFLAGS += $(subst ",, $(UCLIBC_EXTRA_CFLAGS))
479endif
480
53d8027c 481LDADD_LIBFLOAT=
3a7ac9c7 482ifeq ($(UCLIBC_HAS_SOFT_FLOAT),y)
53d8027c 483# If -msoft-float isn't supported, we want an error anyway.
3c44c596
MNI
484# Hmm... might need to revisit this for arm since it has 2 different
485# soft float encodings.
40770ac3 486ifneq ($(TARGET_ARCH),nios)
d38e11bd 487ifneq ($(TARGET_ARCH),nios2)
a8267f12 488ifneq ($(TARGET_ARCH),sh)
c57c6023 489CFLAGS += -msoft-float
5ddfefa4 490endif
40770ac3 491endif
a8267f12 492endif
15870aba 493ifeq ($(TARGET_ARCH),arm)
3c44c596
MNI
494# No longer needed with current toolchains, but leave it here for now.
495# If anyone is actually still using gcc 2.95 (say), they can uncomment it.
496# LDADD_LIBFLOAT=-lfloat
53d8027c
MNI
497endif
498endif
499
86de93b8
DV
500# Please let us see private headers' parts
501CFLAGS += -DUCLIBC_INTERNAL
502
c57c6023
PM
503# We need this to be checked within libc-symbols.h
504ifneq ($(HAVE_SHARED),y)
505CFLAGS += -DSTATIC
9d7a22d3
MNI
506endif
507
33fa6c8e 508CFLAGS += $(call check_gcc,-std=gnu99,)
aa966844 509
51ce75b5
BRF
510LDFLAGS_NOSTRIP:=$(CPU_LDFLAGS-y) -Wl,-shared \
511 -Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc
89736cf6 512# binutils-2.16.1 warns about ignored sections, 2.16.91.0.3 and newer are ok
e619cc8e 513#LDFLAGS_NOSTRIP+=$(call check_ld,--gc-sections)
15870aba
PM
514
515ifeq ($(UCLIBC_BUILD_RELRO),y)
51ce75b5 516LDFLAGS_NOSTRIP+=-Wl,-z,relro
15870aba
PM
517endif
518
519ifeq ($(UCLIBC_BUILD_NOW),y)
51ce75b5 520LDFLAGS_NOSTRIP+=-Wl,-z,now
15870aba
PM
521endif
522
6630516b
CA
523ifeq ($(LDSO_GNU_HASH_SUPPORT),y)
524# Be sure that binutils support it
bc186d1e 525LDFLAGS_GNUHASH:=$(call check_ld,--hash-style=gnu)
6630516b
CA
526ifeq ($(LDFLAGS_GNUHASH),)
527$(error Your binutils don't support --hash-style option, while you want to use it)
528else
529LDFLAGS_NOSTRIP += -Wl,$(LDFLAGS_GNUHASH)
530endif
531endif
532
51ce75b5 533LDFLAGS:=$(LDFLAGS_NOSTRIP) -Wl,-z,defs
98fd3d6c 534ifeq ($(DODEBUG),y)
f58f2dda 535CFLAGS += -O0 -g3
98fd3d6c 536else
f58f2dda
PK
537CFLAGS += $(OPTIMIZATION) $(XARCH_CFLAGS)
538endif
66b01e60 539ifeq ($(DOSTRIP),y)
51ce75b5 540LDFLAGS += -Wl,-s
66b01e60
EA
541else
542STRIPTOOL := true -Stripping_disabled
98fd3d6c
EA
543endif
544
8789ec41 545ifeq ($(DOMULTI),y)
6e3a0044
PM
546# we try to compile all sources at once into an object (IMA), but
547# gcc-3.3.x does not support it
47d8fab8 548# gcc-3.4.x supports it, but does not need and support --combine. though fails on many sources
6e3a0044
PM
549# gcc-4.0.x supports it, supports the --combine flag, but does not need it
550# gcc-4.1(200506xx) supports it, but needs the --combine flag, else libs are useless
f350d5a2 551ifeq ($(GCC_MAJOR_VER),3)
8789ec41 552DOMULTI:=n
6e3a0044
PM
553else
554CFLAGS+=$(call check_gcc,--combine,)
555endif
8789ec41
PM
556else
557DOMULTI:=n
558endif
6e3a0044 559
a96829da
BRF
560ifneq ($(strip $(UCLIBC_EXTRA_LDFLAGS)),"")
561LDFLAGS += $(subst ",, $(UCLIBC_EXTRA_LDFLAGS))
562endif
563
8c7ac6fc 564ifeq ($(UCLIBC_HAS_THREADS),y)
3a7ac9c7 565ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
c0b31e50 566 PTNAME := nptl
a9f5aa1c
MF
567else
568ifeq ($(LINUXTHREADS_OLD),y)
569 PTNAME := linuxthreads.old
c0b31e50
PM
570else
571 PTNAME := linuxthreads
572endif
a9f5aa1c 573endif
5937c62e 574PTDIR := $(top_builddir)libpthread/$(PTNAME)
8c7ac6fc 575# set up system dependencies include dirs (NOTE: order matters!)
3a7ac9c7 576ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
f9edc7cf 577PTINC:= -I$(PTDIR) \
86553e66
PM
578 -I$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH) \
579 -I$(PTDIR)/sysdeps/$(TARGET_ARCH) \
580 -I$(PTDIR)/sysdeps/unix/sysv/linux \
581 -I$(PTDIR)/sysdeps/pthread \
582 -I$(PTDIR)/sysdeps/pthread/bits \
583 -I$(PTDIR)/sysdeps/generic \
f9edc7cf 584 -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) \
7fec9f92 585 -I$(top_srcdir)ldso/include
a6487435
SH
586#
587# Test for TLS if NPTL support was selected.
588#
589GCC_HAS_TLS=$(shell \
590 echo "extern __thread int foo;" | $(CC) -o /dev/null -S -xc - 2>&1)
591ifneq ($(GCC_HAS_TLS),)
592gcc_tls_test_fail:
593 @echo "####";
594 @echo "#### Your compiler does not support TLS and you are trying to build uClibc";
595 @echo "#### with NPTL support. Upgrade your binutils and gcc to versions which";
596 @echo "#### support TLS for your architecture. Do not contact uClibc maintainers";
597 @echo "#### about this problem.";
598 @echo "####";
599 @echo "#### Exiting...";
600 @echo "####";
601 @exit 1;
602endif
603else
0f85f257 604PTINC := \
680f8428 605 -I$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH) \
0f85f257 606 -I$(PTDIR)/sysdeps/$(TARGET_ARCH) \
680f8428 607 -I$(PTDIR)/sysdeps/unix/sysv/linux \
0f85f257 608 -I$(PTDIR)/sysdeps/pthread \
680f8428
MF
609 -I$(PTDIR) \
610 -I$(top_builddir)libpthread
a6487435 611endif
a80fc77b 612CFLAGS+=$(PTINC)
0f85f257 613else
73c81126
EA
614 PTNAME :=
615 PTINC :=
8c7ac6fc 616endif
08e377aa 617CFLAGS += -I$(KERNEL_HEADERS)
8c7ac6fc 618
18f27be3
BRF
619#CFLAGS += -iwithprefix include-fixed -iwithprefix include
620CC_IPREFIX:=$(shell $(CC) --print-file-name=include)
621CFLAGS += -I$(dir $(CC_IPREFIX))/include-fixed -I$(CC_IPREFIX)
4775ec64 622
98fd3d6c 623ifneq ($(DOASSERTS),y)
86553e66 624CFLAGS+=-DNDEBUG
0dd72555 625endif
c5207a55 626
23656d08
BS
627ifeq ($(SYMBOL_PREFIX),_)
628CFLAGS+=-D__UCLIBC_UNDERSCORES__
629endif
630
8c9cfb76 631# Keep the check_as from being needlessly executed
8c9cfb76 632ifndef ASFLAGS_NOEXEC
f8e6aa06 633ifeq ($(UCLIBC_BUILD_NOEXECSTACK),y)
8c9cfb76
MF
634export ASFLAGS_NOEXEC := $(call check_as,--noexecstack)
635else
636export ASFLAGS_NOEXEC :=
637endif
f8e6aa06 638endif
8585cd4d 639ASFLAGS = $(ASFLAGS_NOEXEC)
4a56d69f 640
881e6dca 641LIBGCC_CFLAGS ?= $(CFLAGS) $(CPU_CFLAGS-y)
f149abb8
EA
642LIBGCC:=$(shell $(CC) $(LIBGCC_CFLAGS) -print-libgcc-file-name)
643LIBGCC_DIR:=$(dir $(LIBGCC))
644
0a7b9d5d
PM
645# moved from libpthread/linuxthreads
646ifeq ($(UCLIBC_CTOR_DTOR),y)
5937c62e
PM
647SHARED_START_FILES:=$(top_builddir)lib/crti.o $(LIBGCC_DIR)crtbeginS.o
648SHARED_END_FILES:=$(LIBGCC_DIR)crtendS.o $(top_builddir)lib/crtn.o
0a7b9d5d 649endif
9be49589
CA
650
651LOCAL_INSTALL_PATH := install_dir
This page took 0.322101 seconds and 4 git commands to generate.