Reputation: 3716
I have a Makefile
with multiple subprojects and set its build dependencies.
Now I want to be able to selectively make install
some of those subprojects but include the dependencies in the installation.
How can I do this?
Suppose a Makefile
like this:
lib1:
lib2:
proj1: lib1
proj2: lib2
proj3: lib1 lib2
install_%: $*
make -C $* install
install: $(addprefix install_,$(SUBDIRS) )
And I'd like to be able to do, from command line, things like:
make install SUBDIRS=proj1
or
make install SUBDIRS=proj3
My rules will try to build and install "proj3", but:
Any help is welcome.
Upvotes: 0
Views: 1157
Reputation: 98068
In the makefile for dependent projects and include the makefiles for dependencies and write rules to express the dependency:
proj3/Makefile:
include ../lib1/Makefile
include ../lib2/Makefile
proj3: lib1 lib2
$(CC) ....
install: proj3 install_lib1 install_lib2
cp ...
lib1/Makefile:
lib1: # ....
$(CC) ....
install_lib1: # ....
cp ...
Upvotes: 1