Skip to content
Latchkey

make -C (Directory) Command Reference

Build in another directory without a fragile cd in your pipeline.

make -C DIR changes into DIR before reading its Makefile. It is the clean way to drive a subproject build from a parent pipeline step.

What it does

make -C DIR is equivalent to cd DIR && make, but make handles the directory change itself and reports it in the log (Entering/Leaving directory). Multiple -C options are applied cumulatively.

Common flags and usage

  • -C DIR: change to DIR before reading the Makefile
  • Combine with a target: make -C build install
  • Combine with -j: make -C src -j"$(nproc)"
  • Common with generated build dirs (CMake/Ninja output)

Example

shell
- name: Build subproject
  run: make -C services/api -j"$(nproc)" build

In CI

Prefer make -C over a bare cd in a run step: it keeps the working directory of later steps intact and logs which directory each recipe ran in, which simplifies debugging multi-project pipelines.

Key takeaways

  • make -C DIR runs make in DIR without changing the step working directory.
  • It logs Entering/Leaving directory, aiding multi-project debugging.
  • Combine with a target and -j for subproject parallel builds.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →