OpenCores
URL https://opencores.org/ocsvn/ao486/ao486/trunk

Subversion Repositories ao486

[/] [ao486/] [trunk/] [syn/] [components/] [sd_card/] [firmware/] [exe/] [Makefile] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 alfik
#------------------------------------------------------------------------------
2
#              VARIABLES APPENDED TO BY INCLUDED MAKEFILE FRAGMENTS
3
#------------------------------------------------------------------------------
4
 
5
# List of include directories for -I compiler option (-I added when used).
6
# Includes the BSP.
7
ALT_INCLUDE_DIRS :=
8
 
9
# List of library directories for -L linker option (-L added when used).
10
# Includes the BSP.
11
ALT_LIBRARY_DIRS :=
12
 
13
# List of library names for -l linker option (-l added when used).
14
# Includes the BSP.
15
ALT_LIBRARY_NAMES :=
16
 
17
# List of library names for -msys-lib linker option (-msys-lib added when used).
18
# These are libraries that might be located in the BSP and depend on the BSP
19
# library, or vice versa
20
ALT_BSP_DEP_LIBRARY_NAMES :=
21
 
22
# List of dependencies for the linker.  This is usually the full pathname
23
# of each library (*.a) file.
24
# Includes the BSP.
25
ALT_LDDEPS :=
26
 
27
# List of root library directories that support running make to build them.
28
# Includes the BSP and any ALT libraries.
29
MAKEABLE_LIBRARY_ROOT_DIRS :=
30
 
31
# Generic flags passed to the compiler for different types of input files.
32
ALT_CFLAGS :=
33
ALT_CXXFLAGS :=
34
ALT_CPPFLAGS :=
35
ALT_ASFLAGS :=
36
ALT_LDFLAGS :=
37
 
38
 
39
#------------------------------------------------------------------------------
40
#                         The adjust-path macro
41
#
42
# If COMSPEC/ComSpec is defined, Make is launched from Windows through
43
# Cygwin.  The adjust-path macro converts absolute windows paths into
44
# unix style paths (Example: c:/dir -> /c/dir). This will ensture
45
# paths are readable by GNU Make.
46
#
47
# If COMSPEC/ComSpec is not defined, Make is launched from linux, and no
48
# adjustment is necessary
49
#
50
#------------------------------------------------------------------------------
51
 
52
ifndef COMSPEC
53
ifdef ComSpec
54
COMSPEC = $(ComSpec)
55
endif # ComSpec
56
endif # COMSPEC
57
 
58
ifdef COMSPEC # if Windows OS
59
 
60
ifeq ($(MAKE_VERSION),3.81)
61
#
62
# adjust-path/adjust-path-mixed for Mingw Gnu Make on Windows
63
#
64
# Example Usage:
65
# $(call adjust-path,c:/aaa/bbb) => /c/aaa/bbb
66
# $(call adjust-path-mixed,/c/aaa/bbb) => c:/aaa/bbb
67
# $(call adjust-path-mixed,/cygdrive/c/aaa/bbb) => c:/aaa/bbb
68
#
69
 
70
#
71
# adjust-path
72
#  - converts back slash characters into forward slashes
73
#  - if input arg ($1) is an empty string then return the empty string
74
#  - if input arg ($1) does not contain the string ":/", then return input arg
75
#  - using sed, convert mixed path [c:/...] into mingw path [/c/...]
76
define adjust-path
77
$(strip \
78
$(if $1,\
79
$(if $(findstring :/,$(subst \,/,$1)),\
80
$(shell echo $(subst \,/,$1) | sed -e 's,^\([a-zA-Z]\):/,/\1/,'),\
81
$(subst \,/,$1))))
82
endef
83
 
84
#
85
# adjust-path-mixed
86
#  - converts back slash characters into forward slashes
87
#  - if input arg ($1) is an empty string then return the empty string
88
#  - if input arg ($1) does not begin with a forward slash '/' char, then
89
#    return input arg
90
#  - using sed, convert mingw path [/c/...] or cygwin path [/c/cygdrive/...]
91
#    into a mixed path [c:/...]
92
define adjust-path-mixed
93
$(strip \
94
$(if $1,\
95
$(if $(findstring $(subst \,/,$1),$(patsubst /%,%,$(subst \,/,$1))),\
96
$(subst \,/,$1),\
97
$(shell echo $(subst \,/,$1) | sed -e 's,^/cygdrive/\([a-zA-Z]\)/,\1:/,' -e 's,^/\([a-zA-Z]\)/,\1:/,'))))
98
endef
99
 
100
else # MAKE_VERSION != 3.81 (MAKE_VERSION == 3.80 or MAKE_VERSION == 3.79)
101
#
102
#  adjust-path for Cygwin Gnu Make
103
# $(call adjust-path,c:/aaa/bbb) = /cygdrive/c/aaa/bbb
104
# $(call adjust-path-mixed,/cygdrive/c/aaa/bbb) = c:/aaa/bbb
105
#
106
adjust-path = $(if $1,$(shell cygpath -u "$1"),)
107
adjust-path-mixed = $(if $1,$(shell cygpath -m "$1"),)
108
endif
109
 
110
else # !COMSPEC
111
 
112
adjust-path = $1
113
adjust-path-mixed = $1
114
 
115
endif # COMSPEC
116
 
117
 
118
#vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
119
#                           GENERATED SETTINGS START                         v
120
#vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
121
 
122
#START GENERATED
123
ACTIVE_BUILD_CONFIG := default
124
BUILD_CONFIGS := default
125
 
126
# The following TYPE comment allows tools to identify the 'type' of target this
127
# makefile is associated with.
128
# TYPE: APP_MAKEFILE
129
 
130
# This following VERSION comment indicates the version of the tool used to
131
# generate this makefile. A makefile variable is provided for VERSION as well.
132
# ACDS_VERSION: 14.0
133
ACDS_VERSION := 14.0
134
 
135
# This following BUILD_NUMBER comment indicates the build number of the tool
136
# used to generate this makefile.
137
# BUILD_NUMBER: 200
138
 
139
# Define path to the application ELF.
140
# It may be used by the makefile fragments so is defined before including them.
141
#
142
ELF := exe.elf
143
 
144
# Paths to C, C++, and assembly source files.
145
C_SRCS :=
146
CXX_SRCS := main.cpp
147
ASM_SRCS :=
148
 
149
 
150
# Path to root of object file tree.
151
OBJ_ROOT_DIR := obj
152
 
153
# Options to control objdump.
154
CREATE_OBJDUMP := 1
155
OBJDUMP_INCLUDE_SOURCE := 0
156
OBJDUMP_FULL_CONTENTS := 0
157
 
158
# Options to enable/disable optional files.
159
CREATE_ELF_DERIVED_FILES := 0
160
CREATE_LINKER_MAP := 1
161
 
