This is probably one of those "well duh" things people already know about, but I spent a few minutes figuring it out and I thought I'd post about it briefly to hopefully spare someone else the momentary confusion.

renameutils is a fantastic little set of tools that make it disturbingly easy to bulk rename or copy files and directories. It's free, open source and easy to use once you get the hang of it. It uses GNU Autoconf and GNU Automake to handle compilation. This is pretty common, and the typical process for building such a package looks like this:

$ ./configure
$ make
$ sudo make install

I wanted to use this tool set on my Synology DS2419+, but unfortunately the custom Linux distribution it runs doesn't include it or any compilers or build tools, so it became necessary to build it on a different Linux box and copy the binaries over by hand.

This led to another problem – the DS2419+'s custom distro also doesn't include some of the libraries that renameutils needs, so I needed a static build of the tools. Unfortunately, the renameutils package doesn't include a --static option for its configuration script.

Autoconf to the rescue! I'd forgotten about this (it's been awhile since I've messed with this, gimme a break!) but it's possible to add custom arguments and settings to various steps of the build process. I just needed to set an LD_FLAGS environment variable when running configure, like this:

$ LD_FLAGS=-static ./configure
$ make

Note: Some autoconf-based packages use LDFLAGS instead of LD_FLAGS for this; if you end up with a dynamic build despite running the above, try setting LDFLAGS. It's also safe to just set them both:

$ LD_FLAGS=-static LDFLAGS=-static ./configure

I didn't need to run sudo make install here since I'm just copying the final binaries over to the target system by hand.

The result? Static binaries that happily run on my DS2419+! They complain about setting their locale, which is a bit odd since the locale is set just fine in the environment, but the tools still work anyway. I might need to recompile the tools again with additional settings to handle locales, but for now, this does the job!

On a side note: the scary thing about this is I just used the Debian build that's available for Microsoft's WSL2 environment to build these binaries, and it still worked. Natively-compiled Linux binaries built on a Windows box, and they worked on a target host running Linux on bare metal. Scary, crazy times we live in!