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

Subversion Repositories ao486

[/] [ao486/] [trunk/] [syn/] [components/] [sd_card/] [software/] [exe/] [Makefile] - Blame information for rev 2

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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