Project

General

Profile

1 3793 aaronmk
include ../lib/common.Makefile
2
3
4 785 aaronmk
##### Vars/functions
5
6 3823 aaronmk
# Make
7
SHELL := /bin/bash
8
9 1272 aaronmk
# Paths
10 895 aaronmk
bin := ../bin
11 4098 aaronmk
inputCoreMaps := Veg+.terms.csv Veg+-VegCore.csv VegCore-VegBIEN.csv \
12 4099 aaronmk
VegX-VegCore.csv
13 895 aaronmk
14 1824 aaronmk
# Via formats
15
coreMaps := $(wildcard *-VegBIEN.*.csv)
16
filenameVia = $(shell echo '$(1)'|grep --only-matching --extended-regexp\
17 4088 aaronmk
'^[a-zA-Z+]+')
18 1824 aaronmk
# can't use --ignore-case because in Mac grep, a bug causes it to break [] exprs
19 4155 aaronmk
vias := $(strip $(sort $(foreach coreMap,$(coreMaps),$(call\
20
filenameVia,$(coreMap)))))
21 1824 aaronmk
22 1272 aaronmk
# Commands
23
24 3810 aaronmk
review_ = $(bin)/review 1 <$(1) >for_review/$(1)
25 1115 aaronmk
review = $(call review_,$@)
26 924 aaronmk
27 4088 aaronmk
join = env header_num=0 $(bin)/join_union_sort
28 1824 aaronmk
selfMap_ = $(bin)/cols 0 0
29 3776 aaronmk
mkSelfMap = $(selfMap_) <$<|$(bin)/sort_map >$@
30 744 aaronmk
31 785 aaronmk
##### General targets
32
33 4088 aaronmk
all: _always $(inputCoreMaps) vegcsv_maps self_maps ;
34 150 aaronmk
35 383 aaronmk
clean: _always
36 196 aaronmk
	$(RM) $(all)
37 188 aaronmk
38 924 aaronmk
all :=
39
40 785 aaronmk
##### Core maps cleanup
41 198 aaronmk
42 895 aaronmk
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
43 3967 aaronmk
44
.Veg+.terms.csv.last_cleanup: .%.last_cleanup: %
45
	$(bin)/in_place $< $(bin)/sort_map
46
	touch $@
47
48 895 aaronmk
.%.last_cleanup: %
49 1132 aaronmk
	$(bin)/in_place $< $(bin)/sort_map
50 895 aaronmk
	touch $@
51 1115 aaronmk
	$(call review_,$<)
52 3967 aaronmk
53 895 aaronmk
else
54 1824 aaronmk
$(inputCoreMaps): _always
55 895 aaronmk
	$(MAKE) $(@:%=.%.last_cleanup)
56
endif
57 350 aaronmk
58 1824 aaronmk
##### Self maps
59
60
selfMaps :=
61
62
viaCoreMap = $(via)-VegBIEN.%.csv
63
viaSelfMap = $(via).self.%.csv
64
viaCoreMaps = $(wildcard $(subst %,*,$(viaCoreMap)))
65
66
define selfMapTargets
67
selfMaps += $(viaCoreMaps:$(viaCoreMap)=$(viaSelfMap))
68
69
$(viaSelfMap): $(viaCoreMap)
70
	$$(mkSelfMap)
71
endef
72
$(foreach via,$(vias),$(eval $(selfMapTargets)))
73
74
ifneq ($(filter self_maps,$(MAKECMDGOALS)),)
75
self_maps: _always $(selfMaps) ;
76
else
77
self_maps: _always
78
	$(MAKE) self_maps
79
# re-run make so that cache of existing files for $(viaCoreMaps) is reset
80
endif
81
82
all += $(selfMaps)
83
84 4088 aaronmk
##### VegCSV
85 1115 aaronmk
86 4088 aaronmk
vegcsvMaps :=
87 1115 aaronmk
88 4155 aaronmk
Veg+.cs-VegBIEN.csv: Veg+-VegCore.csv VegCore-VegBIEN.csv
89 4157 aaronmk
	env quiet=1 $(join) <$+ >$@
90 4098 aaronmk
vegcsvMaps += Veg+.cs-VegBIEN.csv
91 1452 aaronmk
92 4098 aaronmk
Veg+-VegBIEN.csv: Veg+.cs-VegBIEN.csv
93 1457 aaronmk
	$(bin)/ci_map $< >$@
94 4098 aaronmk
vegcsvMaps += Veg+-VegBIEN.csv
95 1118 aaronmk
96 3823 aaronmk
vegcsv_maps: _always $(vegcsvMaps) ;
97
98
all += $(vegcsvMaps)