Project

General

Profile

1 3793 aaronmk
include ../lib/common.Makefile
2
3
4 785 aaronmk
##### Vars/functions
5
6 1272 aaronmk
# Paths
7 895 aaronmk
bin := ../bin
8 1824 aaronmk
inputCoreMaps := DwC1-DwC2.specimens.csv DwC2-VegBIEN.specimens.csv\
9 1843 aaronmk
VegX-VegBIEN.stems.csv
10 895 aaronmk
11 1824 aaronmk
# Via formats
12
coreMaps := $(wildcard *-VegBIEN.*.csv)
13
filenameVia = $(shell echo '$(1)'|grep --only-matching --extended-regexp\
14
'^[a-zA-Z]+')
15
# can't use --ignore-case because in Mac grep, a bug causes it to break [] exprs
16
vias := $(strip $(sort $(foreach coreMap,$(coreMaps),$(call filenameVia,$(coreMap)))))
17
18 1272 aaronmk
# Commands
19
20 3810 aaronmk
review_ = $(bin)/review 1 <$(1) >for_review/$(1)
21 1115 aaronmk
review = $(call review_,$@)
22 924 aaronmk
23 1272 aaronmk
join = env header_num=1 $(bin)/join_union_sort
24 1824 aaronmk
selfMap_ = $(bin)/cols 0 0
25 3776 aaronmk
mkSelfMap = $(selfMap_) <$<|$(bin)/sort_map >$@
26 744 aaronmk
27 785 aaronmk
##### General targets
28
29 3804 aaronmk
all: _always $(inputCoreMaps) dwc_maps self_maps ;
30 150 aaronmk
31 383 aaronmk
clean: _always
32 196 aaronmk
	$(RM) $(all)
33 188 aaronmk
34 924 aaronmk
all :=
35
36 785 aaronmk
##### Core maps cleanup
37 198 aaronmk
38 895 aaronmk
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
39
.%.last_cleanup: %
40
	$(bin)/in_place $< $(bin)/simplify_xpath
41 1132 aaronmk
	$(bin)/in_place $< $(bin)/sort_map
42 895 aaronmk
	touch $@
43 1115 aaronmk
	$(call review_,$<)
44 895 aaronmk
else
45 1824 aaronmk
$(inputCoreMaps): _always
46 895 aaronmk
	$(MAKE) $(@:%=.%.last_cleanup)
47
endif
48 350 aaronmk
49 1824 aaronmk
##### Self maps
50
51
selfMaps :=
52
53
viaCoreMap = $(via)-VegBIEN.%.csv
54
viaSelfMap = $(via).self.%.csv
55
viaCoreMaps = $(wildcard $(subst %,*,$(viaCoreMap)))
56
57
define selfMapTargets
58
selfMaps += $(viaCoreMaps:$(viaCoreMap)=$(viaSelfMap))
59
60
$(viaSelfMap): $(viaCoreMap)
61
	$$(mkSelfMap)
62
endef
63
$(foreach via,$(vias),$(eval $(selfMapTargets)))
64
65
ifneq ($(filter self_maps,$(MAKECMDGOALS)),)
66
self_maps: _always $(selfMaps) ;
67
else
68
self_maps: _always
69
	$(MAKE) self_maps
70
# re-run make so that cache of existing files for $(viaCoreMaps) is reset
71
endif
72
73
all += $(selfMaps)
74
75 1272 aaronmk
##### DwC
76 1115 aaronmk
77 1812 aaronmk
dwcMaps :=
78 1115 aaronmk
79 1452 aaronmk
DwC.cs-VegBIEN.specimens.csv: DwC1-DwC2.specimens.csv DwC2-VegBIEN.specimens.csv
80
	$(join) <$+ >$@
81 1812 aaronmk
dwcMaps += DwC.cs-VegBIEN.specimens.csv
82 1452 aaronmk
83 1802 aaronmk
DwC-VegBIEN.specimens.csv: DwC.cs-VegBIEN.specimens.csv
84 1457 aaronmk
	$(bin)/ci_map $< >$@
85 1812 aaronmk
dwcMaps += DwC-VegBIEN.specimens.csv
86 1118 aaronmk
87 3805 aaronmk
for_review/VegBIEN-DwC2.specimens.csv: for_review/DwC2-VegBIEN.specimens.csv
88 3818 aaronmk
	$(bin)/cols 1 0 + <$< >$@
89 3805 aaronmk
dwcMaps += for_review/VegBIEN-DwC2.specimens.csv
90 3818 aaronmk
# keep comments column(s)
91 3805 aaronmk
92 1824 aaronmk
dwc_maps: _always $(dwcMaps) ;
93 1140 aaronmk
94 1812 aaronmk
all += $(dwcMaps)