build-makefile

Original🇨🇳 Chinese
Translated
1 scripts

Used when you need to compile embedded firmware projects based on bare Makefiles (without CMake/IDE), call the built-in script to parse the Makefile, execute make, and locate firmware artifacts.

4installs
Added on

NPX Install

npx skill4agent add leokemp223/embed-ai-tool build-makefile

SKILL.md Content (Chinese)

View Translation Comparison →

Build Makefile Projects

Applicable Scenarios

  • Project Profile
    specifies
    build_system: makefile
    .
  • The workspace contains
    Makefile
    /
    makefile
    /
    GNUmakefile
    , but no
    CMakeLists.txt
    ,
    platformio.ini
    ,
    .uvprojx
    or
    .ewp
    .
  • Users want to compile or confirm firmware artifacts for bare Makefile MCU projects.
  • New
    ELF
    ,
    HEX
    or
    BIN
    files are required for flashing or debugging processes.

Required Inputs

  • Workspace path, or an existing
    Project Profile
    .
  • Optional make target name, additional variables (e.g.,
    CROSS_COMPILE
    ,
    MCU
    ), make flags, and number of parallel tasks.

Automatic Detection

  • If
    Makefile
    /
    makefile
    /
    GNUmakefile
    exists in the workspace root directory, the script automatically identifies it.
  • Parse Makefile variables:
    CROSS_COMPILE
    ,
    CC
    ,
    TARGET
    ,
    MCU
    ,
    BOARD
    ,
    CFLAGS
    ,
    LDFLAGS
    , etc.
  • Infer toolchain family from
    CROSS_COMPILE
    prefix (
    arm-none-eabi-
    gnu-arm
    ,
    riscv32-unknown-elf-
    gnu-riscv
    ,
    xtensa-esp32-elf-
    gnu-esp
    ).
  • Infer target chip from
    MCU
    variable,
    -mcpu=
    flag or linker script name.
  • Detect if
    make
    /
    gmake
    /
    mingw32-make
    is available.
  • If the Makefile contains
    # Generated by CMake
    , prompt the user to use the
    build-cmake
    skill.

Execution Steps

  1. First read references/usage.md to confirm whether this time is for environment detection, Makefile parsing, target listing, build execution, or just artifact scanning.
  2. If you are not sure whether the environment is ready, first run the
    --detect
    mode of the built-in script scripts/makefile_builder.py to confirm.
  3. Run
    --parse-makefile
    to check the parsed variables and toolchain information, and confirm the target chip and compiler.
  4. To view available targets, run
    --list-targets
    .
  5. Use
    --source
    to run the build, specifying
    --target
    ,
    --clean
    ,
    --extra-args
    and
    -j
    as needed.
  6. Read the build results and artifact scan report output by the script, write the artifact path back to
    Project Profile
    and pass it to downstream skills.

Failure Diversion

  • Return
    environment-missing
    when
    make
    or cross-compiler is missing.
  • Return
    project-config-error
    when there are Makefile syntax errors, link failures or invalid target names.
  • Return
    artifact-missing
    when the build is successful but no flashable artifacts are found in the source directory and
    build/
    ,
    output/
    ,
    out/
    .
  • Return
    ambiguous-context
    when multiple top-level Makefiles exist in the workspace and the intent is unclear.

Platform Notes

  • make
    is usually pre-installed on Linux / macOS.
  • On Windows,
    make
    is provided by MSYS2, MinGW or WSL. The script will try
    make
    ,
    gmake
    ,
    mingw32-make
    in sequence.
  • The build directory in the output should remain an absolute path for direct reuse by downstream flashing and debugging skills.

Output Conventions

  • Output build commands, build directories, parsed toolchain information and preferred artifact paths.
  • Update
    Project Profile
    with
    artifact_path
    ,
    artifact_kind
    ,
    toolchain
    and
    target_mcu
    .
  • Recommend
    flash-openocd
    ,
    flash-jlink
    or
    debug-gdb-openocd
    after success.

Handover Relationships

  • When the next step is to flash the program to hardware, pass the successful build result to
    flash-openocd
    or
    flash-jlink
    .
  • When symbol information or a debugging session is needed for the next step, pass the successful build result to
    debug-gdb-openocd
    or
    debug-jlink
    .