1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
|
#
# Top level Makerules
# it uses Makerules.env for build env vars and optional branding.inc
#
# Copyright (C) 1999-2011, Broadcom Corporation
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to you
# under the terms of the GNU General Public License version 2 (the "GPL"),
# available at http://www.broadcom.com/licenses/GPLv2.php, with the
# following added to such license:
#
# As a special exception, the copyright holders of this software give you
# permission to link this software with independent modules, and to copy and
# distribute the resulting executable under terms of your choice, provided that
# you also meet, for each linked independent module, the terms and conditions of
# the license of that module. An independent module is a module which is not
# derived from this software. The special exception does not apply to any
# modifications of the software.
#
# Notwithstanding the above, under no circumstances may you combine this
# software in any way with any other Broadcom software provided under a license
# other than the GPL, without Broadcom's express prior written consent.
#
# $Id: Makerules,v 2.78.42.1 2010-05-11 17:55:55 Exp $
# This is the TOP level makefile rules, which is used by many makefiles.
# Please be cautious on changes, especially compatibilities.
# e.g. new gcc compile option should be protected with version check
# or "check_gcc" trick
# first rule (default)
all:
# SRCBASE should be set by the Makefile that includes this.
ifndef SRCBASE
SRCBASE = .
endif
# Set up the build environment variables
include ${SRCBASE}/Makerules.env
# Define space to be a single space character. Using " " gets the quotes
# as well, which we don't want.
empty :=
space := $(empty) $(empty)
ifeq ($(HOSTOS), Windows_NT)
# force use of bash, otherwise you will get the broken sh.exe.
SHELL=bash
endif
#
# Setup make variables depending on target
#
ifeq ($(TARGETOS), unix)
# The environment for native unix builds
EXEEXT =
OBJEXT = .o
GCINCS = -I$(SRCBASE)/include
GCDEFS = -DTARGETENV_$(TARGETENV) -DTARGETOS_$(TARGETOS) -DTARGETARCH_$(TARGETARCH)
ifeq ($(TARGETARCH), x86_mmx)
GCDEFS := $(GCDEFS) -D_X86_ -D_MMX_
endif
ifeq ($(TARGETARCH), x86)
GCDEFS := $(GCDEFS) -D_X86_
endif
ifeq ($(TARGETARCH), mips)
GCDEFS := $(GCDEFS) -D_MIPS_
endif
ifeq ($(TARGETARCH), mips_be)
GCDEFS := $(GCDEFS) -D_MIPS_ -DIL_BIGENDIAN
endif
ifeq ($(TARGETARCH), arm)
GCDEFS := $(GCDEFS) -D_ARM_ -DIL_BIGENDIAN
endif
ifeq ($(TARGETARCH), arm_le)
GCDEFS := $(GCDEFS) -D_ARM_
endif
ifeq ($(TARGETARCH), arm_android)
GCDEFS := $(GCDEFS) -D_ARM_
endif
ifeq ($(TARGETENV), freebsd)
GCINCS := $(GCINCS) -I/usr/local/include
endif
ifeq ($(TARGETENV), sun4)
GCDEFS := $(GCDEFS) -D_SPARC_
endif
ifeq ($(TARGETENV), macos)
MACOS_VER := $(shell sw_vers -productVersion)
ifneq (,$(findstring 10.5,$(MACOS_VER)))
SDK=/Developer/SDKs/MacOSX10.5.sdk
else
ifneq (,$(findstring 10.6,$(MACOS_VER)))
SDK=/Developer/SDKs/MacOSX10.6.sdk
else
SDK=/Developer/SDKs/MacOSX10.4u.sdk
endif
endif
GCDEFS := $(GCDEFS) -DMACOSX
GCDEFS := $(GCDEFS) -pipe -fpascal-strings -fasm-blocks -fmessage-length=0
GCDEFS := $(GCDEFS) -fvisibility=hidden -isysroot $(SDK)
ifeq ($(TARGETARCH), PPC)
GCDEFS := $(GCDEFS) -arch ppc -mtune=G4
GLDFLAGS = -arch ppc -Wl,-syslibroot,$(SDK)
endif
ifeq ($(TARGETARCH), x86)
GCDEFS := $(GCDEFS) -arch i386
GLDFLAGS = -arch i386 -Wl,-syslibroot,$(SDK)
endif
endif
GCOPTS =
GCFLAGS = -g -Wall
CC_TARGET =-o $@
LINK_TARGET =-o $@
ifeq ($(TARGETENV), linuxmips)
TARGET_PREFIX = mipsel-linux-
else
ifeq ($(TARGETENV), linux26mips)
TARGET_PREFIX = mipsel-linux-linux26-
else
ifeq ($(TARGETENV), linuxmips_be)
TARGET_PREFIX = mips-linux-
else
ifeq ($(TARGETENV), linuxarm)
TARGET_PREFIX = armeb-linux-
else
ifeq ($(TARGETENV), linuxarm_le)
TARGET_PREFIX = arm-linux-
else
ifeq ($(TARGETENV), android)
TARGET_PREFIX = arm-eabi-
GCFLAGS += -Dlinux
GCFLAGS += -I/projects/hnd/tools/linux/hndtools-arm-eabi-4.2.1/android-ndk-r3/build/platforms/android-3/arch-arm/usr/include
# GCFLAGS += -I/projects/hnd/tools/linux/hndtools-arm-eabi-4.2.1/arm-eabi/include/bionic/libc/include
# GCFLAGS += -I/projects/hnd/tools/linux/hndtools-arm-eabi-4.2.1/arm-eabi/include/bionic/libc/arch-arm/include/
GCFLAGS += -I/tools/linux/src/linux-2.6.25-01843-gfea26b0/include/
else
TARGET_PREFIX =
endif
endif
endif
endif
endif
endif
CC = $(TARGET_PREFIX)gcc
AS = $(TARGET_PREFIX)as
LD = $(TARGET_PREFIX)ld
AR = $(TARGET_PREFIX)ar
INSTALL = install -c
TCFLAGS =
ifeq ($(TARGETENV), freebsd)
GLDFLAGS = -static
endif
ifeq ($(TARGETENV), linuxarm)
GLDFLAGS = -static
endif
ifeq ($(TARGETENV), linuxarm_le)
GLDFLAGS = -static
endif
ifeq ($(TARGETENV), android)
GLDFLAGS = -static
endif
GLDLIBS = -lgcc
endif # $(TARGETOS) == unix
ifeq ($(TARGETOS), Windows_NT)
# The environment for windows builds
EXEEXT = .exe
ifeq ($(TARGETENV), win32)
# standard win32 using MS compiler
OBJEXT = .obj
GCINCS = /I$(SRCBASE)/include
GCDEFS = /DTARGETENV_$(TARGETENV) /DTARGETOS_$(TARGETOS) \
/DTARGETARCH_$(TARGETARCH) /D_X86_
ifeq ($(TARGETARCH), x86_mmx)
GCDEFS += /D_MMX_
endif
GCOPTS = /nologo
GCFLAGS = /GM /W3 /Z7
CC_TARGET =-Fo$@
LINK_TARGET =-out:$@
CC = cl
AS = cl
LD = cl
TCFLAGS =
GLDFLAGS = /nologo /link /nologo /INCREMENTAL:NO
GLDLIBS =
else
# cygwin32 based environment
OBJEXT = .o
GCINCS = -I$(SRCBASE)/include
GCDEFS = -DTARGETENV_$(TARGETENV) -DTARGETOS_$(TARGETOS) \
-DTARGETARCH_$(TARGETARCH) -D_X86_
ifeq ($(TARGETARCH), x86_mmx)
GCDEFS += -D_MMX_
endif
GCOPTS =
GCFLAGS = -g -Wall
CC_TARGET =-o $@
LINK_TARGET =-o $@
CC = gcc
AS = gcc
LD = gcc
INSTALL = install -c
TCFLAGS =
GLDFLAGS =
GLDLIBS = -liberty -lgcc
endif
# Tools common to cygwin/win32
INSTALL = install -c
BUILD = build -ceZ
# RELEASE_TARGET is a the directory under RELEASE_DIR where
# target dependant files go. It is composed of the OS and
# the CPU, some examples are: winnt40/i386, win98 ...
#
# NEEDSWORK: For now only NT 4.0 stuff uses it.
ifneq ($(findstring $(TARGETPLATFORM), "Wdm wdm"), )
RELEASE_TARGET = wdm/i386
else
RELEASE_TARGET = winnt40/i386
endif
# RELEASE_TOOLS_DIR is a the directory under RELEASE_DIR where
# common tools go.
# For compatability with previous installs &test scripts, old
# tools still go in "yosemite".
RELEASE_YOS_DIR = yosemite
RELEASE_TOOLS_DIR = tools
endif # $(TARGETOS) == Windows_NT
ifeq ($(TARGETOS), vxWorks)
WIND_REGISTRY = sol
ifndef WIND_BASE
ifeq ($(HOSTOS), unix)
WIND_BASE = /dfs/tools/vxWorks
else
WIND_BASE = z:/tools/vxWorks
endif
endif
include $(WIND_BASE)/target/h/make/defs.default
ifeq ($(HOSTENV), Windows_NT)
WIND_HOST_TYPE = x86-win32
else
ifeq ($(HOSTENV), sun4)
WIND_HOST_TYPE = sun4-solaris2
else
WIND_HOST_TYPE = i386-freebsd
endif
endif
ifeq ($(TARGETENV), vxsim)
CPU = SIMSPARCSOLARIS
else
ifeq ($(TARGETENV), vx386)
CPU = i386
else
CPU = R4650
VXFLAGS = -DCPU_VAR=$(CPU)
endif
endif
include $(WIND_BASE)/target/h/make/make.$(CPU)$(TOOL)
include $(WIND_BASE)/target/h/make/defs.$(WIND_HOST_TYPE)
GCINCS = -I$(WIND_BASE)/target/h -I$(SRCBASE)/include
GCDEFS = $(DEFINE_CC) -DCPU=$(CPU) -DTARGETENV_$(TARGETENV) -DTARGETOS_$(TARGETOS) -DTARGETARCH_$(TARGETARCH)
GCOPTS = -g -O2
GCFLAGS = -Wall $(CC_ARCH_SPEC)
LDFLAGS = $(GLDFLAGS) $(LLDFLAGS)
GLDLIBS = $(LIBS)
WIND_BIN = $(WIND_BASE)/host/$(WIND_HOST_TYPE)/bin
AR := $(WIND_BIN)/$(AR)
AS := $(WIND_BIN)/$(AS)
BINHEX := $(WIND_BIN)/$(BINHEX)
CC := $(WIND_BIN)/$(CC)
CF := $(WIND_BIN)/$(CF)
LD := $(CC)
NM := $(WIND_BIN)/$(NM)
RANLIB := $(WIND_BIN)/$(RANLIB)
BINXSYM_NAME := $(WIND_BIN)/$(BINXSYM)
endif # $(TARGETOS) == vxWorks
ifeq ($(TARGETENV), nucleusarm)
# The environment for nucleus builds
ifeq ($(BSP_BASE_DIR),)
BSP_BASE_DIR := $(SRCBASE)/../bsp
endif
ifeq ($(NUCLEUS_INC_DIR),)
NUCLEUS_INC_DIR := $(BSP_BASE_DIR)/rtos/nucleus/inc
endif
EXEEXT :=
OBJEXT := .o
GCINCS := -I$(SRCBASE)/include -I$(NUCLEUS_INC_DIR)
GCDEFS := -DTARGETENV_$(TARGETENV) -DTARGETOS_$(TARGETOS) -DTARGETARCH_$(TARGETARCH)
GCOPTS :=
ifeq ($(OBJDIR),)
OBJDIR := $(TARGETENV)/
endif
# --md: This option compiles the source and writes make file dependency lines
# to a file. The output file is suitable for use by a make utility.
# -c: Compiles but does not perform the link phase.
# -O2: High optimization.
# ---memaccess -UL41: This option tells the compiler that the memory in the
# target system has slightly restricted or expanded capabilities.
# Disables unaligned mode for code that uses pre-ARMv6 unaligned
# access behavior.
# "/adsabi" is added to "--apcs /interwork/$(SWST)" so that objects created
# under ADS 1.2 can be linked with objects compiled under RVCT 2.2.
# --diag_suppress 2084,1658 = blocks the diagnostic warning "Warning: C2084W: support for --apcs /adsabi is deprecated"
# 1293: Suppress "Assignment in condition" warning.
GCFLAGS := --md \
-c \
-O2 \
--memaccess -UL41 \
--apcs /adsabi/interwork/NOSWST \
--diag_suppress 2084,1658,1293 \
--li
# --cpu 'name': This option generates code for a specific ARM processor or architecture.
ifeq ($(TARGETCPU),2153)
GCFLAGS += --cpu ARM1136J-S
else
$(error "Unknown target CPU type!")
endif
#CPPFLAGS := -embeddedcplusplus
CC_TARGET =-o $@
CPP_TARGET =-o $@
LINK_TARGET =-o $@
CC := tcc
CPP := tcpp
AS := armasm
LD := armlink
AR := armar -c -r --create
INSTALL := install -c
TCFLAGS :=
GLDFLAGS :=
GLDLIBS := --ELF --symbols --debug --map --info sizes,totals --errors link.err --list link.map --verbose
# Convert windows style directories to cygwin style.
# It should be used in situations where the host environment is cygwin, and
# the host compiler is a native Win32 app (non-cygwin). It will convert the
# Windows style directories in the dependencies list to cygwin style. This is
# necessary for the dependency files to be included by cygwin make.
ifeq ($(HOSTOS),Windows_NT)
FILTER_DEPENDS_IN_C_TO_OBJ_RULE := 1
endif
endif # $(TARGETENV) == nucleusarm
ifeq ($(TARGETENV), bcmmips)
OBJEXT = .o
GCINCS = -I$(SRCBASE)/include
GCDEFS = -DTARGETENV_$(TARGETENV) -DTARGETOS_$(TARGETOS) \
-DTARGETARCH_$(TARGETARCH) -D__mips__
GCOPTS = -g -O2
GCFLAGS = -Wall
GLDFLAGS = -Wl,-tidt.dld
AS = bcmas
CC = bcmgcc
LD = $(CC)
NM = bcmnm
RANLIB = bcmranlib
endif # $(TARGETENV) == bcmmips
ifeq ($(TARGETENV), klsi)
OBJEXT = .obj
GCINCS = -I$(SRCBASE)/include
GCDEFS = -DTARGETENV_$(TARGETENV) -DTARGETOS_$(TARGETOS) \
-DTARGETARCH_$(TARGETARCH) -D__klsi__
AS = qtasm
GASFLAGS = -m20
CC = qtcc
TCFLAGS = -w asm=$(GASFLAGS) +c -Vcdv -w cc=+reginfo
endif # $(TARGETENV) == klsi
CFLAGS = $(LCINCS) $(GCINCS) $(GCDEFS) $(GCOPTS) $(GCFLAGS) $(TCFLAGS) $(HCFLAGS) \
$(LCDEFS) $(LCOPTS) $(LCFLAGS) $(CENV)
ASFLAGS = $(GASFLAGS) $(LASFLAGS) $(ASENV)
LDFLAGS = $(GLDFLAGS) $(LLDFLAGS) $(LDENV)
LDLIBS = $(LLDLIBS) $(GLDLIBS)
# dependency files including the .d file itself.
# note the example in GNU documentation seems to have a bug:
# two backslashes where one is correct.
%.d: %.c
ifeq ($(findstring s, $(MAKEFLAGS) ),)
@ echo making $@
endif
@ $(SHELL) -ec '$(CC) -MM $(CFLAGS) $(CPPFLAGS) $< \
| sed '\''s/$*\.o[ :]*/$@ &/g'\'' >$@'
ifeq ($(TARGETENV), win32)
# win32 needs different command line args
%.s: %.c
$(CC) /FAs $(CFLAGS) $(CPPFLAGS) /Fa$@ /c $<
%.i: %.c
$(CC) /E $(CFLAGS) $(CPPFLAGS) $< > $@
else # !win32
%.s: %.c
$(CC) -S $(CFLAGS) $(CPPFLAGS) -o $@ $<
%.i: %.c
$(CC) -o $@ -E -dD $(CFLAGS) $(CPPFLAGS) $<
endif # win32
ifeq ($(TARGETENV), klsi)
%$(OBJEXT): %.c
$(CC) $(CFLAGS) $*.c
%$(OBJEXT): %.asm
$(AS) $(ASFLAGS) $*.asm
%.asm: %.c
$(CC) $(CFLAGS) -asm $*.c
%.i: %.c
$(CC) $(CFLAGS) -cc -peep -asm $*.c
mv $*.pp $*.i
else
# This command sequence will:
# - Convert back-slashes to foward-slashes
# - Convert long filenames to 8.3 format (e.g. Program Files --> PROGRA~1)
# - Convert windows-style drive letters to cygwin style.
#
# It should be used in situations where the host environment is cygwin, and
# the host compiler is a native Win32 app (non-cygwin). It will convert the
# Windows style directories in the dependencies list to cygwin style. This is
# necessary for the dependency files to be included by cygwin make.
define FILTER_DEPENDS
sed -e 's/\\/\//g' \
-e 's/Program Files/PROGRA~1/g' \
-e 's/\([A-Za-z]\):\//\/cygdrive\/\1\//' < $(notdir $(@:.o=.d)) > $(@:.o=.d) && \
rm -f $(notdir $(@:.o=.d))
endef
$(OBJDIR)%$(OBJEXT): %.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $(CC_TARGET) $<
ifeq ($(FILTER_DEPENDS_IN_C_TO_OBJ_RULE),1)
${FILTER_DEPENDS}
endif
$(OBJDIR)%$(OBJEXT): %.cpp
$(CPP) -c $(CFLAGS) $(CPPFLAGS) $(CPP_TARGET) $<
ifeq ($(FILTER_DEPENDS_IN_C_TO_OBJ_RULE),1)
${FILTER_DEPENDS}
endif
endif # klsi
%.h: %.x
rpcgen -C -h $< > $@
%_xdr.c: %.x
@ (if [ ! -f `basename $<` ] ; then ln -s $< . ; fi; true)
rpcgen -C -c -i 0 `basename $<` > $@
# Makefile debugging rule
env:
printenv
# if the user mistakenly specified RELEASE_DIR in unix-style notation,
# convert it to Win32 notation for them.
#
# RELEASE_DIR is assumed to be in windows-style notation if it has both
# backslashes ('\') and colons (':').
#
ifneq ("$(subst \,,$(RELEASE_DIR))", "$(RELEASE_DIR)")
ifneq ("$(subst :,,$(RELEASE_DIR))", "$(RELEASE_DIR)")
RELEASE_DIR := $(subst :,,$(RELEASE_DIR))
RELEASE_DIR := $(subst \,/,$(RELEASE_DIR))
RELEASE_DIR := //$(RELEASE_DIR)
endif
endif
# all release rules depend on a valid RELEASE_DIR
release: check_release_dir
check_release_dir:
@if [ "x$(RELEASE_DIR)" = "x" ]; then \
echo "RELEASE_DIR is not set!"; \
exit 1; \
fi;
include ${SRCBASE}/branding.inc
|