Project

General

Profile

1
include ../lib/common.Makefile
2

    
3

    
4
##### Vars/functions
5

    
6
# Make
7
SHELL := /bin/bash
8

    
9
# Paths
10
bin := ../bin
11
inputCoreMaps := Veg+.terms.csv DwC1-DwC2.specimens.csv \
12
DwC2-VegBIEN.specimens.csv VegCSV-VegBIEN.specimens.csv VegX-VegCSV.stems.csv
13

    
14
# 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
# Commands
22

    
23
review_ = $(bin)/review 1 <$(1) >for_review/$(1)
24
review = $(call review_,$@)
25

    
26
join = env header_num=1 $(bin)/join_union_sort
27
selfMap_ = $(bin)/cols 0 0
28
mkSelfMap = $(selfMap_) <$<|$(bin)/sort_map >$@
29

    
30
##### General targets
31

    
32
all: _always $(inputCoreMaps) dwc_maps vegcsv_maps self_maps ;
33

    
34
clean: _always
35
	$(RM) $(all)
36

    
37
all :=
38

    
39
##### Core maps cleanup
40

    
41
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
42

    
43
.Veg+.terms.csv.last_cleanup: .%.last_cleanup: %
44
	$(bin)/in_place $< $(bin)/sort_map
45
	touch $@
46

    
47
.%.last_cleanup: %
48
	$(bin)/in_place $< $(bin)/sort_map
49
	touch $@
50
	$(call review_,$<)
51

    
52
else
53
$(inputCoreMaps): _always
54
	$(MAKE) $(@:%=.%.last_cleanup)
55
endif
56

    
57
##### 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
##### DwC
84

    
85
dwcMaps :=
86

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

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

    
95
dwc_maps: _always $(dwcMaps) ;
96

    
97
all += $(dwcMaps)
98

    
99
##### VegCSV
100

    
101
vegcsvMaps :=
102

    
103
vegcsv_maps: _always $(vegcsvMaps) ;
104

    
105
all += $(vegcsvMaps)
(11-11/24)