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

Subversion Repositories wf3d

[/] [wf3d/] [trunk/] [implement/] [synth/] [de0/] [qtproject_wb/] [software/] [space_ship/] [Makefile] - Blame information for rev 4

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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