Project

General

Profile

1
include ../lib/common.Makefile
2

    
3

    
4
##### Vars/functions
5

    
6
# Paths
7
bin := ../bin
8
inputCoreMaps := DwC1-DwC2.specimens.csv DwC2-VegBIEN.specimens.csv\
9
VegX-VegBIEN.stems.csv
10

    
11
# 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
# Commands
19

    
20
review_ = $(bin)/review <$(1) >for_review/$(1)
21
review = $(call review_,$@)
22

    
23
join = env header_num=1 $(bin)/join_union_sort
24
selfMap_ = $(bin)/cols 0 0
25
mkSelfMap = $(selfMap_) <$<|$(bin)/sort_map >$@
26

    
27
define chRoot
28
$(bin)/ch_root <$< >$@
29
$(review)
30
endef
31

    
32
define cpReview
33
$(cp)
34
$(review)
35
endef
36

    
37
##### General targets
38

    
39
all: _always $(inputCoreMaps) dwc_maps self_maps ;
40

    
41
clean: _always
42
	$(RM) $(all)
43

    
44
all :=
45

    
46
##### Core maps cleanup
47

    
48
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
49
.%.last_cleanup: %
50
	$(bin)/in_place $< $(bin)/simplify_xpath
51
	$(bin)/in_place $< $(bin)/sort_map
52
	touch $@
53
	$(call review_,$<)
54
else
55
$(inputCoreMaps): _always
56
	$(MAKE) $(@:%=.%.last_cleanup)
57
endif
58

    
59
##### Self maps
60

    
61
selfMaps :=
62

    
63
viaCoreMap = $(via)-VegBIEN.%.csv
64
viaSelfMap = $(via).self.%.csv
65
viaCoreMaps = $(wildcard $(subst %,*,$(viaCoreMap)))
66

    
67
define selfMapTargets
68
selfMaps += $(viaCoreMaps:$(viaCoreMap)=$(viaSelfMap))
69

    
70
$(viaSelfMap): $(viaCoreMap)
71
	$$(mkSelfMap)
72
endef
73
$(foreach via,$(vias),$(eval $(selfMapTargets)))
74

    
75
ifneq ($(filter self_maps,$(MAKECMDGOALS)),)
76
self_maps: _always $(selfMaps) ;
77
else
78
self_maps: _always
79
	$(MAKE) self_maps
80
# re-run make so that cache of existing files for $(viaCoreMaps) is reset
81
endif
82

    
83
all += $(selfMaps)
84

    
85
##### DwC
86

    
87
dwcMaps :=
88

    
89
DwC.cs-VegBIEN.specimens.csv: DwC1-DwC2.specimens.csv DwC2-VegBIEN.specimens.csv
90
	$(join) <$+ >$@
91
dwcMaps += DwC.cs-VegBIEN.specimens.csv
92

    
93
DwC-VegBIEN.specimens.csv: DwC.cs-VegBIEN.specimens.csv
94
	$(bin)/ci_map $< >$@
95
dwcMaps += DwC-VegBIEN.specimens.csv
96

    
97
for_review/VegBIEN-DwC2.specimens.csv: for_review/DwC2-VegBIEN.specimens.csv
98
	$(bin)/cols 1 0 2 <$< >$@
99
dwcMaps += for_review/VegBIEN-DwC2.specimens.csv
100
# keep Comments column
101

    
102
dwc_maps: _always $(dwcMaps) ;
103

    
104
all += $(dwcMaps)
(9-9/18)