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|grep -vE '^\??[A-Z][a-z]')\
35
#<$< >$@
36
#	# Canonicalize alternatives of ambiguous terms using unambiguous mappings
37
#	$(bin)/in_place $@ $(bin)/translate 1 <(grep -vE '^\?' $(dict))
38
#	$(bin)/in_place $@ $(bin)/collapse_multimap
39
#	# Replace ambiguous terms with alternatives lists
40
#	$(bin)/in_place $@ $(bin)/translate 1 $(dict)
41

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

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

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

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

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

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

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

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