Newer
Older
web-dumps / halcnrs-dumps / Makefile
@Nicolas Thouvenin Nicolas Thouvenin on 3 May 1 KB refactor: like conditor dump
NPROCS = $(shell grep -c 'processor' /proc/cpuinfo)
MAKEFLAGS += --keep-going -j$(NPROCS) --max-load=$(NPROCS)
# This ensures the next time you run Make, it’ll properly re-run the failed
# rule, and guards against broken files.
# See https://tech.davis-hansson.com/p/make/#change-some-make-defaults
.DELETE_ON_ERROR:

# To prevent deleting intermediate files (for controls)
.PRECIOUS: 02-download/%.jsonl 03-export/%.csv

SOURCE_FILES := $(wildcard 01-query/*.txt)
TARGET_FILES := $(patsubst 01-query/%.txt, 05-report/%.log, $(SOURCE_FILES))

watch: ## Automatically build files when they change
	while true; do \
		inotifywait -qr -e modify -e create -e delete -e move --exclude '/\.' 01-query; \
		$(MAKE) all; \
	done

# Rules
all: $(TARGET_FILES) ## Build all files
	echo $(TARGET_FILES)

# cible : dépendance
05-report/%.log: 03-export/%.csv
	mkdir -p $(@D)
	wc -l $< > $@

03-export/%.csv: 02-download/%.jsonl
	mkdir -p $(@D)
	time npx ezs 03-export.ini < $< > $@.crdownload
	mv $@.crdownload $@

02-download/%.jsonl: 01-query/%.txt
	mkdir -p $(@D)
	time npx ezs 02-download.ini < $< > $@.crdownload
	mv $@.crdownload $@