Building a Makefile Project
Applicable Scenarios
Project Profile indicates build_system: makefile。
- The workspace contains
Makefile / makefile / GNUmakefile, but does not have CMakeLists.txt、platformio.ini、.uvprojx or .ewp。
- The user wants to compile a bare Makefile MCU project or confirm the firmware artifact.
- The flashing or debugging process requires a new
ELF、HEX or BIN。
Required Inputs
- Workspace path, or an existing
Project Profile。
- Optional make target name, extra variables (such as
CROSS_COMPILE、MCU), make flags, and number of parallel jobs.
Automatic Detection
- Upon startup, the script automatically reuses the last successful profile in the project root directory
.em_skill.json as default parameters (explicit parameters take precedence; no need to manually pass --resume);--resume is only used to assert that the cache must exist; if there is no cache, it exits with a non-zero code. When there is no cache or the user explicitly requests re-detection, the script automatically falls back to a normal scan.
- If the workspace root directory contains
Makefile / makefile / GNUmakefile, the script automatically recognizes it.
- Parse Makefile variables:
CROSS_COMPILE、CC、TARGET、MCU、BOARD、CFLAGS、LDFLAGS , etc.
- From
CROSS_COMPILE infer the toolchain family from the prefix (arm-none-eabi- → gnu-arm,riscv32-unknown-elf- → gnu-riscv,xtensa-esp32-elf- → gnu-esp)。
- From
MCU variable,-mcpu= flags, or linker script name, infer the target chip.
- Detect
make / gmake / mingw32-make whether it is available.
- If the Makefile contains
# Generated by CMake, prompt the user to use build-cmake skill。
Execution Steps
- First read references/usage.md, and confirm whether this time it is environment detection, parsing the Makefile, listing targets, executing the build, or only scanning artifacts.
- If unsure whether the environment is ready, first run the bundled script scripts/makefile_builder.py 's
--detect mode to confirm.
- Run
--parse-makefile to check the parsed variables and toolchain information, and confirm the target chip and compiler.
- If you need to view available targets, run
--list-targets。
- Use
--source to run the build, specifying as needed --target、--clean、--extra-args and -j。
- Read the build result and artifact scan report output by the script, write the artifact path back to
Project Profile and hand it to the downstream skill.
Failure Triage
- When
make or the cross compiler is missing, return environment-missing。
- When the Makefile has a syntax error, linking fails, or the target name is invalid, return
project-config-error。
- When the build succeeds but no flashable artifact is found in the source directory and
build/、output/、out/ , return artifact-missing。
- When the workspace has multiple top-level Makefiles and the intent is unclear, return
ambiguous-context。
Platform Notes
- On Linux / macOS,
make is usually preinstalled.
- On Windows, MSYS2, MinGW, or WSL is required to provide
make. The script will try in sequence make、gmake、mingw32-make。
- The build directory in the output should remain an absolute path, making it convenient for downstream flashing and debugging skills to reuse directly.
Output Conventions
- Output the build command, build directory, parsed toolchain information, and the preferred artifact path.
- Use
artifact_path、artifact_kind、toolchain and target_mcu to update Project Profile。
- After success, recommend
flash-openocd、flash-jlink or debug-gdb-openocd。
Handoff Relationships
- When the next step's intent is to flash the program onto hardware, hand the successful build result to
flash-openocd or flash-jlink。
- When the next step requires symbol information or a debugging session, hand the successful build result to
debug-gdb-openocd or debug-jlink。