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
vias := $(strip $(sort $(foreach coreMap,$(coreMaps),$(call filenameVia,$(coreMap)))))
20
21 1272 aaronmk
# Commands
22
23 3810 aaronmk
review_ = $(bin)/review 1 <$(1) >for_review/$(1)
24 1115 aaronmk
review = $(call review_,$@)
25 924 aaronmk
26 4088 aaronmk
join = env header_num=0 $(bin)/join_union_sort
27 1824 aaronmk
selfMap_ = $(bin)/cols 0 0
28 3776 aaronmk
mkSelfMap = $(selfMap_) <$<|$(bin)/sort_map >$@
29 744 aaronmk
30 785 aaronmk
##### General targets
31
32 4088 aaronmk
all: _always $(inputCoreMaps) vegcsv_maps self_maps ;
33 150 aaronmk
34 383 aaronmk
clean: _always
35 196 aaronmk
	$(RM) $(all)
36 188 aaronmk
37 924 aaronmk
all :=
38
39 785 aaronmk
##### Core maps cleanup
40 198 aaronmk
41 895 aaronmk
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
42 3967 aaronmk
43
.Veg+.terms.csv.last_cleanup: .%.last_cleanup: %
44
	$(bin)/in_place $< $(bin)/sort_map
45
	touch $@
46
47 895 aaronmk
.%.last_cleanup: %
48 1132 aaronmk
	$(bin)/in_place $< $(bin)/sort_map
49 895 aaronmk
	touch $@
50 1115 aaronmk
	$(call review_,$<)
51 3967 aaronmk
52 895 aaronmk
else
53 1824 aaronmk
$(inputCoreMaps): _always
54 895 aaronmk
	$(MAKE) $(@:%=.%.last_cleanup)
55
endif
56 350 aaronmk
57 1824 aaronmk
##### Self maps
58
59
selfMaps :=
60
61
viaCoreMap = $(via)-VegBIEN.%.csv
62
viaSelfMap = $(via).self.%.csv
63
viaCoreMaps = $(wildcard $(subst %,*,$(viaCoreMap)))
64
65
define selfMapTargets
66
selfMaps += $(viaCoreMaps:$(viaCoreMap)=$(viaSelfMap))
67
68
$(viaSelfMap): $(viaCoreMap)
69
	$$(mkSelfMap)
70
endef
71
$(foreach via,$(vias),$(eval $(selfMapTargets)))
72
73
ifneq ($(filter self_maps,$(MAKECMDGOALS)),)
74
self_maps: _always $(selfMaps) ;
75
else
76
self_maps: _always
77
	$(MAKE) self_maps
78
# re-run make so that cache of existing files for $(viaCoreMaps) is reset
79
endif
80
81
all += $(selfMaps)
82
83 4088 aaronmk
##### VegCSV
84 1115 aaronmk
85 4088 aaronmk
vegcsvMaps :=
86 1115 aaronmk
87 4098 aaronmk
Veg+.cs-VegBIEN.csv: Veg+-VegCore.csv\
88
VegCore-VegBIEN.csv
89 1452 aaronmk
	$(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)