GNU “install” -d flag — how’s it work

coreutils

I'm trying to write a makefile rule to copy a directory, maintaining its structure, and since all the other rules in our makefiles use install, I wanted to be consistent.

In the manpage, it says:

SYNOPSIS

   install [OPTION]... [-T] SOURCE DEST
   install [OPTION]... SOURCE... DIRECTORY
   install [OPTION]... -t DIRECTORY SOURCE...
   install [OPTION]... -d DIRECTORY...

   -d, --directory
          treat all arguments as directory names; create all components of
          the specified directories

OK, that sounds like what I need… but the flags don't make sense. How do you specify the destination directory to install to?

I tried doing a basic test by making an arbitrary directory structure on my local hard disk:

~>tree test
test
├── a
│   └── b
│       └── c
│           └── e.txt
└── d

4 directories, 1 file

And then running install -d and looking at what was created:

~>install -d test test2
~>tree test2
test2

0 directories, 0 files

Nothing happened!

Can anyone point me in the right direction? Googling "gnu install -d flag" isn't bringing me much.

Best Answer

It looks like the install -D command is actually what I want.

Manpage:

-D create all leading components of DEST except the last, then copy SOURCE to DEST

Works great, except you have to specify every file individually.

Related Question