Project

General

Profile

1 3793 aaronmk
include ../lib/common.Makefile
2
3
4 785 aaronmk
##### Vars/functions
5
6 1272 aaronmk
# Paths
7 895 aaronmk
bin := ../bin
8 6845 aaronmk
inputCoreMaps := Veg+-VegCore.csv VegCore-VegBIEN.csv VegX-VegCore.csv
9 5065 aaronmk
vocab := VegCore.csv
10
dict := Veg+-VegCore.csv
11 895 aaronmk
12 785 aaronmk
##### General targets
13
14 6849 aaronmk
all: _always VegCore.csv VegCore.tables.csv $(inputCoreMaps) ;
15 150 aaronmk
16 383 aaronmk
clean: _always
17 196 aaronmk
	$(RM) $(all)
18 188 aaronmk
19 924 aaronmk
all :=
20
21 6845 aaronmk
##### Core maps
22 198 aaronmk
23 6845 aaronmk
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
	$(sed) -n 's/^.*<a name="([^"]+)">.*$$/\1/p' <$< >$@
28
29 6849 aaronmk
VegCore.tables.csv: VegCore.htm
30
	<$< $(sed) -n 's/^.*<h1 *><a href="#[^>]+>([^<]+).*$$/\1/p'\
31
|grep -vE '^Namespaces$$' >$@
32
33 5045 aaronmk
# This tracks VegCore terms that are mapped to VegBIEN but not documented in
34
# VegCore.csv. This file is *not* svn:ignored, so it will show up with a ? when
35
# the user runs `svn st` if there are any unsourced terms.
36
VegCore-VegBIEN.unsourced_terms.csv: VegCore-VegBIEN.csv VegCore.csv
37
	$(bin)/filter_out_ci 0 <$+ >$@
38
	$(bin)/autoremove $@
39
40 895 aaronmk
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
41 3967 aaronmk
42 6597 aaronmk
.Veg+-VegCore.csv.last_cleanup: .%.last_cleanup: % $(dict)
43 5067 aaronmk
	$(bin)/in_place $< $(bin)/translate 1 $(dict)
44 6830 aaronmk
	$(bin)/in_place $< $(bin)/canon 1 $(vocab)
45 6703 aaronmk
	$(bin)/in_place $< env text=1 $(bin)/repl $(dict) 2
46 6629 aaronmk
	$(bin)/in_place $< $(bin)/sort 2 0
47 4890 aaronmk
	touch $@
48 6597 aaronmk
.PRECIOUS: .Veg+-VegCore.csv.last_cleanup
49 4890 aaronmk
50 6597 aaronmk
.VegX-VegCore.csv.last_cleanup: .%.last_cleanup: % $(dict)
51
	$(bin)/in_place $< $(bin)/translate 1 $(dict)
52
	$(bin)/in_place $< $(bin)/sort_map
53
	touch $@
54
# can't canon because this would remove ? prefixes
55
.PRECIOUS: .VegX-VegCore.csv.last_cleanup
56
57 5065 aaronmk
.VegCore-VegBIEN.csv.last_cleanup: .%.last_cleanup: % $(dict) $(vocab)
58
	$(bin)/in_place $< $(bin)/translate 0 $(dict)
59
	$(bin)/in_place $< $(bin)/canon 0 $(vocab)
60 1132 aaronmk
	$(bin)/in_place $< $(bin)/sort_map
61 895 aaronmk
	touch $@
62 4692 aaronmk
	$(bin)/review 1 <$< >for_review/$<
63 5045 aaronmk
	$(MAKE) VegCore-VegBIEN.unsourced_terms.csv
64 5253 aaronmk
.PRECIOUS: .VegCore-VegBIEN.csv.last_cleanup
65 3967 aaronmk
66 895 aaronmk
else
67 1824 aaronmk
$(inputCoreMaps): _always
68 895 aaronmk
	$(MAKE) $(@:%=.%.last_cleanup)
69 5254 aaronmk
.PRECIOUS: $(inputCoreMaps)
70 895 aaronmk
endif