Project

General

Profile

1 785 aaronmk
##### Vars/functions
2
3 1272 aaronmk
# Paths
4 895 aaronmk
bin := ../bin
5 1272 aaronmk
coreMaps := DwC1-DwC2.specimens.csv DwC2-VegBIEN.specimens.csv\
6
VegX-VegBIEN.organisms.csv
7 895 aaronmk
8 1272 aaronmk
# Commands
9
10 1115 aaronmk
review_ = $(bin)/review <$(1) >for_review/$(1)
11
review = $(call review_,$@)
12 924 aaronmk
13 1272 aaronmk
join = env header_num=1 $(bin)/join_union_sort
14
selfMap = $(bin)/cols 0 0
15 1812 aaronmk
mkSelfMap = $(selfMap) <$<|$(bin)/sort_map >$@
16 744 aaronmk
17 1272 aaronmk
define chRoot
18
$(bin)/ch_root <$< >$@
19
$(review)
20
endef
21
22 785 aaronmk
##### General targets
23
24 1115 aaronmk
all: _always $(coreMaps) join_maps ch_root_maps ;
25 150 aaronmk
26 1260 aaronmk
.SUFFIXES: # turn off built-in suffix rules
27
.SECONDARY: # don't automatically delete intermediate files
28 1354 aaronmk
.DELETE_ON_ERROR: # delete target if recipe fails
29 223 aaronmk
30 383 aaronmk
_always:
31
.PHONY: _always
32 188 aaronmk
33 383 aaronmk
clean: _always
34 196 aaronmk
	$(RM) $(all)
35 188 aaronmk
36 924 aaronmk
all :=
37
38 785 aaronmk
##### Core maps cleanup
39 198 aaronmk
40 895 aaronmk
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
41
.%.last_cleanup: %
42
	$(bin)/in_place $< $(bin)/simplify_xpath
43 1132 aaronmk
	$(bin)/in_place $< $(bin)/sort_map
44 895 aaronmk
	touch $@
45 1115 aaronmk
	$(call review_,$<)
46 895 aaronmk
else
47
$(coreMaps): _always
48
	$(MAKE) $(@:%=.%.last_cleanup)
49
endif
50 350 aaronmk
51 1272 aaronmk
##### DwC
52 1115 aaronmk
53 1812 aaronmk
dwcMaps :=
54 1115 aaronmk
55 1452 aaronmk
DwC.cs-VegBIEN.specimens.csv: DwC1-DwC2.specimens.csv DwC2-VegBIEN.specimens.csv
56
	$(join) <$+ >$@
57 1812 aaronmk
dwcMaps += DwC.cs-VegBIEN.specimens.csv
58 1452 aaronmk
59 1802 aaronmk
DwC-VegBIEN.specimens.csv: DwC.cs-VegBIEN.specimens.csv
60 1457 aaronmk
	$(bin)/ci_map $< >$@
61 1812 aaronmk
dwcMaps += DwC-VegBIEN.specimens.csv
62 1118 aaronmk
63 1802 aaronmk
DwC.self.specimens.csv: DwC-VegBIEN.specimens.csv
64 1812 aaronmk
	$(mkSelfMap)
65
dwcMaps += DwC.self.specimens.csv
66 1140 aaronmk
67 1812 aaronmk
join_maps: $(dwcMaps) ;
68 1115 aaronmk
69 1812 aaronmk
all += $(dwcMaps)
70 1115 aaronmk
71 1272 aaronmk
##### VegX
72 212 aaronmk
73 1812 aaronmk
vegxMaps :=
74 924 aaronmk
75 1816 aaronmk
VegX.self.organisms.csv: VegX-VegBIEN.organisms.csv
76
	$(mkSelfMap)
77
vegxMaps += VegX.self.organisms.csv
78 1812 aaronmk
79 1818 aaronmk
rootAttrs := :[@xmlns:tcs="http://www.tdwg.org/schemas/tcs/1.01"]
80 1816 aaronmk
81 438 aaronmk
VegX-VegBIEN.plots.csv: VegX-VegBIEN.organisms.csv
82 188 aaronmk
	env \
83 1816 aaronmk
left_in_root='$(rootAttrs)/*s/individualOrganismObservation/*ID->/*s/plotObservation' \
84 439 aaronmk
left_out_root='/*s/plotObservation' \
85 525 aaronmk
right_in_root='/taxonoccurrence/*_id/locationevent' \
86
right_out_root='/locationevent' \
87 439 aaronmk
$(chRoot)
88 1812 aaronmk
vegxMaps += VegX-VegBIEN.plots.csv
89 439 aaronmk
90
VegX-VegBIEN.stems.csv: VegX-VegBIEN.organisms.csv
91
	env \
92 1816 aaronmk
left_in_root='$(rootAttrs)/*s/individualOrganismObservation->/*s/individualOrganismObservation[relatedItem[relationshipType=stemParent]/relatedItemID]' \
93
left_out_root='$(rootAttrs)/*s/individualOrganismObservation[relatedItem[relationshipType=stemParent]/relatedItemID]' \
94 681 aaronmk
right_in_root='/taxonoccurrence/aggregateoccurrence/*_id/plantobservation/stemobservation' \
95 673 aaronmk
right_out_root='/stemobservation' \
96 439 aaronmk
$(chRoot)
97 1816 aaronmk
vegxMaps += VegX-VegBIEN.stems.csv
98 924 aaronmk
99 1812 aaronmk
ch_root_maps: $(vegxMaps) ;
100 924 aaronmk
101 1812 aaronmk
all += $(vegxMaps)