I want to use this code as a basis for my project. I am forking the
mv command, since it's relatively simple (~500 lines of dedicated
code), and its functions closely match the purpose of my program.
That is an inaccurate assessment.
While "mv.c" itself is about ~500 lines,
it uses "copy.c" which is ~3000 lines,
which in turn uses many gnulib modules.
Also used are "remove.c", "cp-hash.c", "selinux.c", etc.
Compiling the file 'mv.c' alone would not yield an executable with mv's
functionality.
I tried doing make help and ./configure --help, but I found no
option to simply compile one binary.
There is no such option at the moment.
You could run "./configure" followed by "make src/mv"
which will then compile only the required files to build the 'mv'
executable, but this will still result in many compiled files.
I did a trace on the Makefile, and isolated the command that produces
the mv binary:
Of course, it doesn't work without all the object files already
generated. I can't tell which lines are producing them, and after
skimming the Makefile and configure.ac.
coreutils uses gnu autoconf and automake to generate the Makefiles.
The file "src/local.mk" contains the following line:
src_mv_SOURCES = src/mv.c src/remove.c \
$(copy_sources) $(selinux_sources)
Which defines the needed files to build 'mv'.
To learn more about using or tweaking autotools projects
see here:
https://en.wikipedia.org/wiki/GNU_Build_Systemhttps://www.lrde.epita.fr/~adl/autotools.htmlhttps://autotools.io/index.html
In projects that use Autotools there's little point in
modifying a "Makefile" directly.
I've concluded that I have a
newfound appreciation for docker build environments. (I'm mostly a
Python programmer, and don't have too much experience with the
in-depth GNU toolchains.)
(the following is just my personal opinion:)
In most cases you'll find that a "docker build environment" is
just a lazy substitute for properly packaging a software project
using existing frameworks (be it autotools, cmake, ninja, waf,
Makefiles, or in python's case: a properly setuptools configuration).
In many of these cases, the developer decides that instead of spending
the time to use a build infrastructure and document the pre-requisites,
they just "freeze" their build environment and expect others to just
deploy their copy.
That is a poor way to build scalable reliable systems.
Unfortunately, I can't figure out how to compile it without, y'know,
compiling everything else. I don't want to have to drag 50M of source
code around just for a variation on a coreutils binary. How can I
compile just `mv.c?
There is no way to do so, because mv's functionality is spread of over
many files, and they are all needed.
(technically, you can compile 'mv.c' alone to 'mv.o', but that won't get
you the 'mv' executable, which I assume is what you need.)
GNU coreutils's mv has a lot of features, and perhaps you don't need all
of them.
If you want to build something based on a minimal 'mv' functionality,