1
|
include ../lib/common.Makefile
|
2
|
|
3
|
|
4
|
##### Vars/functions
|
5
|
|
6
|
# Paths
|
7
|
bin := ../bin
|
8
|
inputCoreMaps := Veg+-VegCore.csv VegCore-VegBIEN.csv VegX-VegCore.csv
|
9
|
vocab := VegCore.csv
|
10
|
dict := Veg+-VegCore.csv
|
11
|
|
12
|
##### General targets
|
13
|
|
14
|
all: _always VegCore.csv VegCore.tables.redmine $(inputCoreMaps) ;
|
15
|
|
16
|
clean: _always
|
17
|
$(RM) $(all)
|
18
|
|
19
|
all :=
|
20
|
|
21
|
##### Core maps
|
22
|
|
23
|
VegCore.htm:
|
24
|
php -r 'fpassthru(fopen("https://projects.nceas.ucsb.edu/nceas/projects/bien/wiki/VegCore", "r"));' >$@
|
25
|
|
26
|
VegCore.csv: VegCore.htm
|
27
|
(echo VegCore; $(sed) -n 's/^.*<a name="([a-z][^"]*|[A-Z]+)">.*$$/\1/p')\
|
28
|
<$< >$@
|
29
|
|
30
|
#Veg+-VegCore.csv: VegCore.htm
|
31
|
# (echo "Veg+,VegCore"; $(bin)/redmine_synonyms|$(bin)/collapse_multimap)\
|
32
|
#<$< >$@
|
33
|
# $(bin)/in_place $@ $(bin)/translate 1 $(dict)
|
34
|
|
35
|
VegCore.tables.csv: VegCore.htm
|
36
|
<$< $(sed) -n 's/^.*<h1 *><a href="#[^>]+>([^?<][^<]*).*$$/\1/p' >$@
|
37
|
|
38
|
VegCore.tables.redmine: VegCore.tables.csv
|
39
|
$(sed) -n 's/^.*$$/[[VegCore#&|&]]/p' <$< >$@
|
40
|
|
41
|
# This tracks VegCore terms that are mapped to VegBIEN but not documented in
|
42
|
# VegCore.csv. This file is *not* svn:ignored, so it will show up with a ? when
|
43
|
# the user runs `svn st` if there are any unsourced terms.
|
44
|
VegCore-VegBIEN.unsourced_terms.csv: VegCore-VegBIEN.csv VegCore.csv
|
45
|
$(bin)/filter_out_ci 0 <$+ >$@
|
46
|
$(bin)/autoremove $@
|
47
|
|
48
|
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
|
49
|
|
50
|
.Veg+-VegCore.csv.last_cleanup: .%.last_cleanup: % $(dict)
|
51
|
$(bin)/in_place $< $(bin)/translate_ci 1 $(dict)
|
52
|
$(bin)/in_place $< $(bin)/canon 1 $(vocab)
|
53
|
touch $@
|
54
|
.PRECIOUS: .Veg+-VegCore.csv.last_cleanup
|
55
|
|
56
|
.VegX-VegCore.csv.last_cleanup: .%.last_cleanup: % $(dict)
|
57
|
$(bin)/in_place $< $(bin)/translate_ci 1 $(dict)
|
58
|
$(bin)/in_place $< $(bin)/sort_map
|
59
|
touch $@
|
60
|
# can't canon because this would remove ? prefixes
|
61
|
.PRECIOUS: .VegX-VegCore.csv.last_cleanup
|
62
|
|
63
|
.VegCore-VegBIEN.csv.last_cleanup: .%.last_cleanup: % $(dict) $(vocab)
|
64
|
$(bin)/in_place $< $(bin)/translate_ci 0 $(dict)
|
65
|
$(bin)/in_place $< $(bin)/canon 0 $(vocab)
|
66
|
$(bin)/in_place $< $(bin)/sort_map
|
67
|
touch $@
|
68
|
$(bin)/review 1 <$< >for_review/$<
|
69
|
$(MAKE) VegCore-VegBIEN.unsourced_terms.csv
|
70
|
.PRECIOUS: .VegCore-VegBIEN.csv.last_cleanup
|
71
|
|
72
|
else
|
73
|
$(inputCoreMaps): _always
|
74
|
$(MAKE) $(@:%=.%.last_cleanup)
|
75
|
.PRECIOUS: $(inputCoreMaps)
|
76
|
endif
|