Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
blob: 4ddec3b9863df8d802f63afd34f4106ddc284459 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# @configure_input@
#
# TAME Makefile
#
#   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/>.
#
# This fragment exists as a kluge to provide support for running a command
# after all targets have been run (in this case, dslc).
#
# A list of everything to be compiled is output into .cqueue, which is then
# picked up by dslc; this avoids the overhead of starting the JVM,
# recompiling XSL stylesheets, etc, which is quite substantial.
#
# !!! Unfortunately, this does not yet support parallel job execution.

path_rates         := $(path_suppliers)/rates
path_map           := map
path_c1map         := $(path_map)/c1
path_dsl           := rater
path_ui            := ui
path_tests         := test
path_suppliers     := suppliers
path_lv            := lovullo
path_srv           := srv
path_lvroot        := lvroot
path_intralov_root := "intralov-root/@program@"

.PHONY: FORCE prepare program-data-copy lvroot program-ui-immediate test

JAVA_HEAP_SIZE ?= 5120M
JAVA_STACK_SIZE ?= 5M

.DELETE_ON_ERROR:

# less verbose output; all to runlog
define saneout
  time -f 'total time: %E' awk ' \
    BEGIN { e=0; w=0; } \
    { printf "[%d] ", systime() >> ".runlog"; print >> ".runlog"; } \
    /^~~~~\[begin /,/^~~~~\[end / { next } \
    /^rm / { next } \
    /^Exception|^\t+at / { \
      if ( /^E/ ) { \
        print; \
        print "Stack trace written to .runlog"; \
      } \
      next; \
     } \
    /[Ww]arning:|[Nn]otice:/ { printf "\033[0;33m"; w++; out=1; } \
    /[Ff]atal:/ { printf "\033[0;31m"; out=1; } \
    /!|[Ee]rror:/ { printf "\033[0;31m"; e++; out=1; } \
    /internal:/ { printf "\033[0;35m"; out=1; } \
    /internal error:/ { printf "\033[1m"; out=1; } \
    /^[^[]/ || out { print; printf "\033[0;0m"; out=0; } \
    END { printf "%d error(s); %d warning(s).\n", e, w; } \
  '
endef

define _go
  touch .cqueue \
  && ( test -s .cqueue || echo "Nothing to be done for \`$@'." ) \
  && echo "$(JAVA_HEAP_SIZE) $(JAVA_STACK_SIZE)" \ \
  && CLASSPATH="$(RATER_CLASSPATH):rater/src/dslc.jar" \
     $(JAVA) -Xmx$(JAVA_HEAP_SIZE) -Xss$(JAVA_STACK_SIZE) \
	   com.lovullo.dslc.DslCompiler < .cqueue 2>&1 \
     | $(saneout); \
  exit $${PIPESTATUS[0]}; \
  @>.cqueue
endef

SHELL = /bin/bash -O extglob

all: program-data-copy

program-ui-immediate:
	@>.cqueue
	@$(MAKE) --no-print-directory -f Makefile.2 program-ui-immediate
	@$(MAKE) program-data-copy
	@$(_go)

