The qrules.mk include file

The qrules.mk include file defines the macros used for compiling.

You can inspect—and in some cases, also set—the following macros when you use qrules.mk. Since the qtargets.mk file includes qrules.mk, these are available there as well. Don't modify those that are marked “(read-only).”

VARIANT_LIST (read-only)
A space-separated list of the variant names macro. Useful with the $(filter ...) make function for picking out individual variant names.
CPU
The name of the target CPU. Defaults to the name of the next directory up with all parent directories stripped off.
CPU_ROOT (read-only)
The full pathname of the directory tree up to and including the OS level.
OS
The name of the target OS. Defaults to the name of the directory two levels up with all parent directories stripped off.
OS_ROOT (read-only)
The full pathname of the directory tree up to and including the OS level.
SECTION
The name of the section. This is set only if there's a section level in the tree.
SECTION_ROOT (read-only)
The full pathname of the directory tree up to and including the section level.
PROJECT (read-only)
The basename() of the directory containing the common.mk file.
PROJECT_ROOT (read-only)
The full pathname of the directory tree up to and including the project level.
PRODUCT (read-only)
The basename() of the directory above the project level.
PRODUCT_ROOT (read-only)
The full pathname of the directory tree up to and including the product level.
NAME
The basename() of the executable or library being built. Defaults to $(PROJECT).
SRCVPATH
A space-separated list of directories to search for source files. Defaults to all the directories from the current working directory up to and including the project root directory. You'd almost never want to set this; use EXTRA_SRCVPATH to add paths instead.
EXTRA_SRCVPATH
Added to the end of SRCVPATH. Defaults to none.
INCVPATH
A space-separated list of directories to search for include files. Defaults to $(SRCVPATH) plus $(USE_ROOT_INCLUDE). You'd almost never want to set this; use EXTRA_INCVPATH to add paths instead.
EXTRA_INCVPATH
Added to INCVPATH just before the $(USE_ROOT_INCLUDE). Default is none.
LIBVPATH
A space-separated list of directories to search for library files. Defaults to:
. $(INSTALL_ROOT_support)/$(OS)/$(CPUDIR)/lib $(USE_ROOT_LIB).
  

You'll almost never want to use this; use EXTRA_LIBVPATH to add paths instead.

EXTRA_LIBVPATH
Added to LIBVPATH just before $(INSTALL_ROOT_support)/$(OS)/$(CPUDIR)/lib. Default is none.
DEFFILE
The name of an assembler define file created by mkasmoff. Default is none.
SRCS
A space-separated list of source files to be compiled. Defaults to all *.s, *.S, *.c, and *.cc files in SRCVPATH.
EXCLUDE_OBJS
A space-separated list of object files not to be included in the link/archive step. Defaults to none.
EXTRA_OBJS
A space-separated list of object files to be added to the link/archive step even though they don't have corresponding source files (or have been excluded by EXCLUDE_OBJS). Default is none.
OBJPREF_object, OBJPOST_object
Options to add before or after the specified object:
OBJPREF_object = options
OBJPOST_object = options
  

The options string is inserted verbatim. Here's an example:

OBJPREF_libc_cut.a = -Wl,--whole-archive
OBJPOST_libc_cut.a = -Wl,--no-whole-archive
  
LIBS
A space-separated list of library stems to be included in the link. Default is none.
LIBPREF_library, LIBPOST_library
Options to add before or after the specified library:
LIBPREF_library = options
LIBPOST_library = options
   

The options string is inserted verbatim.

You can use these macros to link some libraries statically and others dynamically. For example, here's how to bind libmystat.a and libmydyn.so to the same program:

LIBS += mystat mydyn

LIBPREF_mystat = -Bstatic
LIBPOST_mystat = -Bdynamic
  

This places the -Bstatic option just before -lmystat, and -Bdynamic right after it, so that only that library is linked statically.

CCFLAGS
Flags to add to the C compiler command line.
CXXFLAGS
Flags to add to the C++ compiler command line.
ASFLAGS
Flags to add to the assembler command line.
LDFLAGS
Flags to add to the linker command line.
VFLAG_which
Flags to add to the command line for C compiles, assemblies, and links; see below.
CCVFLAG_which
Flags to add to C compiles; see below.
ASVFLAG_which
Flags to add to assemblies; see below.
LDVFLAG_which
Flags to add to links; see below.
OPTIMIZE_TYPE
The optimization type; one of:
  • OPTIMIZE_TYPE=TIME — optimize for execution speed (the default for AArch64 and x86 platforms)
  • OPTIMIZE_TYPE=SIZE — optimize for executable size (the default for ARM platforms)
  • OPTIMIZE_TYPE=NONE — turn off optimization

Note that for the VFLAG_which, CCVFLAG_which, ASVFLAG_which, and LDVFLAG_which macros, the which part is the name of a variant. This combined macro is passed to the appropriate command line. For example, if there were a variant called 403,” then the macro VFLAG_403 would be passed to the C compiler, assembler, and linker.

Note: Don't use this mechanism to define a C macro constant that you can test in the source code to see if you're in a particular variant. The makefiles do that automatically for you. Don't set the *VFLAG_* macros for any of the distinguished variant names (listed in the Recognized variant names section, above). The common makefiles will get confused if you do.