Project

General

Profile

1
##### Vars/functions
2

    
3
# Paths
4
bin := ../bin
5
coreMaps := DwC1-DwC2.specimens.csv DwC2-VegBIEN.specimens.csv\
6
VegX-VegBIEN.organisms.csv
7

    
8
# Commands
9

    
10
review_ = $(bin)/review <$(1) >for_review/$(1)
11
review = $(call review_,$@)
12

    
13
join = env header_num=1 $(bin)/join_union_sort
14
selfMap = $(bin)/cols 0 0
15
removeEmpty = $(bin)/remove_empty
16

    
17
define chRoot
18
$(bin)/ch_root <$< >$@
19
$(review)
20
endef
21

    
22
##### General targets
23

    
24
all: _always $(coreMaps) join_maps ch_root_maps ;
25

    
26
.SUFFIXES: # turn off built-in suffix rules
27
.SECONDARY: # don't automatically delete intermediate files
28
.DELETE_ON_ERROR: # delete target if recipe fails
29

    
30
_always:
31
.PHONY: _always
32

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

    
36
all :=
37

    
38
##### Core maps cleanup
39

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

    
51
##### DwC
52

    
53
joinMaps :=
54

    
55
DwC.cs-VegBIEN.specimens.csv: DwC1-DwC2.specimens.csv DwC2-VegBIEN.specimens.csv
56
	$(join) <$+ >$@
57
joinMaps += DwC.cs-VegBIEN.specimens.csv
58

    
59
DwC.ci-VegBIEN.specimens.csv: DwC.cs-VegBIEN.specimens.csv
60
	$(bin)/ci_map $< >$@
61
joinMaps += DwC.ci-VegBIEN.specimens.csv
62

    
63
DwC-VegBIEN.specimens.csv: DwC.ci-VegBIEN.specimens.csv
64
	$(removeEmpty) <$< >$@
65
joinMaps += DwC-VegBIEN.specimens.csv
66

    
67
# deprecated
68
DwC-VegBIEN.specimens.no_empty.csv: DwC-VegBIEN.specimens.csv
69
	cp -p $< $@
70
joinMaps += DwC-VegBIEN.specimens.no_empty.csv
71

    
72
DwC.self.specimens.csv: DwC.ci-VegBIEN.specimens.csv
73
	$(selfMap) <$<|$(bin)/sort_map >$@
74
joinMaps += DwC.self.specimens.csv
75

    
76
join_maps: $(joinMaps) ;
77

    
78
all += $(joinMaps)
79

    
80
##### VegX
81

    
82
chRootMaps :=
83

    
84
VegX-VegBIEN.plots.csv: VegX-VegBIEN.organisms.csv
85
	env \
86
left_in_root='/*s/individualOrganismObservation/*ID->/*s/plotObservation' \
87
left_out_root='/*s/plotObservation' \
88
right_in_root='/taxonoccurrence/*_id/locationevent' \
89
right_out_root='/locationevent' \
90
$(chRoot)
91
chRootMaps += VegX-VegBIEN.plots.csv
92

    
93
VegX-VegBIEN.stems.csv: VegX-VegBIEN.organisms.csv
94
	env \
95
left_in_root='/*s/individualOrganismObservation->/*s/individualOrganismObservation[relatedItem[relationshipType=stemParent]/relatedItemID]' \
96
left_out_root='/*s/individualOrganismObservation[relatedItem[relationshipType=stemParent]/relatedItemID]' \
97
right_in_root='/taxonoccurrence/aggregateoccurrence/*_id/plantobservation/stemobservation' \
98
right_out_root='/stemobservation' \
99
$(chRoot)
100
chRootMaps += VegX-VegBIEN.plots.csv
101

    
102
ch_root_maps: $(chRootMaps) ;
103

    
104
all += $(chRootMaps)
(11-11/17)