# Autotools

In CLion, you can work with projects that require pre-configuration steps to prepare the actual Makefile. The scripts of [GNU Autotools](https://www.gnu.org/software/automake/faq/autotools-faq.html), [Kbuild](https://www.kernel.org/doc/html/latest/kbuild/kbuild.html), and [PERL MakeMaker](https://perldoc.perl.org/ExtUtils::MakeMaker) are detected automatically and executed to get the Makefile and load the project. CLion also supports the [xmkmf](https://www.x.org/releases/X11R7.7/doc/man/man1/xmkmf.1.xhtml) tool, which generates Makefiles from the [Imakefile](https://www.x.org/releases/X11R7.7/doc/man/man1/imake.1.xhtml) template.

> **Tip:**
> General instructions below are given for the case of GNU Autotools. For additional tips on PERL MakeMaker, refer to [this section](#makemaker).

## Autotools project

When you open a project folder, CLion recognizes it as an Autotools project in the following cases:

* If there is a `configure.ac` or a `configure.in` file under the project root, but not both.

* If there is a `Makefile.in`, `Makefile.am`, or both.

The presence of an already generated `Makefile` or a `configure` script does not affect this.

## Pre-configuration (GNU Autoconf)

If [GNU Autoconf](https://www.gnu.org/software/autoconf/) is installed on your system (autoreconf should be in the system `PATH`), CLion will call it first.

![Pre-configuring the project with autoreconf](https://resources.jetbrains.com/help/img/idea/2026.2/cl_makefile_autoreconf.png)

> **Note:**
> Pre-configuration is performed on every project [reload](makefiles-support.html#manual-reload).

By default, CLion uses the following commands to configure an Autotools project:

```CONSOLE
which autoreconf && autoreconf --install --force --verbose; /bin/sh configure
```

You can [change](#preconf-settings) this set of commands as needed (see below).

Procedure: Control preconfigure parameters

If required, you can adjust the pre-configuration commands.

1. Go to `Settings | Build, Execution, Deployment | Makefile`.

2. Make necessary changes in the Commands field:

![Pre-configuration commands](https://resources.jetbrains.com/help/img/idea/2026.2/cl_makefile_autotools_commands.png)

For example, to run an additional pre-configuration script like `bootstrap`, add the following command:

```CONSOLE
./bootstrap <args>
```

Also notice the very first line in the default set of commands, `#!/bin/sh`. It explicitly specifies the POSIX default interpreter `/bin/sh`. You can leave this command as is or change it to use another interpreter, for example `#!/usr/bin/python` for Python.

3. You can also change the build directory either in the Build directory field or via the `-C path` flag in Build options.

Note the following when changing the build directory:

* The previous directory will not be removed.

* If the new build directory doesn't exist, CLion will create it before the pre-configure step if the script is not empty. Otherwise, the directory will not be created.

> **Note:**
> If you are using a pre-configuration script with a remote toolchain such as Docker, WSL, or SSH, you should use either relative or full remote paths to the project files. This is because the pre-configuration script will be run in the remote environment. If you do not want to change the pre-configuration script every time you change a toolchain, use relative paths.
>
>
>
> [With a Docker toolchain](clion-toolchains-in-docker.html#build-run-debug-docker), the project folder is mounted to the `/tmp` folder in the container by default. Thus, the project files can be accessed at `/tmp/your-project-name`.

Procedure: Change the toolchain

* When executing Autotools scripts, CLion fetches the compilers from the toolchain specified in `Settings | Build, Execution, Deployment | Makefile`.

If you open the project for the first time, CLion will use the default toolchain.

Note that you can specify a remote toolchain here as well.

![Selecting the toolchain for a Makefile project](https://resources.jetbrains.com/help/img/idea/2026.2/cl_makefile_autotools_toolchain.png)

## PERL MakeMaker projects

MakeMaker-generated Makefiles don't have separate targets for `clean` and `distclean`. There is only the `clean` target, which cleans up the project tree and also deletes the `Makefile` itself.

So for MakeMaker projects, the `make clean` command should only be run as a part of the [pre-configuration](#preconf-settings) step. CLion uses the following pre-configuration script, which you can always [adjust](#toolchain-settings) if required:

```CONSOLE
#!/bin/sh
#
# ExtUtils::MakeMaker template, feel free to customize.
#
[ -f Makefile ] && "${MAKE:-make}" clean
perl Makefile.PL
```

> **Note:**
> If a MakeMaker project is cleaned after pre-configuration, the `Makefile` will be deleted, and the project will fail to load, so make sure to do the following:
>
>
>
> * When [opening](makefiles-support.html#open-prj) the project, skip the Clean step by clearing the corresponding checkbox: ![Skipping the step of Clean when opening a Makefile project](https://resources.jetbrains.com/help/img/idea/2026.2/cl_makefiles_skip_clean.png)
>
> * For [reloading](makefiles-support.html#manual-reload) the project, use Reload Makefile Project instead of Clean and Reload Makefile Project.

## Remote mode limitations

* In remote mode, the `build` directory is not synchronized to the local machine. Make sure to sync `config.h` manually.

Windows-specific issues on remote:

* Line endings are not converted to UNIX (LF) style when the project is uploaded to remote host ([CPP-26698](https://youtrack.jetbrains.com/issue/CPP-26698)).

* The upload stage may indicate successful completion when no files are actually transferred to the remote host ([CPP-26700](https://youtrack.jetbrains.com/issue/CPP-26700)).

## See also

### Procedures

[Makefile projects](makefiles-support.html)

