c++ - Makefile to move programs to specific directory -
c++ - Makefile to move programs to specific directory -
i have makefile didn't write, , i'm not @ bash scripting , makefiles in general, forgive me lack of knowledge beforehand;
as title states want move executables when compiled ../bin/ folder. effort @ (shamelessy copied post here on so) given below (i.e. tried making phony install should move files, alas doesnt."
cxx = g++ cc = g++ # define preprocessor, compiler, , linker flags. uncomment # lines # if utilize clang++ , wish utilize libc++ instead of libstd++. cppflags = -std=c++11 -i.. cxxflags = -g -o2 -wall -w -pedantic-errors cxxflags += -wmissing-braces -wparentheses -wold-style-cast cxxflags += -std=c++11 ldflags = -g -l.. mv = mv prog_path = ../bin/ #cppflags += -stdlib=libc++ #cxxflags += -stdlib=libc++ #ldflags += -stdlib=libc++ # libraries #ldlibs = -lclientserver # targets progs = myserver myclient libclientserver.a all: $(progs) # targets rely on implicit rules compiling , linking # dependency on libclientserver.a not defined. myserver: myserver.o messagehandler.o server.o connection.o database_memory.o database_file.o myclient: myclient.o connection.o server.o messagehandler.o libclientserver.a: connection.o server.o ar rv libclientserver.a connection.o server.o ranlib libclientserver.a # phony targets .phony: install clean all: $(progs) install install: $(mv) $(progs) $(prog_path) # standard clean clean: rm -f *.o $(progs) # generate dependencies in *.d files %.d: %.cc @set -e; rm -f $@; \ $(cpp) -mm $(cppflags) $< > $@.$$$$; \ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ rm -f $@.$$$$ # include *.d files src = $(wildcard *.cc) include $(src:.cc=.d)
so how best this? compiler says
make: *** no rule create target `mv', needed `install'. stop.
a makefile rule consists of 2 parts, declaration of rule's dependencies , commands invoke.
the dependencies listed on first line of rule after colon , commands execute listed on subsequent lines, indented tabs.
your install rule needs depend on programs moving , perchance destination directory (you may want rule creates destination), not mv
utility don't need build that.
install: $(progs) mv $(progs) $(prog_path)
note although i've used 4 spaces, indentation needs tab. don't (yet?) have rule create prog_path
, i've left out of dependency list.
also note rule, create have rebuild programs if invoke create twice have moved. way want consider using cp
or install
instead of mv
.
c++ bash makefile mv
Comments
Post a Comment