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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [altera_de0_nano_soc/] [doc/] [Terasic/] [DE0_NANO_SOC/] [Demonstrations/] [FPGA/] [DE0_NANO_SOC_ADC/] [software/] [DE0_NANO_SOC_ADC/] [Makefile] - Blame information for rev 221

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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