Skip to content

Repository files navigation

Reforge

Reforge translates projects built with Autoconf and Automake into modern Meson, CMake, or Bazel build definitions.

Point Reforge at an existing source tree and choose a backend. Reforge reads configure.ac, recursive Makefile.am files, included Automake fragments, and supported project-specific macros, then generates a normalized build graph. It reports behavior it cannot translate instead of silently dropping it.

Important

Reforge is a migration assistant, not a complete m4 or shell interpreter. Review generated files and validate them on every platform supported by your project before replacing the original build system.

Install

Install the latest released command with Go:

go install github.com/moriyoshi/reforge/cmd/reforge@latest

Or build the current source checkout:

go build -o reforge ./cmd/reforge

Reforge itself requires Go 1.26 or newer. Building translated projects also requires the selected backend and the project's normal compiler, libraries, and source-generation tools. For example, a project using Bison or re2c still needs those tools when its generated-source rules run.

Quick start

Generate a Meson build in an Autotools project:

cd /path/to/project
reforge --backend meson --output meson.build
meson setup build
meson compile -C build
meson test -C build

Generate and build with CMake:

cd /path/to/project
reforge --backend cmake --output CMakeLists.txt
cmake -S . -B build
cmake --build build
ctest --test-dir build --output-on-failure

Generate and build with Bazel:

cd /path/to/project
reforge --backend bazel --output BUILD.bazel
bazel build //...

When Bazel output is written to a file, Reforge also writes a sibling MODULE.bazel file. Check existing build files before running these commands: --output replaces its destination, and Bazel generation replaces the sibling module file.

The project path may be supplied without changing directories:

reforge --backend meson --output /path/to/project/meson.build /path/to/project

Without --output, generated content is written to standard output. Without a backend, Reforge prints its normalized project model as JSON.

Choose a project configuration

Autoconf projects often declare optional features through --enable-* and --with-* choices. Use --resolve-options to apply the defaults discovered by Reforge and materialize one concrete build graph:

reforge --backend cmake --resolve-options --output CMakeLists.txt .

Override choices with repeatable --enable and --disable flags. Each flag also accepts a comma-separated list:

reforge --backend meson \
  --resolve-options \
  --disable all \
  --enable cli,embed \
  --output meson.build \
  /path/to/php-src

Names are the feature names reported in the normalized model. If options are not resolved, targets guarded by unresolved conditions are excluded and the generated file contains a diagnostic directing you to --resolve-options.

Inspect a translation

Print the normalized build graph:

reforge --json /path/to/project

Generate a compatibility audit:

reforge --audit /path/to/project

The audit summarizes target and source coverage, conditional targets, and unsupported macros. Use it before generating build files for a new project to identify areas that need manual work.

Both reports can be written to a file:

reforge --audit --output reforge-audit.json /path/to/project

Command reference

Usage: reforge [<project>] [flags]

Arguments:
  [<project>]                 Autotools project directory or file.

Flags:
  -h, --help                  Show context-sensitive help.
      --backend=BACKEND       Output backend: meson, cmake, or bazel.
      --output=FILE           Output file, or - for stdout.
      --json                  Write the normalized model as JSON.
      --audit                 Write a compatibility audit as JSON.
      --resolve-options       Materialize targets using option defaults and
                              overrides.
      --enable=OPTION,...     Enable an option; repeat or use comma-separated
                              names.
      --disable=OPTION,...    Disable an option; repeat or use comma-separated
                              names.

Run reforge --help to view the reference supplied by your installed version.

Supported project features

Reforge currently understands the parts of Autoconf and Automake needed by its fixture suite, including:

  • recursive SUBDIRS projects and non-recursive included Automake fragments;
  • installed and non-installed programs, static/shared libraries, tests, headers, and pkg-config modules;
  • target sources, dependencies, compile definitions, include paths, compiler flags, linker flags, and libraries;
  • common Automake assignments, continuations, variable references, nodist_*_SOURCES, and generated-source recipes;
  • AC_INIT, configuration headers and definitions, header/function/library checks, substitutions, and enable/with option discovery;
  • CMake, Meson, and Bazel generated-source edges, including staged Bison and re2c pipelines; and
  • PHP extension/SAPI declarations, option selection, bundled source profiles, make fragments, installed headers, and generator commands.

The fixture suite covers GNU Hello, GNU Time, GNU Libtool, GNU GSL, GNU Bison, GNU Coreutils, and PHP. A minimal PHP CLI configuration builds and runs using generated CMake and Meson definitions. Bazel supports the translated PHP graph and staged generators, but a complete PHP Bazel build is not yet guaranteed.

Known limitations

Reforge does not fully evaluate arbitrary m4 programs or shell code. Projects may still need manual changes when they rely on:

  • dynamic configure-time shell behavior;
  • complex gnulib or gettext bootstrap graphs;
  • platform-specific or cross-compilation checks;
  • uncommon Automake installation classes; or
  • custom macros and generated rules outside the recognized patterns.

Unsupported constructs are retained as source-located diagnostics wherever possible. A generated build file is only considered successful after the resulting project configures, builds, tests, installs, and behaves like the original build on the required platforms.

Project documentation

Development checks

Run the Go test and static-analysis suite:

go test ./...
go vet ./...

Run the network-independent container gate:

docker build -f e2e/Dockerfile -t reforge-e2e:dev .
docker run --rm -e E2E_MODE=quick reforge-e2e:dev

See the E2E guide for pinned upstream fixtures and the full test matrix.

License

Reforge is available under the MIT License. Third-party attribution is recorded in THIRD_PARTY_NOTICES.md.

Reforge does not impose its own license on generated build definitions. Generated output may remain subject to licenses applicable to the source project and any material incorporated from it.

About

Reforge translates projects built with Autoconf and Automake into modern Meson, CMake, or Bazel build definitions.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages