Nios II Classic Software Developer’s Handbook

ID 683282
Date 5/14/2015
Public
Document Table of Contents

15.4.1. Application Makefile Variables

You can modify the following application makefile variables on the command line:
  • CREATE_OBJDUMP—Assign 1 to this variable to enable creation of an object dump file (.objdump) after linking the application. The nios2-elf-objdump utility is called to create this file. An object dump contains information about all object files linked into the .elf file. It provides a complete view of all code linked into your application. An object dump contains a disassembly view showing each instruction and its address.
  • OBJDUMP_INCLUDE_SOURCE—Assign 1 to this variable to include source code inline with disassembled instructions in the object dump. When enabled, this includes the --source switch when calling the object dump executable. This is useful for debugging and examination of how the preprocessor and compiler generate instructions from higher level source code (such as C) or from macros.
  • OBJDUMP_FULL_CONTENTS—Assign 1 to this variable to include a raw display of the contents of the .text linker section. When enabled, this variable includes the --full-contents switch when calling the object dump executable.
  • CREATE_.elf_DERIVED_FILES—Setting this variable to 1 creates the HDL simulation and onchip memory initialization files when you invoke the makefile with the all target. When this variable is 0 (the default), these files are only created when you make the mem_init_generate or mem_init_install target.
Note: Creating the HDL simulation and onchip memory initialization files increases project build time.
  • CREATE_LINKER_MAP—Assign 1 to this variable to enable creation of a link map file (.map) after linking the application. A link map file provides information including which object files are included in the executable, the path to each object file, where objects and symbols are located in memory, and how the common symbols are allocated.
  • APP_CFLAGS_DEFINED_SYMBOLS—This variable allows you to define macros using the -D argument, for example -D <macro name> . The contents of this variable are passed to the compiler and linker without modification.
  • APP_CFLAGS_UNDEFINED_SYMBOLS—This variable allows you to remove macro definitions using the -U argument, for example -U <macro name> . The contents of this variable are passed to the compiler and linker without modification.
  • APP_CFLAGS_OPTIMIZATION—The C/C++ compiler optimization level. For example, -O0 provides no optimization and -O2 provides standard optimization. -O0 is recommended for debugging code, because compiler optimization can remove variables and produce non-sequential execution of code while debugging.
  • APP_CFLAGS_DEBUG_LEVEL—The C/C++ compiler debug level. -g provides the default set of debug symbols typically required to debug an application. Omitting -g omits debug symbols from the .elf.
  • APP_CFLAGS_WARNINGS—The C/C++ compiler warning level. -Wall is commonly used, enabling all warning messages.
  • APP_CFLAGS_USER_FLAGS
  • APP_INCLUDE_DIRS—Use this variable to specify paths for the preprocessor to search. These paths commonly contain C header files (.h) that application code requires. Each path name is formatted and passed to the preprocessor with the -I option.

    You can add multiple directories by enclosing them in double quotes, for example --set APP_INCLUDE_DIRS "../my_includes ../../other_includes".

  • APP_LIBRARY_DIRS—Use this variable to specify paths for additional libraries that your application links with.
Note: When you specify a user library path with APP_LIBRARY_DIRS, you also need to specify the user library names with the APP_LIBRARY_NAMES variable.

APP_LIBRARY_DIRS specifies only the directory where the user library file(s) are located, not the library archive file (.a) name.

Note: Do not use this variable to specify the path to a BSP or user library created with the SBT. The paths to these libraries are specified in public.mk files included in the application makefile.

You can add multiple directories by enclosing them in double quotes, for example --set APP_LIBRARY_DIRS "../my_libs ../../other_libs".

  • APP_LIBRARY_NAMES—Use this variable to specify the names of additional libraries that your application must link with. Library files are .a files.
Note: You do not specify the full name of the .a file. Instead, you specify the user library name <name>, and the SBT constructs the filename lib<name>.a. For example, if you add the string "math" to APP_LIBRARY_NAMES, the SBT assumes that your library file is named libmath.a.

Each specified user library name is passed to the linker with the -l option. The paths to locate these libraries must be specified in the APP_LIBRARY_DIRS variable.

Note: You cannot use this variable to specify a BSP or user library created with the SBT. The paths to these libraries are specified in public.mk file included in the application makefile.
  • BUILD_PRE_PROCESS—This variable allows you to specify a command to be executed prior to building the application, for example, 
cp *.elf ../lastbuild.
  • BUILD_POST_PROCESS—This variable allows you to specify a command to be executed after building the application, for example, 
cp *.elf //production/test/nios2executables.