Makefile for pulling and building projects
conditional-statements, git, makefile
Solution
Something like this would work I think. It doesn't have make do the work because without depending on something inside the project directories I'm not sure you could only conditionally run the clone.
force: ;
proj%: force
@echo [ -d $@ ] || git clone srv:$@
@cd $@ && git pull
If you wanted to list something like `proj1/.git/config` as your entry-point prereq you could split the clone up as an order-only prereq on those with a clone for the project directory. Though you would still need the force on the config prereq to force the pull to happen.
Something like this perhaps:
proj%:
git clone srv:$@
proj%/.git/config: force | proj%
git pull
Problem
I am building a project that requires an ecosystem of projects (linux, qemu, uboot etc) most of which are in git repositories. I used to manage them all with a script but I find myself implementing stuff that is better done with make. So I decided to migrate my script to a makefile. The problem is I want to projects to be cloned if not present and pulled if present. Is there a way to do that without repeaing myself too much?