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 $(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
# This tracks VegCore terms that are mapped to VegBIEN but not documented in
30
# VegCore.csv. This file is *not* svn:ignored, so it will show up with a ? when
31
# the user runs `svn st` if there are any unsourced terms.
32
VegCore-VegBIEN.unsourced_terms.csv: VegCore-VegBIEN.csv VegCore.csv
33
	$(bin)/filter_out_ci 0 <$+ >$@
34
	$(bin)/autoremove $@
35

    
36
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
37

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

    
46
.VegX-VegCore.csv.last_cleanup: .%.last_cleanup: % $(dict)
47
	$(bin)/in_place $< $(bin)/translate 1 $(dict)
48
	$(bin)/in_place $< $(bin)/sort_map
49
	touch $@
50
# can't canon because this would remove ? prefixes
51
.PRECIOUS: .VegX-VegCore.csv.last_cleanup
52

    
53
.VegCore-VegBIEN.csv.last_cleanup: .%.last_cleanup: % $(dict) $(vocab)
54
	$(bin)/in_place $< $(bin)/translate 0 $(dict)
55
	$(bin)/in_place $< $(bin)/canon 0 $(vocab)
56
	$(bin)/in_place $< $(bin)/sort_map
57
	touch $@
58
	$(bin)/review 1 <$< >for_review/$<
59
	$(MAKE) VegCore-VegBIEN.unsourced_terms.csv
60
.PRECIOUS: .VegCore-VegBIEN.csv.last_cleanup
61

    
62
else
63
$(inputCoreMaps): _always
64
	$(MAKE) $(@:%=.%.last_cleanup)
65
.PRECIOUS: $(inputCoreMaps)
66
endif
(5-5/15)