162
# Common arguments for ALT_CFLAGSs
163
APP_CFLAGS_DEFINED_SYMBOLS :=
164
APP_CFLAGS_UNDEFINED_SYMBOLS :=
165
APP_CFLAGS_OPTIMIZATION := -Os
166
APP_CFLAGS_DEBUG_LEVEL := -g
167
APP_CFLAGS_WARNINGS := -Wall
168
APP_CFLAGS_USER_FLAGS :=
169
 
170
APP_ASFLAGS_USER :=
171
APP_LDFLAGS_USER :=
172
 
173
# Linker options that have default values assigned later if not
174
# assigned here.
175
LINKER_SCRIPT :=
176
CRT0 :=
177
SYS_LIB :=
178
 
179
# Define path to the root of the BSP.
180
BSP_ROOT_DIR := ../bsp/
181
 
182
# List of application specific include directories, library directories and library names
183
APP_INCLUDE_DIRS :=
184
APP_LIBRARY_DIRS :=
185
APP_LIBRARY_NAMES :=
186
 
187
# Pre- and post- processor settings.
188
BUILD_PRE_PROCESS :=
189
BUILD_POST_PROCESS :=
190
 
191
 
192
 
193
#END GENERATED
194
 
195
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
196
#                            GENERATED SETTINGS END                           ^
197
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
198
 
199
 
200
#------------------------------------------------------------------------------
201
#                           DEFAULT TARGET
202
#------------------------------------------------------------------------------
203
 
204
# Define the variable used to echo output if not already defined.
205
ifeq ($(ECHO),)
206
ECHO := echo
207
endif
208
 
209
# Put "all" rule before included makefile fragments because they may
210
# define rules and we don't want one of those to become the default rule.
211
.PHONY : all
212
 
213
all:
214
        @$(ECHO) [$(APP_NAME) build complete]
215
 
216
all : build_pre_process libs app build_post_process
217
 
218
 
219
#------------------------------------------------------------------------------
220
#                 VARIABLES DEPENDENT ON GENERATED CONTENT
221
#------------------------------------------------------------------------------
222
 
223
# Define object file directory per build configuration
224
CONFIG_OBJ_DIR := $(OBJ_ROOT_DIR)/$(ACTIVE_BUILD_CONFIG)
225
 
226
ifeq ($(BSP_ROOT_DIR),)
227
$(error Edit Makefile and provide a value for BSP_ROOT_DIR)
228
endif
229
 
230
ifeq ($(wildcard $(BSP_ROOT_DIR)),)
231
$(error BSP directory does not exist: $(BSP_ROOT_DIR))
232
endif
233
 
234
# Define absolute path to the root of the BSP.
235
ABS_BSP_ROOT_DIR := $(call adjust-path-mixed,$(shell cd "$(BSP_ROOT_DIR)"; pwd))
236
 
237
# Include makefile fragments.  Define variable ALT_LIBRARY_ROOT_DIR before
238
# including each makefile fragment so that it knows the path to itself.
239
BSP_INCLUDE_FILE := $(BSP_ROOT_DIR)/public.mk
240
ALT_LIBRARY_ROOT_DIR := $(BSP_ROOT_DIR)
241
include $(BSP_INCLUDE_FILE)
242
# C2H will need this to touch the BSP public.mk and avoid the sopc file
243
# out-of-date error during a BSP make
244
ABS_BSP_INCLUDE_FILE := $(ABS_BSP_ROOT_DIR)/public.mk
245
 
246
 
247
ifneq ($(WARNING.SMALL_STACK_SIZE),)
248
# This WARNING is here to protect you from unknowingly using a very small stack
249
# If the warning is set, increase your stack size or enable the BSP small stack
250
# setting to eliminate the warning
251
$(warning WARNING: $(WARNING.SMALL_STACK_SIZE))
252
endif
253
 
254
# If the BSP public.mk indicates that ALT_SIM_OPTIMIZE is set, rename the ELF
255
# by prefixing it with RUN_ON_HDL_SIMULATOR_ONLY_.
256
ifneq ($(filter -DALT_SIM_OPTIMIZE,$(ALT_CPPFLAGS)),)
257
ELF := RUN_ON_HDL_SIMULATOR_ONLY_$(ELF)
258
endif
259
 
260
# If the BSP public.mk indicates that ALT_PROVIDE_GMON is set, add option to
261
# download_elf target
262
ifneq ($(filter -DALT_PROVIDE_GMON,$(ALT_CPPFLAGS)),)
263
GMON_OUT_FILENAME := gmon.out
264
WRITE_GMON_OPTION := --write-gmon $(GMON_OUT_FILENAME)
265
endif
266
 
267
# Name of ELF application.
268
APP_NAME := $(basename $(ELF))
269
 
270
# Set to defaults if variables not already defined in settings.
271
ifeq ($(LINKER_SCRIPT),)
272
LINKER_SCRIPT := $(BSP_LINKER_SCRIPT)
273
endif
274
ifeq ($(CRT0),)
275
CRT0 := $(BSP_CRT0)
276
endif
277
ifeq ($(SYS_LIB),)
278
SYS_LIB := $(BSP_SYS_LIB)
279
endif
280
 
281
OBJDUMP_NAME := $(APP_NAME).objdump
282
OBJDUMP_FLAGS := --disassemble --syms --all-header
283
ifeq ($(OBJDUMP_INCLUDE_SOURCE),1)
284
OBJDUMP_FLAGS += --source
285
endif
286
ifeq ($(OBJDUMP_FULL_CONTENTS),1)
287
OBJDUMP_FLAGS += --full-contents
288
endif
289
 
290
# Create list of linker dependencies (*.a files).
291
APP_LDDEPS := $(ALT_LDDEPS) $(LDDEPS)
292
 
293
# Take lists and add required prefixes.
294
APP_INC_DIRS := $(addprefix -I, $(ALT_INCLUDE_DIRS) $(APP_INCLUDE_DIRS) $(INC_DIRS))
295
ASM_INC_PREFIX := -Wa,-I
296
APP_ASM_INC_DIRS := $(addprefix $(ASM_INC_PREFIX), $(ALT_INCLUDE_DIRS) $(APP_INCLUDE_DIRS) $(INC_DIRS))
297
APP_LIB_DIRS := $(addprefix -L, $(ALT_LIBRARY_DIRS) $(APP_LIBRARY_DIRS) $(LIB_DIRS))
298
APP_LIBS := $(addprefix -l, $(ALT_LIBRARY_NAMES) $(APP_LIBRARY_NAMES) $(LIBS))
299
 
300
ifneq ($(AVOID_NIOS2_GCC3_OPTIONS),)
301
 
302
#
303
# Avoid Nios II GCC 3.X options.
304
#
305
 
