Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

install -d is just used to create directories. You told it to create two directories, test and test2. test already existed, so all it needed to do was make test2. I don't think install supports copying entire directory trees; it's normally used on files. You probably need to use cp

share|improve this answer
add comment
up vote 1 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.