Makefile 28 KB

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