2018-07-05 16:04:33 -04:00
|
|
|
# @configure_input@
|
|
|
|
#
|
|
|
|
# Compiles packages written in the Calc DSL.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2018 R-T Specialty, LLC.
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
# Note that this build process is unconventional in order to avoid the startup
|
|
|
|
# costs that would be associated with executing dslc with each and every package
|
|
|
|
# (see the other Makefile for more information). Therefore, everything is
|
|
|
|
# written to .cqueue for later processing by dslc.
|
|
|
|
#
|
|
|
|
# The issue of re-building based on timestamps---which Make would normally take
|
|
|
|
# care of exclusively---must also be given special care now that we are handling
|
|
|
|
# the building separately from Make. Each enqueued request also touches the
|
|
|
|
# destination file to update its timestamp, ensuring that it is seen by Make as
|
|
|
|
# modified (as if it were compiled) and therefore will trigger the building of
|
|
|
|
# the targets that depend upon it. In the case of the object files (xmlo), a
|
|
|
|
# temporary file is created when it is enqueued. As part of the queued request
|
|
|
|
# for compilation is a request to delete this temporary file. In the event that
|
|
|
|
# the build fails, this temporary file will be seen and will force a rebuild of
|
|
|
|
# the file, despite its timestamp.
|
|
|
|
#
|
|
|
|
# The same issue does not exist for xmle, js, and html files, since they have
|
|
|
|
# linear dependency trees and dslc will rm the file on failure, which
|
|
|
|
# obliterates the timestamp.
|
|
|
|
# #
|
|
|
|
|
|
|
|
path_rates := $(path_suppliers)/rates
|
|
|
|
path_map := map
|
|
|
|
path_c1map := $(path_map)/c1
|
|
|
|
path_dsl := rater
|
|
|
|
path_ui := ui
|
|
|
|
path_suppliers := suppliers
|
|
|
|
path_lv := lovullo
|
|
|
|
path_srv := srv
|
|
|
|
|
|
|
|
src_suppliers := $(wildcard $(path_suppliers)/*.xml)
|
|
|
|
src_map := $(wildcard $(path_map)/*.xml)
|
|
|
|
src_c1map := $(wildcard $(path_c1map)/*.xml)
|
|
|
|
|
|
|
|
dest_summary_html := $(patsubst \
|
|
|
|
$(path_suppliers)/%.xml, \
|
|
|
|
$(path_suppliers)/%.html, \
|
|
|
|
$(src_suppliers))
|
|
|
|
dest_standalone := $(patsubst \
|
|
|
|
$(path_suppliers)/%.xml, \
|
|
|
|
$(path_suppliers)/%.js, \
|
|
|
|
$(src_suppliers))
|
|
|
|
dest_map := $(patsubst \
|
|
|
|
$(path_map)/%.xml, \
|
|
|
|
$(path_map)/%.xmle, \
|
|
|
|
$(src_map))
|
|
|
|
dest_c1map := $(patsubst \
|
|
|
|
$(path_c1map)/%.xml, \
|
|
|
|
$(path_c1map)/%.php, \
|
|
|
|
$(src_c1map))
|
|
|
|
|
|
|
|
compiled_suppliers := $(src_suppliers:.xml=.xmlo)
|
|
|
|
linked_suppliers := $(src_suppliers:.xml=.xmle)
|
|
|
|
|
|
|
|
comma := ,
|
|
|
|
extless_supp_delim := $(subst .xml,,$(subst .xml ,$(comma),$(src_suppliers)))
|
|
|
|
|
|
|
|
cqueue=.cqueue
|
|
|
|
|
|
|
|
ant = @ANT@ -e
|
|
|
|
|
|
|
|
.DELETE_ON_ERROR:
|
|
|
|
|
|
|
|
.PHONY: default clean \
|
|
|
|
interp-rate-tables summary-html c1map \
|
|
|
|
standalones program-ui program-ui-immediate program-data-copy \
|
|
|
|
do-build version FORCE
|
|
|
|
|
|
|
|
# these files will never be deleted when Make considers them to be intermediate
|
|
|
|
# (e.g. when building summary pages), since they are still needed or take a
|
|
|
|
# while to build
|
|
|
|
.PRECIOUS: %.js %.xml %.xmle %.xmlo
|
|
|
|
|
|
|
|
SHELL = /bin/bash -O extglob
|
|
|
|
|
|
|
|
default: program-ui c1map FORCE
|
|
|
|
|
|
|
|
program-ui: standalones ui/package.js ui/Program.js program-ui-immediate
|
|
|
|
program-ui-immediate: ui/html/index.phtml
|
|
|
|
|
|
|
|
include suppliers.mk
|
|
|
|
|
|
|
|
# starts with a fresh cqueue
|
|
|
|
prexmlo:
|
|
|
|
@>$(cqueue)
|
|
|
|
|
|
|
|
summary-html: $(dest_summary_html) ;
|
|
|
|
|
|
|
|
%.html: %.js
|
|
|
|
@echo "summary $*.xmle $@" >>.cqueue
|
|
|
|
@touch $@
|
|
|
|
|
|
|
|
standalones: $(dest_standalone)
|
|
|
|
%.xmle: %.xmlo
|
|
|
|
@echo "link $< $@" >>.cqueue
|
|
|
|
@touch $@
|
|
|
|
%.js: %.xmle
|
|
|
|
@echo "standalone $< $@" >>.cqueue
|
|
|
|
@touch $@
|
|
|
|
|
2018-07-05 16:05:44 -04:00
|
|
|
# C1 XML (specific recipes are in suppliers.mk)
|
2018-07-05 16:04:33 -04:00
|
|
|
c1map: $(dest_c1map)
|
|
|
|
|
|
|
|
%.dot: %.xmlo
|
|
|
|
@echo "dot $< $@" >> .cqueue
|
|
|
|
%.dote: %.xmle
|
|
|
|
@echo "dot $< $@" >> .cqueue
|
|
|
|
|
|
|
|
%.svg: %.dote
|
|
|
|
dot -Tsvg "$<" > "$@"
|
|
|
|
%.svg: %.dot
|
|
|
|
dot -Tsvg "$<" > "$@"
|
|
|
|
|
|
|
|
%.xml: %.dat
|
|
|
|
rater/tools/tdat2xml $< > $@
|
|
|
|
|
|
|
|
%.xml: %.typelist
|
|
|
|
rater/tame/build-aux/list2typedef $(*F) < $< > $@
|
|
|
|
|
|
|
|
%.csvo: %.csvm
|
|
|
|
rater/tools/csvm2csv $< > $@
|
|
|
|
%.csvo: %.csvi
|
|
|
|
rater/tools/csvi $< > $@
|
|
|
|
%.csvo: %.csv
|
|
|
|
cp $< $@
|
|
|
|
|
|
|
|
%.xml: %.csvo
|
|
|
|
rater/tools/csv2xml $< > $@
|
|
|
|
|
|
|
|
version: .version.xml
|
|
|
|
.version.xml: FORCE
|
|
|
|
git log HEAD^.. -1 --pretty=format:'<version>%h</version>' > .version.xml
|
|
|
|
|
|
|
|
ui/program.expanded.xml: ui/program.xml | .version.xml
|
|
|
|
@echo "progui-expand $< $@" >> .cqueue
|
|
|
|
ui/Program.js: ui/program.expanded.xml ui/package.js
|
|
|
|
@echo "progui-class $< $@ include-path=../../../ui/" >> .cqueue
|
|
|
|
ui/html/index.phtml: ui/program.expanded.xml
|
|
|
|
@echo "progui-html $< $@ out-path=./" >> .cqueue
|
|
|
|
ui/package-dfns.xmlo: ui/package-dfns.xml
|
|
|
|
ui/package-dfns.xml: ui/program.expanded.xml
|
|
|
|
@echo "progui-pkg $< $@" >> .cqueue
|
|
|
|
ui/package-map.xmlo: ui/package-map.xml
|
|
|
|
ui/package-map.xml: ui/program.expanded.xml ui/package-dfns.xml
|
|
|
|
@echo "progui-pkg-map $< $@" >> .cqueue
|
|
|
|
|
|
|
|
# for the time being, this does not depend on clean-rate-tables because $(ant) will
|
|
|
|
specs:
|
|
|
|
$(MAKE) -C doc/specs
|
|
|
|
#
|
|
|
|
# this will eventually go away once we don't have X-repo klugery
|
|
|
|
|
|
|
|
# for the time being, this does not depend on clean-rate-tables because ant will
|
|
|
|
# run it
|
|
|
|
clean:
|
|
|
|
find $(path_suppliers) $(path_map) $(path_c1map) common/ rater/core rater/lv \( \
|
|
|
|
-name '*.xmlo' \
|
|
|
|
-o -name '*.xmle' \
|
|
|
|
-o -name '*.js' \
|
|
|
|
-o -name '*.html' \
|
|
|
|
-o -name '*.dep' \
|
|
|
|
-o -name '*.tmp' \
|
|
|
|
\) -exec rm -v {} \;
|
|
|
|
rm -rf $(path_ui)/package-dfns.* \
|
|
|
|
$(path_ui)/package-map.* \
|
|
|
|
$(path_ui)/program.expanded.xml \
|
|
|
|
$(path_ui)/include.js \
|
|
|
|
$(path_ui)/Program.js \
|
|
|
|
$(path_ui)/html
|
|
|
|
find . -path '*/tables/*.csvm' -o -path '*/territories/*.dat' \
|
|
|
|
| sed 's/\.csvm$$/\.xml/; s/\.dat$$/\.xml/' \
|
|
|
|
| xargs rm -fv
|
|
|
|
|
|
|
|
# generates a Makefile that will properly build all package dependencies; note
|
|
|
|
# that territory and rate packages also have includes; see top of this file for
|
|
|
|
# an explanation
|
|
|
|
suppliers.mk:
|
|
|
|
$(ant) pkg-dep \
|
|
|
|
&& mv $(path_ui)/program.dep $(path_ui)/package-dfns.dep
|
|
|
|
xmlo_cmd='@echo "validate $$(patsubst %.tmp,%.xml,$$<) $$@" >> .cqueue \
|
|
|
|
&& echo "compile $$(patsubst %.tmp,%.xml,$$<) $$@" >> .cqueue \
|
|
|
|
&& echo "rm $$(patsubst %.xmlo,%.tmp,$$@)" >> .cqueue \
|
|
|
|
&& touch $$@ \
|
|
|
|
&& touch -d +1sec $$(patsubst %.xmlo,%.tmp,$$@) >> .cqueue' \
|
2018-07-05 16:05:44 -04:00
|
|
|
./rater/tame/build-aux/gen-make common/ $(path_suppliers)/ $(path_dsl)/ $(path_map)/ $(path_ui)/ >$@ \
|
|
|
|
&& ./rater/tame/build-aux/gen-c1make $(path_c1map)/*.xml >>$@
|
2018-07-05 16:04:33 -04:00
|
|
|
|
|
|
|
me-a-sandwich:
|
|
|
|
@test $$EUID -eq 0 \
|
|
|
|
&& echo 'You actually ran me as root? Are you insane!?' \
|
|
|
|
|| echo 'Make it yourself.'
|
|
|
|
|
|
|
|
# simply forces a job to run, thereby forcing the invocation of the secondary
|
|
|
|
# Makefile (this is not explicitly required, because of prepare, but signifies
|
|
|
|
# intent and is self-documenting)
|
|
|
|
FORCE: ;
|