Makefile for pull and construction projects

I am creating a project that requires an ecosystem of projects (linux, qemu, uboot, etc.), most of which are in git repositories. I used them for everyone with a script, but I found myself implementing things that are best done with make. Therefore, I decided to transfer my script to a make file.

The problem is that I want the projects to be cloned, if not present, and pulled out, if any. Is there a way to do this without repeating too much?

+4
source share
2 answers

It seems to me something like this. This does not work, because, regardless of something inside the project directories, I am not sure that you can conditionally start the clone.

force: ; proj%: force @echo [ -d $@ ] || git clone srv: $@ @cd $@ && git pull 

If you want to list something like proj1/.git/config as a prereq starting point, you could split the cloning as a pre-order only prereq into those who have a clone for the project directory. Although you still need the power in the config prereq to make gravity happen.

Something like this is possible:

 proj%: git clone srv: $@ proj%/.git/config: force | proj% git pull 
+3
source

I was working on a Makefile that basically has PHONY goals and came up with this template:

 .PHONY all all: foo-docker foo: git clone https://example.org/foo-project.git $@ .PHONY: foo-update foo-update: foo @cd foo && git pull .PHONY: foo-docker foo-docker: foo-update @cd foo && docker build 
0
source

Source: https://habr.com/ru/post/1495859/


All Articles