Loesung des Praktikums Systementwurf - Bjarne Hoesch - Bernhard Schoeffel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 33KB

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