forked from trr266/treat
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (51 loc) · 1.85 KB
/
Makefile
File metadata and controls
86 lines (51 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# If you are new to Makefiles: https://makefiletutorial.com
# Config
PYTHON := python
RSCRIPT := Rscript --encoding=UTF-8
CONFIG := config/global_cfg.yaml
PULL_WRDS_DATA_CFG := config/pull_wrds_data_cfg.yaml
# Refer to `config/global_cfg.yaml` for file locations
# Output Targets
PAPER := $(shell yq -r '.output_paper' $(CONFIG))
PRESENTATION := $(shell yq -r '.output_presentation' $(CONFIG))
TARGETS := $(PAPER) $(PRESENTATION)
# Input Targets
SECRETS := $(shell yq -r '.secrets_file' $(CONFIG))
EXTERNAL_DATA := $(shell yq -r '.fama_french_12' $(CONFIG)) \
$(shell yq -r '.fama_french_48' $(CONFIG))
WRDS_DATA := $(shell yq -r '.cstat_us_parquet_file' $(CONFIG))
GENERATED_DATA := $(shell yq -r '.acc_sample' $(CONFIG))
RESULTS := $(shell yq -r '.results_r' $(CONFIG))
# Phony Targets
.phony: all clean very-clean dist-clean
all: $(TARGETS)
clean:
rm -f $(TARGETS)
rm -f $(RESULTS)
rm -f $(GENERATED_DATA)
very-clean: clean
rm -f $(WRDS_DATA)
dist-clean: very-clean
rm secrets.env
# Recipes for intermediate targets
$(SECRETS):
@echo "To start, you need to copy _$(SECRETS) to $(SECRETS) and edit it"
@false
$(WRDS_DATA): code/python/pull_wrds_data.py $(SECRETS) \
$(PULL_DATA_CFG) $(CONFIG)
$(PYTHON) $<
$(GENERATED_DATA): code/python/prepare_data.py $(WRDS_DATA) $(CONFIG) \
$(EXTERNAL_DATA) $(PREPARE_DATA_CFG)
$(PYTHON) $<
$(RESULTS): $(GENERATED_DATA) code/R/do_analysis.R code/R/utils.R $(CONFIG)
$(RSCRIPT) code/R/do_analysis.R
# Recipes for final targets
$(PAPER): doc/paper_r.qmd doc/references.bib $(RESULTS)
quarto render doc/paper_r.qmd --quiet
mv output/paper_r.pdf $(PAPER)
rm -f doc/paper_r.ttt doc/paper_r.fff
$(PRESENTATION): doc/presentation_r.qmd $(RESULTS) \
doc/beamer_theme_trr266.sty
quarto render doc/presentation_r.qmd --quiet
mv output/presentation_r.pdf $(PRESENTATION)
rm -rf output/presentation_r_files