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
mkSelfMap = $(selfMap) <$<|$(bin)/sort_map >$@
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
dwcMaps :=
54

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

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

    
63
DwC.self.specimens.csv: DwC-VegBIEN.specimens.csv
64
	$(mkSelfMap)
65
dwcMaps += DwC.self.specimens.csv
66

    
67
join_maps: $(dwcMaps) ;
68

    
69
all += $(dwcMaps)
70

    
71
##### VegX
72

    
73
vegxMaps :=
74

    
75
VegX.self.organisms.csv: VegX-VegBIEN.organisms.csv
76
	$(mkSelfMap)
77
vegxMaps += VegX.self.organisms.csv
78

    
79
rootAttrs := :[@xmlns:tcs="http://www.tdwg.org/schemas/tcs/1.01"]
80

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

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

    
99
ch_root_maps: $(vegxMaps) ;
100

    
101
all += $(vegxMaps)
(9-9/16)