From 60a3e1ea707f87316d9449a579e00845097b35b5 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 8 Jun 2020 12:26:11 -0400 Subject: [PATCH] Fix Makefile duplicate runs (#923) Make sure that core targets (i.e. part of the `all` target like build-sql and build yaml files) do not run multiple times if they already exist. Makefile for some reason does not like it when a real target depends on a PHONY target, and re-runs it. I added an `if` statement to skip building targets if their result already exists. --- Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index fff3e29e..ff4997e2 100644 --- a/Makefile +++ b/Makefile @@ -192,24 +192,31 @@ help: .PHONY: init-dirs init-dirs: - @mkdir -p build/sql + @mkdir -p build/sql/parallel + @mkdir -p build/openmaptiles.tm2source @mkdir -p data/borders @mkdir -p cache build/openmaptiles.tm2source/data.yml: init-dirs - mkdir -p build/openmaptiles.tm2source +ifeq (,$(wildcard build/openmaptiles.tm2source/data.yml)) $(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools generate-tm2source openmaptiles.yaml --host="postgres" --port=5432 --database="openmaptiles" --user="openmaptiles" --password="openmaptiles" > $@ +endif build/mapping.yaml: init-dirs +ifeq (,$(wildcard build/mapping.yaml)) $(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools generate-imposm3 openmaptiles.yaml > $@ +endif .PHONY: build-sql build-sql: init-dirs +ifeq (,$(wildcard build/sql/run_last.sql)) + @mkdir -p build/sql/parallel $(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools bash -c \ 'generate-sql openmaptiles.yaml --dir ./build/sql \ && generate-sqltomvt openmaptiles.yaml \ --key --gzip --postgis-ver 3.0.1 \ - --function --fname=getmvt >> "./build/sql/run_last.sql"' + --function --fname=getmvt >> ./build/sql/run_last.sql' +endif .PHONY: clean clean: