Environment variables
Host-side environment variables can be accessed in a buildfile. All occurrences of ${NAME} are replaced by the value of the environment variable with the given name. You can set additional variables in the buildfile to define the environment of any processes started on the target at boot time.
- A buildfile line of the form
varname=value progname arguments...
creates a local variable and addsvarname=value
only to the environment of that one process. - A buildfile line of the form
varname=value
creates a global variable whose setting is added to the environment of every process started below in the buildfile. You must carefully consider the effects of such settings made early in the buildfile, particularly in the bootstrap file (i.e., the first section) as explained below. - Global variables can be accessed just like regular host environment variables by using
${varname}
.
Note that only environment variables defined in the buildfile are visible on the target.
Setting environment variables in the bootstrap file
[image=0x80200000]
[virtual=aarch64le,elf] .boot = {
startup-honeycomb_lx2 -W
PATH=/proc/boot:/sbin:/bin:/usr/bin:/usr/sbin:/usr/libexec
LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/lib/dll:/lib/dll/pci
CONFIG_PATH=/etc/cfg procnto-smp-instr -v
}
Setting environment variables in a script file
Buildfile structure and contentsin which the SYSNAME, TERM, and ENV variables are defined at the beginning of the script file and, thus, apply for all user processes. Suppose we then define the PATH variable for a specific process later on:
[image=0x80200000]
[virtual=aarch64le,elf] .boot = {
...
}
[+script] .script = {
SYSNAME=nto
TERM=qansi
ENV=/etc/profile
procmgr_symlink ../../proc/boot/ldqnx-64.so.2 /usr/lib/ldqnx-64.so.2
...
devc-ser8250-abc123 -F -e -c14745600 -b115200 0xc8000000 ^2,15 &
...
PATH=/proc/boot:/bin esh &
}
dumpifs -vv myimage.ifs
Two -v options are needed to print the environment variable settings
that are passed to each process started in the buildfile.SYSNAME=nto TERM=qansi ENV=/etc/profile devc-ser8250-abc123 -F -e \
-c14745600 -b115200 0xc8000000 ^2,15 &
SYSNAME=nto TERM=qansi ENV=/etc/profile PATH=/proc/boot:/bin esh &
Defining search paths of utilities and libraries
The procnto-smp-instr process manager uses the value of its PATH variable to set
the _CS_PATH configuration string. Similarily, it sets the _CS_LIBPATH configuration string
to the value of its LD_LIBRARY_PATH variable. For more information about setting these environment variables
in the buildfile, see Setting PATH and LD_LIBRARY_PATH
in the QNX OS User's Guide.
Host-side environment variables used for generating the target image
The host environment variable MKIFS_PATH is used to control where mkifs
looks for the files it places in the image (see Including files in the image
in this chapter).
You can set it when running mkifs to define primary lookup paths. Additional root directories specified with
the mkifs -r options append path lists to this variable; another path list rooted in
${QNX_TARGET} is appended at the very end.
The PROCESSOR, PROCESSOR_BASE, and CPU_BASE environment variables are set by the virtual attribute of the bootstrap file. They are used in constructing the MKIFS_PATH path lists.