Alex Rivera | Logout

What's the best way to move a directory into place in a Makefile install?

Asked 2009-01-06T16:35:51.193
17

I'm currently using the usual technique in my Makefile to install individual files:

install:
    install -D executable ${BIN_DIR}

But I just ran across a situation where I need to move a whole directory and all files underneath it into place.

Is cp -r the best way or is there a more linux-y/unix-y way to do this?

Edit
Report

1 Answer

4

My version of install(1) (Debian) has:

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

   -t, --target-directory=DIRECTORY
          copy all SOURCE arguments into DIRECTORY

So if you wanted to use install(1) consistently throughout your Makefile you could do:

install -d destdir
install srcdir/* -t destdir

-t isn't recursive however - if srcdir contains directories, then they won't get copied.

answered 2009-01-06T17:01:35.853

Your Answer