r/C_Programming • u/momaloltote_ • Sep 26 '26
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.
54
u/WittyStick Sep 26 '26 edited Sep 26 '26
It's precisely because there are so many built targets and different configuration options between them that autotools exist. If everyone wrote a hacky Makefile to handle every platform and option, there would be a bigger explosion of complexity, and you can guarantee that far fewer software would ever be compiled for BSD because not many use it.
Autotools provides a normalized and consistent approach to that complexity by extracting out the configuration options and auto-generating a Makefile which can work over multiple targets. For most software this requires two commands to build:
./configureto create theMakefile, thenmaketo actually build it with all the platform specific options in place. The configure script itself is usually generated withautoconfusing a simpler input (configure.ac) - but most projects provide the./configurescript already generated.The "path hardcoding" problem was largely solved by
pkg-config, but it is not universally used. Each project defines its libraries, include paths, and compiler flags in a<pkg>.pcfile, and then any dependencies use eg,$(pkg-config --libs <pkg>)to locate the libraries rather than specifying them explicitly inconfigure.ac.9
u/RogerLeigh Sep 26 '26 edited Sep 26 '26
The specific problem here is that by default Autoconf/Automake do not give you portability. They give you the potential for portability. But only if you take the effort to make sure it's portable, and that's only achievable by testing on every platform you need to target. Anything outside that is an unknown. Based upon past experience, if you haven't tested it it's more than likely to be broken. Autoconf code was historically portable; but code written by a package maintainer in configure.ac/custom modules/Makefile.in/Makefile.am is only portable if they made the effort to make it portable.
This was true in 1999 when I was developing on Linux and finding my Autoconf/Automake projects broken on Solaris, and it's equally true today.
The main fault is that Autoconf doesn't give you a project model. Automake has a very simplified one, but it's not really that much.
Other build systems like CMake, Meson and Bazel do. In the case of CMake it's what allows it to use multiple backend generators to turn that project model into Makefiles, Ninja files, or IDE-specific project files. Though nowadays most IDEs can work with the exported project model directly.
These tools have abstracted various things. This includes how to compile and link. You don't have to directly use
-Loptions to link or-Ioptions to include. You specify search paths, but you're linking against targets not by specifying-loptions directly. Platform-specific detail is abstracted. As a result, most projects would work on FreeBSD just as well as Linux, because the potential for a developer to accidentally hardcode platform-specific detail has been greatly reduced. Not to say it's impossible, you still have full control to do so if you so decide, but the scope for doing it if you follow the standard working practices is greatly reduced. And if you use the Makefile generator, you aren't writing handwritten rules, they are all generated directly from the project model and will work with GNU make or BSD make. Same for all of the other generators.Based on past experience, projects I've maintained using CMake have worked without any extra effort across the board. Solaris, FreeBSD, MinGW, Cygwin, MSVC, cross-compiled. All worked without trouble. Today, it is far superior to Autoconf in its effective portability.
14
u/catbrane Sep 26 '26
I like freebsd and wouldn't deliberately break it, but it's an extreme minority platform and so you will inevitably face many more issues than a more mainstream system.
build systems are necessary if you want portability. You like makefiles because of ports, but they work for you because they have an enforced common structure. Trying to build something with a large crufty hacky ad hoc makefile is not a good experience. If you have something that enforces a structure on makefiles so that they have a sane and common interface ... you've just invented a build system.
15
u/Massive-Policy3417 Sep 26 '26
Autoconf is a delight compared to the maze of build files cmake introduces, definitely skill issue
8
u/chakie2 Sep 26 '26
The auto tools are not exactly new and come from an era of loads of wildly different versions of Unix. They made some sense then. Now, not so much.
4
u/pfp-disciple Sep 26 '26
Short answer: time and effort. These are programmers that are writing software for free, often in their spare time. Supporting greatly disparate systems in a Makefile requires knowledge of all the systems and those volunteers likely don't have the time to learn those system.
3
u/recursion_is_love Sep 26 '26
Why? Because the maker don't have any problem using it. If they have, I am pretty sure they will change the tool-chain.
The problem is us try to do what they do and they might not care about us.
3
u/Gold-Part4688 Sep 27 '26
lol this thread is the xkcd standards meme
12
u/takaci Sep 26 '26
autoconf? That’s not very modern. These days, just use CMake. It’s not that difficult
2
u/HealthyCapacitor Sep 26 '26
Autoconf is close to something useful but is over-complicated yes. What I end up doing is to just put a custom Makefile that compiles the whole source (all .c files) with the needed HAVE_ defines that autoconf ends up generating. There usually aren't more than 1-2 .in files that I can quickly manually create. It's easy if you don't try to force autoconf to work and instead focus on the source only. Otherwise autoconf makes sense for OS integrators which have to rely on a unified build process for thousands of packages.
2
u/LegitimatePants Sep 26 '26
Yo dawg I heard you like makefiles, so here's a makefile for your makefile so you can make while you make
2
u/LB-- Sep 26 '26
I'm a little confused how a makefile is better. Different compiler toolchains can have drastically different argument syntax. The whole point of build system abstraction tools is to figure all that out for you and let you just define the actual commonalities of building the code. Last I checked, make was a pretty poor choice for that. Has it gotten new powers in recent years? (Note, I'm not very fond of autoconf either, but at least it's a step up from makefiles in my eyes.)
1
u/thatdevilyouknow Sep 26 '26
I’ve done a lot of work porting older Linux code to FreeBSD (some of it even written with THINK C). Autotools exists for a few different reasons some of which are placing things in pkg-config so other tools can find them but also the verbosity allows to port code to architectures which may not even exist. So libtool and LD and friends can be switched out. If you were creating a new OS or something you would want those features. The other conventions are things like lex and yacc which, if you don’t encounter them, may not seem to matter. Patches for FreeBSD are versioned in the port system and if you get the hang of it along with make.conf it can be pretty versatile. So certain conventions like simply exporting a different LDCONFIG to test against another version of a library still work. In the past UNIX/LINUX binaries were sometimes just sh files some of which would do some linking right there so having the makefiles available could tell you what you were looking for. 90% of the time on BSD for porting outside stuff you’ll want to run gmake anyhow. If you talk to a lot of OSS maintainers their main issue is not having access to a BSD machine so it’s not an intentional thing at all.
1
u/FedUp233 Sep 26 '26
Just out of curiosity op, when you made the changes to get things to build on BSD, were you careful to not break the Linux builds? And did you submit those changes back to the original project/authors so they could incorporate the changes in their build system for other people in your position? Did you test the resultant build on Linux as well to be sure you didn’t break that?
The developers are supplying their time for free or pretty cheap on these projects and Linux is the biggest target audience. If you, who want it, aren’t willing to spend the time to help support the programs on your platform of choice, and help other users of that platform, why should the original developers do end their time? Be thankful they were willing to donate their time to develop and diatribe the application you want at all!
Maybe volunteer on some of these projects to maintain support for BSD platforms.
1
u/GodOfSunHimself Sep 27 '26
That's why so many people including me switched to Rust or other languages. I just couldn't stand this pain any longer.
1
u/lmarcantonio Sep 28 '26
A lot of people migrated to cmake or meson, for various reasons.
Essentially autoconf is from an era when you have lots of different systems and some non-conformant C compilers too. It still works if you like it (usually with automake/libtool) but there are newer tools available.
Not that they are flawless, they still have issues detecting uncommon things.
1
u/lmemsm Sep 28 '26
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.
1
u/stef_eda Oct 02 '26
Autotools are good if things go straight from start to finish. If anything fails anywhere in the flow you are better off writing a Makefile manually.
-5
u/Dev_Lachie Sep 26 '26
Something something Rust 🦀
0
u/Linguistic-mystic Sep 28 '26
Cause it’s dead. Nobody uses it. It was killed by its inferior license. Just join the Linux community, we’ve got distros for all use cases.
-1
u/Dependent_Bit7825 Sep 26 '26
Fixing build issues is something the AI tools are legitimately good at, and because the build scripts always look like a dog's breakfast anyway, nobody will notice a little AI slop.
Don't waste time on this again.
0
u/Wertbon1789 Sep 28 '26
You can really only demand that much from random maintainers, maybe just send them a patch with options for the changes you want, and make suggestions. If it's bad, it doesn't have to be bad forever, but someone has to at least try the change. If I wanted a package to be compiled on Linux, FreeBSD, and maybe MacOS, I would probably pick meson, and if I used autotools before, I would probably want to port that to meson. That's largely where the Linux userspace has settled, and it's designed to give you good options for cross-platform compat. CMake is probably also an option, though I haven't used it that much personally. You can use make, you'll just need to put some effort in, especially when it comes to templates and dependencies.