Search code examples
windowsgnu-makeconfigureautotools

How to produce a configure script for windows with autotools


I am writing an application in C++, and I am making the build script with autotools. The end user will then be able to run ./configure && make && make install in the source directory. My question is : can the same command be used on windows ? If not, how can i achieve a similar process with autotools ? Or is autotools incapable of producing a build script for windows ? If so, which build tool could be used for windows ? Thanks in advance !


Solution

  • can the same command be used on windows ?

    Autoconf produces configure as a portable (POSIX) shell script. Windows does not come standard with a POSIX shell, nor with any of the standard tools on which Autotools configuration scripts and makefiles rely. Windows also does not come standard with a make implementation suitable for use with Autotools-built makefiles, and to the best of my knowledge, Visual Studio does not provide one either.

    You could pretty easily build and run your project inside a WSL container on Windows, but that does not get you a native Windows executable.

    If you want to use an Autotools build system on Windows to produce Windows executables then your best bet is probably to rely on msys2 and mingw-w64. These, together, can provide a standard-ish POSIX environment running natively in Windows, able to build Windows libraries and executables via the usual commands. But note well that this approach means that anyone who wants to build your project on Windows has to install these or comparable components first.

    If not, how can i achieve a similar process with autotools ? Or is autotools incapable of producing a build script for windows ?

    The Autotools produce build systems targeting Unix-like operating systems, including (but not limited to) Linux and MacOS. Such build systems are not appropriate for Windows machines except with the addition of a fairly large suite of third-party components, such as msys2 and mingw-x64 can provide.

    If so, which build tool could be used for windows ?

    CMake is a more typical choice if you're after build compatibility with both Windows and Unix. That would ordinarily be instead of the Autotools, not in addition to them, because who wants to maintain multiple independent build systems for the same project?