Project

General

Profile

1
include ../lib/common.Makefile
2

    
3

    
4
##### Vars/functions
5

    
6
# Make
7
SHELL := /bin/bash
8

    
9
# Paths
10
bin := ../bin
11
inputCoreMaps := Veg+-VegCore.csv VegCore-VegBIEN.csv VegX-VegCore.csv
12
vocab := VegCore.csv
13
dict := Veg+-VegCore.csv
14

    
15
##### General targets
16

    
17
all: _always VegCore.csv VegCore.tables.redmine $(inputCoreMaps) ;
18

    
19
clean: _always
20
	$(RM) $(all)
21

    
22
all :=
23

    
24
##### Core maps
25

    
26
VegCore.htm:
27
	php -r 'fpassthru(fopen("https://projects.nceas.ucsb.edu/nceas/projects/bien/wiki/VegCore", "r"));' >$@
28

    
29
VegCore.csv: VegCore.htm
30
	(echo VegCore; $(sed) -n 's/^.*<a name="([a-z][^"]*|[A-Z]+)">.*$$/\1/p')\
31
<$< >$@
32

    
33
#Veg+-VegCore.csv: VegCore.htm
34
#	(echo "Veg+,VegCore"; $(bin)/redmine_synonyms) <$< >$@
35
#	# Canonicalize alternatives of ambiguous terms using unambiguous mappings
36
#	$(bin)/in_place $@ $(bin)/translate 1 <(grep -vE '^\?' $(dict))
37
#	$(bin)/in_place $@ $(bin)/collapse_multimap
38
#	# Replace ambiguous terms with alternatives lists
39
#	$(bin)/in_place $@ $(bin)/translate 1 $(dict)
40

    
41
VegCore.tables.csv: VegCore.htm
42
	<$< $(sed) -n 's/^.*<h1 *><a href="#[^>]+>([^?<][^<]*).*$$/\1/p' >$@
43

    
44
VegCore.tables.redmine: VegCore.tables.csv
45
	$(sed) -n 's/^.*$$/[[VegCore#&|&]]/p' <$< >$@
46

    
47
# This tracks VegCore terms that are mapped to VegBIEN but not documented in
48
# VegCore.csv. This file is *not* svn:ignored, so it will show up with a ? when
49
# the user runs `svn st` if there are any unsourced terms.
50
VegCore-VegBIEN.unsourced_terms.csv: VegCore-VegBIEN.csv VegCore.csv
51
	$(bin)/filter_out_ci 0 <$+ >$@
52
	$(bin)/autoremove $@
53

    
54
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
55

    
56
.Veg+-VegCore.csv.last_cleanup: .%.last_cleanup: % $(dict)
57
	$(bin)/in_place $< $(bin)/translate_ci 1 $(dict)
58
	$(bin)/in_place $< $(bin)/canon 1 $(vocab)
59
	touch $@
60
.PRECIOUS: .Veg+-VegCore.csv.last_cleanup
61

    
62
.VegX-VegCore.csv.last_cleanup: .%.last_cleanup: % $(dict)
63
	$(bin)/in_place $< $(bin)/translate_ci 1 $(dict)
64
	$(bin)/in_place $< $(bin)/sort 0 1
65
	touch $@
66
.PRECIOUS: .VegX-VegCore.csv.last_cleanup
67

    
68
.VegCore-VegBIEN.csv.last_cleanup: .%.last_cleanup: % $(dict) $(vocab)
69
	$(bin)/in_place $< $(bin)/translate_ci 0 $(dict)
70
	$(bin)/in_place $< $(bin)/canon 0 $(vocab)
71
	$(bin)/in_place $< $(bin)/sort_map
72
	touch $@
73
	$(bin)/review 1 <$< >for_review/$<
74
	$(MAKE) VegCore-VegBIEN.unsourced_terms.csv
75
.PRECIOUS: .VegCore-VegBIEN.csv.last_cleanup
76

    
77
else
78
$(inputCoreMaps): _always
79
	$(MAKE) $(@:%=.%.last_cleanup)
80
.PRECIOUS: $(inputCoreMaps)
81
endif
(5-5/16)