Project

General

Profile

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.csv $(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
	$(sed) -n 's/^.*<a name="([^"]+)">.*$$/\1/p' <$< >$@
28

    
29
VegCore.tables.csv: VegCore.htm
30
	<$< $(sed) -n 's/^.*<h1 *><a href="#[^>]+>([^<]+).*$$/\1/p'\
31
|grep -vE '^Namespaces$$' >$@
32

    
33
# 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
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
41

    
42
.Veg+-VegCore.csv.last_cleanup: .%.last_cleanup: % $(dict)
43
	$(bin)/in_place $< $(bin)/translate 1 $(dict)
44
	$(bin)/in_place $< $(bin)/canon 1 $(vocab)
45
	$(bin)/in_place $< env text=1 $(bin)/repl $(dict) 2
46
	$(bin)/in_place $< $(bin)/sort 2 0
47
	touch $@
48
.PRECIOUS: .Veg+-VegCore.csv.last_cleanup
49

    
50
.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
.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
	$(bin)/in_place $< $(bin)/sort_map
61
	touch $@
62
	$(bin)/review 1 <$< >for_review/$<
63
	$(MAKE) VegCore-VegBIEN.unsourced_terms.csv
64
.PRECIOUS: .VegCore-VegBIEN.csv.last_cleanup
65

    
66
else
67
$(inputCoreMaps): _always
68
	$(MAKE) $(@:%=.%.last_cleanup)
69
.PRECIOUS: $(inputCoreMaps)
70
endif
(5-5/16)