OpenCores
URL https://opencores.org/ocsvn/usb_ft232h_avalon-mm_interface/usb_ft232h_avalon-mm_interface/trunk

Subversion Repositories usb_ft232h_avalon-mm_interface

[/] [usb_ft232h_avalon-mm_interface/] [trunk/] [testbench/] [altera_project/] [test_usb_ft232h/] [software/] [usb_ft232h/] [Makefile] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 melman701
#------------------------------------------------------------------------------
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: 16.0
133
ACDS_VERSION := 16.0
134
 
135
# This following BUILD_NUMBER comment indicates the build number of the tool
136
# used to generate this makefile.
137
# BUILD_NUMBER: 222
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 := usb_ft232h.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 := 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 := -O0
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 := ../usb_ft232h_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
# If the BSP public.mk indicates that ALT_SIM_OPTIMIZE is set, rename the ELF
256
# by prefixing it with RUN_ON_HDL_SIMULATOR_ONLY_.
257
ifneq ($(filter -DALT_SIM_OPTIMIZE,$(ALT_CPPFLAGS)),)
258
ELF := RUN_ON_HDL_SIMULATOR_ONLY_$(ELF)
259
endif
260
 
261
# If the BSP public.mk indicates that ALT_PROVIDE_GMON is set, add option to
262
# download_elf target
263
ifneq ($(filter -DALT_PROVIDE_GMON,$(ALT_CPPFLAGS)),)
264
GMON_OUT_FILENAME := gmon.out
265
WRITE_GMON_OPTION := --write-gmon $(GMON_OUT_FILENAME)
266
endif
267
 
268
# Name of ELF application.
269
APP_NAME := $(basename $(ELF))
270
 
271
# Set to defaults if variables not already defined in settings.
272
ifeq ($(LINKER_SCRIPT),)
273
LINKER_SCRIPT := $(BSP_LINKER_SCRIPT)
274
endif
275
ifeq ($(CRT0),)
276
CRT0 := $(BSP_CRT0)
277
endif
278
ifeq ($(SYS_LIB),)
279
SYS_LIB := $(BSP_SYS_LIB)
280
endif
281
 
282
OBJDUMP_NAME := $(APP_NAME).objdump
283
OBJDUMP_FLAGS := --disassemble --syms --all-header
284
ifeq ($(OBJDUMP_INCLUDE_SOURCE),1)
285
OBJDUMP_FLAGS += --source
286
endif
287
ifeq ($(OBJDUMP_FULL_CONTENTS),1)
288
OBJDUMP_FLAGS += --full-contents
289
endif
290
 
291
# Create list of linker dependencies (*.a files).
292
APP_LDDEPS := $(ALT_LDDEPS) $(LDDEPS)
293
 
294
# Take lists and add required prefixes.
295
APP_INC_DIRS := $(addprefix -I, $(ALT_INCLUDE_DIRS) $(APP_INCLUDE_DIRS) $(INC_DIRS))
296
ASM_INC_PREFIX := -Wa,-I
297
APP_ASM_INC_DIRS := $(addprefix $(ASM_INC_PREFIX), $(ALT_INCLUDE_DIRS) $(APP_INCLUDE_DIRS) $(INC_DIRS))
298
APP_LIB_DIRS := $(addprefix -L, $(ALT_LIBRARY_DIRS) $(APP_LIBRARY_DIRS) $(LIB_DIRS))
299
APP_LIBS := $(addprefix -l, $(ALT_LIBRARY_NAMES) $(APP_LIBRARY_NAMES) $(LIBS))
300
 
301
ifneq ($(AVOID_NIOS2_GCC3_OPTIONS),)
302
 
303
#
304
# Avoid Nios II GCC 3.X options.
305
#
306
 
307
# Detect if small newlib C library is requested.
308
# If yes, remove the -msmallc option because it is
309
# now handled by other means.
310
ifneq ($(filter -msmallc,$(ALT_LDFLAGS)),)
311
        ALT_LDFLAGS := $(filter-out -msmallc,$(ALT_LDFLAGS))
