Revision 1139
Added by Aaron Marcuse-Kubitza almost 13 years ago
input.Makefile | ||
---|---|---|
68 | 68 |
|
69 | 69 |
##### Maps |
70 | 70 |
|
71 |
allViaMaps := $(filter-out maps/VegBIEN.%.csv,$(wildcard maps/*.csv)) |
|
71 |
fullViaMap := maps/%.full.csv |
|
72 |
allViaMaps := $(filter-out maps/VegBIEN.%.csv $(fullViaMap),\ |
|
73 |
$(wildcard maps/*.csv)) |
|
72 | 74 |
via := $(firstword $(sort $(basename $(basename $(notdir $(allViaMaps)))))) |
73 | 75 |
|
74 | 76 |
coreMap := $(mappings)/$(via)-VegBIEN.%.csv |
77 |
selfMap := $(mappings)/$(via).self.%.csv |
|
75 | 78 |
|
76 | 79 |
viaMaps := $(wildcard $(tablesSort:%=maps/$(via).%.csv)) |
77 |
viaMaps += $(filter-out $(viaMaps),$(wildcard maps/$(via).*.csv)) |
|
80 |
viaMaps += $(filter-out $(viaMaps) $(fullViaMap),$(wildcard maps/$(via).*.csv))
|
|
78 | 81 |
|
79 | 82 |
autogenMaps := $(subst $(via).,VegBIEN.,$(viaMaps)) |
80 | 83 |
directMaps := $(autogenMaps) $(filter-out $(autogenMaps),\ |
81 | 84 |
$(wildcard maps/VegBIEN.*.csv)) |
82 | 85 |
tables := $(directMaps:maps/VegBIEN.%.csv=%) |
83 | 86 |
|
84 |
maps: $(directMaps) _always ; |
|
85 |
|
|
86 | 87 |
.PRECIOUS: $(allViaMaps) $(directMaps) |
87 | 88 |
|
88 |
all += $(autogenMaps)
|
|
89 |
maps :=
|
|
89 | 90 |
|
90 | 91 |
maps/VegBIEN.%.csv: maps/$(via).%.csv $(coreMap) |
91 | 92 |
$(root)/bin/join_union_sort <$+ >$@ |
92 | 93 |
.PRECIOUS: maps/VegBIEN.%.csv $(coreMap) |
93 | 94 |
|
95 |
maps += $(autogenMaps) |
|
96 |
|
|
97 |
maps/$(via).%.full.csv: maps/$(via).%.csv $(selfMap) |
|
98 |
env ignore=1 $(root)/bin/union <$+|$(root)/bin/sort_map >$@ |
|
99 |
maps/$(via).%.full.csv: maps/$(via).%.csv # fallback if no self map |
|
100 |
cp -p $< $@ |
|
101 |
.PRECIOUS: maps/$(via).%.full.csv maps/$(via).%.csv $(selfMap) |
|
102 |
|
|
103 |
maps += $(patsubst maps/%.csv,maps/%.full.csv,$(viaMaps)) |
|
104 |
|
|
105 |
maps: $(maps) _always ; |
|
106 |
|
|
107 |
all += $(maps) |
|
108 |
|
|
94 | 109 |
##### Mapping |
95 | 110 |
|
96 | 111 |
dbFile := $(firstword $(wildcard src/db.*.sql)) |
... | ... | |
99 | 114 |
+maps = $(filter maps/% $(mappings)/%,$(+_)) |
100 | 115 |
<in = $(firstword $(filter-out $(+maps),$(+_)) $(wildcard $(exts:%=src/*.$*.%))) |
101 | 116 |
map = $(if $(<in),<$(<in) ,$(if $(mapEnv),env $(mapEnv) ,$(error\ |
102 |
No input file src/*.{$(tables)}.{$(exts)} )))$(root)/map $(+maps)
|
|
117 |
No input file src/*.$*.{$(exts)} )))$(root)/map $(+maps)
|
|
103 | 118 |
map2db = env out_database=vegbien $(map) |
104 | 119 |
|
105 | 120 |
##### Import to VegBIEN |
... | ... | |
184 | 199 |
|
185 | 200 |
tests := |
186 | 201 |
|
187 |
test/$(via).%.xml: maps/$(via).%.csv _always |
|
202 |
test/$(via).%.xml: maps/$(via).%.full.csv _always
|
|
188 | 203 |
$(test2File) |
189 | 204 |
tests += test/$(via).%.xml |
190 | 205 |
|
Also available in: Unified diff
input.Makefile: Generate full via maps from input via maps by appending mappings from the via format to itself when available