1
|
include ../lib/common.Makefile
|
2
|
|
3
|
|
4
|
##### Vars/functions
|
5
|
|
6
|
# Make
|
7
|
SHELL := /bin/bash
|
8
|
|
9
|
# Paths
|
10
|
bin := ../bin
|
11
|
inputCoreMaps := Veg+.terms.csv Veg+-VegCore.csv VegCore-VegBIEN.csv \
|
12
|
VegX-VegCore.csv
|
13
|
|
14
|
# Via formats
|
15
|
coreMaps := $(wildcard *-VegBIEN.csv)
|
16
|
filenameVia = $(shell echo '$(1)'|grep --only-matching --extended-regexp\
|
17
|
'^[a-zA-Z+]+')
|
18
|
# can't use --ignore-case because in Mac grep, a bug causes it to break [] exprs
|
19
|
vias := $(strip $(sort $(foreach coreMap,$(coreMaps),$(call\
|
20
|
filenameVia,$(coreMap)))))
|
21
|
|
22
|
# Commands
|
23
|
|
24
|
review_ = $(bin)/review 1 <$(1) >for_review/$(1)
|
25
|
review = $(call review_,$@)
|
26
|
|
27
|
join = env header_num=0 $(bin)/join_union_sort
|
28
|
selfMap_ = $(bin)/cols 0 0
|
29
|
mkSelfMap = $(selfMap_) <$<|$(bin)/sort_map >$@
|
30
|
|
31
|
##### General targets
|
32
|
|
33
|
all: _always $(inputCoreMaps) vegcsv_maps self_maps ;
|
34
|
|
35
|
clean: _always
|
36
|
$(RM) $(all)
|
37
|
|
38
|
all :=
|
39
|
|
40
|
##### Core maps cleanup
|
41
|
|
42
|
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
|
43
|
|
44
|
.Veg+.terms.csv.last_cleanup: .%.last_cleanup: %
|
45
|
$(bin)/in_place $< $(bin)/sort_map
|
46
|
touch $@
|
47
|
|
48
|
.%.last_cleanup: %
|
49
|
$(bin)/in_place $< $(bin)/sort_map
|
50
|
touch $@
|
51
|
$(call review_,$<)
|
52
|
|
53
|
else
|
54
|
$(inputCoreMaps): _always
|
55
|
$(MAKE) $(@:%=.%.last_cleanup)
|
56
|
endif
|
57
|
|
58
|
##### Self maps
|
59
|
|
60
|
selfMaps :=
|
61
|
|
62
|
viaCoreMap = $(via)-VegBIEN.csv
|
63
|
viaSelfMap = $(via).self.csv
|
64
|
viaCoreMaps = $(wildcard $(subst %,*,$(viaCoreMap)))
|
65
|
|
66
|
define selfMapTargets
|
67
|
selfMaps += $(viaCoreMaps:$(viaCoreMap)=$(viaSelfMap))
|
68
|
|
69
|
$(viaSelfMap): $(viaCoreMap)
|
70
|
$$(mkSelfMap)
|
71
|
endef
|
72
|
$(foreach via,$(vias),$(eval $(selfMapTargets)))
|
73
|
|
74
|
ifneq ($(filter self_maps,$(MAKECMDGOALS)),)
|
75
|
self_maps: _always $(selfMaps) ;
|
76
|
else
|
77
|
self_maps: _always
|
78
|
$(MAKE) self_maps
|
79
|
# re-run make so that cache of existing files for $(viaCoreMaps) is reset
|
80
|
endif
|
81
|
|
82
|
all += $(selfMaps)
|
83
|
|
84
|
##### VegCSV
|
85
|
|
86
|
vegcsvMaps :=
|
87
|
|
88
|
Veg+-VegBIEN.csv: Veg+-VegCore.csv VegCore-VegBIEN.csv
|
89
|
env quiet=1 $(join) <$+ >$@
|
90
|
vegcsvMaps += Veg+-VegBIEN.csv
|
91
|
|
92
|
Veg+.vocab.csv: Veg+-VegCore.csv VegCore-VegBIEN.csv
|
93
|
env all=1 $(bin)/union <$+|$(bin)/cols 0|$(bin)/sort 0|uniq >$@
|
94
|
vegcsvMaps += Veg+.vocab.csv
|
95
|
|
96
|
vegcsv_maps: _always $(vegcsvMaps) ;
|
97
|
|
98
|
all += $(vegcsvMaps)
|