What is the MK file format?
A .mk file is a plain-text build script fragment written in make syntax. Where the main build file is conventionally named Makefile (no extension), .mk files serve as modular sub-makefiles - partial rule sets, variable definitions, or platform-specific configuration blocks - pulled into a parent build via make's include directive. The same rules and syntax apply to both.
A makefile rule consists of a target line (target: dependencies) followed by one or more recipe lines. Recipe lines must begin with a literal TAB character, not spaces - a notorious source of build failures that produce a cryptic missing separator error. Variable assignments, pattern rules, and conditional directives (ifeq, ifdef) are all valid in .mk files.
GNU Make (Free Software Foundation, currently version 4.4.1 released 2023) is the most widely used implementation. Microsoft's NMAKE (bundled with Visual Studio) and BSD make are broadly compatible. The .MAK extension serves a similar purpose and is common in Windows-oriented projects using NMAKE. .mk files became especially prominent through Android's legacy build system, which relied on Android.mk fragments extensively before Google replaced it with Android.bp and the Soong system.
CMake, Ninja, Meson, and Bazel have emerged as alternatives for large projects, but GNU Make and .mk fragments remain ubiquitous in open-source C/C++ codebases, embedded firmware, and the Linux kernel.
Security & safety
RISK: MEDIUMA .mk file is plain text and cannot infect a machine by itself, but it contains shell commands that execute when make runs it. Running an untrusted .mk file (e.g. from an unknown source) can delete files, download malware, or modify system settings - the same risk as running any untrusted shell script. Always inspect the file in a text editor before running make.
Format details
in a nutshellPrograms that open MK files
Technical details
deep spec| Format type | Plain-text make rule fragment (sub-makefile / included build script) |
| Encoding | ASCII or UTF-8 |
| Byte order | N/A (plain text) |
| Container | Plain text |
| Critical syntax requirement | Recipe lines must start with a literal TAB character; spaces cause a 'missing separator' error |
| Include mechanism | Pulled into a parent Makefile via the 'include' directive |
| Typical file size | 1 KB - 50 KB |
| Implementations | GNU Make 4.4.1 (2023), BSD make, Microsoft NMAKE, POSIX make (IEEE 1003.1-2017) |
| POSIX standard | IEEE 1003.1-2017 (POSIX make specification) |
| Notable usage | Android legacy build system (Android.mk, used before Soong/Android.bp) |
| Platform | Linux, macOS, Windows (MSYS2, WSL, Cygwin, NMAKE), BSD, Unix |
| Released | 1976 (Stuart Feldman, Bell Labs - original make); .mk convention ~1980s |
| Latest version | GNU Make 4.4.1 (2023) |
| Open standard | Yes · royalty-free |
| Specification | www.gnu.org |
MK conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about MK files.