312
        ALT_C_LIBRARY := smallc
313
else
314
        ALT_C_LIBRARY := c
315
endif
316
 
317
# Put each BSP dependent library in a group to avoid circular dependencies.
318
APP_BSP_DEP_LIBS := $(foreach l,$(ALT_BSP_DEP_LIBRARY_NAMES),-Wl,--start-group -l$(ALT_C_LIBRARY) -lgcc -lm -l$(l) -Wl,--end-group)
319
 
320
else # !AVOID_NIOS2_GCC3_OPTIONS
321
 
322
#
323
# Use Nios II GCC 3.X options.
324
#
325
ALT_BSP_DEP_LIBRARY_NAMES += $(ALT_BSP_DEP_LIBRARY_NAMES) m
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 := $(firstword $(wildcard $(QUARTUS_PROJECT_DIR)/output_files/*.jdi) $(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_STACKREPORT),)
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 RM),default)
679
RM := $(DEFAULT_RM)
680
endif
681
 
682
ifeq ($(NM),)
683
NM := $(CROSS_COMPILE)nm
684
endif
685
 
686
ifeq ($(CP),)
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
STACKREPORT := $(DEFAULT_STACKREPORT) --prefix $(CROSS_COMPILE)
700
else
701
DISABLE_STACKREPORT := 1
702
endif
703
 
704
ifeq ($(DOWNLOAD),)
705
DOWNLOAD := $(DEFAULT_DOWNLOAD)
706
endif
707
 
708
ifeq ($(FLASHPROG),)
709
FLASHPROG := $(DEFAULT_FLASHPROG)
710
endif
711
 
712
ifeq ($(ELFPATCH),)
713
ELFPATCH := $(DEFAULT_ELFPATCH)
714
endif
715
 
716
ifeq ($(MKDIR),)
717
MKDIR := $(DEFAULT_MKDIR)
718
endif
719
 
720
#------------------------------------------------------------------------------
721
#                     PATTERN RULES TO BUILD OBJECTS
722
#------------------------------------------------------------------------------
723
 
724
define compile.c
725
@$(ECHO) Info: Compiling $< to $@
726
@$(MKDIR) $(@D)
727
$(CC) -MP -MMD -c $(APP_CPPFLAGS) $(APP_CFLAGS) -o $@ $<
728
$(CC_POST_PROCESS)
729
endef
730
 
731
define compile.cpp
732
@$(ECHO) Info: Compiling $< to $@
733
@$(MKDIR) $(@D)
734
$(CXX) -MP -MMD -c $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
735
$(CXX_POST_PROCESS)
736
endef
737
 
738
# If assembling with the compiler, ensure "-Wa," is prepended to all APP_ASFLAGS
739
ifeq ($(AS),$(patsubst %as,%,$(AS)))
740
COMMA := ,
741
APP_ASFLAGS :=  $(filter-out $(APP_CFLAGS),$(addprefix -Wa$(COMMA),$(patsubst -Wa$(COMMA)%,%,$(APP_ASFLAGS))))
742
endif
743
 
744
define compile.s
745
@$(ECHO) Info: Assembling $< to $@
746
@$(MKDIR) $(@D)
747
$(AS) -MP -MMD -c $(APP_CPPFLAGS) $(APP_CFLAGS) $(APP_ASFLAGS) -o $@ $<
748
$(AS_POST_PROCESS)
749
endef
750
 
751
ifeq ($(MAKE_VERSION),3.81)
752
.SECONDEXPANSION:
753
 
754
$(APP_OBJS_C): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.c)
755
        $(compile.c)
756
 
757
$(APP_OBJS_CPP): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.cpp)
758
        $(compile.cpp)
759
 
760
$(APP_OBJS_CC): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.cc)
761
        $(compile.cpp)
762
 
763
$(APP_OBJS_CXX): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.cxx)
764
        $(compile.cpp)
765
 
766
$(APP_OBJS_S): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.S)
767
        $(compile.s)
768
 
769
$(APP_OBJS_SS): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.s)
770
        $(compile.s)
771
 
772
endif # MAKE_VERSION != 3.81
773
 
774
$(CONFIG_OBJ_DIR)/%.o: %.c
775
        $(compile.c)
776
 
777
$(CONFIG_OBJ_DIR)/%.o: %.cpp
778
        $(compile.cpp)
779
 
780
$(CONFIG_OBJ_DIR)/%.o: %.cc
781
        $(compile.cpp)
782
 
783
$(CONFIG_OBJ_DIR)/%.o: %.cxx
784
        $(compile.cpp)
785
 
786
$(CONFIG_OBJ_DIR)/%.o: %.S
787
        $(compile.s)
788
 
789
$(CONFIG_OBJ_DIR)/%.o: %.s
790
        $(compile.s)
791
 
792
 
793
#------------------------------------------------------------------------------
794
#                     PATTERN RULES TO INTERMEDIATE FILES
795
#------------------------------------------------------------------------------
796
 
797
$(CONFIG_OBJ_DIR)/%.s: %.c
798
        @$(ECHO) Info: Compiling $< to $@
799
        @$(MKDIR) $(@D)
800
        $(CC) -S $(APP_CPPFLAGS) $(APP_CFLAGS) -o $@ $<
801
 
802
$(CONFIG_OBJ_DIR)/%.s: %.cpp
803
        @$(ECHO) Info: Compiling $< to $@
804
        @$(MKDIR) $(@D)
805
        $(CXX) -S $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
806
 
807
$(CONFIG_OBJ_DIR)/%.s: %.cc
808
        @$(ECHO) Info: Compiling $< to $@
809
        @$(MKDIR) $(@D)
810
        $(CXX) -S $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
811
 
812
$(CONFIG_OBJ_DIR)/%.s: %.cxx
813
        @$(ECHO) Info: Compiling $< to $@
814
        @$(MKDIR) $(@D)
815
        $(CXX) -S $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
816
 
817
$(CONFIG_OBJ_DIR)/%.i: %.c
818
        @$(ECHO) Info: Compiling $< to $@
819
        @$(MKDIR) $(@D)
820
        $(CC) -E $(APP_CPPFLAGS) $(APP_CFLAGS) -o $@ $<
821
 
822
$(CONFIG_OBJ_DIR)/%.i: %.cpp
823
        @$(ECHO) Info: Compiling $< to $@
824
        @$(MKDIR) $(@D)
825
        $(CXX) -E $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
826
 
827
$(CONFIG_OBJ_DIR)/%.i: %.cc
828
        @$(ECHO) Info: Compiling $< to $@
829
        @$(MKDIR) $(@D)
830
        $(CXX) -E $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
831
 
832
$(CONFIG_OBJ_DIR)/%.i: %.cxx
833
        @$(ECHO) Info: Compiling $< to $@
834
        @$(MKDIR) $(@D)
835
        $(CXX) -E $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
836
 
837
 
838
#------------------------------------------------------------------------------
839
#                        TARGET RULES
840
#------------------------------------------------------------------------------
841
 
842
.PHONY : help
843
help :
844
        @$(ECHO) "Summary of Makefile targets"
845
        @$(ECHO) "  Build targets:"
846
        @$(ECHO) "    all (default)     - Application and all libraries (including BSP)"
847
        @$(ECHO) "    bsp               - Just the BSP"
848
        @$(ECHO) "    libs              - All libraries (including BSP)"
849
        @$(ECHO) "    flash             - All flash files"
850
        @$(ECHO) "    mem_init_generate - All memory initialization files"
851
        @$(ECHO)
852
        @$(ECHO) "  Clean targets:"
853
        @$(ECHO) "    clean_all         - Application and all libraries (including BSP)"
854
        @$(ECHO) "    clean             - Just the application"
855
        @$(ECHO) "    clean_bsp         - Just the BSP"
856
        @$(ECHO) "    clean_libs        - All libraries (including BSP)"
857
        @$(ECHO)
858
        @$(ECHO) "  Run targets:"
859
        @$(ECHO) "    download-elf      - Download and run your elf executable"
860
        @$(ECHO) "    program-flash     - Program flash contents to the board"
861
 
862
# Handy rule to skip making libraries and just make application.
863
.PHONY : app
864
app : $(ELF)
865
 
866
ifeq ($(CREATE_OBJDUMP), 1)
867
app : $(OBJDUMP_NAME)
868
endif
869
 
870
ifeq ($(CREATE_ELF_DERIVED_FILES),1)
871
app : elf_derived_files
872
endif
873
 
874
.PHONY: elf_derived_files
875
elf_derived_files: default_mem_init
876
 
877
# Handy rule for making just the BSP.
878
.PHONY : bsp
879
bsp :
880
        @$(ECHO) Info: Building $(BSP_ROOT_DIR)
881
        @$(MAKE) --no-print-directory -C $(BSP_ROOT_DIR)
882
 
883
 
884
# Make sure all makeable libraries (including the BSP) are up-to-date.
885
LIB_TARGETS := $(patsubst %,%-recurs-make-lib,$(MAKEABLE_LIBRARY_ROOT_DIRS))
886
 
887
.PHONY : libs
888
libs : $(LIB_TARGETS)
889
 
890
ifneq ($(strip $(LIB_TARGETS)),)
891
$(LIB_TARGETS): %-recurs-make-lib:
892
        @$(ECHO) Info: Building $*
893
        $(MAKE) --no-print-directory -C $*
894
endif
895
 
896
ifneq ($(strip $(APP_LDDEPS)),)
897
$(APP_LDDEPS): libs
898
        @true
899
endif
900
 
901
# Rules to force your project to rebuild or relink
902
# .force_relink file will cause any application that depends on this project to relink
903
# .force_rebuild file will cause this project to rebuild object files
904
# .force_rebuild_all file will cause this project and any project that depends on this project to rebuild object files
905
 
906
FORCE_RELINK_DEP  := .force_relink
907
FORCE_REBUILD_DEP := .force_rebuild
908
FORCE_REBUILD_ALL_DEP := .force_rebuild_all
909
FORCE_REBUILD_DEP_LIST := $(CONFIG_OBJ_DIR)/$(FORCE_RELINK_DEP) $(CONFIG_OBJ_DIR)/$(FORCE_REBUILD_DEP) $(FORCE_REBUILD_ALL_DEP)
910
 
911
$(FORCE_REBUILD_DEP_LIST):
912
 
913
$(APP_OBJS): $(wildcard $(CONFIG_OBJ_DIR)/$(FORCE_REBUILD_DEP)) $(wildcard $(addsuffix /$(FORCE_REBUILD_ALL_DEP), . $(ALT_LIBRARY_DIRS)))
914
 
915
$(ELF): $(wildcard $(addsuffix /$(FORCE_RELINK_DEP), $(CONFIG_OBJ_DIR) $(ALT_LIBRARY_DIRS)))
916
 
917
 
918
# Clean just the application.
919
.PHONY : clean
920
ifeq ($(CREATE_ELF_DERIVED_FILES),1)
921
clean : clean_elf_derived_files
922
endif
923
 
924
clean :
925
        @$(RM) -r $(ELF) $(OBJDUMP_NAME) $(LINKER_MAP_NAME) $(OBJ_ROOT_DIR) $(RUNTIME_ROOT_DIR) $(FORCE_REBUILD_DEP_LIST)
926
        @$(ECHO) [$(APP_NAME) clean complete]
927
 
928
# Clean just the BSP.
929
.PHONY : clean_bsp
930
clean_bsp :
931
        @$(ECHO) Info: Cleaning $(BSP_ROOT_DIR)
932
        @$(MAKE) --no-print-directory -C $(BSP_ROOT_DIR) clean
933
 
934
# Clean all makeable libraries including the BSP.
935
LIB_CLEAN_TARGETS := $(patsubst %,%-recurs-make-clean-lib,$(MAKEABLE_LIBRARY_ROOT_DIRS))
936
 
937
.PHONY : clean_libs
938
clean_libs : $(LIB_CLEAN_TARGETS)
939
 
940
ifneq ($(strip $(LIB_CLEAN_TARGETS)),)
941
$(LIB_CLEAN_TARGETS): %-recurs-make-clean-lib:
942
        @$(ECHO) Info: Cleaning $*
943
        $(MAKE) --no-print-directory -C $* clean
944
endif
945
 
946
.PHONY: clean_elf_derived_files
947
clean_elf_derived_files: mem_init_clean
948
 
949
# Clean application and all makeable libraries including the BSP.
950
.PHONY : clean_all
951
clean_all : clean mem_init_clean clean_libs
952
 
953
# Include the dependency files unless the make goal is performing a clean
954
# of the application.
955
ifneq ($(firstword $(MAKECMDGOALS)),clean)
956
ifneq ($(firstword $(MAKECMDGOALS)),clean_all)
957
-include $(APP_DEPS)
958
endif
959
endif
960
 
961
.PHONY : download-elf
962
download-elf : $(ELF)
963
        @if [ "$(DOWNLOAD)" = "none" ]; \
964
        then \
965
                $(ECHO) Downloading $(ELF) not supported; \
966
        else \
967
                $(ECHO) Info: Downloading $(ELF); \
968
                $(DOWNLOAD) --go --cpu_name=$(CPU_NAME) $(DOWNLOAD_CABLE_FLAG) $(SOPC_SYSID_FLAG) $(DOWNLOAD_JDI_FLAG) $(WRITE_GMON_OPTION) $(ELF); \
969
        fi
970
 
971
# Delete the target of a rule if it has changed and its commands exit
972
# with a nonzero exit status.
973
.DELETE_ON_ERROR:
974
 
975
# Rules for flash programming commands
976
PROGRAM_FLASH_SUFFIX := -program
977
PROGRAM_FLASH_TARGET := $(addsuffix $(PROGRAM_FLASH_SUFFIX), $(FLASH_FILES))
978
 
979
.PHONY : program-flash
980
program-flash : $(PROGRAM_FLASH_TARGET)
981
 
982
.PHONY : $(PROGRAM_FLASH_TARGET)
983
$(PROGRAM_FLASH_TARGET) : flash
984
        @if [ "$(FLASHPROG)" = "none" ]; \
985
        then \
986
                $(ECHO) Programming flash not supported; \
987
        else \
988
                $(ECHO) Info: Programming $(basename $@).flash; \
989
                if [ -z "$($(basename $@)_EPCS_FLAGS)" ]; \
990
                then \
991
                        $(ECHO) $(FLASHPROG) $(SOPC_SYSID_FLAG) --base=$($(basename $@)_START) $(basename $@).flash; \
992
                        $(FLASHPROG) $(DOWNLOAD_CABLE_FLAG) $(SOPC_SYSID_FLAG) --base=$($(basename $@)_START) $(basename $@).flash; \
993
                else \
994
                        $(ECHO) $(FLASHPROG) $(SOPC_SYSID_FLAG) --epcs --base=$($(basename $@)_START) $(basename $@).flash; \
995
                        $(FLASHPROG) $(DOWNLOAD_CABLE_FLAG) $(SOPC_SYSID_FLAG) --epcs --base=$($(basename $@)_START) $(basename $@).flash; \
996
                fi \
997
        fi
998
 
999
 
1000
# Rules for simulating with an HDL Simulator [QSYS only]
1001
ifeq ($(QSYS),1)
1002
IP_MAKE_SIMSCRIPT := ip-make-simscript
1003
 
1004
ifeq ($(VSIM),)
1005
VSIM_EXE := "$(if $(VSIM_DIR),$(VSIM_DIR)/,)vsim"
1006
ifeq ($(ENABLE_VSIM_GUI),1)
1007
VSIM := $(VSIM_EXE) -gui
1008
else
1009
VSIM := $(VSIM_EXE) -c
1010
endif # ENABLE_VSIM_GUI == 1
1011
endif # VSIM not set
1012
 
1013
ifeq ($(SPD),)
1014
ifneq ($(ABS_QUARTUS_PROJECT_DIR),)
1015
ifneq ($(SOPC_NAME),)
1016
SPD_LOCATION = $(ABS_QUARTUS_PROJECT_DIR)/$(SOPC_NAME)_tb/$(SOPC_NAME)_tb/$(SOPC_NAME)_tb.spd
1017
LEGACY_SPD_LOCATION = $(ABS_QUARTUS_PROJECT_DIR)/$(SOPC_NAME)_tb.spd
1018
SPD = $(if $(wildcard $(SPD_LOCATION)),$(SPD_LOCATION),$(LEGACY_SPD_LOCATION))
1019
endif # SOPC_NAME set
1020
endif # ABS_QUARTUS_PROJECT_DIR set
1021
endif # SPD == empty string
1022
 
1023
ifeq ($(MSIM_SCRIPT),)
1024
SIM_SCRIPT_DIR := $(RUNTIME_ROOT_DIR)/sim
1025
MSIM_SCRIPT := $(SIM_SCRIPT_DIR)/mentor/msim_setup.tcl
1026
endif # MSIM_SCRIPT == empty string
1027
 
1028
ifeq ($(MAKE_VERSION),3.81)
1029
ABS_MEM_INIT_DESCRIPTOR_FILE := $(abspath $(MEM_INIT_DESCRIPTOR_FILE))
1030
else
1031
ABS_MEM_INIT_DESCRIPTOR_FILE := $(call adjust-path-mixed,$(shell pwd))/$(MEM_INIT_DESCRIPTOR_FILE)
1032
endif
1033
 
1034
$(MSIM_SCRIPT): $(SPD) $(MEM_INIT_DESCRIPTOR_FILE)
1035
ifeq ($(SPD),)
1036
        $(error No SPD file specified. Ensure QUARTUS_PROJECT_DIR variable is set)
1037
endif
1038
        @$(MKDIR) $(SIM_SCRIPT_DIR)
1039
        $(IP_MAKE_SIMSCRIPT) --spd=$(SPD) --spd=$(MEM_INIT_DESCRIPTOR_FILE) --output-directory=$(SIM_SCRIPT_DIR)
1040
 
1041
VSIM_COMMAND = \
1042
        cd $(dir $(MSIM_SCRIPT)) && \
1043
        $(VSIM) -do "do $(notdir $(MSIM_SCRIPT)); ld; $(if $(VSIM_RUN_TIME),run ${VSIM_RUN_TIME};quit;)"
1044
 
1045
.PHONY: sim
1046
sim: $(MSIM_SCRIPT) mem_init_generate
1047
ifeq ($(MSIM_SCRIPT),)
1048
        $(error MSIM_SCRIPT not set)
1049
endif
1050
        $(VSIM_COMMAND)
1051
 
1052
endif # QSYS == 1
1053
 
1054
 
1055
#------------------------------------------------------------------------------
1056
#                         ELF TARGET RULE
1057
#------------------------------------------------------------------------------
1058
# Rule for constructing the executable elf file.
1059
$(ELF) : $(APP_OBJS) $(LINKER_SCRIPT) $(APP_LDDEPS)
1060
        @$(ECHO) Info: Linking $@
1061
        $(LD) $(APP_LDFLAGS) $(APP_CFLAGS) -o $@ $(filter-out $(CRT0),$(APP_OBJS)) $(APP_LIBS) $(APP_BSP_DEP_LIBS)
1062
ifneq ($(DISABLE_ELFPATCH),1)
1063
        $(ELFPATCH) $@ $(ELF_PATCH_FLAG)
1064
endif
1065
ifneq ($(DISABLE_STACKREPORT),1)
1066
        @bash -c "$(STACKREPORT) $@"
1067
endif
1068
 
1069
$(OBJDUMP_NAME) : $(ELF)
1070
        @$(ECHO) Info: Creating $@
1071
        $(OBJDUMP) $(OBJDUMP_FLAGS) $< >$@
1072
 
1073
# Rule for printing the name of the elf file
1074
.PHONY: print-elf-name
1075
print-elf-name:
1076
        @$(ECHO) $(ELF)
1077
 
1078
 

powered by: WebSVN 2.1.0

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