AOSP Foundations
3 min read

Product Makefiles

Learn how Product Makefiles define the software configuration and included apps for a specific Android device.

Once you select a device using the lunch command, the build system needs to know exactly which applications, framework modules, and hardware drivers to actually compile and include in the final system.img.

Because AOSP contains thousands of apps and drivers, compiling all of them would result in a massive, unbootable 100GB operating system. Product Makefiles are the filter that defines the exact software composition of a specific device.

The Configuration Hierarchy

A device configuration is typically split across three primary Makefiles located within the device/<vendor>/<codename>/ directory.

1. AndroidProducts.mk

This is the entry point. It registers your device with the build system and tells the lunch command that your device exists. It simply points to the location of the main device.mk file.

2. BoardConfig.mk

This file defines the absolute lowest-level hardware architecture.

  • Does the device use an ARM64 or x86 processor?
  • What is the exact physical size of the /system partition?
  • Which bootloader and kernel configuration should be used?
  • This file is almost entirely concerned with silicon and memory layouts, not software applications.
# Example of BoardConfig.mk syntax
TARGET_ARCH := arm64
TARGET_ARCH_VARIANT := armv8-a
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648

3. device.mk (or <product>.mk)

This is the main Product Makefile. It defines the high-level software configuration.

  • What is the device's brand name and model number?
  • Which system apps should be pre-installed?
  • Which custom audio or display configurations should be included?

Defining Software with PRODUCT_PACKAGES

The most important variable in a Product Makefile is PRODUCT_PACKAGES. This variable acts as the master shopping list for the build system.

If you write a new system application (e.g., MyCustomSettingsApp defined in an Android.bp file), compiling AOSP will not include your app in the final image by default. You must explicitly add it to the shopping list in your device.mk:

# Inside device.mk
PRODUCT_PACKAGES += \
    MyCustomSettingsApp \
    ChromeBrowser \
    CustomBluetoothDriver

When Ninja executes the build, it reads PRODUCT_PACKAGES, looks up the modules, and ensures they are compiled and copied into the final /system or /vendor output directories.

Device Identification Variables

Product Makefiles also define the system properties that apps read to identify the device.

# Standard variables found in device.mk
PRODUCT_NAME := aosp_coral
PRODUCT_DEVICE := coral
PRODUCT_BRAND := google
PRODUCT_MODEL := Pixel 4 XL

When a user opens the "About Phone" screen in Android Settings, the device name displayed there is pulled directly from these specific variables defined in the Product Makefile.

# You can query these properties on a live device via ADB
adb shell getprop ro.product.model
# Output: Pixel 4 XL