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

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

    
21
##### General targets
22

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

    
25
.SUFFIXES: # turn off built-in suffix rules
26
.SECONDARY: # don't automatically delete intermediate files
27

    
28
_always:
29
.PHONY: _always
30

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

    
34
all :=
35

    
36
remake: _always clean 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
DwC2.ci-VegBIEN.specimens.csv: DwC2-VegBIEN.specimens.csv
56
	$(selfMap) <$<|$(bin)/ucase_first 0|$(join) $< >$@
57
joinMaps += DwC2.ci-VegBIEN.specimens.csv
58

    
59
DwC-VegBIEN.specimens.csv: DwC1-DwC2.specimens.csv DwC2.ci-VegBIEN.specimens.csv
60
	$(join) <$+ >$@
61
joinMaps += DwC-VegBIEN.specimens.csv
62

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

    
67
join_maps: $(joinMaps) ;
68

    
69
all += $(joinMaps)
70

    
71
##### VegX
72

    
73
chRootMaps :=
74

    
75
VegX-VegBIEN.plots.csv: VegX-VegBIEN.organisms.csv
76
	env \
77
left_in_root='/*s/individualOrganismObservation/*ID->/*s/plotObservation' \
78
left_out_root='/*s/plotObservation' \
79
right_in_root='/taxonoccurrence/*_id/locationevent' \
80
right_out_root='/locationevent' \
81
$(chRoot)
82
chRootMaps += VegX-VegBIEN.plots.csv
83

    
84
VegX-VegBIEN.stems.csv: VegX-VegBIEN.organisms.csv
85
	env \
86
left_in_root='/*s/individualOrganismObservation->/*s/individualOrganismObservation[relatedItem[relationshipType=stemParent]/relatedItemID]' \
87
left_out_root='/*s/individualOrganismObservation[relatedItem[relationshipType=stemParent]/relatedItemID]' \
88
right_in_root='/taxonoccurrence/aggregateoccurrence/*_id/plantobservation/stemobservation' \
89
right_out_root='/stemobservation' \
90
$(chRoot)
91
chRootMaps += VegX-VegBIEN.plots.csv
92

    
93
ch_root_maps: $(chRootMaps) ;
94

    
95
all += $(chRootMaps)
(9-9/15)