Skip to main content
The following variables and macros are defined in include/image.mk and are available when writing image generation rules in target/linux/<target>/image/Makefile.

Core Directory Variables

VariableDescription
KDIRKernel build directory: $(BUILD_DIR)/linux-$(BOARD)_$(SUBTARGET)
KDIR_TMPTemporary directory inside KDIR: $(KDIR)/tmp
DTS_DIRCompiled Device Tree blobs directory: $(LINUX_DIR)/arch/$(LINUX_KARCH)/boot/dts
TARGET_DIRStaged rootfs directory: $(BUILD_DIR)/root-$(BOARD)
BUILD_DIRPackage build base directory
STAGING_DIR_IMAGEImage staging directory: $(STAGING_DIR)/image

Image Naming Variables

VariableDescriptionExample
IMG_PREFIXBase filename prefix for all imagesopenwrt-ath79-generic
IMG_PREFIX_EXTRAAdditional suffix from CONFIG_EXTRA_IMAGE_NAME (sanitized)custom-
IMG_PREFIX_VERNUMVersion number suffix (if CONFIG_VERSION_FILENAMES)23.05.3-
IMG_PREFIX_VERCODEVersion code suffix (if CONFIG_VERSION_CODE_FILENAMES)r23809-
IMG_ROOTFSRootfs image name: $(IMG_PREFIX)-rootfsopenwrt-ath79-generic-rootfs
IMG_COMBINEDCombined image name: $(IMG_PREFIX)-combinedopenwrt-ath79-generic-combined
EXTRA_IMAGE_NAMERaw value before sanitization; set via CONFIG_EXTRA_IMAGE_NAMEcustom
VariableDescription
IMG_PART_SIGNATURE8-character MD5 of SOURCE_DATE_EPOCH + LINUX_VERMAGIC. Used for partition UUIDs.
IMG_PART_DISKGUIDGUID formatted from the same hash. Used in GPT partition tables.

Profile Variables

VariableDescription
PROFILECurrent device profile name being built
PROFILE_SANITIZEDLowercase, space-replaced version of PROFILE used in filenames
PROFILE_PACKAGESPackage list specific to this device profile
DEVICE_VENDORVendor name (e.g., TP-Link)
DEVICE_MODELModel name (e.g., Archer C7)
DEVICE_VARIANTHardware variant (e.g., v2)
DEVICE_DTSDTS file name (without .dts extension)
IMAGE_SIZEMaximum image size in bytes or with unit suffix

Filesystem Option Variables

VariableDescription
SQUASHFS_BLOCKSIZESquashFS block size (from CONFIG_TARGET_SQUASHFS_BLOCK_SIZE)
SQUASHFSOPTFull mksquashfs options string
SQUASHFSCOMPCompression algorithm: gzip or xz $(LZMA_XZ_OPTIONS)
LZMA_XZ_OPTIONSXZ compression options: -Xpreset 9 -Xe -Xlc 0 -Xlp 2 -Xpb 2
VariableDescription
JFFS2OPTSJFFS2 mkfs options (endianness, compression, squash UIDs)
JFFS2_BLOCKSIZEDefault JFFS2 erase block sizes: 64k 128k
EROFSOPTEROFS mkfs options
EROFSCOMPEROFS compression: lz4hc,12 or lzma,109
EROFS_PCLUSTERSIZEEROFS physical cluster size from CONFIG_TARGET_EROFS_PCLUSTER_SIZE

Utility Macros

These are GNU make functions (called with $(call macro,args)):
MacroSignatureDescription
exp_units$(call exp_units,<size>)Convert a size with unit postfix to a byte expression. Postfixes: k (kilobytes), m (megabytes), g (gigabytes). E.g., $(call exp_units,4m) expands to 4 * 1024 * 1024.
param_get$(call param_get,<key>,<list>)Extract the value from a key=value entry in a space-separated list.
param_get_default$(call param_get_default,<key>,<list>,<default>)Like param_get, but returns <default> if the key is not found.
param_mangle$(call param_mangle,<str>)Replace spaces with underscores.
param_unmangle$(call param_unmangle,<str>)Replace underscores with spaces.
mkfs_packages_id$(call mkfs_packages_id,<pkg-list>)Generate an 8-character hash from a sorted package list.
mkfs_target_dir$(call mkfs_target_dir,<params>)Get the target directory, optionally per-package.
Image rules use pattern matching via $* to pass parameters:
# In a Device/ definition:
IMAGE/sysupgrade.bin := append-kernel | pad-to 64k | append-rootfs | check-size

# The target_params macro splits '+'-separated parameters:
target_params = $(subst +,$(space),$*)

Filesystem Type Variables

VariableDescription
TARGET_FILESYSTEMSSpace-separated list of enabled filesystem types (e.g., squashfs ext4)
fs-types-yFilesystems selected by CONFIG_TARGET_ROOTFS_* variables
FS_64K / FS_128K / FS_256KFilesystem lists with specific JFFS2 block sizes
MKFS_DEVTABLE_OPTDevice table option: -D $(INCLUDE_DIR)/device_table.txt