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.specimens.csv \
|
12
|
VegCore-VegBIEN.specimens.csv VegX-VegCore.stems.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 filenameVia,$(coreMap)))))
|
20
|
|
21
|
# Commands
|
22
|
|
23
|
review_ = $(bin)/review 1 <$(1) >for_review/$(1)
|
24
|
review = $(call review_,$@)
|
25
|
|
26
|
join = env header_num=0 $(bin)/join_union_sort
|
27
|
selfMap_ = $(bin)/cols 0 0
|
28
|
mkSelfMap = $(selfMap_) <$<|$(bin)/sort_map >$@
|
29
|
|
30
|
##### General targets
|
31
|
|
32
|
all: _always $(inputCoreMaps) vegcsv_maps self_maps ;
|
33
|
|
34
|
clean: _always
|
35
|
$(RM) $(all)
|
36
|
|
37
|
all :=
|
38
|
|
39
|
##### Core maps cleanup
|
40
|
|
41
|
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
|
42
|
|
43
|
.Veg+.terms.csv.last_cleanup: .%.last_cleanup: %
|
44
|
$(bin)/in_place $< $(bin)/sort_map
|
45
|
touch $@
|
46
|
|
47
|
.%.last_cleanup: %
|
48
|
$(bin)/in_place $< $(bin)/sort_map
|
49
|
touch $@
|
50
|
$(call review_,$<)
|
51
|
|
52
|
else
|
53
|
$(inputCoreMaps): _always
|
54
|
$(MAKE) $(@:%=.%.last_cleanup)
|
55
|
endif
|
56
|
|
57
|
##### Self maps
|
58
|
|
59
|
selfMaps :=
|
60
|
|
61
|
viaCoreMap = $(via)-VegBIEN.%.csv
|
62
|
viaSelfMap = $(via).self.%.csv
|
63
|
viaCoreMaps = $(wildcard $(subst %,*,$(viaCoreMap)))
|
64
|
|
65
|
define selfMapTargets
|
66
|
selfMaps += $(viaCoreMaps:$(viaCoreMap)=$(viaSelfMap))
|
67
|
|
68
|
$(viaSelfMap): $(viaCoreMap)
|
69
|
$$(mkSelfMap)
|
70
|
endef
|
71
|
$(foreach via,$(vias),$(eval $(selfMapTargets)))
|
72
|
|
73
|
ifneq ($(filter self_maps,$(MAKECMDGOALS)),)
|
74
|
self_maps: _always $(selfMaps) ;
|
75
|
else
|
76
|
self_maps: _always
|
77
|
$(MAKE) self_maps
|
78
|
# re-run make so that cache of existing files for $(viaCoreMaps) is reset
|
79
|
endif
|
80
|
|
81
|
all += $(selfMaps)
|
82
|
|
83
|
##### VegCSV
|
84
|
|
85
|
vegcsvMaps :=
|
86
|
|
87
|
Veg+.cs-VegBIEN.specimens.csv: Veg+-VegCore.specimens.csv\
|
88
|
VegCore-VegBIEN.specimens.csv
|
89
|
$(join) <$+ >$@
|
90
|
vegcsvMaps += Veg+.cs-VegBIEN.specimens.csv
|
91
|
|
92
|
Veg+-VegBIEN.specimens.csv: Veg+.cs-VegBIEN.specimens.csv
|
93
|
$(bin)/ci_map $< >$@
|
94
|
vegcsvMaps += Veg+-VegBIEN.specimens.csv
|
95
|
|
96
|
vegcsv_maps: _always $(vegcsvMaps) ;
|
97
|
|
98
|
all += $(vegcsvMaps)
|