306
# Detect if small newlib C library is requested.
307
# If yes, remove the -msmallc option because it is
308
# now handled by other means.
309
ifneq ($(filter -msmallc,$(ALT_LDFLAGS)),)
310
        ALT_LDFLAGS := $(filter-out -msmallc,$(ALT_LDFLAGS))
311
        ALT_C_LIBRARY := smallc
312
else
313
        ALT_C_LIBRARY := c
314
endif
315
 
316
# Put each BSP dependent library in a group to avoid circular dependencies.
317
APP_BSP_DEP_LIBS := $(foreach l,$(ALT_BSP_DEP_LIBRARY_NAMES),-Wl,--start-group -l$(ALT_C_LIBRARY) -lgcc -l$(l) -Wl,--end-group)
318
 
319
else # !AVOID_NIOS2_GCC3_OPTIONS
320
 
321
#
322
# Use Nios II GCC 3.X options.
323
#
324
APP_BSP_DEP_LIBS := $(addprefix -msys-lib=, $(ALT_BSP_DEP_LIBRARY_NAMES))
325
 
326
endif # !AVOID_NIOS2_GCC3_OPTIONS
327
 
328
# Arguments for the C preprocessor, C/C++ compiler, assembler, and linker.
329
APP_CFLAGS := $(APP_CFLAGS_DEFINED_SYMBOLS) \
330
              $(APP_CFLAGS_UNDEFINED_SYMBOLS) \
331
              $(APP_CFLAGS_OPTIMIZATION) \
332
              $(APP_CFLAGS_DEBUG_LEVEL) \
333
              $(APP_CFLAGS_WARNINGS) \
334
              $(APP_CFLAGS_USER_FLAGS) \
335
              $(ALT_CFLAGS) \
336
              $(CFLAGS)
337
 
338
# Arguments only for the C++ compiler.
339
APP_CXXFLAGS := $(ALT_CXXFLAGS) $(CXXFLAGS)
340
 
341
# Arguments only for the C preprocessor.
342
# Prefix each include directory with -I.
343
APP_CPPFLAGS := $(APP_INC_DIRS) \
344
                $(ALT_CPPFLAGS) \
345
                $(CPPFLAGS)
346
 
347
# Arguments only for the assembler.
348
APP_ASFLAGS := $(APP_ASM_INC_DIRS) \
349
               $(ALT_ASFLAGS) \
350
               $(APP_ASFLAGS_USER) \
351
               $(ASFLAGS)
352
 
353
# Arguments only for the linker.
354
APP_LDFLAGS := $(APP_LDFLAGS_USER)
355
 
356
ifneq ($(LINKER_SCRIPT),)
357
APP_LDFLAGS += -T'$(LINKER_SCRIPT)'
358
endif
359
 
360
ifneq ($(AVOID_NIOS2_GCC3_OPTIONS),)
361
 
362
# Avoid Nios II GCC 3.x options.
363
ifneq ($(CRT0),)
364
APP_LDFLAGS += $(CRT0)
365
endif
366
 
367
# The equivalent of the -msys-lib option is provided
368
# by the GROUP() command in the linker script.
369
# Note this means the SYS_LIB variable is now ignored.
370
 
371
else # !AVOID_NIOS2_GCC3_OPTIONS
372
 
373
# Use Nios II GCC 3.x options.
374
ifneq ($(CRT0),)
375
APP_LDFLAGS += -msys-crt0='$(CRT0)'
376
endif
377
ifneq ($(SYS_LIB),)
378
APP_LDFLAGS += -msys-lib=$(SYS_LIB)
379
endif
380
 
381
endif # !AVOID_NIOS2_GCC3_OPTIONS
382
 
383
APP_LDFLAGS += \
384
           $(APP_LIB_DIRS) \
385
           $(ALT_LDFLAGS) \
386
           $(LDFLAGS)
387
 
388
LINKER_MAP_NAME := $(APP_NAME).map
389
ifeq ($(CREATE_LINKER_MAP), 1)
390
APP_LDFLAGS += -Wl,-Map=$(LINKER_MAP_NAME)
391
endif
392
 
393
# QUARTUS_PROJECT_DIR and SOPC_NAME need to be defined if you want the
394
# mem_init_install target of the mem_init.mk (located in the associated BSP)
395
# to know how to copy memory initialization files (e.g. .dat, .hex) into
396
# directories required for Quartus compilation or RTL simulation.
397
 
398
# Defining QUARTUS_PROJECT_DIR causes mem_init_install to copy memory
399
# initialization files into your Quartus project directory. This is required
400
# to provide the initial memory contents of FPGA memories that can be
401
# initialized by the programming file (.sof) or Hardcopy ROMs. It is also used
402
# for VHDL simulation of on-chip memories.
403
 
404
# Defining SOPC_NAME causes the mem_init_install target to copy memory
405
# initialization files into your RTL simulation directory.  This is required
406
# to provide the initial memory contents of all memories that can be
407
# initialized by RTL simulation. This variable should be set to the same name
408
# as your SOPC Builder system name. For example, if you have a system called
409
# "foo.sopc", this variable should be set to "foo".
410
 
