Project

General

Profile

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 3927 aaronmk
VegCSV-VegBIEN.specimens.csv VegX-VegCSV.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 1132 aaronmk
	$(bin)/in_place $< $(bin)/sort_map
44 895 aaronmk
	touch $@
45 1115 aaronmk
	$(call review_,$<)
46 895 aaronmk
else
47 1824 aaronmk
$(inputCoreMaps): _always
48 895 aaronmk
	$(MAKE) $(@:%=.%.last_cleanup)
49
endif
50 350 aaronmk
51 1824 aaronmk
##### Self maps
52
53
selfMaps :=
54
55
viaCoreMap = $(via)-VegBIEN.%.csv
56
viaSelfMap = $(via).self.%.csv
57
viaCoreMaps = $(wildcard $(subst %,*,$(viaCoreMap)))
58
59
define selfMapTargets
60
selfMaps += $(viaCoreMaps:$(viaCoreMap)=$(viaSelfMap))
61
62
$(viaSelfMap): $(viaCoreMap)
63
	$$(mkSelfMap)
64
endef
65
$(foreach via,$(vias),$(eval $(selfMapTargets)))
66
67
ifneq ($(filter self_maps,$(MAKECMDGOALS)),)
68
self_maps: _always $(selfMaps) ;
69
else
70
self_maps: _always
71
	$(MAKE) self_maps
72
# re-run make so that cache of existing files for $(viaCoreMaps) is reset
73
endif
74
75
all += $(selfMaps)
76
77 1272 aaronmk
##### DwC
78 1115 aaronmk
79 1812 aaronmk
dwcMaps :=
80 1115 aaronmk
81 1452 aaronmk
DwC.cs-VegBIEN.specimens.csv: DwC1-DwC2.specimens.csv DwC2-VegBIEN.specimens.csv
82
	$(join) <$+ >$@
83 1812 aaronmk
dwcMaps += DwC.cs-VegBIEN.specimens.csv
84 1452 aaronmk
85 1802 aaronmk
DwC-VegBIEN.specimens.csv: DwC.cs-VegBIEN.specimens.csv
86 1457 aaronmk
	$(bin)/ci_map $< >$@
87 1812 aaronmk
dwcMaps += DwC-VegBIEN.specimens.csv
88 1118 aaronmk
89 1824 aaronmk
dwc_maps: _always $(dwcMaps) ;
90 1140 aaronmk
91 1812 aaronmk
all += $(dwcMaps)
92 3823 aaronmk
93
##### VegCSV
94
95
vegcsvMaps :=
96
97
vegcsv_maps: _always $(vegcsvMaps) ;
98
99
all += $(vegcsvMaps)