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 <$(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
##### General targets
28

    
29
all: _always $(inputCoreMaps) dwc_maps self_maps ;
30

    
31
clean: _always
32
	$(RM) $(all)
33

    
34
all :=
35

    
36
##### Core maps cleanup
37

    
38
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
39
.%.last_cleanup: %
40
	$(bin)/in_place $< $(bin)/simplify_xpath
41
	$(bin)/in_place $< $(bin)/sort_map
42
	touch $@
43
	$(call review_,$<)
44
else
45
$(inputCoreMaps): _always
46
	$(MAKE) $(@:%=.%.last_cleanup)
47
endif
48

    
49
##### 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
##### DwC
76

    
77
dwcMaps :=
78

    
79
DwC.cs-VegBIEN.specimens.csv: DwC1-DwC2.specimens.csv DwC2-VegBIEN.specimens.csv
80
	$(join) <$+ >$@
81
dwcMaps += DwC.cs-VegBIEN.specimens.csv
82

    
83
DwC-VegBIEN.specimens.csv: DwC.cs-VegBIEN.specimens.csv
84
	$(bin)/ci_map $< >$@
85
dwcMaps += DwC-VegBIEN.specimens.csv
86

    
87
for_review/VegBIEN-DwC2.specimens.csv: for_review/DwC2-VegBIEN.specimens.csv
88
	$(bin)/invert <$< >$@
89
dwcMaps += for_review/VegBIEN-DwC2.specimens.csv
90
# keep comments column(s)
91

    
92
dwc_maps: _always $(dwcMaps) ;
93

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