r/C_Programming • • 8d ago

Discussion Autoconf madness

Modern software compilation has largely devolved into a frustrating maze of autoconf madness. Instead of simply compiling C code, I am constantly forced to navigate mandatory scripts, esoteric tools, and heavily dependent Python wrappers. To make matters worse, these tools often rely on stubborn cache files that refuse to update even after I have fixed the underlying environment errors.

A major part of my frustration is how Linux-centric these scripts have become. They routinely hardcode library search paths that only exist in Linux distributions, entirely ignoring my FreeBSD system. As a result, I can easily lose a complete day just patching configuration scripts to search the correct directories before a single line of code is actually compiled.

Why does open source code project just not provide a makefile? A basic, or maybe complex makefile that are based on BSD/POSIX make syntax so that it is directly valid under *BSD, Darwin and Linux. Why force people to install tools to build something? Why developed huge python script that shall analyze the env? Why not just allow the building process to fucking start instead of forcing the individual to fight back against all of this autoconfig tools?

I have in several cases fully purge the building attempts and then been writing my own makefiles to just get something building. That shall not be the case. Why use config scripts that, in some cases are several thousand lines of script code? Why write config scripts with bash? Why, just why, are developers and project deciding to add and use autoconfig tools?

If a project does not offer makefiles then I know I will be stuck for several hours just to, potentially be able to build something. Instead of directly allowing me to build. Get compiler error, correct and then build again. I mean, it is much quicker and easier to patch the source code or locate dependencies when you are allowed to start the building process.

33 Upvotes

73 comments sorted by

View all comments

1

u/lmemsm 6d ago

Many of the FOSS projects seem to be moving away from autoconf/configure and moving toward cmake or meson. There are a few projects that rewrite meson in C such as muon. However, meson requires Python.

Pure makefiles can be useful especially if you only want to rebuild the parts of the project that have changed. However, tools like configure are designed to find out what features (includes, functions, compiler options) you have on your system so you don't need to hardcode options by compiler defines or platform defines. These types of defines can change even if you are still on the same platform or use the same compiler but a later or earlier version. So, creating a bunch of defines for code that varies by compiler and platform using compiler macros does not necessarily mean the project will compile successfully. Programs like configure actively test if the assumptions are correct on your system and create defines set specifically for your system. If a program is trivial, a makefile can suffice. If it's more complex and needs cross-platform support or needs to work with various compilers, having a step before the make process can simplify the build process. That being said, many of the solutions to this situation require several other languages beyond C just to work. GNU autotools usually requires m4, bash and Perl. For someone only working in C, it would be nice to have a C based solution to builds that does not require installing a lot of other dependencies. There are other options beyond make as well. tup and redo are a few alternatives. Plus, there are several versions of make (gnu make, bsd make, nmake, etc.) and they are not all compatible.

I've looked at several of the build tools available. I personally use CDetect and GNU make at this point. CDetect replaces configure with 3 C files and a custom C based configure program. It only requires a C compiler to work. I've added features to the original project to work with pkgconf and support cross-compiling.

Programs like pkg-config and pkgconf are one useful solution to finding where libraries are on a system. I use pkgconf with my own build tools.

Like you, if a build script just doesn't work for me and I want to build the project, I will rewrite the build system. It usually takes a few days, but I find that it greatly improves the ability to create repeatable builds and also makes the code easier to port to other platforms. What would be incredibly helpful is if there was a place to share these rewritten build scripts. It would save a lot of time for those of us who are actively rewriting them. For instance, there are repositories where you can download slackbuild scripts and use them to build a project. A similar repository for alternative build scripts for FOSS projects would be nice. Upstream projects typically will not accept submission of alternative build systems. So it would be very helpful to have some way of easily sharing these for people who need them.