1 |
3793
|
aaronmk
|
include ../lib/common.Makefile
|
2 |
|
|
|
3 |
|
|
|
4 |
785
|
aaronmk
|
##### Vars/functions
|
5 |
|
|
|
6 |
3823
|
aaronmk
|
# Make
|
7 |
|
|
SHELL := /bin/bash
|
8 |
|
|
|
9 |
1272
|
aaronmk
|
# Paths
|
10 |
895
|
aaronmk
|
bin := ../bin
|
11 |
1824
|
aaronmk
|
inputCoreMaps := DwC1-DwC2.specimens.csv DwC2-VegBIEN.specimens.csv\
|
12 |
1843
|
aaronmk
|
VegX-VegBIEN.stems.csv
|
13 |
895
|
aaronmk
|
|
14 |
1824
|
aaronmk
|
# 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 |
1272
|
aaronmk
|
# Commands
|
22 |
|
|
|
23 |
3810
|
aaronmk
|
review_ = $(bin)/review 1 <$(1) >for_review/$(1)
|
24 |
1115
|
aaronmk
|
review = $(call review_,$@)
|
25 |
924
|
aaronmk
|
|
26 |
1272
|
aaronmk
|
join = env header_num=1 $(bin)/join_union_sort
|
27 |
1824
|
aaronmk
|
selfMap_ = $(bin)/cols 0 0
|
28 |
3776
|
aaronmk
|
mkSelfMap = $(selfMap_) <$<|$(bin)/sort_map >$@
|
29 |
744
|
aaronmk
|
|
30 |
785
|
aaronmk
|
##### General targets
|
31 |
|
|
|
32 |
3823
|
aaronmk
|
all: _always $(inputCoreMaps) dwc_maps vegcsv_maps self_maps ;
|
33 |
150
|
aaronmk
|
|
34 |
383
|
aaronmk
|
clean: _always
|
35 |
196
|
aaronmk
|
$(RM) $(all)
|
36 |
188
|
aaronmk
|
|
37 |
924
|
aaronmk
|
all :=
|
38 |
|
|
|
39 |
785
|
aaronmk
|
##### Core maps cleanup
|
40 |
198
|
aaronmk
|
|
41 |
895
|
aaronmk
|
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
|
42 |
|
|
.%.last_cleanup: %
|
43 |
|
|
$(bin)/in_place $< $(bin)/simplify_xpath
|
44 |
1132
|
aaronmk
|
$(bin)/in_place $< $(bin)/sort_map
|
45 |
895
|
aaronmk
|
touch $@
|
46 |
1115
|
aaronmk
|
$(call review_,$<)
|
47 |
895
|
aaronmk
|
else
|
48 |
1824
|
aaronmk
|
$(inputCoreMaps): _always
|
49 |
895
|
aaronmk
|
$(MAKE) $(@:%=.%.last_cleanup)
|
50 |
|
|
endif
|
51 |
350
|
aaronmk
|
|
52 |
1824
|
aaronmk
|
##### 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 |
1272
|
aaronmk
|
##### DwC
|
79 |
1115
|
aaronmk
|
|
80 |
1812
|
aaronmk
|
dwcMaps :=
|
81 |
1115
|
aaronmk
|
|
82 |
1452
|
aaronmk
|
DwC.cs-VegBIEN.specimens.csv: DwC1-DwC2.specimens.csv DwC2-VegBIEN.specimens.csv
|
83 |
|
|
$(join) <$+ >$@
|
84 |
1812
|
aaronmk
|
dwcMaps += DwC.cs-VegBIEN.specimens.csv
|
85 |
1452
|
aaronmk
|
|
86 |
1802
|
aaronmk
|
DwC-VegBIEN.specimens.csv: DwC.cs-VegBIEN.specimens.csv
|
87 |
1457
|
aaronmk
|
$(bin)/ci_map $< >$@
|
88 |
1812
|
aaronmk
|
dwcMaps += DwC-VegBIEN.specimens.csv
|
89 |
1118
|
aaronmk
|
|
90 |
3805
|
aaronmk
|
for_review/VegBIEN-DwC2.specimens.csv: for_review/DwC2-VegBIEN.specimens.csv
|
91 |
3820
|
aaronmk
|
$(bin)/invert <$< >$@
|
92 |
3805
|
aaronmk
|
dwcMaps += for_review/VegBIEN-DwC2.specimens.csv
|
93 |
3818
|
aaronmk
|
# keep comments column(s)
|
94 |
3805
|
aaronmk
|
|
95 |
1824
|
aaronmk
|
dwc_maps: _always $(dwcMaps) ;
|
96 |
1140
|
aaronmk
|
|
97 |
1812
|
aaronmk
|
all += $(dwcMaps)
|
98 |
3823
|
aaronmk
|
|
99 |
|
|
##### VegCSV
|
100 |
|
|
|
101 |
|
|
vegcsvMaps :=
|
102 |
|
|
|
103 |
3826
|
aaronmk
|
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 |
3899
|
aaronmk
|
VegX-VegCSV.stems.csv: _always
|
109 |
3826
|
aaronmk
|
$(MAKE) $(@:%=.%.last_cleanup)
|
110 |
|
|
endif
|
111 |
3823
|
aaronmk
|
|
112 |
3825
|
aaronmk
|
VegCSV-VegBIEN.specimens.csv: VegX-VegCSV.stems.csv VegX-VegBIEN.stems.csv\
|
113 |
|
|
DwC2-VegBIEN.specimens.csv
|
114 |
|
|
<$< $(bin)/invert\
|
115 |
|
|
|$(bin)/join $(word 2,$+)\
|
116 |
|
|
|$(bin)/union $(word 3,$+)\
|
117 |
|
|
|$(bin)/sort_map >$@
|
118 |
|
|
vegcsvMaps += VegCSV-VegBIEN.specimens.csv
|
119 |
|
|
|
120 |
3823
|
aaronmk
|
vegcsv_maps: _always $(vegcsvMaps) ;
|
121 |
|
|
|
122 |
|
|
all += $(vegcsvMaps)
|