Studentenversion des ESY6/A Praktikums "signal_processing".
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 28KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781
  1. #------------------------------------------------------------------------------
  2. # BSP MAKEFILE
  3. #
  4. # This makefile was automatically generated by the nios2-bsp-generate-files
  5. # command. Its purpose is to build a custom Board Support Package (BSP)
  6. # targeting a specific Nios II processor in an SOPC Builder-based design.
  7. #
  8. # To create an application or library Makefile which uses this BSP, try the
  9. # nios2-app-generate-makefile or nios2-lib-generate-makefile commands.
  10. #------------------------------------------------------------------------------
  11. #------------------------------------------------------------------------------
  12. # TOOLS
  13. #------------------------------------------------------------------------------
  14. MKDIR := mkdir -p
  15. ECHO := echo
  16. SPACE := $(empty) $(empty)
  17. #------------------------------------------------------------------------------
  18. # The adjust-path macro
  19. #
  20. # If Make is launched from Windows through
  21. # Windows Subsystem for Linux (WSL). The adjust-path macro converts absolute windows
  22. # paths into unix style paths (Example: c:/dir -> /c/dir).
  23. # The adjust_path_mixed function converts WSL path to Windows path.
  24. # This will ensure paths are readable by GNU Make.
  25. #------------------------------------------------------------------------------
  26. UNAME = $(shell uname -r | tr A-Z a-z)
  27. ifeq ($(findstring microsoft,$(UNAME)),microsoft)
  28. WINDOWS_EXE = .exe
  29. endif
  30. eq = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1)))
  31. ifdef WINDOWS_EXE
  32. adjust-path = $(if $1,$(shell wslpath "$1"),)
  33. adjust-path-mixed = $(if $(call eq,$(shell echo $1 | head -c 5),/mnt/),$(shell echo $1 | sed 's/\/mnt\///g;s/\//:\//1'),$1)
  34. else # !WINDOWS_EXE
  35. adjust-path = $1
  36. adjust-path-mixed = $1
  37. endif
  38. #------------------------------------------------------------------------------
  39. # DEFAULT TARGET
  40. #
  41. # The default target, "all", must appear before any other target in the
  42. # Makefile. Note that extra prerequisites are added to the "all" rule later.
  43. #------------------------------------------------------------------------------
  44. .PHONY: all
  45. all:
  46. @$(ECHO) [BSP build complete]
  47. #------------------------------------------------------------------------------
  48. # PATHS & DIRECTORY NAMES
  49. #
  50. # Explicitly locate absolute path of the BSP root
  51. #------------------------------------------------------------------------------
  52. BSP_ROOT_DIR := .
  53. # Define absolute path to the root of the BSP.
  54. ABS_BSP_ROOT := $(shell pwd)
  55. # Stash all BSP object files here
  56. OBJ_DIR := ./obj
  57. #------------------------------------------------------------------------------
  58. # MANAGED CONTENT
  59. #
  60. # All content between the lines "START MANAGED" and "END MANAGED" below is
  61. # generated based on variables in the BSP settings file when the
  62. # nios2-bsp-generate-files command is invoked. If you wish to persist any
  63. # information pertaining to the build process, it is recomended that you
  64. # utilize the BSP settings mechanism to do so.
  65. #
  66. # Note that most variable assignments in this section have a corresponding BSP
  67. # setting that can be changed by using the nios2-bsp-create-settings or
  68. # nios2-bsp-update-settings command before nios2-bsp-generate-files; if you
  69. # want any variable set to a specific value when this Makefile is re-generated
  70. # (to prevent hand-edits from being over-written), use the BSP settings
  71. # facilities above.
  72. #------------------------------------------------------------------------------
  73. #START MANAGED
  74. # The following TYPE comment allows tools to identify the 'type' of target this
  75. # makefile is associated with.
  76. # TYPE: BSP_PRIVATE_MAKEFILE
  77. # This following VERSION comment indicates the version of the tool used to
  78. # generate this makefile. A makefile variable is provided for VERSION as well.
  79. # ACDS_VERSION: 22.1
  80. ACDS_VERSION := 22.1
  81. # This following BUILD_NUMBER comment indicates the build number of the tool
  82. # used to generate this makefile.
  83. # BUILD_NUMBER: 917
  84. SETTINGS_FILE := settings.bsp
  85. SOPC_FILE := ../../niosII.sopcinfo
  86. #-------------------------------------------------------------------------------
  87. # TOOL & COMMAND DEFINITIONS
  88. #
  89. # The base command for each build operation are expressed here. Additional
  90. # switches may be expressed here. They will run for all instances of the
  91. # utility.
  92. #-------------------------------------------------------------------------------
  93. # Archiver command. Creates library files.
  94. AR = nios2-elf-ar$(WINDOWS_EXE)
  95. # Assembler command. Note that CC is used for .S files.
  96. AS = nios2-elf-gcc$(WINDOWS_EXE)
  97. # Custom flags only passed to the archiver. This content of this variable is
  98. # directly passed to the archiver rather than the more standard "ARFLAGS". The
  99. # reason for this is that GNU Make assumes some default content in ARFLAGS.
  100. # This setting defines the value of BSP_ARFLAGS in Makefile.
  101. BSP_ARFLAGS = -src
  102. # Custom flags only passed to the assembler. This setting defines the value of
  103. # BSP_ASFLAGS in Makefile.
  104. BSP_ASFLAGS = -Wa,-gdwarf2
  105. # C/C++ compiler debug level. '-g' provides the default set of debug symbols
  106. # typically required to debug a typical application. Omitting '-g' removes
  107. # debug symbols from the ELF. This setting defines the value of
  108. # BSP_CFLAGS_DEBUG in Makefile.
  109. BSP_CFLAGS_DEBUG = -g
  110. # C/C++ compiler optimization level. "-O0" = no optimization,"-O2" = "normal"
  111. # optimization, etc. "-O0" is recommended for code that you want to debug since
  112. # compiler optimization can remove variables and produce non-sequential
  113. # execution of code while debugging. This setting defines the value of
  114. # BSP_CFLAGS_OPTIMIZATION in Makefile.
  115. BSP_CFLAGS_OPTIMIZATION = -O0
  116. # C/C++ compiler warning level. "-Wall" is commonly used.This setting defines
  117. # the value of BSP_CFLAGS_WARNINGS in Makefile.
  118. BSP_CFLAGS_WARNINGS = -Wall
  119. # C compiler command.
  120. CC = nios2-elf-gcc$(WINDOWS_EXE) -xc
  121. # C++ compiler command.
  122. CXX = nios2-elf-gcc$(WINDOWS_EXE) -xc++
  123. # Command used to remove files during 'clean' target.
  124. RM = rm -f
  125. #-------------------------------------------------------------------------------
  126. # BUILD PRE & POST PROCESS COMMANDS
  127. #
  128. # The following variables are treated as shell commands in the rule
  129. # definitions for each file-type associated with the BSP build, as well as
  130. # commands run at the beginning and end of the entire BSP build operation.
  131. # Pre-process commands are executed before the relevant command (for example,
  132. # a command defined in the "CC_PRE_PROCESS" variable executes before the C
  133. # compiler for building .c files), while post-process commands are executed
  134. # immediately afterwards.
  135. #
  136. # You can view each pre/post-process command in the "Build Rules: All &
  137. # Clean", "Pattern Rules to Build Objects", and "Library Rules" sections of
  138. # this Makefile.
  139. #-------------------------------------------------------------------------------
  140. #-------------------------------------------------------------------------------
  141. # BSP SOURCE BUILD SETTINGS (FLAG GENERATION)
  142. #
  143. # Software build settings such as compiler optimization, debug level, warning
  144. # flags, etc., may be defined in the following variables. The variables below
  145. # are concatenated together in the 'Flags' section of this Makefile to form
  146. # final variables of flags passed to the build tools.
  147. #
  148. # These settings are considered private to the BSP and apply to all library &
  149. # driver files in it; they do NOT automatically propagate to, for example, the
  150. # build settings for an application.
  151. # # For additional detail and syntax requirements, please refer to GCC help
  152. # (example: "nios2-elf-gcc --help --verbose").
  153. #
  154. # Unless indicated otherwise, multiple entries in each variable should be
  155. # space-separated.
  156. #-------------------------------------------------------------------------------
  157. # Altera HAL alt_sys_init.c generated source file
  158. GENERATED_C_FILES := $(ABS_BSP_ROOT)/alt_sys_init.c
  159. GENERATED_C_LIB_SRCS += alt_sys_init.c
  160. #-------------------------------------------------------------------------------
  161. # BSP SOURCE FILE LISTING
  162. #
  163. # All source files that comprise the BSP are listed here, along with path
  164. # information to each file expressed relative to the BSP root. The precise
  165. # list and location of each file is derived from the driver, operating system,
  166. # or software package source file declarations.
  167. #
  168. # Following specification of the source files for each component, driver, etc.,
  169. # each source file type (C, assembly, etc.) is concatenated together and used
  170. # to construct a list of objects. Pattern rules to build each object are then
  171. # used to build each file.
  172. # altera_avalon_jtag_uart_driver sources root
  173. altera_avalon_jtag_uart_driver_SRCS_ROOT := drivers
  174. # altera_avalon_jtag_uart_driver sources
  175. altera_avalon_jtag_uart_driver_C_LIB_SRCS := \
  176. $(altera_avalon_jtag_uart_driver_SRCS_ROOT)/src/altera_avalon_jtag_uart_init.c \
  177. $(altera_avalon_jtag_uart_driver_SRCS_ROOT)/src/altera_avalon_jtag_uart_read.c \
  178. $(altera_avalon_jtag_uart_driver_SRCS_ROOT)/src/altera_avalon_jtag_uart_write.c \
  179. $(altera_avalon_jtag_uart_driver_SRCS_ROOT)/src/altera_avalon_jtag_uart_ioctl.c \
  180. $(altera_avalon_jtag_uart_driver_SRCS_ROOT)/src/altera_avalon_jtag_uart_fd.c
  181. # altera_avalon_pio_driver sources root
  182. altera_avalon_pio_driver_SRCS_ROOT := drivers
  183. # altera_avalon_pio_driver sources
  184. # altera_avalon_sysid_qsys_driver sources root
  185. altera_avalon_sysid_qsys_driver_SRCS_ROOT := drivers
  186. # altera_avalon_sysid_qsys_driver sources
  187. altera_avalon_sysid_qsys_driver_C_LIB_SRCS := \
  188. $(altera_avalon_sysid_qsys_driver_SRCS_ROOT)/src/altera_avalon_sysid_qsys.c
  189. # altera_nios2_gen2_hal_driver sources root
  190. altera_nios2_gen2_hal_driver_SRCS_ROOT := HAL
  191. # altera_nios2_gen2_hal_driver sources
  192. altera_nios2_gen2_hal_driver_C_LIB_SRCS := \
  193. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/altera_nios2_gen2_irq.c \
  194. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_usleep.c \
  195. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_busy_sleep.c \
  196. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_irq_vars.c \
  197. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_icache_flush.c \
  198. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_icache_flush_all.c \
  199. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_dcache_flush.c \
  200. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_dcache_flush_all.c \
  201. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_dcache_flush_no_writeback.c \
  202. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_ecc_fatal_exception.c \
  203. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_instruction_exception_entry.c \
  204. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_irq_register.c \
  205. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_iic.c \
  206. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_remap_cached.c \
  207. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_remap_uncached.c \
  208. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_uncached_free.c \
  209. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_uncached_malloc.c \
  210. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_do_ctors.c \
  211. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_do_dtors.c \
  212. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_gmon.c
  213. altera_nios2_gen2_hal_driver_ASM_LIB_SRCS := \
  214. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_ecc_fatal_entry.S \
  215. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_exception_entry.S \
  216. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_exception_trap.S \
  217. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_exception_muldiv.S \
  218. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_irq_entry.S \
  219. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_software_exception.S \
  220. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_mcount.S \
  221. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_log_macro.S \
  222. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/crt0.S
  223. # hal sources root
  224. hal_SRCS_ROOT := HAL
  225. # hal sources
  226. hal_C_LIB_SRCS := \
  227. $(hal_SRCS_ROOT)/src/alt_alarm_start.c \
  228. $(hal_SRCS_ROOT)/src/alt_close.c \
  229. $(hal_SRCS_ROOT)/src/alt_dev.c \
  230. $(hal_SRCS_ROOT)/src/alt_dev_llist_insert.c \
  231. $(hal_SRCS_ROOT)/src/alt_dma_rxchan_open.c \
  232. $(hal_SRCS_ROOT)/src/alt_dma_txchan_open.c \
  233. $(hal_SRCS_ROOT)/src/alt_environ.c \
  234. $(hal_SRCS_ROOT)/src/alt_env_lock.c \
  235. $(hal_SRCS_ROOT)/src/alt_errno.c \
  236. $(hal_SRCS_ROOT)/src/alt_execve.c \
  237. $(hal_SRCS_ROOT)/src/alt_exit.c \
  238. $(hal_SRCS_ROOT)/src/alt_fcntl.c \
  239. $(hal_SRCS_ROOT)/src/alt_fd_lock.c \
  240. $(hal_SRCS_ROOT)/src/alt_fd_unlock.c \
  241. $(hal_SRCS_ROOT)/src/alt_find_dev.c \
  242. $(hal_SRCS_ROOT)/src/alt_find_file.c \
  243. $(hal_SRCS_ROOT)/src/alt_flash_dev.c \
  244. $(hal_SRCS_ROOT)/src/alt_fork.c \
  245. $(hal_SRCS_ROOT)/src/alt_fs_reg.c \
  246. $(hal_SRCS_ROOT)/src/alt_fstat.c \
  247. $(hal_SRCS_ROOT)/src/alt_get_fd.c \
  248. $(hal_SRCS_ROOT)/src/alt_getchar.c \
  249. $(hal_SRCS_ROOT)/src/alt_getpid.c \
  250. $(hal_SRCS_ROOT)/src/alt_gettod.c \
  251. $(hal_SRCS_ROOT)/src/alt_iic_isr_register.c \
  252. $(hal_SRCS_ROOT)/src/alt_instruction_exception_register.c \
  253. $(hal_SRCS_ROOT)/src/alt_ioctl.c \
  254. $(hal_SRCS_ROOT)/src/alt_io_redirect.c \
  255. $(hal_SRCS_ROOT)/src/alt_irq_handler.c \
  256. $(hal_SRCS_ROOT)/src/alt_isatty.c \
  257. $(hal_SRCS_ROOT)/src/alt_kill.c \
  258. $(hal_SRCS_ROOT)/src/alt_link.c \
  259. $(hal_SRCS_ROOT)/src/alt_load.c \
  260. $(hal_SRCS_ROOT)/src/alt_log_printf.c \
  261. $(hal_SRCS_ROOT)/src/alt_lseek.c \
  262. $(hal_SRCS_ROOT)/src/alt_main.c \
  263. $(hal_SRCS_ROOT)/src/alt_malloc_lock.c \
  264. $(hal_SRCS_ROOT)/src/alt_open.c \
  265. $(hal_SRCS_ROOT)/src/alt_printf.c \
  266. $(hal_SRCS_ROOT)/src/alt_putchar.c \
  267. $(hal_SRCS_ROOT)/src/alt_putcharbuf.c \
  268. $(hal_SRCS_ROOT)/src/alt_putstr.c \
  269. $(hal_SRCS_ROOT)/src/alt_read.c \
  270. $(hal_SRCS_ROOT)/src/alt_release_fd.c \
  271. $(hal_SRCS_ROOT)/src/alt_rename.c \
  272. $(hal_SRCS_ROOT)/src/alt_sbrk.c \
  273. $(hal_SRCS_ROOT)/src/alt_settod.c \
  274. $(hal_SRCS_ROOT)/src/alt_stat.c \
  275. $(hal_SRCS_ROOT)/src/alt_tick.c \
  276. $(hal_SRCS_ROOT)/src/alt_times.c \
  277. $(hal_SRCS_ROOT)/src/alt_unlink.c \
  278. $(hal_SRCS_ROOT)/src/alt_wait.c \
  279. $(hal_SRCS_ROOT)/src/alt_write.c
  280. # Assemble all component C source files
  281. COMPONENT_C_LIB_SRCS += \
  282. $(altera_avalon_jtag_uart_driver_C_LIB_SRCS) \
  283. $(altera_avalon_sysid_qsys_driver_C_LIB_SRCS) \
  284. $(altera_nios2_gen2_hal_driver_C_LIB_SRCS) \
  285. $(hal_C_LIB_SRCS)
  286. # Assemble all component assembly source files
  287. COMPONENT_ASM_LIB_SRCS += \
  288. $(altera_nios2_gen2_hal_driver_ASM_LIB_SRCS)
  289. # Assemble all component C++ source files
  290. COMPONENT_CPP_LIB_SRCS += \
  291. #END MANAGED
  292. #------------------------------------------------------------------------------
  293. # PUBLIC.MK
  294. #
  295. # The generated public.mk file contains BSP information that is shared with
  296. # other external makefiles, such as a Nios II application makefile. System-
  297. # dependent information such as hardware-specific compiler flags and
  298. # simulation file generation are stored here.
  299. #
  300. # In addition, public.mk contains include paths that various software,
  301. # such as a device driver, may need for the C compiler. These paths are
  302. # written to public.mk with respect to the BSP root. In public.mk, each
  303. # path is prefixed with a special variable, $(ALT_LIBRARY_ROOT_DIR). The
  304. # purpose of this variable is to allow an external Makefile to append on
  305. # path information to precisely locate paths expressed in public.mk
  306. # Since this is the BSP Makefile, we set ALT_LIBRARY_ROOT_DIR to point right
  307. # here ("."), at the BSP root.
  308. #
  309. # ALT_LIBRARY_ROOT_DIR must always be set before public.mk is included.
  310. #------------------------------------------------------------------------------
  311. ALT_LIBRARY_ROOT_DIR := .
  312. include public.mk
  313. #------------------------------------------------------------------------------
  314. # FLAGS
  315. #
  316. # Include paths for BSP files are written into the public.mk file and must
  317. # be added to the existing list of pre-processor flags. In addition, "hooks"
  318. # for standard flags left intentionally empty (CFLAGS, CPPFLAGS, ASFLAGS,
  319. # and CXXFLAGS) are provided for conveniently adding to the relevant flags
  320. # on the command-line or via script that calls make.
  321. #------------------------------------------------------------------------------
  322. # Assemble final list of compiler flags from generated content
  323. BSP_CFLAGS += \
  324. $(BSP_CFLAGS_DEFINED_SYMBOLS) \
  325. $(BSP_CFLAGS_UNDEFINED_SYMBOLS) \
  326. $(BSP_CFLAGS_OPTIMIZATION) \
  327. $(BSP_CFLAGS_DEBUG) \
  328. $(BSP_CFLAGS_WARNINGS) \
  329. $(BSP_CFLAGS_USER_FLAGS) \
  330. $(ALT_CFLAGS) \
  331. $(CFLAGS)
  332. # Make ready the final list of include directories and other C pre-processor
  333. # flags. Each include path is made ready by prefixing it with "-I".
  334. BSP_CPPFLAGS += \
  335. $(addprefix -I, $(BSP_INC_DIRS)) \
  336. $(addprefix -I, $(ALT_INCLUDE_DIRS)) \
  337. $(ALT_CPPFLAGS) \
  338. $(CPPFLAGS)
  339. # Finish off assembler flags with any user-provided flags
  340. BSP_ASFLAGS += $(ASFLAGS)
  341. # Finish off C++ flags with any user-provided flags
  342. BSP_CXXFLAGS += $(CXXFLAGS)
  343. # And finally, the ordered list
  344. C_SRCS += $(GENERATED_C_LIB_SRCS) \
  345. $(COMPONENT_C_LIB_SRCS)
  346. CXX_SRCS += $(GENERATED_CPP_LIB_SRCS) \
  347. $(COMPONENT_CPP_LIB_SRCS)
  348. ASM_SRCS += $(GENERATED_ASM_LIB_SRCS) \
  349. $(COMPONENT_ASM_LIB_SRCS)
  350. #------------------------------------------------------------------------------
  351. # LIST OF GENERATED FILES
  352. #
  353. # A Nios II BSP relies on the generation of several source files used
  354. # by both the BSP and any applications referencing the BSP.
  355. #------------------------------------------------------------------------------
  356. GENERATED_H_FILES := $(ABS_BSP_ROOT)/system.h
  357. GENERATED_LINKER_SCRIPT := $(ABS_BSP_ROOT)/linker.x
  358. GENERATED_FILES += $(GENERATED_H_FILES) \
  359. $(GENERATED_LINKER_SCRIPT)
  360. #------------------------------------------------------------------------------
  361. # SETUP TO BUILD OBJECTS
  362. #
  363. # List of object files which are to be built. This is constructed from the input
  364. # list of C source files (C_SRCS), C++ source files (CXX_SRCS), and assembler
  365. # source file (ASM_SRCS). The permitted file extensions are:
  366. #
  367. # .c .C - for C files
  368. # .cxx .cc .cpp .CXX .CC .CPP - for C++ files
  369. # .S .s - for assembly files
  370. #
  371. # Extended description: The list of objects is a sorted list (duplicates
  372. # removed) of all possible objects, placed beneath the ./obj directory,
  373. # including any path information stored in the "*_SRCS" variable. The
  374. # "patsubst" commands are used to concatenate together multiple file suffix
  375. # types for common files (i.e. c++ as .cxx, .cc, .cpp).
  376. #
  377. # File extensions are case-insensitive in build rules with the exception of
  378. # assembly sources. Nios II assembly sources with the ".S" extension are first
  379. # run through the C preprocessor. Sources with the ".s" extension are not.
  380. #------------------------------------------------------------------------------
  381. OBJS = $(sort $(addprefix $(OBJ_DIR)/, \
  382. $(patsubst %.c, %.o, $(patsubst %.C, %.o, $(C_SRCS))) \
  383. $(patsubst %.cxx, %.o, $(patsubst %.CXX, %.o, \
  384. $(patsubst %.cc, %.o, $(patsubst %.CC, %.o, \
  385. $(patsubst %.cpp, %.o, $(patsubst %.CPP, %.o, \
  386. $(CXX_SRCS) )))))) \
  387. $(patsubst %.S, %.o, $(patsubst %.s, %.o, $(ASM_SRCS))) ))
  388. # List of dependancy files for each object file.
  389. DEPS = $(OBJS:.o=.d)
  390. # Rules to force your project to rebuild or relink
  391. # .force_relink file will cause any application that depends on this project to relink
  392. # .force_rebuild file will cause this project to rebuild object files
  393. # .force_rebuild_all file will cause this project and any project that depends on this project to rebuild object files
  394. FORCE_RELINK_DEP := .force_relink
  395. FORCE_REBUILD_DEP := .force_rebuild
  396. FORCE_REBUILD_ALL_DEP := .force_rebuild_all
  397. FORCE_REBUILD_DEP_LIST := $(FORCE_RELINK_DEP) $(FORCE_REBUILD_DEP) $(FORCE_REBUILD_ALL_DEP)
  398. $(FORCE_REBUILD_DEP_LIST):
  399. $(OBJS): $(wildcard $(FORCE_REBUILD_DEP)) $(wildcard $(FORCE_REBUILD_ALL_DEP))
  400. #------------------------------------------------------------------------------
  401. # BUILD RULES: ALL & CLEAN
  402. #------------------------------------------------------------------------------
  403. .DELETE_ON_ERROR:
  404. .PHONY: all
  405. all: build_pre_process
  406. all: Makefile $(GENERATED_FILES) $(BSP_LIB) $(NEWLIB_DIR)
  407. all: build_post_process
  408. # clean: remove .o/.a/.d
  409. .PHONY: clean
  410. clean:
  411. @$(RM) -r $(BSP_LIB) $(OBJ_DIR) $(FORCE_REBUILD_DEP_LIST)
  412. ifneq ($(wildcard $(NEWLIB_DIR)),)
  413. @$(RM) -r $(NEWLIB_DIR)
  414. endif
  415. @$(ECHO) [BSP clean complete]
  416. #------------------------------------------------------------------------------
  417. # BUILD PRE/POST PROCESS
  418. #------------------------------------------------------------------------------
  419. build_pre_process :
  420. $(BUILD_PRE_PROCESS)
  421. build_post_process :
  422. $(BUILD_POST_PROCESS)
  423. ifneq ($(LICENSE_NOTICE_TEXT),)
  424. build_post_process : $(OBJ_DIR)/emit_license_notice
  425. $(OBJ_DIR)/emit_license_notice: $(LICENSE_NOTICE_TEXT)
  426. @cat $<
  427. @$(MKDIR) $(@D)
  428. @touch $@
  429. endif #LICENCE_NOTICE_TEXT set
  430. .PHONY: build_pre_process build_post_process
  431. #------------------------------------------------------------------------------
  432. # MAKEFILE UP TO DATE?
  433. #
  434. # Is this very Makefile up to date? Someone may have changed the BSP settings
  435. # file or the associated target hardware.
  436. #------------------------------------------------------------------------------
  437. # Skip this check when clean is the only target
  438. ifneq ($(MAKECMDGOALS),clean)
  439. ifneq ($(wildcard $(call adjust-path,$(SETTINGS_FILE))),$(call adjust-path,$(SETTINGS_FILE)))
  440. $(warning Warning: BSP Settings File $(SETTINGS_FILE) could not be found.)
  441. endif
  442. Makefile: $(wildcard $(call adjust-path,$(SETTINGS_FILE)))
  443. @$(ECHO) Makefile not up to date.
  444. @$(ECHO) $(call adjust-path,$(SETTINGS_FILE)) has been modified since the BSP Makefile was generated.
  445. @$(ECHO)
  446. @$(ECHO) Generate the BSP to update the Makefile, and then build again.
  447. @$(ECHO)
  448. @$(ECHO) To generate from Eclipse:
  449. @$(ECHO) " 1. Right-click the BSP project."
  450. @$(ECHO) " 2. In the Nios II Menu, click Generate BSP."
  451. @$(ECHO)
  452. @$(ECHO) To generate from the command line:
  453. @$(ECHO) " nios2-bsp-generate-files --settings=<settings file> --bsp-dir=<target bsp files directory>"
  454. @$(ECHO)
  455. @exit 1
  456. ifneq ($(wildcard $(call adjust-path,$(SOPC_FILE))),$(call adjust-path,$(SOPC_FILE)))
  457. $(warning Warning: SOPC File $(SOPC_FILE) could not be found.)
  458. endif
  459. public.mk: $(wildcard $(call adjust-path,$(SOPC_FILE)))
  460. @$(ECHO) Makefile not up to date.
  461. @$(ECHO) $(call adjust-path,$(SOPC_FILE)) has been modified since the BSP was generated.
  462. @$(ECHO)
  463. @$(ECHO) Generate the BSP to update the Makefile, and then build again.
  464. @$(ECHO)
  465. @$(ECHO) To generate from Eclipse:
  466. @$(ECHO) " 1. Right-click the BSP project."
  467. @$(ECHO) " 2. In the Nios II Menu, click Generate BSP."
  468. @$(ECHO)
  469. @$(ECHO) To generate from the command line:
  470. @$(ECHO) " nios2-bsp-generate-files --settings=<settings file> --bsp-dir=<target bsp files directory>"
  471. @$(ECHO)
  472. @exit 1
  473. endif # $(MAKECMDGOALS) != clean
  474. #------------------------------------------------------------------------------
  475. # PATTERN RULES TO BUILD OBJECTS
  476. #------------------------------------------------------------------------------
  477. $(OBJ_DIR)/%.o: %.c
  478. @$(ECHO) Compiling $(<F)...
  479. @$(MKDIR) $(@D)
  480. $(CC_PRE_PROCESS)
  481. $(CC) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CFLAGS) -o $@ $<
  482. $(CC_POST_PROCESS)
  483. $(OBJ_DIR)/%.o: %.C
  484. @$(ECHO) Compiling $(<F)...
  485. @$(MKDIR) $(@D)
  486. $(CC_PRE_PROCESS)
  487. $(CC) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CFLAGS) -o $@ $<
  488. $(CC_POST_PROCESS)
  489. $(OBJ_DIR)/%.o: %.cpp
  490. @$(ECHO) Compiling $(<F)...
  491. @$(MKDIR) $(@D)
  492. $(CXX_PRE_PROCESS)
  493. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  494. $(CXX_POST_PROCESS)
  495. $(OBJ_DIR)/%.o: %.CPP
  496. @$(ECHO) Compiling $(<F)...
  497. @$(MKDIR) $(@D)
  498. $(CXX_PRE_PROCESS)
  499. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  500. $(CXX_POST_PROCESS)
  501. $(OBJ_DIR)/%.o: %.cc
  502. @$(ECHO) Compiling $(<F)...
  503. @$(MKDIR) $(@D)
  504. $(CXX_PRE_PROCESS)
  505. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  506. $(CXX_POST_PROCESS)
  507. $(OBJ_DIR)/%.o: %.CC
  508. @$(ECHO) Compiling $(<F)...
  509. @$(MKDIR) $(@D)
  510. $(CXX_PRE_PROCESS)
  511. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  512. $(CXX_POST_PROCESS)
  513. $(OBJ_DIR)/%.o: %.cxx
  514. @$(ECHO) Compiling $(<F)...
  515. @$(MKDIR) $(@D)
  516. $(CXX_PRE_PROCESS)
  517. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  518. $(CXX_POST_PROCESS)
  519. $(OBJ_DIR)/%.o: %.CXX
  520. @$(ECHO) Compiling $(<F)...
  521. @$(MKDIR) $(@D)
  522. $(CXX_PRE_PROCESS)
  523. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  524. $(CXX_POST_PROCESS)
  525. $(OBJ_DIR)/%.o: %.S
  526. @$(ECHO) Compiling $(<F)...
  527. @$(MKDIR) $(@D)
  528. $(AS_PRE_PROCESS)
  529. $(AS) -MP -MMD -c $(BSP_CFLAGS) $(BSP_CPPFLAGS) $(BSP_ASFLAGS) -o $@ $<
  530. $(AS_POST_PROCESS)
  531. $(OBJ_DIR)/%.o: %.s
  532. @$(ECHO) Compiling $(<F)...
  533. @$(MKDIR) $(@D)
  534. $(AS_PRE_PROCESS)
  535. $(AS) -MP -MMD -c $(BSP_ASFLAGS) $(BSP_CFLAGS) -o $@ $<
  536. $(AS_POST_PROCESS)
  537. # Pattern rules for making useful intermediate files
  538. $(OBJ_DIR)/%.s: %.c
  539. @$(ECHO) Compiling $(<F) to assembler...
  540. @$(MKDIR) $(@D)
  541. $(CC_PRE_PROCESS)
  542. $(CC) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CFLAGS) -o $@ $<
  543. $(CC_POST_PROCESS)
  544. $(OBJ_DIR)/%.s: %.cpp
  545. @$(ECHO) Compiling $(<F) to assembler...
  546. @$(MKDIR) $(@D)
  547. $(CXX_PRE_PROCESS)
  548. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  549. $(CXX_PRE_PROCESS)
  550. $(OBJ_DIR)/%.s: %.cc
  551. @$(ECHO) Compiling $(<F) to assembler...
  552. @$(MKDIR) $(@D)
  553. $(CXX_PRE_PROCESS)
  554. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  555. $(CXX_PRE_PROCESS)
  556. $(OBJ_DIR)/%.s: %.cxx
  557. @$(ECHO) Compiling $(<F) to assembler...
  558. @$(MKDIR) $(@D)
  559. $(CXX_PRE_PROCESS)
  560. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  561. $(CXX_PRE_PROCESS)
  562. $(OBJ_DIR)/%.i: %.c
  563. @$(ECHO) Compiling $(<F) to assembler...
  564. @$(MKDIR) $(@D)
  565. $(CC_PRE_PROCESS)
  566. $(CC) -E $(CPPFLAGS) $(ALT_CFLAGS) $(CFLAGS) -o $@ $<
  567. $(CC_PRE_PROCESS)
  568. $(OBJ_DIR)/%.i: %.cpp
  569. @$(ECHO) Compiling $(<F) to assembler...
  570. @$(MKDIR) $(@D)
  571. $(CXX_PRE_PROCESS)
  572. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  573. $(CXX_PRE_PROCESS)
  574. $(OBJ_DIR)/%.i: %.cc
  575. @$(ECHO) Compiling $(<F) to assembler...
  576. @$(MKDIR) $(@D)
  577. $(CXX_PRE_PROCESS)
  578. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  579. $(CXX_PRE_PROCESS)
  580. $(OBJ_DIR)/%.i: %.cxx
  581. @$(ECHO) Compiling $(<F) to assembler...
  582. @$(MKDIR) $(@D)
  583. $(CXX_PRE_PROCESS)
  584. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  585. $(CXX_PRE_PROCESS)
  586. # Pattern rules for building other object files.
  587. %.o: %.c
  588. @$(ECHO) Compiling $(<F)...
  589. @$(MKDIR) $(@D)
  590. $(CC_PRE_PROCESS)
  591. $(CC) -MP -MMD -c $(CPPFLAGS) $(ALT_CFLAGS) $(CFLAGS) -o $@ $<
  592. $(CC_POST_PROCESS)
  593. %.o: %.cpp
  594. @$(ECHO) Compiling $(<F)...
  595. @$(MKDIR) $(@D)
  596. $(CXX_POST_PROCESS)
  597. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  598. $(CXX_POST_PROCESS)
  599. %.o: %.cc
  600. @$(ECHO) Compiling $(<F)...
  601. @$(MKDIR) $(@D)
  602. $(CXX_POST_PROCESS)
  603. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  604. $(CXX_POST_PROCESS)
  605. %.o: %.cxx
  606. @$(ECHO) Compiling $(<F)...
  607. @$(MKDIR) $(@D)
  608. $(CXX_PRE_PROCESS)
  609. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  610. $(CXX_POST_PROCESS)
  611. %.o: %.S
  612. @$(ECHO) Compiling $(<F)...
  613. @$(MKDIR) $(@D)
  614. $(AS_PRE_PROCESS)
  615. $(AS) -MP -MMD -c $(BSP_CFLAGS) $(BSP_CPPFLAGS) $(BSP_ASFLAGS) -o $@ $<
  616. $(AS_POST_PROCESS)
  617. %.o: %.s
  618. @$(ECHO) Compiling $(<F)...
  619. @$(MKDIR) $(@D)
  620. $(AS_PRE_PROCESS)
  621. $(AS) -MP -MMD -c $(BSP_ASFLAGS) $(BSP_CFLAGS) -o $@ $<
  622. $(AS_POST_PROCESS)
  623. #------------------------------------------------------------------------------
  624. # NEWLIB RULES
  625. #------------------------------------------------------------------------------
  626. ifneq ($(COMPILE_NEWLIB),)
  627. NEWLIB_FLAGS += $(BSP_CFLAGS)
  628. endif
  629. ifneq ($(NEWLIB_DIR),)
  630. $(NEWLIB_DIR):
  631. @$(ECHO) Creating $(NEWLIB_DIR)...
  632. nios2-newlib-gen --no-multilib $(NEWLIB_DIR)-build-tmp $(NEWLIB_DIR) --custom "$(NEWLIB_FLAGS)"
  633. @$(ECHO) Removing $(NEWLIB_DIR)-build-tmp...
  634. @$(RM) -rf $(NEWLIB_DIR)-build-tmp
  635. endif
  636. #------------------------------------------------------------------------------
  637. # LIBRARY RULES
  638. #------------------------------------------------------------------------------
  639. $(BSP_LIB): $(OBJS)
  640. @$(ECHO) Creating $@...
  641. $(AR_PRE_PROCESS)
  642. $(RM) -f $@
  643. $(AR) $(BSP_ARFLAGS) $@ $^
  644. $(AR_POST_PROCESS)
  645. #------------------------------------------------------------------------------
  646. # DEPENDENCY FILES
  647. #------------------------------------------------------------------------------
  648. ifneq ($(findstring clean, $(MAKECMDGOALS)),clean)
  649. -include $(DEPS)
  650. endif
  651. # End of Makefile