Project

General

Profile

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