411
# If SOPC_NAME is not set and QUARTUS_PROJECT_DIR is set, then derive SOPC_NAME.
412
ifeq ($(SOPC_NAME),)
413
ifneq ($(QUARTUS_PROJECT_DIR),)
414
SOPC_NAME := $(basename $(notdir $(wildcard $(QUARTUS_PROJECT_DIR)/*.sopcinfo)))
415
endif
416
endif
417
 
418
# Defining JDI_FILE is required to specify the JTAG Debug Information File
419
# path. This file is generated by Quartus, and is needed along with the
420
# .sopcinfo file to resolve processor instance ID's from names in a multi-CPU
421
# systems. For multi-CPU systems, the processor instance ID is used to select
422
# from multiple CPU's during ELF download.
423
 
424
# Both JDI_FILE and SOPCINFO_FILE are provided by the BSP if they found during
425
# BSP creation. If JDI_FILE is not set and QUARTUS_PROJECT_DIR is set, then
426
# derive JDI_FILE. We do not attempt to derive SOPCINFO_FILE since there may be
427
# multiple .sopcinfo files in a Quartus project.
428
ifeq ($(JDI_FILE),)
429
ifneq ($(QUARTUS_PROJECT_DIR),)
430
JDI_FILE := $(wildcard $(QUARTUS_PROJECT_DIR)/*.jdi)
431
endif
432
endif
433
 
434
# Path to root runtime directory used for hdl simulation
435
RUNTIME_ROOT_DIR := $(CONFIG_OBJ_DIR)/runtime
436
 
437
 
438
 
439
#------------------------------------------------------------------------------
440
#           MAKEFILE INCLUDES DEPENDENT ON GENERATED CONTENT
441
#------------------------------------------------------------------------------
442
# mem_init.mk is a generated makefile fragment. This file defines all targets
443
# used to generate HDL initialization simulation files and pre-initialized
444
# onchip memory files.
445
MEM_INIT_FILE :=  $(BSP_ROOT_DIR)/mem_init.mk
446
include $(MEM_INIT_FILE)
447
 
448
# Create list of object files to be built using the list of source files.
449
# The source file hierarchy is preserved in the object tree.
450
# The supported file extensions are:
451
#
452
# .c            - for C files
453
# .cxx .cc .cpp - for C++ files
454
# .S .s         - for assembler files
455
#
456
# Handle source files specified by --src-dir & --src-rdir differently, to
457
# save some processing time in calling the adjust-path macro.
458
 
459
OBJ_LIST_C              := $(patsubst %.c,%.o,$(filter %.c,$(C_SRCS)))
460
OBJ_LIST_CPP    := $(patsubst %.cpp,%.o,$(filter %.cpp,$(CXX_SRCS)))
461
OBJ_LIST_CXX    := $(patsubst %.cxx,%.o,$(filter %.cxx,$(CXX_SRCS)))
462
OBJ_LIST_CC     := $(patsubst %.cc,%.o,$(filter %.cc,$(CXX_SRCS)))
463
OBJ_LIST_S              := $(patsubst %.S,%.o,$(filter %.S,$(ASM_SRCS)))
464
OBJ_LIST_SS             := $(patsubst %.s,%.o,$(filter %.s,$(ASM_SRCS)))
465
 
466
OBJ_LIST := $(sort $(OBJ_LIST_C) $(OBJ_LIST_CPP) $(OBJ_LIST_CXX) \
467
                                $(OBJ_LIST_CC) $(OBJ_LIST_S) $(OBJ_LIST_SS))
468
 
469
SDIR_OBJ_LIST_C         := $(patsubst %.c,%.o,$(filter %.c,$(SDIR_C_SRCS)))
470
SDIR_OBJ_LIST_CPP       := $(patsubst %.cpp,%.o,$(filter %.cpp,$(SDIR_CXX_SRCS)))
471
SDIR_OBJ_LIST_CXX       := $(patsubst %.cxx,%.o,$(filter %.cxx,$(SDIR_CXX_SRCS)))
472
SDIR_OBJ_LIST_CC        := $(patsubst %.cc,%.o,$(filter %.cc,$(SDIR_CXX_SRCS)))
473
SDIR_OBJ_LIST_S         := $(patsubst %.S,%.o,$(filter %.S,$(SDIR_ASM_SRCS)))
474
SDIR_OBJ_LIST_SS        := $(patsubst %.s,%.o,$(filter %.s,$(SDIR_ASM_SRCS)))
475
 
476
SDIR_OBJ_LIST := $(sort $(SDIR_OBJ_LIST_C) $(SDIR_OBJ_LIST_CPP) \
477
                                $(SDIR_OBJ_LIST_CXX) $(SDIR_OBJ_LIST_CC) $(SDIR_OBJ_LIST_S) \
478
                                $(SDIR_OBJ_LIST_SS))
479
 
480
# Relative-pathed objects that being with "../" are handled differently.
481
#
482
# Regular objects are created as
483
#   $(CONFIG_OBJ_DIR)//.o
484
# where the path structure is maintained under the obj directory.  This
485
# applies for both absolute and relative paths; in the absolute path
486
# case this means the entire source path will be recreated under the obj
487
# directory.  This is done to allow two source files with the same name
488
# to be included as part of the project.
489
#
490
# Note: On Cygwin, the path recreated under the obj directory will be
491
# the cygpath -u output path.
492
#
493
# Relative-path objects that begin with "../" cause problems under this
494
# scheme, as $(CONFIG_OBJ_DIR)/..// can potentially put the object
495
# files anywhere in the system, creating clutter and polluting the source tree.
496
# As such, their paths are flattened - the object file created will be
497
# $(CONFIG_OBJ_DIR)/.o.  Due to this, two files specified with
498
# "../" in the beginning cannot have the same name in the project.  VPATH
499
# will be set for these sources to allow make to relocate the source file
500
# via %.o rules.
501
#
502
# The following lines separate the object list into the flatten and regular
503
# lists, and then handles them as appropriate.
504
 
505
FLATTEN_OBJ_LIST := $(filter ../%,$(OBJ_LIST))
506
FLATTEN_APP_OBJS := $(addprefix $(CONFIG_OBJ_DIR)/,$(notdir $(FLATTEN_OBJ_LIST)))
507
 
508
REGULAR_OBJ_LIST                := $(filter-out $(FLATTEN_OBJ_LIST),$(OBJ_LIST))
509
REGULAR_OBJ_LIST_C              := $(filter $(OBJ_LIST_C),$(REGULAR_OBJ_LIST))
510
REGULAR_OBJ_LIST_CPP    := $(filter $(OBJ_LIST_CPP),$(REGULAR_OBJ_LIST))
511
REGULAR_OBJ_LIST_CXX    := $(filter $(OBJ_LIST_CXX),$(REGULAR_OBJ_LIST))
512
REGULAR_OBJ_LIST_CC     := $(filter $(OBJ_LIST_CC),$(REGULAR_OBJ_LIST))
513
REGULAR_OBJ_LIST_S              := $(filter $(OBJ_LIST_S),$(REGULAR_OBJ_LIST))
514
REGULAR_OBJ_LIST_SS             := $(filter $(OBJ_LIST_SS),$(REGULAR_OBJ_LIST))
515
 
516
FLATTEN_SDIR_OBJ_LIST := $(filter ../%,$(SDIR_OBJ_LIST))
517
FLATTEN_SDIR_APP_OBJS := $(addprefix $(CONFIG_OBJ_DIR)/,$(notdir $(FLATTEN_SDIR_OBJ_LIST)))
518
 
519
REGULAR_SDIR_OBJ_LIST           := $(filter-out $(FLATTEN_SDIR_OBJ_LIST),$(SDIR_OBJ_LIST))
520
REGULAR_SDIR_OBJ_LIST_C         := $(filter $(SDIR_OBJ_LIST_C),$(REGULAR_SDIR_OBJ_LIST))
521
REGULAR_SDIR_OBJ_LIST_CPP       := $(filter $(SDIR_OBJ_LIST_CPP),$(REGULAR_SDIR_OBJ_LIST))
522
REGULAR_SDIR_OBJ_LIST_CXX       := $(filter $(SDIR_OBJ_LIST_CXX),$(REGULAR_SDIR_OBJ_LIST))
523
REGULAR_SDIR_OBJ_LIST_CC        := $(filter $(SDIR_OBJ_LIST_CC),$(REGULAR_SDIR_OBJ_LIST))
524
REGULAR_SDIR_OBJ_LIST_S         := $(filter $(SDIR_OBJ_LIST_S),$(REGULAR_SDIR_OBJ_LIST))
525
REGULAR_SDIR_OBJ_LIST_SS        := $(filter $(SDIR_OBJ_LIST_SS),$(REGULAR_SDIR_OBJ_LIST))
526
 
527
VPATH := $(sort $(dir $(FLATTEN_OBJ_LIST)) $(dir $(FLATTEN_SDIR_OBJ_LIST)))
528
 
529
APP_OBJS_C := $(addprefix $(CONFIG_OBJ_DIR)/,\
530
        $(REGULAR_SDIR_OBJ_LIST_C) \
531
        $(foreach s,$(REGULAR_OBJ_LIST_C),$(call adjust-path,$s)))
532
 
533
APP_OBJS_CPP := $(addprefix $(CONFIG_OBJ_DIR)/,\
534
        $(REGULAR_SDIR_OBJ_LIST_CPP) \
535
        $(foreach s,$(REGULAR_OBJ_LIST_CPP),$(call adjust-path,$s)))
536
 
537
APP_OBJS_CXX := $(addprefix $(CONFIG_OBJ_DIR)/,\
538
        $(REGULAR_SDIR_OBJ_LIST_CXX) \
539
        $(foreach s,$(REGULAR_OBJ_LIST_CXX),$(call adjust-path,$s)))
540
 
541
APP_OBJS_CC := $(addprefix $(CONFIG_OBJ_DIR)/,\
542
        $(REGULAR_SDIR_OBJ_LIST_CC) \
543
        $(foreach s,$(REGULAR_OBJ_LIST_CC),$(call adjust-path,$s)))
544
 
545
APP_OBJS_S := $(addprefix $(CONFIG_OBJ_DIR)/,\
546
        $(REGULAR_SDIR_OBJ_LIST_S) \
547
        $(foreach s,$(REGULAR_OBJ_LIST_S),$(call adjust-path,$s)))
548
 
549
APP_OBJS_SS := $(addprefix $(CONFIG_OBJ_DIR)/,\
550
        $(REGULAR_SDIR_OBJ_LIST_SS) \
551
        $(foreach s,$(REGULAR_OBJ_LIST_SS),$(call adjust-path,$s)))
552
 
553
APP_OBJS := $(APP_OBJS_C) $(APP_OBJS_CPP) $(APP_OBJS_CXX) $(APP_OBJS_CC) \
554
        $(APP_OBJS_S) $(APP_OBJS_SS) \
555
        $(FLATTEN_APP_OBJS) $(FLATTEN_SDIR_APP_OBJS)
556
 
557
# Add any extra user-provided object files.
558
APP_OBJS += $(OBJS)
559
 
560
# Create list of dependancy files for each object file.
561
APP_DEPS := $(APP_OBJS:.o=.d)
562
 
563
# Patch the Elf file with system specific information
564
 
565
# Patch the Elf with the name of the sopc system
566
ifneq ($(SOPC_NAME),)
567
ELF_PATCH_FLAG += --sopc_system_name $(SOPC_NAME)
568
endif
569
 
570
# Patch the Elf with the absolute path to the Quartus Project Directory
571
ifneq ($(QUARTUS_PROJECT_DIR),)
572
ABS_QUARTUS_PROJECT_DIR := $(call adjust-path-mixed,$(shell cd "$(QUARTUS_PROJECT_DIR)"; pwd))
573
ELF_PATCH_FLAG += --quartus_project_dir "$(ABS_QUARTUS_PROJECT_DIR)"
574
endif
575
 
576
# Patch the Elf and download args with the JDI_FILE if specified
577
ifneq ($(wildcard $(JDI_FILE)),)
578
ELF_PATCH_FLAG += --jdi $(JDI_FILE)
579
DOWNLOAD_JDI_FLAG := --jdi $(JDI_FILE)
580
endif
581
 
582
# Patch the Elf with the SOPCINFO_FILE if specified
583
ifneq ($(wildcard $(SOPCINFO_FILE)),)
584
ELF_PATCH_FLAG += --sopcinfo $(SOPCINFO_FILE)
585
endif
586
 
587
# Use the DOWNLOAD_CABLE variable to specify which JTAG cable to use.
588
# This is not needed if you only have one cable.
589
ifneq ($(DOWNLOAD_CABLE),)
590
DOWNLOAD_CABLE_FLAG := --cable '$(DOWNLOAD_CABLE)'
591
endif
592
 
593
 
594
#------------------------------------------------------------------------------
595
#                           BUILD PRE/POST PROCESS
596
#------------------------------------------------------------------------------
597
build_pre_process :
598
        $(BUILD_PRE_PROCESS)
599
 
600
build_post_process :
601
        $(BUILD_POST_PROCESS)
602
 
603
.PHONY: build_pre_process build_post_process
604
 
605
 
606
#------------------------------------------------------------------------------
607
#                                 TOOLS
608
#------------------------------------------------------------------------------
609
 
610
#
611
# Set tool default variables if not already defined.
612
# If these are defined, they would typically be defined in an
613
# included makefile fragment.
614
#
615
ifeq ($(DEFAULT_CROSS_COMPILE),)
616
DEFAULT_CROSS_COMPILE := nios2-elf-
617
endif
618
 
619
ifeq ($(DEFAULT_STACKREPORT),)
620
DEFAULT_STACKREPORT := nios2-stackreport
621
endif
622
 
623
ifeq ($(DEFAULT_DOWNLOAD),)
624
DEFAULT_DOWNLOAD := nios2-download
625
endif
626
 
627
ifeq ($(DEFAULT_FLASHPROG),)
628
DEFAULT_FLASHPROG := nios2-flash-programmer
629
endif
630
 
631
ifeq ($(DEFAULT_ELFPATCH),)
632
DEFAULT_ELFPATCH := nios2-elf-insert
633
endif
634
 
635
ifeq ($(DEFAULT_RM),)
636
DEFAULT_RM := rm -f
637
endif
638
 
639
ifeq ($(DEFAULT_CP),)
640
DEFAULT_CP := cp -f
641
endif
642
 
643
ifeq ($(DEFAULT_MKDIR),)
644
DEFAULT_MKDIR := mkdir -p
645
endif
646
 
647
#
648
# Set tool variables to defaults if not already defined.
649
# If these are defined, they would typically be defined by a
650
# setting in the generated portion of this makefile.
651
#
652
ifeq ($(CROSS_COMPILE),)
653
CROSS_COMPILE := $(DEFAULT_CROSS_COMPILE)
654
endif
655
 
656
ifeq ($(origin CC),default)
657
CC := $(CROSS_COMPILE)gcc -xc
658
endif
659
 
660
ifeq ($(origin CXX),default)
661
CXX := $(CROSS_COMPILE)gcc -xc++
662
endif
663
 
664
ifeq ($(origin AS),default)
665
AS := $(CROSS_COMPILE)gcc
666
endif
667
 
668
ifeq ($(origin AR),default)
669
AR := $(CROSS_COMPILE)ar
670
endif
671
 
672
ifeq ($(origin LD),default)
673
LD := $(CROSS_COMPILE)g++
674
endif
675
 
676
ifeq ($(origin RM),default)
677
RM := $(DEFAULT_RM)
678
endif
679
 
680
ifeq ($(NM),)
681
NM := $(CROSS_COMPILE)nm
682
endif
683
 
684
ifeq ($(CP),)
685
CP := $(DEFAULT_CP)
686
endif
687
 
688
ifeq ($(OBJDUMP),)
689
OBJDUMP := $(CROSS_COMPILE)objdump
690
endif
691
 
692
ifeq ($(OBJCOPY),)
693
OBJCOPY := $(CROSS_COMPILE)objcopy
694
endif
695
 
696
ifeq ($(STACKREPORT),)
697
STACKREPORT := $(DEFAULT_STACKREPORT) --prefix $(CROSS_COMPILE)
698
else
699
DISABLE_STACKREPORT := 1
700
endif
701
 
702
ifeq ($(DOWNLOAD),)
703
DOWNLOAD := $(DEFAULT_DOWNLOAD)
704
endif
705
 
706
ifeq ($(FLASHPROG),)
707
FLASHPROG := $(DEFAULT_FLASHPROG)
708
endif
709
 
710
ifeq ($(ELFPATCH),)
711
ELFPATCH := $(DEFAULT_ELFPATCH)
712
endif
713
 
714
ifeq ($(MKDIR),)
715
MKDIR := $(DEFAULT_MKDIR)
716
endif
717
 
718
#------------------------------------------------------------------------------
719
#                     PATTERN RULES TO BUILD OBJECTS
720
#------------------------------------------------------------------------------
721
 
722
define compile.c
723
@$(ECHO) Info: Compiling $< to $@
724
@$(MKDIR) $(@D)
725
$(CC) -MP -MMD -c $(APP_CPPFLAGS) $(APP_CFLAGS) -o $@ $<
726
$(CC_POST_PROCESS)
727
endef
728
 
729
define compile.cpp
730
@$(ECHO) Info: Compiling $< to $@
731
@$(MKDIR) $(@D)
732
$(CXX) -MP -MMD -c $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
733
$(CXX_POST_PROCESS)
734
endef
735
 
736
# If assembling with the compiler, ensure "-Wa," is prepended to all APP_ASFLAGS
737
ifeq ($(AS),$(patsubst %as,%,$(AS)))
738
COMMA := ,
739
APP_ASFLAGS :=  $(filter-out $(APP_CFLAGS),$(addprefix -Wa$(COMMA),$(patsubst -Wa$(COMMA)%,%,$(APP_ASFLAGS))))
740
endif
741
 
742
define compile.s
743
@$(ECHO) Info: Assembling $< to $@
744
@$(MKDIR) $(@D)
745
$(AS) -MP -MMD -c $(APP_CPPFLAGS) $(APP_CFLAGS) $(APP_ASFLAGS) -o $@ $<
746
$(AS_POST_PROCESS)
747
endef
748
 
749
ifeq ($(MAKE_VERSION),3.81)
750
.SECONDEXPANSION:
751
 
752
$(APP_OBJS_C): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.c)
753
        $(compile.c)
754
 
755
$(APP_OBJS_CPP): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.cpp)
756
        $(compile.cpp)
757
 
758
$(APP_OBJS_CC): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.cc)
759
        $(compile.cpp)
760
 
761
$(APP_OBJS_CXX): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.cxx)
762
        $(compile.cpp)
763
 
764
$(APP_OBJS_S): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.S)
765
        $(compile.s)
766
 
767
$(APP_OBJS_SS): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.s)
768
        $(compile.s)
769
 
770
endif # MAKE_VERSION != 3.81
771
 
772
$(CONFIG_OBJ_DIR)/%.o: %.c
773
        $(compile.c)
774
 
775
$(CONFIG_OBJ_DIR)/%.o: %.cpp
776
        $(compile.cpp)
777
 
778
$(CONFIG_OBJ_DIR)/%.o: %.cc
779
        $(compile.cpp)
780
 
781
$(CONFIG_OBJ_DIR)/%.o: %.cxx
782
        $(compile.cpp)
783
 
784
$(CONFIG_OBJ_DIR)/%.o: %.S
785
        $(compile.s)
786
 
787
$(CONFIG_OBJ_DIR)/%.o: %.s
788
        $(compile.s)
789
 
790
 
791
#------------------------------------------------------------------------------
792
#                     PATTERN RULES TO INTERMEDIATE FILES
793
#------------------------------------------------------------------------------
794
 
795
$(CONFIG_OBJ_DIR)/%.s: %.c
796
        @$(ECHO) Info: Compiling $< to $@
797
        @$(MKDIR) $(@D)
798
        $(CC) -S $(APP_CPPFLAGS) $(APP_CFLAGS) -o $@ $<
799
 
800
$(CONFIG_OBJ_DIR)/%.s: %.cpp
801
        @$(ECHO) Info: Compiling $< to $@
802
        @$(MKDIR) $(@D)
803
        $(CXX) -S $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
804
 
805
$(CONFIG_OBJ_DIR)/%.s: %.cc
806
        @$(ECHO) Info: Compiling $< to $@
807
        @$(MKDIR) $(@D)
808
        $(CXX) -S $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
809
 
810
$(CONFIG_OBJ_DIR)/%.s: %.cxx
811
        @$(ECHO) Info: Compiling $< to $@
812
        @$(MKDIR) $(@D)
813
        $(CXX) -S $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
814
 
815
$(CONFIG_OBJ_DIR)/%.i: %.c
816
        @$(ECHO) Info: Compiling $< to $@
817
        @$(MKDIR) $(@D)
818
        $(CC) -E $(APP_CPPFLAGS) $(APP_CFLAGS) -o $@ $<
819
 
820
$(CONFIG_OBJ_DIR)/%.i: %.cpp
821
        @$(ECHO) Info: Compiling $< to $@
822
        @$(MKDIR) $(@D)
823
        $(CXX) -E $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
824
 
825
$(CONFIG_OBJ_DIR)/%.i: %.cc
826
        @$(ECHO) Info: Compiling $< to $@
827
        @$(MKDIR) $(@D)
828
        $(CXX) -E $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
829
 
830
$(CONFIG_OBJ_DIR)/%.i: %.cxx
831
        @$(ECHO) Info: Compiling $< to $@
832
        @$(MKDIR) $(@D)
833
        $(CXX) -E $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
834
 
835
 
836
#------------------------------------------------------------------------------
837
#                        TARGET RULES
838
#------------------------------------------------------------------------------
839
 
840
.PHONY : help
841
help :
842
        @$(ECHO) "Summary of Makefile targets"
843
        @$(ECHO) "  Build targets:"
844
        @$(ECHO) "    all (default)     - Application and all libraries (including BSP)"
845
        @$(ECHO) "    bsp               - Just the BSP"
846
        @$(ECHO) "    libs              - All libraries (including BSP)"
847
        @$(ECHO) "    flash             - All flash files"
848
        @$(ECHO) "    mem_init_generate - All memory initialization files"
849
ifeq ($(QSYS),1)
850
        @$(ECHO) "    mem_init_install  - This target is deprecated for QSys Systems"
851
        @$(ECHO) "                         --> Use the mem_init_generate target and then"
852
        @$(ECHO) "                             add the generated meminit.qip file to your"
853
        @$(ECHO) "                             Quartus II Project."
854
else # if QSYS != 1
855
        @$(ECHO) "    mem_init_install  - Copy memory initialization files to Quartus II project"
856
endif # QSYS == 1
857
        @$(ECHO)
858
        @$(ECHO) "  Clean targets:"
859
        @$(ECHO) "    clean_all         - Application and all libraries (including BSP)"
860
        @$(ECHO) "    clean             - Just the application"
861
        @$(ECHO) "    clean_bsp         - Just the BSP"
862
        @$(ECHO) "    clean_libs        - All libraries (including BSP)"
863
        @$(ECHO)
864
        @$(ECHO) "  Run targets:"
865
        @$(ECHO) "    download-elf      - Download and run your elf executable"
866
        @$(ECHO) "    program-flash     - Program flash contents to the board"
867
 
868
# Handy rule to skip making libraries and just make application.
869
.PHONY : app
870
app : $(ELF)
871
 
872
ifeq ($(CREATE_OBJDUMP), 1)
873
app : $(OBJDUMP_NAME)
874
endif
875
 
876
ifeq ($(CREATE_ELF_DERIVED_FILES),1)
877
app : elf_derived_files
878
endif
879
 
880
.PHONY: elf_derived_files
881
elf_derived_files: default_mem_init
882
 
883
# Handy rule for making just the BSP.
884
.PHONY : bsp
885
bsp :
886
        @$(ECHO) Info: Building $(BSP_ROOT_DIR)
887
        @$(MAKE) --no-print-directory -C $(BSP_ROOT_DIR)
888
 
889
 
890
# Make sure all makeable libraries (including the BSP) are up-to-date.
891
LIB_TARGETS := $(patsubst %,%-recurs-make-lib,$(MAKEABLE_LIBRARY_ROOT_DIRS))
892
 
893
.PHONY : libs
894
libs : $(LIB_TARGETS)
895
 
896
ifneq ($(strip $(LIB_TARGETS)),)
897
$(LIB_TARGETS): %-recurs-make-lib:
898
        @$(ECHO) Info: Building $*
899
        $(MAKE) --no-print-directory -C $*
900
endif
901
 
902
ifneq ($(strip $(APP_LDDEPS)),)
903
$(APP_LDDEPS): libs
904
        @true
905
endif
906
 
907
# Rules to force your project to rebuild or relink
908
# .force_relink file will cause any application that depends on this project to relink
909
# .force_rebuild file will cause this project to rebuild object files
910
# .force_rebuild_all file will cause this project and any project that depends on this project to rebuild object files
911
 
912
FORCE_RELINK_DEP  := .force_relink
913
FORCE_REBUILD_DEP := .force_rebuild
914
FORCE_REBUILD_ALL_DEP := .force_rebuild_all
915
FORCE_REBUILD_DEP_LIST := $(CONFIG_OBJ_DIR)/$(FORCE_RELINK_DEP) $(CONFIG_OBJ_DIR)/$(FORCE_REBUILD_DEP) $(FORCE_REBUILD_ALL_DEP)
916
 
917
$(FORCE_REBUILD_DEP_LIST):
918
 
919
$(APP_OBJS): $(wildcard $(CONFIG_OBJ_DIR)/$(FORCE_REBUILD_DEP)) $(wildcard $(addsuffix /$(FORCE_REBUILD_ALL_DEP), . $(ALT_LIBRARY_DIRS)))
920
 
921
$(ELF): $(wildcard $(addsuffix /$(FORCE_RELINK_DEP), $(CONFIG_OBJ_DIR) $(ALT_LIBRARY_DIRS)))
922
 
923
 
924
# Clean just the application.
925
.PHONY : clean
926
ifeq ($(CREATE_ELF_DERIVED_FILES),1)
927
clean : clean_elf_derived_files
928
endif
929
 
930
clean :
931
        @$(RM) -r $(ELF) $(OBJDUMP_NAME) $(LINKER_MAP_NAME) $(OBJ_ROOT_DIR) $(RUNTIME_ROOT_DIR) $(FORCE_REBUILD_DEP_LIST)
932
        @$(ECHO) [$(APP_NAME) clean complete]
933
 
934
# Clean just the BSP.
935
.PHONY : clean_bsp
936
clean_bsp :
937
        @$(ECHO) Info: Cleaning $(BSP_ROOT_DIR)
938
        @$(MAKE) --no-print-directory -C $(BSP_ROOT_DIR) clean
939
 
940
# Clean all makeable libraries including the BSP.
941
LIB_CLEAN_TARGETS := $(patsubst %,%-recurs-make-clean-lib,$(MAKEABLE_LIBRARY_ROOT_DIRS))
942
 
943
.PHONY : clean_libs
944
clean_libs : $(LIB_CLEAN_TARGETS)
945
 
946
ifneq ($(strip $(LIB_CLEAN_TARGETS)),)
947
$(LIB_CLEAN_TARGETS): %-recurs-make-clean-lib:
948
        @$(ECHO) Info: Cleaning $*
949
        $(MAKE) --no-print-directory -C $* clean
950
endif
951
 
952
.PHONY: clean_elf_derived_files
953
clean_elf_derived_files: mem_init_clean
954
 
955
# Clean application and all makeable libraries including the BSP.
956
.PHONY : clean_all
957
clean_all : clean mem_init_clean clean_libs
958
 
959
# Include the dependency files unless the make goal is performing a clean
960
# of the application.
961
ifneq ($(firstword $(MAKECMDGOALS)),clean)
962
ifneq ($(firstword $(MAKECMDGOALS)),clean_all)
963
-include $(APP_DEPS)
964
endif
965
endif
966
 
967
.PHONY : download-elf
968
download-elf : $(ELF)
969
        @if [ "$(DOWNLOAD)" = "none" ]; \
970
        then \
971
                $(ECHO) Downloading $(ELF) not supported; \
972
        else \
973
                $(ECHO) Info: Downloading $(ELF); \
974
                $(DOWNLOAD) --go --cpu_name=$(CPU_NAME) $(DOWNLOAD_CABLE_FLAG) $(SOPC_SYSID_FLAG) $(DOWNLOAD_JDI_FLAG) $(WRITE_GMON_OPTION) $(ELF); \
975
        fi
976
 
977
# Delete the target of a rule if it has changed and its commands exit
978
# with a nonzero exit status.
979
.DELETE_ON_ERROR:
980
 
981
# Rules for flash programming commands
982
PROGRAM_FLASH_SUFFIX := -program
983
PROGRAM_FLASH_TARGET := $(addsuffix $(PROGRAM_FLASH_SUFFIX), $(FLASH_FILES))
984
 
985
.PHONY : program-flash
986
program-flash : $(PROGRAM_FLASH_TARGET)
987
 
988
.PHONY : $(PROGRAM_FLASH_TARGET)
989
$(PROGRAM_FLASH_TARGET) : flash
990
        @if [ "$(FLASHPROG)" = "none" ]; \
991
        then \
992
                $(ECHO) Programming flash not supported; \
993
        else \
994
                $(ECHO) Info: Programming $(basename $@).flash; \
995
                if [ -z "$($(basename $@)_EPCS_FLAGS)" ]; \
996
                then \
997
                        $(ECHO) $(FLASHPROG) $(SOPC_SYSID_FLAG) --base=$($(basename $@)_START) $(basename $@).flash; \
998
                        $(FLASHPROG) $(DOWNLOAD_CABLE_FLAG) $(SOPC_SYSID_FLAG) --base=$($(basename $@)_START) $(basename $@).flash; \
999
                else \
1000
                        $(ECHO) $(FLASHPROG) $(SOPC_SYSID_FLAG) --epcs --base=$($(basename $@)_START) $(basename $@).flash; \
1001
                        $(FLASHPROG) $(DOWNLOAD_CABLE_FLAG) $(SOPC_SYSID_FLAG) --epcs --base=$($(basename $@)_START) $(basename $@).flash; \
1002
                fi \
1003
        fi
1004
 
1005
 
1006
# Rules for simulating with an HDL Simulator [QSYS only]
1007
ifeq ($(QSYS),1)
1008
IP_MAKE_SIMSCRIPT := ip-make-simscript
1009
 
1010
ifeq ($(VSIM),)
1011
VSIM_EXE := "$(if $(VSIM_DIR),$(VSIM_DIR)/,)vsim"
1012
ifeq ($(ENABLE_VSIM_GUI),1)
1013
VSIM := $(VSIM_EXE) -gui
1014
else
1015
VSIM := $(VSIM_EXE) -c
1016
endif # ENABLE_VSIM_GUI == 1
1017
endif # VSIM not set
1018
 
1019
ifeq ($(SPD),)
1020
ifneq ($(ABS_QUARTUS_PROJECT_DIR),)
1021
ifneq ($(SOPC_NAME),)
1022
SPD := $(ABS_QUARTUS_PROJECT_DIR)/$(SOPC_NAME)_tb.spd
1023
endif # SOPC_NAME set
1024
endif # ABS_QUARTUS_PROJECT_DIR set
1025
endif # SPD == empty string
1026
 
1027
ifeq ($(MSIM_SCRIPT),)
1028
SIM_SCRIPT_DIR := $(RUNTIME_ROOT_DIR)/sim
1029
MSIM_SCRIPT := $(SIM_SCRIPT_DIR)/mentor/msim_setup.tcl
1030
endif # MSIM_SCRIPT == empty string
1031
 
1032
ifeq ($(MAKE_VERSION),3.81)
1033
ABS_MEM_INIT_DESCRIPTOR_FILE := $(abspath $(MEM_INIT_DESCRIPTOR_FILE))
1034
else
1035
ABS_MEM_INIT_DESCRIPTOR_FILE := $(call adjust-path-mixed,$(shell pwd))/$(MEM_INIT_DESCRIPTOR_FILE)
1036
endif
1037
 
1038
$(MSIM_SCRIPT): $(SPD) $(MEM_INIT_DESCRIPTOR_FILE)
1039
ifeq ($(SPD),)
1040
        $(error No SPD file specified. Ensure QUARTUS_PROJECT_DIR variable is set)
1041
endif
1042
        @$(MKDIR) $(SIM_SCRIPT_DIR)
1043
        $(IP_MAKE_SIMSCRIPT) --spd=$(SPD) --spd=$(MEM_INIT_DESCRIPTOR_FILE) --output-directory=$(SIM_SCRIPT_DIR)
1044
 
1045
VSIM_COMMAND = \
1046
        cd $(dir $(MSIM_SCRIPT)) && \
1047
        $(VSIM) -do "do $(notdir $(MSIM_SCRIPT)); ld; $(if $(VSIM_RUN_TIME),run ${VSIM_RUN_TIME};quit;)"
1048
 
1049
.PHONY: sim
1050
sim: $(MSIM_SCRIPT) mem_init_generate
1051
ifeq ($(MSIM_SCRIPT),)
1052
        $(error MSIM_SCRIPT not set)
1053
endif
1054
        $(VSIM_COMMAND)
1055
 
1056
endif # QSYS == 1
1057
 
1058
 
1059
#------------------------------------------------------------------------------
1060
#                         ELF TARGET RULE
1061
#------------------------------------------------------------------------------
1062
# Rule for constructing the executable elf file.
1063
$(ELF) : $(APP_OBJS) $(LINKER_SCRIPT) $(APP_LDDEPS)
1064
        @$(ECHO) Info: Linking $@
1065
        $(LD) $(APP_LDFLAGS) $(APP_CFLAGS) -o $@ $(filter-out $(CRT0),$(APP_OBJS)) $(APP_LIBS) $(APP_BSP_DEP_LIBS)
1066
ifneq ($(DISABLE_ELFPATCH),1)
1067
        $(ELFPATCH) $@ $(ELF_PATCH_FLAG)
1068
endif
1069
ifneq ($(DISABLE_STACKREPORT),1)
1070
        @bash -c "$(STACKREPORT) $@"
1071
endif
1072
 
1073
$(OBJDUMP_NAME) : $(ELF)
1074
        @$(ECHO) Info: Creating $@
1075
        $(OBJDUMP) $(OBJDUMP_FLAGS) $< >$@
1076
 
1077
# Rule for printing the name of the elf file
1078
.PHONY: print-elf-name
1079
print-elf-name:
1080
        @$(ECHO) $(ELF)
1081
 
1082
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.