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 3967 aaronmk
inputCoreMaps := Veg+.terms.csv DwC1-DwC2.specimens.csv \
12
DwC2-VegBIEN.specimens.csv 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 3967 aaronmk
43
.Veg+.terms.csv.last_cleanup: .%.last_cleanup: %
44
	$(bin)/in_place $< $(bin)/sort_map
45
	touch $@
46
47 895 aaronmk
.%.last_cleanup: %
48 1132 aaronmk
	$(bin)/in_place $< $(bin)/sort_map
49 895 aaronmk
	touch $@
50 1115 aaronmk
	$(call review_,$<)
51 3967 aaronmk
52 895 aaronmk
else
53 1824 aaronmk
$(inputCoreMaps): _always
54 895 aaronmk
	$(MAKE) $(@:%=.%.last_cleanup)
55
endif
56 350 aaronmk
57 1824 aaronmk
##### 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 1272 aaronmk
##### DwC
84 1115 aaronmk
85 1812 aaronmk
dwcMaps :=
86 1115 aaronmk
87 1452 aaronmk
DwC.cs-VegBIEN.specimens.csv: DwC1-DwC2.specimens.csv DwC2-VegBIEN.specimens.csv
88
	$(join) <$+ >$@
89 1812 aaronmk
dwcMaps += DwC.cs-VegBIEN.specimens.csv
90 1452 aaronmk
91 1802 aaronmk
DwC-VegBIEN.specimens.csv: DwC.cs-VegBIEN.specimens.csv
92 1457 aaronmk
	$(bin)/ci_map $< >$@
93 1812 aaronmk
dwcMaps += DwC-VegBIEN.specimens.csv
94 1118 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
vegcsv_maps: _always $(vegcsvMaps) ;
104
105
all += $(vegcsvMaps)