program-data-copy:
	@>.cqueue
	@$(MAKE) --no-print-directory -f Makefile.2 standalones program-ui c1map
	@$(_go)
	mkdir -p "$(path_lv)/src/node/program/rater/programs/@program@"
	mkdir -p "$(path_lv)/src/node/program/classify"
	mkdir -p "$(path_lv)/src/node/program/ui/custom"
	mkdir -p "$(path_lv)/src/_gen/scripts/program/@program@"
	mkdir -p "$(path_lv)/src/_gen/views/scripts/quote/@program@"
	mkdir -p "$(path_lv)/src/lib/c1/interfaces/c1/contract/@program@"
	mkdir -p "$(path_lv)/misc/rater/programs"
	mkdir -p "$(path_lv)/src/www/scripts/program"
	cp -v .version.xml \
	  "$(path_lv)/misc/rater/programs/.version-@program@.xml"
	cp -v "$(path_ui)/custom.js" \
	  "$(path_lv)/src/www/scripts/program/@program@.js"
	cp -v "$(path_ui)/"!(custom|package|include).js \
	  "$(path_lv)/src/node/program/ui/custom/"
	cp -v "$(path_srv)/rater.js" \
	  "$(path_lv)/src/node/program/rater/programs/@program@.js"
	cp -v "$(path_ui)/package.js" \
	  "$(path_lv)/src/node/program/classify/@program@.js"
	cp -v "$(path_ui)/"{Program,include,package}.js \
	  "$(path_lv)/src/_gen/scripts/program/@program@/"
	cp -vr "$(path_ui)/html/"* \
	  "$(path_lv)/src/_gen/views/scripts/quote/@program@/"
	cp -v "$(path_suppliers)/"*.js \
	  "$(path_lv)/src/node/program/rater/programs/@program@"
	test ! -d "$(path_c1map)" || cp -v "$(path_c1map)/"*.php \
	  "$(path_lv)/src/lib/c1/interfaces/c1/contract/@program@/"
	ant -f "$(path_lv)/build.xml" js-mod-order

# TODO: merge this and the above
lvroot: prepare
	mkdir -p "$(path_lvroot)/src/node/program/rater/programs/@program@"
	mkdir -p "$(path_lvroot)/src/node/program/classify"
	mkdir -p "$(path_lvroot)/src/node/program/ui/custom"
	mkdir -p "$(path_lvroot)/src/_gen/scripts/program/@program@"
	mkdir -p "$(path_lvroot)/src/_gen/views/scripts/quote/@program@"
	mkdir -p "$(path_lvroot)/src/www/scripts/program"
	mkdir -p "$(path_lvroot)/src/lib/c1/interfaces/c1/contract/@program@"
	cp -v "$(path_srv)/rater.js" \
	  "$(path_lvroot)/src/node/program/rater/programs/@program@.js"
	cp -v "$(path_suppliers)/"*.js \
	  "$(path_lvroot)/src/node/program/rater/programs/@program@"
	cp -v "$(path_ui)/package.js" \
	  "$(path_lvroot)/src/node/program/classify/@program@.js"
	cp -v "$(path_ui)/"{Program,include,package}.js \
	  "$(path_lvroot)/src/_gen/scripts/program/@program@/"
	cp -vr "$(path_ui)/html/"* \
	  "$(path_lvroot)/src/_gen/views/scripts/quote/@program@/"
	cp -v "$(path_ui)/custom.js" \
	  "$(path_lvroot)/src/www/scripts/program/@program@.js"
	cp -v "$(path_ui)/"*Ui.js \
	  "$(path_lvroot)/src/node/program/ui/custom/"
	test ! -d "$(path_c1map)" || cp -v "$(path_c1map)/"*.php \
	  "$(path_lvroot)/src/lib/c1/interfaces/c1/contract/@program@/"

intralov-root: summary-html
	mkdir -p "$(path_intralov_root)/"{rater/scripts,suppliers}
	ln -fL $(path_dsl)/summary.css "$(path_intralov_root)/rater"
	ln -fL $(path_dsl)/scripts/*.js "$(path_intralov_root)/rater/scripts/"
	ln -fL $(path_suppliers)/*.{html,js} "$(path_intralov_root)/suppliers"


# because of the crazy wildcard target below, we want to ignore
# some Automake-generated stuff
%.am:
%.m4:
%.ac:

%: prepare
	@if [[ "$@" != [Mm]akefile ]]; then \
		$(MAKE) --no-print-directory -f Makefile.2 $@; \
		$(_go); \
	fi

clean:
	$(MAKE) --no-print-directory -f Makefile.2 clean

prepare: FORCE
	@>.cqueue

test: check
check-am: standalones ui/package.js
	@$(path_dsl)/build-aux/progtest-runner $(path_suppliers) $(path_tests)
	@$(path_dsl)/build-aux/progtest-runner ui/package.xml $(path_tests)/ui

FORCE: ;