How to move files with a make file?

I am using a make file for my c++ project and i would like to move my bin files to a directory bin that i have created in the same dir as my cc files.
How can i do this?
Some of the  make file is posted and looks like this:
# Targets
PROGS      = mydiskserver mymemserver myclient

# Phony targets
.PHONY: all clean cleaner

all: $(PROGS)

mydiskserver: mydiskserver.o messagehandler.o commandfactory.o createnewsgroup.o listnewsgroup.o deletenewsgroup.o listarticles.o createarticle.o getarticle.o deletearticle.o diskdatabase.o filehandler.o identifier.o

mymemserver: mymemserver.o messagehandler.o commandfactory.o createnewsgroup.o listnewsgroup.o deletenewsgroup.o listarticles.o createarticle.o getarticle.o deletearticle.o memorydatabase.o filehandler.o identifier.o

myclient: myclient.o uiprinter.o uicommandfactory.o messagehandler.o uilistnewsgroup.o uicreatenewsgroup.o uideletenewsgroup.o uilistarticles.o uicreatearticle.o uireadarticle.o uideletearticle.o uiclearwindow.o

    $(MV) myclient mydisserver mymemserver ../bin/
# Standard clean and cleaner
      $(RM) *.o    

cleaner: clean
      $(RM) $(PROGS)

it is the movebin command that i cant get to work the bin files have the same names as the link command.
The error i get is
 Makefile:50: *** missing separator.  Stop.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mikrodidaktAuthor Commented:
I dont get the error message any more  by using tab instead og space at the movebin command but i dont get the bin files to be moved to the bin dir?
I changed the make file to this

# Targets
PROGS     = mydiskserver mymemserver myclient movebin
    $(MV) myclient mydisserver mymemserver ../bin/

what can i do?

Duncan RoeSoftware DeveloperCommented:
movebin should be declared PHONY, as you've done for all & clean. It's not a program, and you should't have it in PROGS
But that's not your real problem. movebin needs dependencies or make won't make it.
However if all you want to do is have your executables in the bin subdirectory, you can do that directly by something like:
PROGS     = bin/mydiskserver bin/mymemserver bin/myclient
  bin/bin/mydiskserver: $(SERVEROBJS)
^I$(CC) -o $@ $^

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Duncan RoeSoftware DeveloperCommented:
See "info make" "Automatic Variables" for an explanation
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

    $(MV) myclient mydisserver mymemserver ../bin/

# or

movebin: myclient mydisserver mymemserver
    $(MV) myclient mydisserver mymemserver ../bin/

# keep the tab in mind :)
Duncan RoeSoftware DeveloperCommented:
A few typos in my last post - and I didn't notice you wanted ../bin. Sorry about that.

Really Really simple solution: get rid of movebin and do the move as a part of all

PROGS     = mydiskserver mymemserver myclient

 all: $(PROGS)
    mv $^ ../bin

You can use a macro like MV for your wanted mv command (mv -i, mv -f &c) as ahoffman suggests.
make will expand $^ to the contents of $(PROGS) (in general, $^ expands to the current rule's dependencies).
As always, put a tab at the start of the 2nd line above (I showed ^I last time to indicate that).

BTW my bad last time: movebin *could* be in PROGS ( and also .PHONY because no movebin file is created). But then movebin must have all targets in PROGS except itself as dependencies - not real neat.

ahoffman - I hadn't seen that double-colon to avoid the need for dependencies before - cool
> hadn't seen that double-colon ..
not all make do support it, but most modern make (IIRC not part of the original AT&T), you then have to use:
.PHONY: movebin
I'd vote for a split
Duncan RoeSoftware DeveloperCommented:
Fine with me
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux OS Dev

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.