Nios® II Software Developer Handbook

ID 683525
Date 8/28/2023
Public
Document Table of Contents

16.1.4. nios2-app-generate-makefile

Usage: nios2-app-generate-makefile --bsp-dir <directory> [<options>]

Description: The nios2-app-generate-makefile command generates an application makefile (called Makefile). The path to a BSP created by nios2-bsp-generate-files is a mandatory command line option.

Required Arguments:

--bsp-dir <directory>: Specifies the path to the BSP generated files directory (populated using the nios2-bsp-generate-files command).

Optional Arguments:

  • --app-dir <directory>: Directory to place the application makefile and executable and linking format file (.elf). If omitted, it defaults to the current directory.
  • --debug: Output debug, exception traces, verbose, and default information about the command's operation to stdout.
  • --elf-name <filename>: Name of the .elf file to create. If omitted, it defaults to the first source file specified with the file name extension replaced with .elf and placed in the application directory.
  • --extended-help: Displays full information about this command and its options.
  • --help: Displays basic information about this command and its options.
  • --inc-dir <directory>: Searches for source include files in <filepath>. Use "." to look in the current directory. Multiple --inc-dir options are allowed.
  • --inc-rdir <directory>: Same as --inc-dir option but recursively search for source include files in or under <filepath>. Multiple --inc-rdir options are allowed.
  • --jvm-max-heap-size <value> Optional. The maximum memory size to be used for allocations when running this tool. This value is specified as <size><unit> where unit can be m (or M) for multiples of megabytes or g (or G) for multiples of gigabytes. The default value is 512m.
  • --log <filename>: Create a debug log and write to specified file. Also logs debug information to stdout.
  • --no-src: Allows no sources files to be set in the Makefile. You must add source files in manually before compiling
  • --set <name> <value>: Set the makefile variable called <name> to <value>. If the variable exists in the managed section of the makefile, <value> replaces the default settings. If the variable does not already exist, it is added. Multiple --set options are allowed.
  • --silent: Suppress information about the command's operation normally sent to stdout.
  • --src-dir <directory>: Searches for source files in <directory>. Use . to look in the current directory. Multiple --src-dir options are allowed.
  • --src-files <filenames>: Adds a list of space-separated source file names to the makefile. The list of file names is terminated by the next option or the end of the command line. Multiple --src-files options are allowed.
  • --src-rdir <directory>: Same as --src-dir option but recursively search for source files in or under <directory>. Multiple --src-rdir options are allowed and can be freely mixed with --src-dir options.
  • --use-lib-dir <directory>: Specifies the path to a dependent user library directory. The user library directory must contain a makefile fragment called public.mk. Multiple --use-lib-dir options are allowed.
  • --verbose: Output verbose, and default information about the command’s operation to stdout.
  • --version: Displays the version of this command and exits with a zero exit status.

Examples:

Example:

> 'nios2-app-generate-makefile --bsp-dir ../my_bsp --src-files hello_world.c'

Generates a Makefile setup to compile one source file in the current directory.

> 'make'

Recursively makes the BSP and then compiles and links the application to create hello_world.elf.

Example:

> 'nios2-app-generate-makefile --bsp-dir ../my_bsp --app-dir /tmp/my_dir/release --elf foo --src-rdir /data/jball/src/foo --src-files extra1.c extra2.c

Generates a Makefile in /tmp/my_dir/release that builds an ELF called /tmp/mydir/release/foo.elf. The source files are all those recursively found under /data/jball/src/foo and extra files called extra1.c and extra2.c in the current directory.