Makefile 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  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: 646
  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_pio_driver sources root
  184. altera_avalon_pio_driver_SRCS_ROOT := drivers
  185. # altera_avalon_pio_driver sources
  186. # altera_nios2_gen2_hal_driver sources root
  187. altera_nios2_gen2_hal_driver_SRCS_ROOT := HAL
  188. # altera_nios2_gen2_hal_driver sources
  189. altera_nios2_gen2_hal_driver_C_LIB_SRCS := \
  190. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/altera_nios2_gen2_irq.c \
  191. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_usleep.c \
  192. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_busy_sleep.c \
  193. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_irq_vars.c \
  194. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_icache_flush.c \
  195. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_icache_flush_all.c \
  196. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_dcache_flush.c \
  197. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_dcache_flush_all.c \
  198. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_dcache_flush_no_writeback.c \
  199. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_ecc_fatal_exception.c \
  200. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_instruction_exception_entry.c \
  201. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_irq_register.c \
  202. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_iic.c \
  203. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_remap_cached.c \
  204. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_remap_uncached.c \
  205. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_uncached_free.c \
  206. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_uncached_malloc.c \
  207. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_do_ctors.c \
  208. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_do_dtors.c \
  209. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_gmon.c
  210. altera_nios2_gen2_hal_driver_ASM_LIB_SRCS := \
  211. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_ecc_fatal_entry.S \
  212. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_exception_entry.S \
  213. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_exception_trap.S \
  214. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_exception_muldiv.S \
  215. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_irq_entry.S \
  216. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_software_exception.S \
  217. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_mcount.S \
  218. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_log_macro.S \
  219. $(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/crt0.S
  220. # hal sources root
  221. hal_SRCS_ROOT := HAL
  222. # hal sources
  223. hal_C_LIB_SRCS := \
  224. $(hal_SRCS_ROOT)/src/alt_alarm_start.c \
  225. $(hal_SRCS_ROOT)/src/alt_close.c \
  226. $(hal_SRCS_ROOT)/src/alt_dev.c \
  227. $(hal_SRCS_ROOT)/src/alt_dev_llist_insert.c \
  228. $(hal_SRCS_ROOT)/src/alt_dma_rxchan_open.c \
  229. $(hal_SRCS_ROOT)/src/alt_dma_txchan_open.c \
  230. $(hal_SRCS_ROOT)/src/alt_environ.c \
  231. $(hal_SRCS_ROOT)/src/alt_env_lock.c \
  232. $(hal_SRCS_ROOT)/src/alt_errno.c \
  233. $(hal_SRCS_ROOT)/src/alt_execve.c \
  234. $(hal_SRCS_ROOT)/src/alt_exit.c \
  235. $(hal_SRCS_ROOT)/src/alt_fcntl.c \
  236. $(hal_SRCS_ROOT)/src/alt_fd_lock.c \
  237. $(hal_SRCS_ROOT)/src/alt_fd_unlock.c \
  238. $(hal_SRCS_ROOT)/src/alt_find_dev.c \
  239. $(hal_SRCS_ROOT)/src/alt_find_file.c \
  240. $(hal_SRCS_ROOT)/src/alt_flash_dev.c \
  241. $(hal_SRCS_ROOT)/src/alt_fork.c \
  242. $(hal_SRCS_ROOT)/src/alt_fs_reg.c \
  243. $(hal_SRCS_ROOT)/src/alt_fstat.c \
  244. $(hal_SRCS_ROOT)/src/alt_get_fd.c \
  245. $(hal_SRCS_ROOT)/src/alt_getchar.c \
  246. $(hal_SRCS_ROOT)/src/alt_getpid.c \
  247. $(hal_SRCS_ROOT)/src/alt_gettod.c \
  248. $(hal_SRCS_ROOT)/src/alt_iic_isr_register.c \
  249. $(hal_SRCS_ROOT)/src/alt_instruction_exception_register.c \
  250. $(hal_SRCS_ROOT)/src/alt_ioctl.c \
  251. $(hal_SRCS_ROOT)/src/alt_io_redirect.c \
  252. $(hal_SRCS_ROOT)/src/alt_irq_handler.c \
  253. $(hal_SRCS_ROOT)/src/alt_isatty.c \
  254. $(hal_SRCS_ROOT)/src/alt_kill.c \
  255. $(hal_SRCS_ROOT)/src/alt_link.c \
  256. $(hal_SRCS_ROOT)/src/alt_load.c \
  257. $(hal_SRCS_ROOT)/src/alt_log_printf.c \
  258. $(hal_SRCS_ROOT)/src/alt_lseek.c \
  259. $(hal_SRCS_ROOT)/src/alt_main.c \
  260. $(hal_SRCS_ROOT)/src/alt_malloc_lock.c \
  261. $(hal_SRCS_ROOT)/src/alt_open.c \
  262. $(hal_SRCS_ROOT)/src/alt_printf.c \
  263. $(hal_SRCS_ROOT)/src/alt_putchar.c \
  264. $(hal_SRCS_ROOT)/src/alt_putcharbuf.c \
  265. $(hal_SRCS_ROOT)/src/alt_putstr.c \
  266. $(hal_SRCS_ROOT)/src/alt_read.c \
  267. $(hal_SRCS_ROOT)/src/alt_release_fd.c \
  268. $(hal_SRCS_ROOT)/src/alt_rename.c \
  269. $(hal_SRCS_ROOT)/src/alt_sbrk.c \
  270. $(hal_SRCS_ROOT)/src/alt_settod.c \
  271. $(hal_SRCS_ROOT)/src/alt_stat.c \
  272. $(hal_SRCS_ROOT)/src/alt_tick.c \
  273. $(hal_SRCS_ROOT)/src/alt_times.c \
  274. $(hal_SRCS_ROOT)/src/alt_unlink.c \
  275. $(hal_SRCS_ROOT)/src/alt_wait.c \
  276. $(hal_SRCS_ROOT)/src/alt_write.c
  277. # Assemble all component C source files
  278. COMPONENT_C_LIB_SRCS += \
  279. $(altera_avalon_jtag_uart_driver_C_LIB_SRCS) \
  280. $(altera_nios2_gen2_hal_driver_C_LIB_SRCS) \
  281. $(hal_C_LIB_SRCS)
  282. # Assemble all component assembly source files
  283. COMPONENT_ASM_LIB_SRCS += \
  284. $(altera_nios2_gen2_hal_driver_ASM_LIB_SRCS)
  285. # Assemble all component C++ source files
  286. COMPONENT_CPP_LIB_SRCS += \
  287. #END MANAGED
  288. #------------------------------------------------------------------------------
  289. # PUBLIC.MK
  290. #
  291. # The generated public.mk file contains BSP information that is shared with
  292. # other external makefiles, such as a Nios II application makefile. System-
  293. # dependent information such as hardware-specific compiler flags and
  294. # simulation file generation are stored here.
  295. #
  296. # In addition, public.mk contains include paths that various software,
  297. # such as a device driver, may need for the C compiler. These paths are
  298. # written to public.mk with respect to the BSP root. In public.mk, each
  299. # path is prefixed with a special variable, $(ALT_LIBRARY_ROOT_DIR). The
  300. # purpose of this variable is to allow an external Makefile to append on
  301. # path information to precisely locate paths expressed in public.mk
  302. # Since this is the BSP Makefile, we set ALT_LIBRARY_ROOT_DIR to point right
  303. # here ("."), at the BSP root.
  304. #
  305. # ALT_LIBRARY_ROOT_DIR must always be set before public.mk is included.
  306. #------------------------------------------------------------------------------
  307. ALT_LIBRARY_ROOT_DIR := .
  308. include public.mk
  309. #------------------------------------------------------------------------------
  310. # FLAGS
  311. #
  312. # Include paths for BSP files are written into the public.mk file and must
  313. # be added to the existing list of pre-processor flags. In addition, "hooks"
  314. # for standard flags left intentionally empty (CFLAGS, CPPFLAGS, ASFLAGS,
  315. # and CXXFLAGS) are provided for conveniently adding to the relevant flags
  316. # on the command-line or via script that calls make.
  317. #------------------------------------------------------------------------------
  318. # Assemble final list of compiler flags from generated content
  319. BSP_CFLAGS += \
  320. $(BSP_CFLAGS_DEFINED_SYMBOLS) \
  321. $(BSP_CFLAGS_UNDEFINED_SYMBOLS) \
  322. $(BSP_CFLAGS_OPTIMIZATION) \
  323. $(BSP_CFLAGS_DEBUG) \
  324. $(BSP_CFLAGS_WARNINGS) \
  325. $(BSP_CFLAGS_USER_FLAGS) \
  326. $(ALT_CFLAGS) \
  327. $(CFLAGS)
  328. # Make ready the final list of include directories and other C pre-processor
  329. # flags. Each include path is made ready by prefixing it with "-I".
  330. BSP_CPPFLAGS += \
  331. $(addprefix -I, $(BSP_INC_DIRS)) \
  332. $(addprefix -I, $(ALT_INCLUDE_DIRS)) \
  333. $(ALT_CPPFLAGS) \
  334. $(CPPFLAGS)
  335. # Finish off assembler flags with any user-provided flags
  336. BSP_ASFLAGS += $(ASFLAGS)
  337. # Finish off C++ flags with any user-provided flags
  338. BSP_CXXFLAGS += $(CXXFLAGS)
  339. # And finally, the ordered list
  340. C_SRCS += $(GENERATED_C_LIB_SRCS) \
  341. $(COMPONENT_C_LIB_SRCS)
  342. CXX_SRCS += $(GENERATED_CPP_LIB_SRCS) \
  343. $(COMPONENT_CPP_LIB_SRCS)
  344. ASM_SRCS += $(GENERATED_ASM_LIB_SRCS) \
  345. $(COMPONENT_ASM_LIB_SRCS)
  346. #------------------------------------------------------------------------------
  347. # LIST OF GENERATED FILES
  348. #
  349. # A Nios II BSP relies on the generation of several source files used
  350. # by both the BSP and any applications referencing the BSP.
  351. #------------------------------------------------------------------------------
  352. GENERATED_H_FILES := $(ABS_BSP_ROOT)/system.h
  353. GENERATED_LINKER_SCRIPT := $(ABS_BSP_ROOT)/linker.x
  354. GENERATED_FILES += $(GENERATED_H_FILES) \
  355. $(GENERATED_LINKER_SCRIPT)
  356. #------------------------------------------------------------------------------
  357. # SETUP TO BUILD OBJECTS
  358. #
  359. # List of object files which are to be built. This is constructed from the input
  360. # list of C source files (C_SRCS), C++ source files (CXX_SRCS), and assembler
  361. # source file (ASM_SRCS). The permitted file extensions are:
  362. #
  363. # .c .C - for C files
  364. # .cxx .cc .cpp .CXX .CC .CPP - for C++ files
  365. # .S .s - for assembly files
  366. #
  367. # Extended description: The list of objects is a sorted list (duplicates
  368. # removed) of all possible objects, placed beneath the ./obj directory,
  369. # including any path information stored in the "*_SRCS" variable. The
  370. # "patsubst" commands are used to concatenate together multiple file suffix
  371. # types for common files (i.e. c++ as .cxx, .cc, .cpp).
  372. #
  373. # File extensions are case-insensitive in build rules with the exception of
  374. # assembly sources. Nios II assembly sources with the ".S" extension are first
  375. # run through the C preprocessor. Sources with the ".s" extension are not.
  376. #------------------------------------------------------------------------------
  377. OBJS = $(sort $(addprefix $(OBJ_DIR)/, \
  378. $(patsubst %.c, %.o, $(patsubst %.C, %.o, $(C_SRCS))) \
  379. $(patsubst %.cxx, %.o, $(patsubst %.CXX, %.o, \
  380. $(patsubst %.cc, %.o, $(patsubst %.CC, %.o, \
  381. $(patsubst %.cpp, %.o, $(patsubst %.CPP, %.o, \
  382. $(CXX_SRCS) )))))) \
  383. $(patsubst %.S, %.o, $(patsubst %.s, %.o, $(ASM_SRCS))) ))
  384. # List of dependancy files for each object file.
  385. DEPS = $(OBJS:.o=.d)
  386. # Rules to force your project to rebuild or relink
  387. # .force_relink file will cause any application that depends on this project to relink
  388. # .force_rebuild file will cause this project to rebuild object files
  389. # .force_rebuild_all file will cause this project and any project that depends on this project to rebuild object files
  390. FORCE_RELINK_DEP := .force_relink
  391. FORCE_REBUILD_DEP := .force_rebuild
  392. FORCE_REBUILD_ALL_DEP := .force_rebuild_all
  393. FORCE_REBUILD_DEP_LIST := $(FORCE_RELINK_DEP) $(FORCE_REBUILD_DEP) $(FORCE_REBUILD_ALL_DEP)
  394. $(FORCE_REBUILD_DEP_LIST):
  395. $(OBJS): $(wildcard $(FORCE_REBUILD_DEP)) $(wildcard $(FORCE_REBUILD_ALL_DEP))
  396. #------------------------------------------------------------------------------
  397. # BUILD RULES: ALL & CLEAN
  398. #------------------------------------------------------------------------------
  399. .DELETE_ON_ERROR:
  400. .PHONY: all
  401. all: build_pre_process
  402. all: Makefile $(GENERATED_FILES) $(BSP_LIB) $(NEWLIB_DIR)
  403. all: build_post_process
  404. # clean: remove .o/.a/.d
  405. .PHONY: clean
  406. clean:
  407. @$(RM) -r $(BSP_LIB) $(OBJ_DIR) $(FORCE_REBUILD_DEP_LIST)
  408. ifneq ($(wildcard $(NEWLIB_DIR)),)
  409. @$(RM) -r $(NEWLIB_DIR)
  410. endif
  411. @$(ECHO) [BSP clean complete]
  412. #------------------------------------------------------------------------------
  413. # BUILD PRE/POST PROCESS
  414. #------------------------------------------------------------------------------
  415. build_pre_process :
  416. $(BUILD_PRE_PROCESS)
  417. build_post_process :
  418. $(BUILD_POST_PROCESS)
  419. .PHONY: build_pre_process build_post_process
  420. #------------------------------------------------------------------------------
  421. # MAKEFILE UP TO DATE?
  422. #
  423. # Is this very Makefile up to date? Someone may have changed the BSP settings
  424. # file or the associated target hardware.
  425. #------------------------------------------------------------------------------
  426. # Skip this check when clean is the only target
  427. ifneq ($(MAKECMDGOALS),clean)
  428. ifneq ($(wildcard $(SETTINGS_FILE)),$(SETTINGS_FILE))
  429. $(warning Warning: BSP Settings File $(SETTINGS_FILE) could not be found.)
  430. endif
  431. Makefile: $(wildcard $(SETTINGS_FILE))
  432. @$(ECHO) Makefile not up to date.
  433. @$(ECHO) $(SETTINGS_FILE) has been modified since the BSP Makefile was generated.
  434. @$(ECHO)
  435. @$(ECHO) Generate the BSP to update the Makefile, and then build again.
  436. @$(ECHO)
  437. @$(ECHO) To generate from Eclipse:
  438. @$(ECHO) " 1. Right-click the BSP project."
  439. @$(ECHO) " 2. In the Nios II Menu, click Generate BSP."
  440. @$(ECHO)
  441. @$(ECHO) To generate from the command line:
  442. @$(ECHO) " nios2-bsp-generate-files --settings=<settings file> --bsp-dir=<target bsp files directory>"
  443. @$(ECHO)
  444. @exit 1
  445. ifneq ($(wildcard $(SOPC_FILE)),$(SOPC_FILE))
  446. $(warning Warning: SOPC File $(SOPC_FILE) could not be found.)
  447. endif
  448. public.mk: $(wildcard $(SOPC_FILE))
  449. @$(ECHO) Makefile not up to date.
  450. @$(ECHO) $(SOPC_FILE) has been modified since the BSP was generated.
  451. @$(ECHO)
  452. @$(ECHO) Generate the BSP to update the Makefile, and then build again.
  453. @$(ECHO)
  454. @$(ECHO) To generate from Eclipse:
  455. @$(ECHO) " 1. Right-click the BSP project."
  456. @$(ECHO) " 2. In the Nios II Menu, click Generate BSP."
  457. @$(ECHO)
  458. @$(ECHO) To generate from the command line:
  459. @$(ECHO) " nios2-bsp-generate-files --settings=<settings file> --bsp-dir=<target bsp files directory>"
  460. @$(ECHO)
  461. @exit 1
  462. endif # $(MAKECMDGOALS) != clean
  463. #------------------------------------------------------------------------------
  464. # PATTERN RULES TO BUILD OBJECTS
  465. #------------------------------------------------------------------------------
  466. $(OBJ_DIR)/%.o: %.c
  467. @$(ECHO) Compiling $(<F)...
  468. @$(MKDIR) $(@D)
  469. $(CC_PRE_PROCESS)
  470. $(CC) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CFLAGS) -o $@ $<
  471. $(CC_POST_PROCESS)
  472. $(OBJ_DIR)/%.o: %.C
  473. @$(ECHO) Compiling $(<F)...
  474. @$(MKDIR) $(@D)
  475. $(CC_PRE_PROCESS)
  476. $(CC) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CFLAGS) -o $@ $<
  477. $(CC_POST_PROCESS)
  478. $(OBJ_DIR)/%.o: %.cpp
  479. @$(ECHO) Compiling $(<F)...
  480. @$(MKDIR) $(@D)
  481. $(CXX_PRE_PROCESS)
  482. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  483. $(CXX_POST_PROCESS)
  484. $(OBJ_DIR)/%.o: %.CPP
  485. @$(ECHO) Compiling $(<F)...
  486. @$(MKDIR) $(@D)
  487. $(CXX_PRE_PROCESS)
  488. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  489. $(CXX_POST_PROCESS)
  490. $(OBJ_DIR)/%.o: %.cc
  491. @$(ECHO) Compiling $(<F)...
  492. @$(MKDIR) $(@D)
  493. $(CXX_PRE_PROCESS)
  494. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  495. $(CXX_POST_PROCESS)
  496. $(OBJ_DIR)/%.o: %.CC
  497. @$(ECHO) Compiling $(<F)...
  498. @$(MKDIR) $(@D)
  499. $(CXX_PRE_PROCESS)
  500. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  501. $(CXX_POST_PROCESS)
  502. $(OBJ_DIR)/%.o: %.cxx
  503. @$(ECHO) Compiling $(<F)...
  504. @$(MKDIR) $(@D)
  505. $(CXX_PRE_PROCESS)
  506. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  507. $(CXX_POST_PROCESS)
  508. $(OBJ_DIR)/%.o: %.CXX
  509. @$(ECHO) Compiling $(<F)...
  510. @$(MKDIR) $(@D)
  511. $(CXX_PRE_PROCESS)
  512. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  513. $(CXX_POST_PROCESS)
  514. $(OBJ_DIR)/%.o: %.S
  515. @$(ECHO) Compiling $(<F)...
  516. @$(MKDIR) $(@D)
  517. $(AS_PRE_PROCESS)
  518. $(AS) -MP -MMD -c $(BSP_CFLAGS) $(BSP_CPPFLAGS) $(BSP_ASFLAGS) -o $@ $<
  519. $(AS_POST_PROCESS)
  520. $(OBJ_DIR)/%.o: %.s
  521. @$(ECHO) Compiling $(<F)...
  522. @$(MKDIR) $(@D)
  523. $(AS_PRE_PROCESS)
  524. $(AS) -MP -MMD -c $(BSP_ASFLAGS) $(BSP_CFLAGS) -o $@ $<
  525. $(AS_POST_PROCESS)
  526. # Pattern rules for making useful intermediate files
  527. $(OBJ_DIR)/%.s: %.c
  528. @$(ECHO) Compiling $(<F) to assembler...
  529. @$(MKDIR) $(@D)
  530. $(CC_PRE_PROCESS)
  531. $(CC) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CFLAGS) -o $@ $<
  532. $(CC_POST_PROCESS)
  533. $(OBJ_DIR)/%.s: %.cpp
  534. @$(ECHO) Compiling $(<F) to assembler...
  535. @$(MKDIR) $(@D)
  536. $(CXX_PRE_PROCESS)
  537. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  538. $(CXX_PRE_PROCESS)
  539. $(OBJ_DIR)/%.s: %.cc
  540. @$(ECHO) Compiling $(<F) to assembler...
  541. @$(MKDIR) $(@D)
  542. $(CXX_PRE_PROCESS)
  543. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  544. $(CXX_PRE_PROCESS)
  545. $(OBJ_DIR)/%.s: %.cxx
  546. @$(ECHO) Compiling $(<F) to assembler...
  547. @$(MKDIR) $(@D)
  548. $(CXX_PRE_PROCESS)
  549. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  550. $(CXX_PRE_PROCESS)
  551. $(OBJ_DIR)/%.i: %.c
  552. @$(ECHO) Compiling $(<F) to assembler...
  553. @$(MKDIR) $(@D)
  554. $(CC_PRE_PROCESS)
  555. $(CC) -E $(CPPFLAGS) $(ALT_CFLAGS) $(CFLAGS) -o $@ $<
  556. $(CC_PRE_PROCESS)
  557. $(OBJ_DIR)/%.i: %.cpp
  558. @$(ECHO) Compiling $(<F) to assembler...
  559. @$(MKDIR) $(@D)
  560. $(CXX_PRE_PROCESS)
  561. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  562. $(CXX_PRE_PROCESS)
  563. $(OBJ_DIR)/%.i: %.cc
  564. @$(ECHO) Compiling $(<F) to assembler...
  565. @$(MKDIR) $(@D)
  566. $(CXX_PRE_PROCESS)
  567. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  568. $(CXX_PRE_PROCESS)
  569. $(OBJ_DIR)/%.i: %.cxx
  570. @$(ECHO) Compiling $(<F) to assembler...
  571. @$(MKDIR) $(@D)
  572. $(CXX_PRE_PROCESS)
  573. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  574. $(CXX_PRE_PROCESS)
  575. # Pattern rules for building other object files.
  576. %.o: %.c
  577. @$(ECHO) Compiling $(<F)...
  578. @$(MKDIR) $(@D)
  579. $(CC_PRE_PROCESS)
  580. $(CC) -MP -MMD -c $(CPPFLAGS) $(ALT_CFLAGS) $(CFLAGS) -o $@ $<
  581. $(CC_POST_PROCESS)
  582. %.o: %.cpp
  583. @$(ECHO) Compiling $(<F)...
  584. @$(MKDIR) $(@D)
  585. $(CXX_POST_PROCESS)
  586. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  587. $(CXX_POST_PROCESS)
  588. %.o: %.cc
  589. @$(ECHO) Compiling $(<F)...
  590. @$(MKDIR) $(@D)
  591. $(CXX_POST_PROCESS)
  592. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  593. $(CXX_POST_PROCESS)
  594. %.o: %.cxx
  595. @$(ECHO) Compiling $(<F)...
  596. @$(MKDIR) $(@D)
  597. $(CXX_PRE_PROCESS)
  598. $(CXX) -MP -MMD -c $(BSP_CPPFLAGS) $(BSP_CXXFLAGS) $(BSP_CFLAGS) -o $@ $<
  599. $(CXX_POST_PROCESS)
  600. %.o: %.S
  601. @$(ECHO) Compiling $(<F)...
  602. @$(MKDIR) $(@D)
  603. $(AS_PRE_PROCESS)
  604. $(AS) -MP -MMD -c $(BSP_CFLAGS) $(BSP_CPPFLAGS) $(BSP_ASFLAGS) -o $@ $<
  605. $(AS_POST_PROCESS)
  606. %.o: %.s
  607. @$(ECHO) Compiling $(<F)...
  608. @$(MKDIR) $(@D)
  609. $(AS_PRE_PROCESS)
  610. $(AS) -MP -MMD -c $(BSP_ASFLAGS) $(BSP_CFLAGS) -o $@ $<
  611. $(AS_POST_PROCESS)
  612. #------------------------------------------------------------------------------
  613. # NEWLIB RULES
  614. #------------------------------------------------------------------------------
  615. ifneq ($(COMPILE_NEWLIB),)
  616. NEWLIB_FLAGS += $(BSP_CFLAGS)
  617. endif
  618. ifneq ($(NEWLIB_DIR),)
  619. $(NEWLIB_DIR):
  620. @$(ECHO) Creating $(NEWLIB_DIR)...
  621. nios2-newlib-gen --no-multilib $(NEWLIB_DIR)-build-tmp $(NEWLIB_DIR) --custom "$(NEWLIB_FLAGS)"
  622. @$(ECHO) Removing $(NEWLIB_DIR)-build-tmp...
  623. @$(RM) -rf $(NEWLIB_DIR)-build-tmp
  624. endif
  625. #------------------------------------------------------------------------------
  626. # LIBRARY RULES
  627. #------------------------------------------------------------------------------
  628. $(BSP_LIB): $(OBJS)
  629. @$(ECHO) Creating $@...
  630. $(AR_PRE_PROCESS)
  631. $(RM) -f $@
  632. $(AR) $(BSP_ARFLAGS) $@ $^
  633. $(AR_POST_PROCESS)
  634. #------------------------------------------------------------------------------
  635. # DEPENDENCY FILES
  636. #------------------------------------------------------------------------------
  637. ifneq ($(findstring clean, $(MAKECMDGOALS)),clean)
  638. -include $(DEPS)
  639. endif
  640. # End of Makefile