Is there a way to build and install only a few of the GNU coreutils?

The README in coreutils-8.19.tar.xz lists 100-odd, but the INSTALL doesn't say how to install only a few, and the Makefile is (to me) opaque.

  • 2
    Not so much an answer as a pointer to an idea - buildroot normally sets up only a subset of coreutils, and if you have a smallish subset, you might want to consider busybox with the relevant tools. Commented Oct 10, 2012 at 16:41

2 Answers 2

  cd ./lib
  cd ../src
  make version.h
  make cat
  make ls



UPDATE as of February 26, 2015:

The recipe above doesn't work in at least coreutils-8.23. I would not recommended building separate files.

The following shows the complexity of internal dependencies for cat and ls:

make src/version.h
make lib/configmake.h
make lib/arg-nonnull.h
make lib/warn-on-use.h
make lib/fcntl.h
make lib/sys/stat.h
make lib/selinux/context.h
make lib/selinux/selinux.h
make lib/unitypes.h
make lib/unistr.h
make lib/uniwidth.h
make lib/getopt.h
make src/cat
make src/ls
  • Thanks @Deer Hunter. How might a mortal have discovered this, or is it just common knowledge ?
    – denis
    Commented Oct 12, 2012 at 10:01
  • Trial and error - mostly reading the output from naive attempts to make chroot etc. and figuring out the dependencies. Commented Oct 12, 2012 at 10:03
  • Now it doesn't work. There's no Makefile after ./configure in lib subdirectory.
    – enedil
    Commented Feb 26, 2015 at 16:34
  • Do you know any workaround?
    – enedil
    Commented Feb 26, 2015 at 17:24
  • @enedil - fixed a bit, you can try building cat, can't vouch for other utils. Commented Feb 26, 2015 at 18:14

Try this to build only cat and ls:

wget -O- https://ftp.gnu.org/gnu/coreutils/coreutils-9.1.tar.xz |tar xJf -

cd coreutils-9.1 && mkdir my && cd my && ../configure

echo -e "\nmy: \$(BUILT_SOURCES)\n\t\$(MAKE) \$(AM_MAKEFLAGS) src/cat src/ls" >>Makefile

make my

strip src/cat src/ls
file src/cat src/ls

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .