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 := DwC1-DwC2.specimens.csv DwC2-VegBIEN.specimens.csv\
|
12
|
VegX-VegBIEN.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=1 $(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) dwc_maps 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
|
.%.last_cleanup: %
|
43
|
$(bin)/in_place $< $(bin)/simplify_xpath
|
44
|
$(bin)/in_place $< $(bin)/sort_map
|
45
|
touch $@
|
46
|
$(call review_,$<)
|
47
|
else
|
48
|
$(inputCoreMaps): _always
|
49
|
$(MAKE) $(@:%=.%.last_cleanup)
|
50
|
endif
|
51
|
|
52
|
##### Self maps
|
53
|
|
54
|
selfMaps :=
|
55
|
|
56
|
viaCoreMap = $(via)-VegBIEN.%.csv
|
57
|
viaSelfMap = $(via).self.%.csv
|
58
|
viaCoreMaps = $(wildcard $(subst %,*,$(viaCoreMap)))
|
59
|
|
60
|
define selfMapTargets
|
61
|
selfMaps += $(viaCoreMaps:$(viaCoreMap)=$(viaSelfMap))
|
62
|
|
63
|
$(viaSelfMap): $(viaCoreMap)
|
64
|
$$(mkSelfMap)
|
65
|
endef
|
66
|
$(foreach via,$(vias),$(eval $(selfMapTargets)))
|
67
|
|
68
|
ifneq ($(filter self_maps,$(MAKECMDGOALS)),)
|
69
|
self_maps: _always $(selfMaps) ;
|
70
|
else
|
71
|
self_maps: _always
|
72
|
$(MAKE) self_maps
|
73
|
# re-run make so that cache of existing files for $(viaCoreMaps) is reset
|
74
|
endif
|
75
|
|
76
|
all += $(selfMaps)
|
77
|
|
78
|
##### DwC
|
79
|
|
80
|
dwcMaps :=
|
81
|
|
82
|
DwC.cs-VegBIEN.specimens.csv: DwC1-DwC2.specimens.csv DwC2-VegBIEN.specimens.csv
|
83
|
$(join) <$+ >$@
|
84
|
dwcMaps += DwC.cs-VegBIEN.specimens.csv
|
85
|
|
86
|
DwC-VegBIEN.specimens.csv: DwC.cs-VegBIEN.specimens.csv
|
87
|
$(bin)/ci_map $< >$@
|
88
|
dwcMaps += DwC-VegBIEN.specimens.csv
|
89
|
|
90
|
for_review/VegBIEN-DwC2.specimens.csv: for_review/DwC2-VegBIEN.specimens.csv
|
91
|
$(bin)/invert <$< >$@
|
92
|
dwcMaps += for_review/VegBIEN-DwC2.specimens.csv
|
93
|
# keep comments column(s)
|
94
|
|
95
|
dwc_maps: _always $(dwcMaps) ;
|
96
|
|
97
|
all += $(dwcMaps)
|
98
|
|
99
|
##### VegCSV
|
100
|
|
101
|
vegcsvMaps :=
|
102
|
|
103
|
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
|
104
|
.VegX-VegCSV.stems.csv.last_cleanup: VegX-VegCSV.stems.csv
|
105
|
$(bin)/in_place $< $(bin)/sort_map
|
106
|
touch $@
|
107
|
else
|
108
|
VegX-VegCSV.stems.csv: _always # initially autogenerated
|
109
|
$(if $(wildcard $@),,env only_one=1 $(bin)/join \
|
110
|
<for_review/VegX-VegBIEN.stems.csv for_review/VegBIEN-DwC2.specimens.csv\
|
111
|
|$(bin)/remove_empty\
|
112
|
|$(bin)/union VegX.self.stems.csv\
|
113
|
|$(bin)/union <(echo ',VegCSV[DwC]')\
|
114
|
|$(bin)/review 1\
|
115
|
>$@)
|
116
|
$(MAKE) $(@:%=.%.last_cleanup)
|
117
|
endif
|
118
|
|
119
|
VegCSV-VegBIEN.specimens.csv: VegX-VegCSV.stems.csv VegX-VegBIEN.stems.csv\
|
120
|
DwC2-VegBIEN.specimens.csv
|
121
|
<$< $(bin)/invert\
|
122
|
|$(bin)/join $(word 2,$+)\
|
123
|
|$(bin)/union $(word 3,$+)\
|
124
|
|$(bin)/sort_map >$@
|
125
|
vegcsvMaps += VegCSV-VegBIEN.specimens.csv
|
126
|
|
127
|
vegcsv_maps: _always $(vegcsvMaps) ;
|
128
|
|
129
|
all += $(vegcsvMaps)
|