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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
|
[+ AutoGen5 template -*- Mode: Shell-script -*-
sh
+][+COMMENT use 'autogen --trace=everything melt-build-script.def' to debug this
See http://www.gnu.org/software/autogen/
+]#!/bin/bash
[+ (. (dne "#@#@# " "#@! ")) +]
# Generated shell script for MELT modules and MELT translator bootstrap
# Copyright (C) 2012-2015 Free Software Foundation
#
# This file 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.
#
#@ [+ (. (tpl-file-line))+] generated by Autogen [+ (. autogen-version)+] using [+ (.(def-file))+]
## melt-build-script.tpl generates melt-build-script.sh which may
## create meltbuild-* files and directories. The invoking makefile
## may clean these meltbuild-* things.
## Ypu may want to set the GCCMELT_BUILD_NOTIFICATION environment variable
## to a shell script called with two arguments (a title, and a message)
## e.g. using notify-send or logger in such a script.
shopt -s nullglob
[+(. (define comefromcount 0))+]
[+(. (define (fromline) (set! comefromcount (+ comefromcount 1))
(sprintf "%s/%d" (tpl-file-line "%s:%d") comefromcount)
))+]
## set the overallgoal [+(.(fromline))+]
melt_overall_goal=$1
if [ -z "$melt_overall_goal" ]; then
melt_overall_goal=gendoc
fi
## source the builtin settings [+(.(fromline))+] generated from the MELT runtime
. ./melt-build-settings.sh
## source the parameters [+(.(fromline))+]
. ./melt-build-param.sh
export GAWK=${GAWK:=gawk}
export MD5SUM=${MD5SUM:=md5sum}
## internal variables for this script [+(.(fromline))+]
## GCCMELT_STAGE is an internal variable; it keeps the current MELT stage
export GCCMELT_STAGE=""
## GCCMELT_BASE is an internal variable; it keeps the current MELT base
export GCCMELT_BASE=""
## GCCMELT_SKIPEMITC is an internal variable; it skips the emission of C++ code when non-empty
export GCCMELT_SKIPEMITC=""
date +"/*empty file for MELT build %c*/" > meltbuild-empty-file.c
[ -d meltbuild-workdir ] || mkdir meltbuild-workdir
[ -d meltbuild-tempdir ] || mkdir meltbuild-tempdir
## our error function [+(.(fromline))+]
## we are using printenv and pstree to help debugging.
function meltbuild_error () {
echo MELT BUILD SCRIPT FAILURE: $@ >&2
printf '\n\n\n\n\n\n_________________________________________________\n\n' >&2
date +"MELT BUILD Failure at %c" > _meltbuild_error.log
echo MELT BUILD SCRIPT Failure: $@ >> _meltbuild_error.log
printenv >> _meltbuild_error.log
echo >> _meltbuild_error.log
pstree -a -l -p -s $USER >> _meltbuild_error.log
echo >> _meltbuild_error.log
ls -l _meltbuild_error.log >&2
sleep 1
exit 1
}
## symbolic linking
function meltbuild_symlink () {
ln -svf `realpath $1` $2
}
## our info function
function meltbuild_info () {
echo MELT BUILD SCRIPT INFO: $@ >&2
}
## our notice function - for more important things than info
function meltbuild_notice () {
meltnotititle=$1
shift
(echo; echo; echo MELT BUILD SCRIPT NOTICE "$meltnotititle:" $@ ; echo ) >&2
if [ -n "$GCCMELT_BUILD_NOTIFICATION" ]; then
$GCCMELT_BUILD_NOTIFICATION "$meltnotititle:" "$*"
fi
}
## utility to build MELT specific arguments in meltbuild_emit
function meltbuild_arg () {
local meltarg=$1
if [ -z "$GCCMELT_IS_PLUGIN" ]; then
echo " -fmelt-$meltarg"
else
echo " -fplugin-arg-melt-$meltarg"
fi
}
if [ ! -f "$GCCMELT_RUNTIME_DEPENDENCY" ]; then
meltbuild_error [+(.(fromline))+] missing MELT runtime dependency "$GCCMELT_RUNTIME_DEPENDENCY"
fi
if [ -z "$GCCMELT_CC1PLUS" ]; then
meltbuild_error [+(.(fromline))+] missing GCCMELT_CC1PLUS
fi
## dont symlink meltrunsup.h anymore!
GCCMELT_RUNTIME_DEPENDENCY_MD5SUM=$($MD5SUM "$GCCMELT_RUNTIME_DEPENDENCY" | cut -b 1-32)
case $melt_overall_goal in
translator) ;;
library) ;;
applications) ;;
modlists) ;;
checkruntime) ;;
gendoc) ;;
regenerate) ;;
*) meltbuild_error [+(.(fromline))+] bad MELT overall goal "$melt_overall_goal:" \
expecting translator, library, applications, modlists, checkruntime, gendoc or regenerate
esac
################################################################
################ stage zero
GCCMELT_ZERO_FLAVOR=${GCCMELT_STAGE_ZERO#meltbuild-stage0-}
## The base name of the MELT translator files [+ (. (fromline))+]
GCCMELT_TRANSLATOR_BASE=([+FOR melt_translator_file " \\\n"+] [+base+][+ENDFOR melt_translator_file+] )
case $GCCMELT_ZERO_FLAVOR in
optimized) ;;
dynamic) ;;
debugnoline) ;;
quicklybuilt) ;;
*) meltbuild_error [+(.(fromline))+] bad zero flavor $GCCMELT_ZERO_FLAVOR ;;
esac
## our stage0 [+(.(fromline))+]
[ -d $GCCMELT_STAGE_ZERO ] || mkdir $GCCMELT_STAGE_ZERO
function meltbuild_do_stage_zero () {
meltbuild_notice STAGE0+ [+(.(fromline))+] starting stage zero
[+FOR melt_translator_file+]
meltbuild_info making stage0 [+base+] [+(.(fromline))+]
## stage0 [+(.(fromline))+] symlink descriptor file [+base+]
if [ ! -f "$GCCMELT_STAGE_ZERO/[+base+]+meltdesc.c" ]; then
meltbuild_symlink $GCCMELT_MELTSOURCEDIR/generated/[+base+]+meltdesc.c $GCCMELT_STAGE_ZERO/
fi
## stage0 [+(.(fromline))+] symlink melt/generated source code [+base+]
if [ ! -f "$GCCMELT_STAGE_ZERO/[+base+].cc" ]; then
meltbuild_info making stage0 [+base+] symlinking sources [+(.(fromline))+]
meltbuild_symlink $GCCMELT_MELTSOURCEDIR/generated/[+base+].cc $GCCMELT_STAGE_ZERO/
for f in $GCCMELT_MELTSOURCEDIR/generated/[+base+]+[0-9][0-9].cc ; do
meltbuild_symlink $f $GCCMELT_STAGE_ZERO/`basename $f`
done
fi
## stage0 [+(.(fromline))+] symlink stamp [+base+]
if [ ! -f "$GCCMELT_STAGE_ZERO/[+base+]+melttime.h" ]; then
meltbuild_info making stage0 [+base+] symlinking timestamp [+(.(fromline))+]
meltbuild_symlink $GCCMELT_MELTSOURCEDIR/generated/[+base+]+melttime.h $GCCMELT_STAGE_ZERO/[+base+]+melttime.h
fi
MELT_ZERO_GENERATED_[+varsuf+]_CUMULMD5=$($GAWK -F\" '/extern/{next} /melt_cumulated_hexmd5/{print $2}' $GCCMELT_MELTSOURCEDIR/generated/[+base+]+meltdesc.c)
## manually generate the stage0 [+base+]+meltbuild.mk file [+(.(fromline))+]
MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK=$GCCMELT_STAGE_ZERO/[+base+]+meltbuild.mk
date +"# file $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK script-generated %c" > $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
echo "# generated " [+(.(fromline))+] >> $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
echo "MELTGEN_MODULENAME=$GCCMELT_STAGE_ZERO/[+base+]" >> $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
echo "MELTGEN_MODULEIDENT=melt_stage_zero_[+varsuf+]" >> $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
echo '# zerostage objects of [+base+] [+(.(fromline))+]' >> $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
echo $GCCMELT_STAGE_ZERO/[+base+].$MELT_ZERO_GENERATED_[+varsuf+]_CUMULMD5.descriptor.meltpic.o: $GCCMELT_STAGE_ZERO/[+base+]+meltdesc.c >> $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
for f in $GCCMELT_STAGE_ZERO/[+base+].cc $GCCMELT_STAGE_ZERO/[+base+]+[0-9][0-9].cc; do
echo >> $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
echo $GCCMELT_STAGE_ZERO/`basename $f .cc`._NOMDFIVESUM_.$GCCMELT_ZERO_FLAVOR.meltpic.o: $f >> $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
done
echo >> $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
echo '# zerostage module of [+base+] [+(.(fromline))+]' >> $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
echo $GCCMELT_STAGE_ZERO/[+base+].meltmod-$MELT_ZERO_GENERATED_[+varsuf+]_CUMULMD5.$GCCMELT_ZERO_FLAVOR.so: \\ >> $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
echo " " $GCCMELT_STAGE_ZERO/[+base+].$MELT_ZERO_GENERATED_[+varsuf+]_CUMULMD5.descriptor.meltpic.o \\ >> $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
for f in $GCCMELT_STAGE_ZERO/[+base+]+[0-9][0-9].cc; do
echo " " $GCCMELT_STAGE_ZERO/`basename $f .cc`._NOMDFIVESUM_.$GCCMELT_ZERO_FLAVOR.meltpic.o \\ >> $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
done
echo " " $GCCMELT_STAGE_ZERO/[+base+]._NOMDFIVESUM_.$GCCMELT_ZERO_FLAVOR.meltpic.o >> $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
echo >> $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
echo MELTGENMOD_CUMULATED_MD5SUM_melt_stage_zero_[+varsuf+]=$MELT_ZERO_GENERATED_[+varsuf+]_CUMULMD5 >> $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
echo MELTGENMOD_NAKED_NAME_melt_stage_zero_[+varsuf+]=[+base+] >> $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
echo '#end of generated file ' $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK >> $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$
##
mv $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK-tmp$$ $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK
meltbuild_info [+(.(fromline))+] generated stagezero makedep $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK
ls -l $MELT_ZERO_GENERATED_[+varsuf+]_BUILDMK >&2
$GCCMELT_MAKE -f $GCCMELT_MODULE_MK melt_module \
GCCMELT_FROM=stagezero-[+(.(fromline))+] \
GCCMELT_COMPILER="$GCCMELT_COMPILER" \
GCCMELTGEN_BUILD=$GCCMELT_STAGE_ZERO/ \
GCCMELT_MODULE_WORKSPACE=meltbuild-workdir \
GCCMELT_MODULE_FLAVOR=$GCCMELT_ZERO_FLAVOR \
GCCMELT_CFLAGS="$GCCMELT_COMPILER_FLAGS" \
GCCMELT_MODULE_SOURCEBASE=$GCCMELT_STAGE_ZERO/[+base+] \
GCCMELT_CUMULATED_MD5=$MELT_ZERO_GENERATED_[+varsuf+]_CUMULMD5 \
GCCMELT_MODULE_BINARYBASE=$GCCMELT_STAGE_ZERO/[+base+] \
GCCMELT_MODULE_DEPENDENCIES="$GCCMELT_CC1PLUS_DEPENDENCIES" \
|| meltbuild_error [+(.(fromline))+] stage0 [+base+] did not build "(with $GCCMELT_MAKE -f $GCCMELT_MODULE_MK)" compiler $GCCMELT_COMPILER cflags $GCCMELT_COMPILER_FLAGS
meltbuild_info [+(.(fromline))+] stage0 [+base+] module
ls -l "$GCCMELT_STAGE_ZERO/[+base+].meltmod-$MELT_ZERO_GENERATED_[+varsuf+]_CUMULMD5.$GCCMELT_ZERO_FLAVOR.so" >&2 \
|| meltbuild_error [+(.(fromline))+] stage0 [+base+] fail to build \
"$GCCMELT_STAGE_ZERO/[+base+].meltmod-$MELT_ZERO_GENERATED_[+varsuf+]_CUMULMD5.$GCCMELT_ZERO_FLAVOR.so"
meltbuild_info [+(.(fromline))+] successfully build stage0 [+base+]
# end stage0 [+(.(fromline))+] base [+base+]
[+ENDFOR melt_translator_file+]
} ################ end of function meltbuild_do_stage_zero [+(.(fromline))+]
################################################################
## stage0 stamp file [+(.(fromline))+]
melt_stagezero_stamp=$GCCMELT_STAGE_ZERO/$GCCMELT_STAGE_ZERO.stamp
## test if stage0 should be skipped then do it [+(.(fromline))+]
if [ ! -f "$melt_stagezero_stamp" -o "$melt_stagezero_stamp" -ot "$GCCMELT_RUNTIME_DEPENDENCY" ]; then
meltbuild_do_stage_zero
melt_stagezero_stamptemp=$melt_stagezero_stamp-tmp$$
echo MELT stagezero stampfile $GCCMELT_STAGE_ZERO.stamp for MELT $MELTGCCBUILTIN_VERSION_STRING from [+(.(fromline))+] > $melt_stagezero_stamptemp
echo $GCCMELT_RUNTIME_DEPENDENCY_MD5SUM $GCCMELT_RUNTIME_DEPENDENCY >> $melt_stagezero_stamptemp
[+FOR melt_translator_file+]
# stagezero stamp [+(.(fromline))+] base [+base+]
$MD5SUM $GCCMELT_STAGE_ZERO/[+base+].cc $GCCMELT_STAGE_ZERO/[+base+]+[0-9][0-9].cc >> $melt_stagezero_stamptemp
$MD5SUM $GCCMELT_STAGE_ZERO/[+base+].meltmod-$MELT_ZERO_GENERATED_[+varsuf+]_CUMULMD5.$GCCMELT_ZERO_FLAVOR.so >> $melt_stagezero_stamptemp
[+ENDFOR melt_translator_file+]
$GCCMELT_MOVE_IF_CHANGE $melt_stagezero_stamptemp $melt_stagezero_stamp
else
meltbuild_info [+(.(fromline))+] skipped stage0 because of stamp file $melt_stagezero_stamp
fi
meltbuild_info [+(.(fromline))+] times after stagezero at `date '+%x %H:%M:%S'`: ; times >&2
################################################################
## function to run MELT to emit C++ code [+(.(fromline))+]
function meltbuild_emit () {
local meltfrom=$1
local meltmode=$2
local meltbase=$3
local meltstage=$4
local meltprevstage=$5
local meltinit=$6
local meltinclude=$7
local meltbuildoption=$8
local meltargs=$meltstage/$meltbase.args
local meltsrc=$(realpath $GCCMELT_MELTSOURCEDIR/$meltbase.melt)
meltbuild_info meltfrom=$meltfrom meltmode=$meltmode meltbase=$meltbase meltstage=$meltstage meltprevstage=$meltprevstage meltinit=$meltinit meltinclude=$meltinclude meltsrc=$meltsrc
local meltsum
local meltprevf
if [ -z "$meltmode" ]; then
meltbuild_error $meltfrom no MELT mode at stage $meltstage
fi
if [ ! -f "$meltsrc" ]; then
meltbuild_error $meltfrom no MELT file $meltsrc at stage $meltstage base $meltbase
fi
if [ -z "$meltinit" ]; then
meltbuild_error $meltfrom no MELT init at stage $meltstage base $meltbase
fi
meltsum=$($MD5SUM $meltsrc | $GAWK '{print $1}')
meltbuild_info $meltfrom emit C++ code for $meltbase of $meltstage
echo -Wno-shadow -frandom-seed=$meltsum > $meltargs-$$-tmp
## various arguments
echo " -DGCCMELT_FROM_ARG=\"$meltfrom\"" >> $meltargs-$$-tmp
meltbuild_arg mode=$meltmode >> $meltargs-$$-tmp
meltbuild_arg arg=$meltsrc >> $meltargs-$$-tmp
meltbuild_arg output=$meltstage/$meltbase >> $meltargs-$$-tmp
meltbuild_arg "module-make-command='$GCCMELT_MAKE'" >> $meltargs-$$-tmp
meltbuild_arg module-makefile=$GCCMELT_MODULE_MK >> $meltargs-$$-tmp
meltbuild_arg "module-cflags='$GCCMELT_INCLUDES -I. -I$meltstage -I$meltprevstage $GCCMELT_COMPILER_FLAGS'" >> $meltargs-$$-tmp
meltbuild_arg init=$meltinit >> $meltargs-$$-tmp
meltbuild_arg workdir=meltbuild-workdir >> $meltargs-$$-tmp
meltbuild_arg tempdir=meltbuild-tempdir >> $meltargs-$$-tmp
meltbuild_arg source-path=$meltstage:$meltprevstage:. >> $meltargs-$$-tmp
meltbuild_arg module-path=$meltstage:$meltprevstage:. >> $meltargs-$$-tmp
meltbuild_arg bootstrapping >> $meltargs-$$-tmp
meltbuild_arg generate-work-link >> $meltargs-$$-tmp
meltbuild_arg generated-c-file-list=$meltstage/$meltbase.cfilist >> $meltargs-$$-tmp
if [ -n "$meltbuildoption" ]; then
echo "$meltbuildoption" >> $meltargs-$$-tmp
fi
## final empty file
echo meltbuild-empty-file.c >> $meltargs-$$-tmp
mv $meltargs-$$-tmp $meltargs
meltbuild_info $meltfrom argument file $meltargs is
cat $meltargs < /dev/null >&2
if [ -z "$GCCMELT_SKIPEMITC" ]; then
$GCCMELT_CC1PLUS_PREFIX $GCCMELT_CC1PLUS @$meltargs || meltbuild_error $meltfrom failed with arguments @$meltargs
## remove obsolete secondary C files left previously in $meltstage
for meltcsecfil in $meltstage/$meltbase+[0-9][0-9].cc ; do
if grep -q `basename $meltcsecfil` "$meltstage/$meltbase.cfilist" ; then
: # at [+(.(fromline))+]
else
meltbuild_info $meltfrom removing obsolete $meltcsecfil
rm -f "$meltcsecfil"
fi
done
else
meltbuild_info $meltfrom skips emission of C++ code with @$meltargs stage $meltstage prevstage $meltprevstage skipreason $GCCMELT_SKIPEMITC [+(.(fromline))+]
ls -l $meltprevstage/$meltbase*
meltbuild_info $meltfrom symlinking previous stage $meltprevstage [+(.(fromline))+]
for meltprevf in $meltprevstage/$meltbase.cc $meltprevstage/$meltbase+[0-9][0-9].cc $meltprevstage/$meltbase+meltdesc.c $meltprevstage/$meltbase+melttime.h $meltprevstage/$meltbase+meltbuild.mk ; do
meltbuild_symlink $meltprevf $meltstage/`basename $meltprevf`
done
meltbuild_info $meltfrom symlinked previous stage $meltprevstage/$meltbase [+(.(fromline))+]
fi
GCCMELT_STAGE=$meltstage
GCCMELT_BASE=$meltbase
} ################################ end function meltbuild_emit
################################################################
################################################################
#################@ before our stages [+(.(fromline))+]
### Our stages [+FOR melt_stage " "+][+stagdir+][+ENDFOR meltstage+]
### are incrementally built, with the former modules of
### the current stage and the later modules of the previous stages
### used to emit the source of the current module in the current stage.
### This is a kind of "diagonalization".
################################################################
#### function to do a stage [+(.(fromline))+]
function meltbuild_do_stage () {
local meltfrom=$1
local meltcurstagedir=$2
local meltcurflavor=$3
local meltprevstagedir=$4
local meltprevflavor=$5
local meltbuildoption=$6
[+FOR melt_translator_file+]
local meltchecksum_[+varsuf+]
[+ENDFOR melt_translator_file+]
local meltstamp
local meltstamptmp
####in meltbuild_do_stage [+(.(fromline))+]
meltbuild_notice "$meltcurstagedir+" starting stage $meltcurstagedir flavor $meltcurflavor from $meltfrom
####in meltbuild_do_stage [+(.(fromline))+]
meltbuild_info $meltfrom starting stage $meltcurstagedir flavor $meltcurflavor previous $meltprevstagedir previous flavor $meltprevflavor
[ -d $meltcurstagedir ] || mkdir $meltcurstagedir
if [ ! -d "$meltprevstagedir" -o ! -f "$meltprevstagedir/$meltprevstagedir.stamp" ]; then
meltbuild_error $meltfrom previous stage "$meltprevstagedir/" without stamp file $meltprevstagedir/$meltprevstagedir.stamp
fi
[+FOR melt_translator_file+][+
(define outbase (get "base")) (define outindex (for-index)) +]
#in meltbuild_do_stage [+(.(fromline))+] base [+base+]
meltbuild_info [+(.(fromline))+] from $meltfrom generating C++ code of [+base+] in $meltcurstagedir
#in meltbuild_do_stage [+(.(fromline))+] emit C++ code for [+base+]
meltbuild_emit [+(.(fromline))+]-$meltfrom \
[+IF (= outindex 0)+]translateinit[+ELSE+]translatefile[+ENDIF+] \
[+base+] \
"$meltcurstagedir" \
"$meltprevstagedir" \
[+FOR melt_translator_file ":"+][+
(define inindex (for-index))
(define depstage (if (< inindex outindex) "$meltcurstagedir" "$meltprevstagedir"))
(define depflavor (if (< inindex outindex) "$meltcurflavor" "$meltprevflavor"))
+][+(. depstage)+]/[+base+].[+ (. depflavor)+][+ENDFOR melt_translator_file+] \
"[+FOR includeload " "+][+includeload+][+ENDFOR includeload+]" \
"$meltbuildoption"
#in meltbuild_do_stage [+(.(fromline))+] checksum C++ code for [+base+]
meltchecksum_cumul_[+varsuf+]=$(cat "$meltcurstagedir"/[+base+].cc "$meltcurstagedir"/[+base+]+[0-9][0-9].cc | $MD5SUM | cut -b 1-32)
#in meltbuild_do_stage [+(.(fromline))+] perhaps compiling C++ code for [+base+]
if [ -z "$GCCMELT_SKIPEMITC" ]; then
meltbuild_info [+(.(fromline))+]-$meltfrom compiling module [+base+] in "$meltcurstagedir"
$GCCMELT_MAKE -f $GCCMELT_MODULE_MK melt_module \
GCCMELT_FROM="[+(.(fromline))+]-$meltfrom" \
GCCMELT_MODULE_WORKSPACE=meltbuild-workdir \
GCCMELT_MODULE_FLAVOR="$meltcurflavor" \
GCCMELT_COMPILER="$GCCMELT_COMPILER" \
GCCMELT_CFLAGS="$GCCMELT_COMPILER_FLAGS" \
GCCMELT_MODULE_SOURCEBASE="$meltcurstagedir/[+base+]" \
GCCMELT_MODULE_BINARYBASE="$meltcurstagedir/[+base+]" \
|| ( meltbuild_info [+(.(fromline))+]-$meltfrom recompiling bad module [+base+] in "$meltcurstagedir" ; \
$GCCMELT_MAKE -f $GCCMELT_MODULE_MK melt_module \
GCCMELT_FROM="[+(.(fromline))+]-$meltfrom" \
GCCMELT_MODULE_WORKSPACE=meltbuild-workdir \
GCCMELT_MODULE_FLAVOR="$meltcurflavor" \
GCCMELT_COMPILER="$GCCMELT_COMPILER" \
GCCMELT_CFLAGS="$GCCMELT_COMPILER_FLAGS -DMELTGCC_NOLINENUMBERING" \
GCCMELT_MODULE_SOURCEBASE="$meltcurstagedir/[+base+]" \
GCCMELT_MODULE_BINARYBASE="$meltcurstagedir/[+base+]" ; \
meltbuild_error [+(.(fromline))+]-$meltfrom in "$meltcurstagedir/" \
failed to make "($GCCMELT_MAKE -f $GCCMELT_MODULE_MK)" module [+base+] compiler "$GCCMELT_COMPILER" cflags "$GCCMELT_COMPILER_FLAGS" )
else
meltbuild_info [+(.(fromline))+]-$meltfrom NOT compiling module [+base+] "in" \
"$meltcurstagedir/" but symlinking previous "$meltprevstagedir/" module [+base+] \
checksum $meltchecksum_cumul_[+varsuf+] skipemitc=$GCCMELT_SKIPEMITC.
meltbuild_symlink "$meltprevstagedir/[+base+].meltmod-$meltchecksum_cumul_[+varsuf+].$meltprevflavor.so" \
"$meltcurstagedir/[+base+].meltmod-$meltchecksum_cumul_[+varsuf+].$meltcurflavor.so"
fi
#in meltbuild_do_stage [+(.(fromline))+] done base [+base+]
[+ENDFOR melt_translator_file+]
#in meltbuild_do_stage [+(.(fromline))+] generating the stampfile
meltstamp=$meltcurstagedir/$meltcurstagedir.stamp
meltstamptmp=$meltstamp-tmp$$
echo "///timestamp file $meltstamp" > $meltstamptmp
echo $GCCMELT_RUNTIME_DEPENDENCY_MD5SUM $GCCMELT_RUNTIME_DEPENDENCY >> $meltstamptmp
[+FOR melt_translator_file+]
$MD5SUM $meltcurstagedir/[+base+].cc $meltcurstagedir/[+base+]+[0-9][0-9].cc >> $meltstamptmp
$MD5SUM "$meltcurstagedir/[+base+].meltmod-$meltchecksum_cumul_[+varsuf+].$meltcurflavor.so" >> $meltstamptmp
[+ENDFOR melt_translator_file+]
echo "///end timestamp file $meltstamp"
$GCCMELT_MOVE_IF_CHANGE $meltstamptmp $meltstamp
#in meltbuild_do_stage [+(.(fromline))+] ending
meltbuild_info $meltfrom done stage $meltcurstagedir flavor $meltcurflavor previous $meltprevstagedir previous flavor $meltprevflavor timestamp $meltstamp
} #### end meltbuild_do_stage [+(.(fromline))+]
################################################################
##### possibly run all our stages [+(.(fromline))+]
[+FOR melt_build_stage+]
#@ [+(.(fromline))+] stagedir [+stagdir+]
GCCMELT_SKIPEMITC=
if [ ! -f [+stagdir+]/[+stagdir+].stamp -o [+stagdir+]/[+stagdir+].stamp -ot $GCCMELT_RUNTIME_DEPENDENCY \
[+FOR melt_translator_file+] -o [+stagdir+]/[+stagdir+].stamp -ot $GCCMELT_MELTSOURCEDIR/[+base+].melt \
[+ENDFOR melt_translator_file+] ]; then
echo ; echo ; echo ; echo ; echo ; echo ; echo ; echo
echo '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
meltbuild_info [+(.(fromline))+] '++++++++++++++++' building stage [+stagdir+] '++++++++++++++++'
## building stage [+stagdir+] previous [+stagprevdir+] [+(.(fromline))+]
meltbuild_do_stage [+(.(fromline))+] [+stagdir+] quicklybuilt [+stagprevdir+] [+stagprevflavor+] "$GCCMELT_EMIT_OPTION_[+stagsuf+]"
else
meltbuild_info [+(.(fromline))+] skipping stage [+stagdir+]
fi
## [+(.(fromline))+]
GCCMELT_LASTSTAGE=[+stagdir+]
[+ENDFOR melt_build_stage+]
################################################################
meltbuild_info [+(.(fromline))+] last stage $GCCMELT_LASTSTAGE
################################################################
################################################################
###########@ before generating meltbuild-sources [+(.(fromline))+]
#### the meltbuild-sources is the final sources directory, to be
#### installed. They are generated from the last stage, using the
#### modules inside it. Notice that in contrast from the intermediate
#### stages no "diagonalization" is involved.
[ -d meltbuild-sources ] || mkdir meltbuild-sources
#@ from [+(.(fromline))+] compiling the modules
[ -d meltbuild-modules ] || mkdir meltbuild-modules
################################################################
function meltbuild_emit_translator_sources () {
[+FOR melt_translator_file+]
## meltbuild_emit_source [+(.(fromline))+] base [+base+]
meltbuild_info [+(.(fromline))+] generating C++ code of [+base+] in meltbuild-sources
meltbuild_emit [+(.(fromline))+] \
[+IF (= (for-index) 0)+]translateinit[+ELSE+]translatefile[+ENDIF+] \
[+base+] \
meltbuild-sources \
"$GCCMELT_LASTSTAGE" \
[+FOR melt_translator_file ":"+]$GCCMELT_LASTSTAGE/[+base+].quicklybuilt[+ENDFOR melt_translator_file+] \
"[+FOR includeload " "+][+includeload+][+ENDFOR includeload+]"
[+ENDFOR melt_translator_file+]
} # end of function meltbuild_emit_translator_sources
################
function meltbuild_compile_translator_modules () {
[+FOR flavor IN quicklybuilt optimized debugnoline+]
# in meltbuild_compile_translator_sources [+flavor+] [+(.(fromline))+]
meltbuild_info [+(.(fromline))+] compiling translator [+flavor+]
[+FOR melt_translator_file+]
#@ [+(.(fromline))+] flavor [+flavor+] base [+base+]
$GCCMELT_MAKE -f $GCCMELT_MODULE_MK melt_module \
GCCMELT_FROM=[+(.(fromline))+] \
GCCMELT_MODULE_WORKSPACE=meltbuild-workdir \
GCCMELT_MODULE_FLAVOR=[+flavor+] \
GCCMELT_COMPILER="$GCCMELT_COMPILER" \
GCCMELT_CFLAGS="$GCCMELT_COMPILER_FLAGS" \
GCCMELT_MODULE_SOURCEBASE=meltbuild-sources/[+base+] \
GCCMELT_MODULE_BINARYBASE=meltbuild-modules/[+base+] \
|| meltbuild_error [+(.(fromline))+] in meltbuild-modules failed to compile translator [+base+] [+flavor+] make "($GCCMELT_MAKE -f $GCCMELT_MODULE_MK)" compiler "$GCCMELT_COMPILER" cflags $GCCMELT_COMPILER_FLAGS
[+ENDFOR melt_translator_file+]
[+ENDFOR flavor+]
} # end of function meltbuild_compile_translator_modules
################################################################
#################@ [+(.(fromline))+]
function meltbuild_symlink_melt_translator_sources () {
[+FOR melt_translator_file+][+
(define outbase (get "base")) (define outindex (for-index)) +]
### symlinking the MELT translator code in meltbuild-sources for [+base+] from [+ (. (fromline))+]
meltbuild_info [+(.(fromline))+] putting MELT translator code of [+base+] in meltbuild-sources
meltbuild_symlink $GCCMELT_MELTSOURCEDIR/[+base+].melt meltbuild-sources/[+base+].melt
[+FOR includeload "\n"+]meltbuild_symlink [+includeload+] meltbuild-sources/[+includeload+][+ENDFOR includeload+]
[+ENDFOR melt_translator_file+]
} # end of meltbuild_symlink_melt_translator_sources
################@ final translator [+(.(fromline))+]
melt_final_translator_stamp=meltbuild-final-translator.stamp
if [ ! -f $melt_final_translator_stamp -o $melt_final_translator_stamp -ot $GCCMELT_RUNTIME_DEPENDENCY \
[+FOR melt_translator_file+] -o $melt_final_translator_stamp -ot $GCCMELT_MELTSOURCEDIR/[+base+].melt \
[+ENDFOR melt_translator_file+] -o $melt_final_translator_stamp -ot $GCCMELT_LASTSTAGE/$GCCMELT_LASTSTAGE.stamp ]; then
meltbuild_notice 'Emit Translator Source' [+(.(fromline))+] emit then translate the MELT translator
meltbuild_info [+(.(fromline))+] emit then translate the compile translator for $melt_final_translator_stamp
meltbuild_emit_translator_sources
meltbuild_symlink_melt_translator_sources
meltbuild_compile_translator_modules
melt_final_translator_stamptemp=$melt_final_translator_stamp-tmp$$
echo "///MELT translator timestamp file $melt_final_translator_stamp" > $melt_final_translator_stamptemp
echo $GCCMELT_RUNTIME_DEPENDENCY_MD5SUM $GCCMELT_RUNTIME_DEPENDENCY >> $melt_final_translator_stamptemp
[+FOR melt_translator_file+]
#@ [+(.(fromline))+]
$MD5SUM meltbuild-sources/[+base+].melt >> $melt_final_translator_stamptemp
[+FOR includeload+]
$MD5SUM meltbuild-sources/[+includeload+] >> $melt_final_translator_stamptemp
[+ENDFOR includeload+]
$MD5SUM meltbuild-sources/[+base+].cc meltbuild-sources/[+base+]+[0-9][0-9].cc >> $melt_final_translator_stamptemp
melt_translator_[+varsuf+]_cumulmd5=$(cat meltbuild-sources/[+base+].cc meltbuild-sources/[+base+]+[0-9][0-9].cc | $MD5SUM | cut -b 1-32)
[+ENDFOR melt_translator_file+]
echo "///end timestamp file $melt_final_translator_stamp"
$GCCMELT_MOVE_IF_CHANGE $melt_final_translator_stamptemp $melt_final_translator_stamp
else
meltbuild_info [+(.(fromline))+] skip final translation of translator stamp $melt_final_translator_stamp
fi
################################################################
#@ [+(.(fromline))+] making the meltbuild-common.args file to make life easier
# I would often use that meltbuild-common.args for testing, etc.
meltcommon_args=meltbuild-common.args
meltbuild_info [+(.(fromline))+] making $meltcommon_args
meltcommon_argstemp=$meltcommon_args-tmp$$
echo ' -DGCCMELT_FROM_ARG="[+(.(fromline))+]"' > $meltcommon_argstemp
meltbuild_arg workdir=meltbuild-workdir >> $meltcommon_argstemp
meltbuild_arg tempdir=meltbuild-tempdir >> $meltcommon_argstemp
meltbuild_arg source-path=meltbuild-sources:$GCCMELT_LASTSTAGE >> $meltcommon_argstemp
meltbuild_arg module-path=meltbuild-modules:$GCCMELT_LASTSTAGE >> $meltcommon_argstemp
meltbuild_arg "module-cflags=\"$GCCMELT_COMPILER_FLAGS\"" >> $meltcommon_argstemp
meltbuild_arg "module-makefile=\"$GCCMELT_MODULE_MK\"" >> $meltcommon_argstemp
$GCCMELT_MOVE_IF_CHANGE $meltcommon_argstemp $meltcommon_args
meltbuild_info [+(.(fromline))+] $meltcommon_args is
cat $meltcommon_args < /dev/null >&2
################
### the warmelt modules lists [+(.(fromline))+]
[+FOR flavor in quicklybuilt optimized debugnoline+]
if [ ! -f meltbuild-sources/warmelt.[+flavor+].modlis \
-o meltbuild-sources/warmelt.[+flavor+].modlis -ot "$melt_final_translator_stamp" ]; then
# [+ (. (fromline))+] warmelt module list [+flavor+]
melt_modlis_temp="meltbuild-sources/warmelt.[+flavor+].modlis-tmp$$"
echo "# MELT translator modules:" >> $melt_modlis_temp
[+FOR melt_translator_file+]
echo [+base+].[+flavor+] >> $melt_modlis_temp
[+ENDFOR melt_translator_file+]
$GCCMELT_MOVE_IF_CHANGE $melt_modlis_temp "meltbuild-sources/warmelt.[+flavor+].modlis"
fi
[+ENDFOR flavor+]
################################################################
#@ [+(.(fromline))+]
if [ "$melt_overall_goal" = "translator" ]; then
meltbuild_info [+(.(fromline))+] done translation overall goal with stamp $melt_final_translator_stamp
exit 0
fi
################################################################
################################################################
### the warmelt modules lists [+ (. (fromline))+]
[+FOR flavor in quicklybuilt optimized debugnoline+]
if [ ! -f "meltbuild-sources/warmelt.[+flavor+].modlis" \
-o "meltbuild-sources/warmelt.[+flavor+].modlis" -ot $melt_final_translator_stamp ]; then
# [+ (. (fromline))+] warmelt module list [+flavor+]
meltbuild_info [+(.(fromline))+] generating warmelt module list "meltbuild-sources/warmelt.[+flavor+].modlis"
melt_modlis_temp="meltbuild-sources/warmelt.[+flavor+].modlis-tmp$$"
echo "# MELT module list file warmelt.[+flavor+].modlis" >> $melt_modlis_temp
echo "# MELT translator modules:" >> $melt_modlis_temp
[+FOR melt_translator_file+]
echo [+base+].[+flavor+] >> $melt_modlis_temp
[+ENDFOR melt_translator_file+]
#@ [+ (. (fromline))+]
$GCCMELT_MOVE_IF_CHANGE $melt_modlis_temp "meltbuild-sources/warmelt.[+flavor+].modlis"
else
meltbuild_info [+(.(fromline))+] keeping warmelt module list "meltbuild-sources/warmelt.[+flavor+].modlis"
fi
[+ENDFOR flavor+]
################################################################
################################################################
######################### REGENERATION #########################
#@ [+(.(fromline))+]
if [ "$melt_overall_goal" = "regenerate" ]; then
meltbuild_notice regenerating runtime support [+(.(fromline))+]
[ -d meltbuild-sources/generated ] || mkdir meltbuild-sources/generated
meltregen_args=meltbuild-regen.args
meltregen_argstemp="$meltregen_args-tmp$$"
echo ' -DGCCMELT_REGENERATING -DGCCMELT_FROM_ARG="[+(.(fromline))+]"' > $meltregen_argstemp
meltbuild_arg mode=runtypesupport >> $meltregen_argstemp
meltbuild_arg output=meltbuild-sources/generated/meltrunsup >> $meltregen_argstemp
meltbuild_arg workdir=meltbuild-workdir >> $meltregen_argstemp
meltbuild_arg tempdir=meltbuild-tempdir >> $meltregen_argstemp
meltbuild_arg source-path=meltbuild-sources >> $meltregen_argstemp
meltbuild_arg init=@warmelt.quicklybuilt >> $meltregen_argstemp
meltbuild_arg bootstrapping >> $meltregen_argstemp
echo meltbuild-empty-file.c >> $meltregen_argstemp
$GCCMELT_MOVE_IF_CHANGE $meltregen_argstemp $meltregen_args
meltbuild_info [+(.(fromline))+] $meltregen_args is
cat $meltregen_args < /dev/null >&2
$GCCMELT_CC1PLUS_PREFIX $GCCMELT_CC1PLUS @$meltregen_args \
|| meltbuild_error [+(.(fromline))+] failed with arguments @$meltregen_args
meltbuild_info [+(.(fromline))+] done regenerate overall goal
exit 0
fi
################################################################
################################################################
########################### LIBRARY ############################
################
#@ [+(.(fromline))+] before library libmelt* modules
################################################################
meltbuild_info [+(.(fromline))+] before library GCCMELT_SKIPEMITC=$GCCMELT_SKIPEMITC.
meltbuild_info [+(.(fromline))+] times before library at `date '+%x %H:%M:%S'`: ; times >&2
melt_final_library_stamp=meltbuild-final-library.stamp
function meltbuild_do_library () {
meltbuild_notice 'start doing library' [+(.(fromline))+] doing library
[+FOR melt_library_file+]
[+ (define apbase (get "base")) (define apindex (for-index)) +]
## meltbuild_do_library [+base+] [+(.(fromline))+]
meltbuild_info [+(.(fromline))+] doing library [+base+]
if [ ! -f meltbuild-sources/[+base+].melt ]; then
meltbuild_symlink $GCCMELT_MELTSOURCEDIR/[+base+].melt meltbuild-sources/[+base+].melt
fi
## meltbuild_do_library [+base+] [+(.(fromline))+]
if [ ! -f meltbuild-sources/[+base+].cc -o ! -f meltbuild-sources/[+base+]+meltdesc.c \
-o meltbuild-sources/[+base+]+meltdesc.c -ot meltbuild-final-translator.stamp \
-o meltbuild-sources/[+base+]+meltdesc.c -ot meltbuild-sources/[+base+].melt \
[+FOR melt_library_file+][+IF (< (for-index) apindex)+] -o meltbuild-sources/[+base+]+meltdesc.c -ot meltbuild-sources/[+(. apbase)+]+meltdesc.c \
[+ENDIF+][+ENDFOR melt_library_file+] ]; then
meltbuild_info [+(.(fromline))+] emit library C++ code for [+base+]
meltbuild_emit [+(.(fromline))+] \
translatefile \
[+base+] \
meltbuild-sources \
meltbuild-modules \
[+FOR melt_translator_file ":"+][+base+].optimized[+ENDFOR melt_translator_file+][+FOR melt_library_file+][+IF (< (for-index) apindex)+]:[+base+].quicklybuilt[+ENDIF+][+ENDFOR melt_library_file+] \
"[+FOR includeload " "+][+includeload+][+ENDFOR includeload+]" \
|| meltbuild_error [+(.(fromline))+] failed to generate C++ code of library [+base+]
else
meltbuild_info [+(.(fromline))+] DONT emit library C++ code for [+base+]
fi
local meltlib_[+varsuf+]_cumulmd5=$(cat meltbuild-sources/[+base+].cc meltbuild-sources/[+base+]+[0-9][0-9].cc | $MD5SUM | cut -b 1-32)
[+FOR flavor IN quicklybuilt optimized debugnoline+]
if [ ! -f meltbuild-modules/[+base+].meltmod-$meltlib_[+varsuf+]_cumulmd5.[+flavor+].so \
-o meltbuild-modules/[+base+].meltmod-$meltlib_[+varsuf+]_cumulmd5.[+flavor+].so -ot meltbuild-final-translator.stamp \
-o meltbuild-modules/[+base+].meltmod-$meltlib_[+varsuf+]_cumulmd5.[+flavor+].so -ot meltbuild-sources/[+base+].cc \
-o meltbuild-modules/[+base+].meltmod-$meltlib_[+varsuf+]_cumulmd5.[+flavor+].so -ot meltbuild-sources/[+base+]+meltdesc.c ]; then
meltbuild_info [+(.(fromline))+] compiling library module for [+base+] [+flavor+]
$GCCMELT_MAKE -f $GCCMELT_MODULE_MK melt_module \
GCCMELT_FROM=[+(.(fromline))+] \
GCCMELT_MODULE_WORKSPACE=meltbuild-workdir \
GCCMELT_MODULE_FLAVOR=[+flavor+] \
GCCMELT_COMPILER="$GCCMELT_COMPILER" \
GCCMELT_CFLAGS="$GCCMELT_COMPILER_FLAGS" \
GCCMELT_MODULE_SOURCEBASE=meltbuild-sources/[+base+] \
GCCMELT_MODULE_BINARYBASE=meltbuild-modules/[+base+] \
|| ( meltbuild_notice [+(.(fromline))+] in meltbuild-modules failure to compile library [+base+] [+flavor+] ; \
$GCCMELT_MAKE -f $GCCMELT_MODULE_MK melt_module \
GCCMELT_FROM=[+(.(fromline))+] \
GCCMELT_MODULE_WORKSPACE=meltbuild-workdir \
GCCMELT_MODULE_FLAVOR=[+flavor+] \
GCCMELT_COMPILER="$GCCMELT_COMPILER" \
GCCMELT_CFLAGS="$GCCMELT_COMPILER_FLAGS -DMELTGCC_NOLINENUMBERING" \
GCCMELT_MODULE_SOURCEBASE=meltbuild-sources/[+base+] \
GCCMELT_MODULE_BINARYBASE=meltbuild-modules/[+base+] ; \
meltbuild_error [+(.(fromline))+] in meltbuild-modules failed to compile library [+base+] [+flavor+] \
"($GCCMELT_MAKE -f $GCCMELT_MODULE_MK)" compiler $GCCMELT_COMPILER_FLAGS cflags $GCCMELT_COMPILER_FLAGS )
else
meltbuild_info [+(.(fromline))+] not compiling library module for [+base+] [+flavor+]
fi
[+ENDFOR flavor+]
[+ENDFOR melt_library_file+]
## meltbuild_do_library [+base+] [+(.(fromline))+]
local meltlibstamptemp=$melt_final_library_stamp-tmp$$
echo "///MELT library time stamp $melt_final_library_stamp" > $meltlibstamptemp
echo $GCCMELT_RUNTIME_DEPENDENCY_MD5SUM $GCCMELT_RUNTIME_DEPENDENCY >> $meltlibstamptemp
[+FOR melt_library_file+]
$MD5SUM meltbuild-sources/[+base+].melt >> $meltlibstamptemp
$MD5SUM meltbuild-sources/[+base+].cc meltbuild-sources/[+base+]+[0-9][0-9].cc >> $meltlibstamptemp
[+FOR flavor IN quicklybuilt optimized debugnoline+]
$MD5SUM meltbuild-modules/[+base+].meltmod-$meltlib_[+varsuf+]_cumulmd5.[+flavor+].so >> $meltlibstamptemp
[+ENDFOR flavor+]
[+ENDFOR melt_library_file+]
echo "///end stamp $melt_final_library_stamp" >> $meltlibstamptemp
$GCCMELT_MOVE_IF_CHANGE $meltlibstamptemp $melt_final_library_stamp
meltbuild_info [+(.(fromline))+] times after library at `date '+%x %H:%M:%S'`: ; times >&2
} ## end function meltbuild_do_library [+(.(fromline))+]
function meltbuild_do_an_extra () {
xtrabase=$1
meltbuild_notice 'start doing an extra' [+(.(fromline))+] doing an xtra $xtrabase
if [ ! -f meltbuild-sources/$xtrabase.melt ]; then
meltbuild_symlink $GCCMELT_MELTSOURCEDIR/$xtrabase.melt meltbuild-sources/$xtrabase.melt
fi
if [ ! -f meltbuild-sources/$xtrabase.cc -o ! -f meltbuild-sources/$xtrabase+meltdesc.c \
-o meltbuild-sources/$xtrabase+meltdesc.c -ot meltbuild-final-translator.stamp \
-o meltbuild-sources/$xtrabase+meltdesc.c -ot meltbuild-final-library.stamp \
-o meltbuild-sources/$xtrabase+meltdesc.c -ot meltbuild-sources/$xtrabase.melt \
] ; then
meltbuild_info [+(.(fromline))+] emit extra C++ code for $xtrabase
meltbuild_emit [+(.(fromline))+] \
translatefile \
$xtrabase \
meltbuild-sources \
meltbuild-modules \
[+FOR melt_translator_file ":"+][+base+].optimized[+ENDFOR melt_translator_file+][+FOR melt_library_file+]:[+base+].quicklybuilt[+ENDFOR melt_library_file+] \
"[+FOR includeload " "+][+includeload+][+ENDFOR includeload+]" \
|| meltbuild_error [+(.(fromline))+] failed to generate C++ code of $xtrabase
else
meltbuild_info [+(.(fromline))+] DONT emit extra C++ code for $xtrabase
fi
[+FOR flavor IN quicklybuilt optimized debugnoline+]
# do_an_extra flavor [+flavor+] [+(.(fromline))+]
if [ ! -f meltbuild-modules/$xtrabase.meltmod-$meltlib_[+varsuf+]_cumulmd5.[+flavor+].so \
-o meltbuild-modules/$xtrabase.meltmod-$meltlib_[+varsuf+]_cumulmd5.[+flavor+].so -ot meltbuild-final-translator.stamp \
-o meltbuild-modules/$xtrabase.meltmod-$meltlib_[+varsuf+]_cumulmd5.[+flavor+].so -ot meltbuild-sources/$xtrabase.cc \
-o meltbuild-modules/$xtrabase.meltmod-$meltlib_[+varsuf+]_cumulmd5.[+flavor+].so -ot meltbuild-sources/$xtrabase+meltdesc.c ]; then
meltbuild_info [+(.(fromline))+] compiling extra module for $xtrabase [+flavor+]
$GCCMELT_MAKE -f $GCCMELT_MODULE_MK melt_module \
GCCMELT_FROM=[+(.(fromline))+] \
GCCMELT_MODULE_WORKSPACE=meltbuild-workdir \
GCCMELT_MODULE_FLAVOR=[+flavor+] \
GCCMELT_COMPILER="$GCCMELT_COMPILER" \
GCCMELT_CFLAGS="$GCCMELT_COMPILER_FLAGS" \
GCCMELT_MODULE_SOURCEBASE=meltbuild-sources/$xtrabase \
GCCMELT_MODULE_BINARYBASE=meltbuild-modules/$xtrabase \
|| ( meltbuild_notice [+(.(fromline))+] in meltbuild-modules failure to compile extra $xtrabase [+flavor+] ; \
$GCCMELT_MAKE -f $GCCMELT_MODULE_MK melt_module \
GCCMELT_FROM=[+(.(fromline))+] \
GCCMELT_MODULE_WORKSPACE=meltbuild-workdir \
GCCMELT_MODULE_FLAVOR=[+flavor+] \
GCCMELT_COMPILER="$GCCMELT_COMPILER" \
GCCMELT_CFLAGS="$GCCMELT_COMPILER_FLAGS -DMELTGCC_NOLINENUMBERING" \
GCCMELT_MODULE_SOURCEBASE=meltbuild-sources/$xtrabase \
GCCMELT_MODULE_BINARYBASE=meltbuild-modules/$xtrabase ; \
meltbuild_error [+(.(fromline))+] in meltbuild-modules failed to compile library $xtrabase [+flavor+] \
"($GCCMELT_MAKE -f $GCCMELT_MODULE_MK)" compiler $GCCMELT_COMPILER_FLAGS cflags $GCCMELT_COMPILER_FLAGS )
else
meltbuild_info [+(.(fromline))+] not compiling extra module for $xtrabase [+flavor+]
fi
[+ENDFOR flavor+]
} ## end function meltbuild_do_an_extra
if [ ! -f "$melt_final_library_stamp" \
-o "$melt_final_library_stamp" -ot "$melt_final_translator_stamp" \
[+FOR melt_library_file+] -o "$melt_final_library_stamp" -ot "$GCCMELT_MELTSOURCEDIR/[+base+].melt" \
[+ENDFOR melt_library_file+] ]; then
meltbuild_info [+(.(fromline))+] building MELT library
meltbuild_do_library
[+FOR melt_extra_file+]
## do an extra [+base+] [+(.(fromline))+]
meltbuild_do_an_extra [+base+]
[+ENDFOR melt_extra_file+]
else
meltbuild_info [+(.(fromline))+] not building MELT library because of libstamp "$melt_final_library_stamp"
fi
################################################################
#@ [+(.(fromline))+]
if [ "$melt_overall_goal" = "library" ]; then
meltbuild_info [+(.(fromline))+] done library overall goal with stamp $melt_final_translator_stamp
meltbuild_notice 'Done library' [+(.(fromline))+] library overall goal
exit 0
fi
################################################################
################################################################
### the modules lists [+ (. (fromline))+]
[+FOR flavor in quicklybuilt optimized debugnoline+]
if [ ! -f "meltbuild-sources/$MELTGCCBUILTIN_DEFAULT_MODLIS.[+flavor+].modlis" \
-o "meltbuild-sources/$MELTGCCBUILTIN_DEFAULT_MODLIS.[+flavor+].modlis" -ot $melt_final_translator_stamp \
-o "meltbuild-sources/$MELTGCCBUILTIN_DEFAULT_MODLIS.[+flavor+].modlis" -ot $melt_final_library_stamp ]; then
# [+ (. (fromline))+] module list [+flavor+]
meltbuild_info [+(.(fromline))+] generating module list "meltbuild-sources/$MELTGCCBUILTIN_DEFAULT_MODLIS.[+flavor+].modlis"
melt_modlis_temp="meltbuild-sources/$MELTGCCBUILTIN_DEFAULT_MODLIS.[+flavor+].modlis-tmp$$"
echo "# MELT module list file $MELTGCCBUILTIN_DEFAULT_MODLIS.[+flavor+].modlis" >> $melt_modlis_temp
echo "# MELT translator modules:" >> $melt_modlis_temp
# [+ (. (fromline))+] module list [+flavor+] translator
[+FOR melt_translator_file+]
echo [+base+].[+flavor+] >> $melt_modlis_temp
[+ENDFOR melt_translator_file+]
# [+ (. (fromline))+] module list [+flavor+] library
echo "# MELT library modules:" >> $melt_modlis_temp
[+FOR melt_library_file+]
echo [+base+].[+flavor+] >> $melt_modlis_temp
[+ENDFOR melt_library_file+]
# [+ (. (fromline))+] module list [+flavor+] extra, with mode condition
echo "# MELT extra modules with mode condition:" >> $melt_modlis_temp
[+FOR melt_extra_file+]
printf '# MELT extra module [+base+]\n' >> $melt_modlis_temp
[ -s meltbuild-sources/[+base+].melt ] || meltbuild_error [+(.(fromline))+] missing or empty meltbuild-sources/[+base+].melt
$GAWK '-F\"' '/\(install_melt_mode /{if (length($2)>1) {nbmod++;printf("?%s [+base+].[+flavor+]\n", $2);}} END{printf("# %d MELT modes in [+base+]\n", nbmod);}' meltbuild-sources/[+base+].melt | sort -u >> $melt_modlis_temp
[+ENDFOR melt_extra_file+]
echo "# end MELT module list $MELTGCCBUILTIN_DEFAULT_MODLIS.[+flavor+].modlis" >> $melt_modlis_temp
$GCCMELT_MOVE_IF_CHANGE $melt_modlis_temp "meltbuild-sources/$MELTGCCBUILTIN_DEFAULT_MODLIS.[+flavor+].modlis"
else
meltbuild_info [+(.(fromline))+] keeping module list "meltbuild-sources/$MELTGCCBUILTIN_DEFAULT_MODLIS.[+flavor+].modlis"
fi
[+ENDFOR flavor+]
#@ [+ (. (fromline))+]
if [ ! -f "meltbuild-sources/$MELTGCCBUILTIN_DEFAULT_MODLIS.modlis" ]; then
meltbuild_symlink "meltbuild-sources/$MELTGCCBUILTIN_DEFAULT_MODLIS.optimized.modlis" "meltbuild-sources/$MELTGCCBUILTIN_DEFAULT_MODLIS.modlis"
fi
################################################################
#@ [+(.(fromline))+] module lists
if [ "$melt_overall_goal" = "modlists" ]; then
meltbuild_info [+(.(fromline))+] done modlists overall goal with stamp $melt_final_library_stamp
exit 0
fi
################################################################
################################################################
########################### EXTRA ############################
################
#@ [+(.(fromline))+] before extra libmelt* modules
################################################################
meltbuild_info [+(.(fromline))+] before extra GCCMELT_SKIPEMITC=$GCCMELT_SKIPEMITC.
meltbuild_info [+(.(fromline))+] times before extras at `date '+%x %H:%M:%S'`: ; times >&2
melt_final_extra_stamp=meltbuild-final-extra.stamp
function meltbuild_do_extras () {
meltbuild_notice 'start doing extras' [+(.(fromline))+] doing extras
[+FOR melt_extra_file+]
[+ (define apbase (get "base")) (define apindex (for-index)) +]
## meltbuild_do_extras [+base+] [+(.(fromline))+]
meltbuild_info [+(.(fromline))+] doing extra [+base+]
if [ ! -f meltbuild-sources/[+base+].melt ]; then
meltbuild_symlink $GCCMELT_MELTSOURCEDIR/[+base+].melt meltbuild-sources/[+base+].melt
fi
## meltbuild_do_extras [+base+] [+(.(fromline))+]
if [ ! -f meltbuild-sources/[+base+].cc -o ! -f meltbuild-sources/[+base+]+meltdesc.c \
-o meltbuild-sources/[+base+]+meltdesc.c -ot meltbuild-final-library.stamp \
-o meltbuild-sources/[+base+]+meltdesc.c -ot meltbuild-sources/[+base+].melt \
]; then
meltbuild_info [+(.(fromline))+] emit extra C++ code for [+base+]
meltbuild_emit [+(.(fromline))+] \
translatefile \
[+base+] \
meltbuild-sources \
meltbuild-modules \
[+FOR melt_translator_file ":"+][+base+].optimized[+ENDFOR melt_translator_file+]:[+FOR melt_library_file ":"+][+base+].optimized[+ENDFOR melt_library_file+] \
"[+FOR includeload " "+][+includeload+][+ENDFOR includeload+]" \
|| meltbuild_error [+(.(fromline))+] failed to generate C++ code of extra [+base+]
else
meltbuild_info [+(.(fromline))+] DONT emit extra C++ code for [+base+]
fi
local meltextra_[+varsuf+]_cumulmd5=$(cat meltbuild-sources/[+base+].cc meltbuild-sources/[+base+]+[0-9][0-9].cc | $MD5SUM | cut -b 1-32)
[+FOR flavor IN quicklybuilt optimized debugnoline+]
if [ ! -f meltbuild-modules/[+base+].meltmod-$meltextra_[+varsuf+]_cumulmd5.[+flavor+].so \
-o meltbuild-modules/[+base+].meltmod-$meltextra_[+varsuf+]_cumulmd5.[+flavor+].so -ot meltbuild-final-translator.stamp \
-o meltbuild-modules/[+base+].meltmod-$meltextra_[+varsuf+]_cumulmd5.[+flavor+].so -ot meltbuild-sources/[+base+].cc \
-o meltbuild-modules/[+base+].meltmod-$meltextra_[+varsuf+]_cumulmd5.[+flavor+].so -ot meltbuild-sources/[+base+]+meltdesc.c ]; then
meltbuild_info [+(.(fromline))+] compiling extra module for [+base+] [+flavor+]
$GCCMELT_MAKE -f $GCCMELT_MODULE_MK melt_module \
GCCMELT_FROM=[+(.(fromline))+] \
GCCMELT_MODULE_WORKSPACE=meltbuild-workdir \
GCCMELT_MODULE_FLAVOR=[+flavor+] \
GCCMELT_COMPILER="$GCCMELT_COMPILER" \
GCCMELT_CFLAGS="$GCCMELT_COMPILER_FLAGS" \
GCCMELT_MODULE_SOURCEBASE=meltbuild-sources/[+base+] \
GCCMELT_MODULE_BINARYBASE=meltbuild-modules/[+base+] \
|| ( meltbuild_notice [+(.(fromline))+] in meltbuild-modules failure to compile extra [+base+] [+flavor+] ; \
$GCCMELT_MAKE -f $GCCMELT_MODULE_MK melt_module \
GCCMELT_FROM=[+(.(fromline))+] \
GCCMELT_MODULE_WORKSPACE=meltbuild-workdir \
GCCMELT_MODULE_FLAVOR=[+flavor+] \
GCCMELT_COMPILER="$GCCMELT_COMPILER" \
GCCMELT_CFLAGS="$GCCMELT_COMPILER_FLAGS -DMELTGCC_NOLINENUMBERING" \
GCCMELT_MODULE_SOURCEBASE=meltbuild-sources/[+base+] \
GCCMELT_MODULE_BINARYBASE=meltbuild-modules/[+base+] ; \
meltbuild_error [+(.(fromline))+] in meltbuild-modules failed to compile extra [+base+] [+flavor+] \
"($GCCMELT_MAKE -f $GCCMELT_MODULE_MK)" compiler $GCCMELT_COMPILER_FLAGS cflags $GCCMELT_COMPILER_FLAGS )
else
meltbuild_info [+(.(fromline))+] not compiling extra module for [+base+] [+flavor+]
fi
[+ENDFOR flavor+]
## meltbuild_do_extras after build [+base+] [+(.(fromline))+]
[+ENDFOR melt_extra_file+]
## meltbuild_do_extras timestamping [+(.(fromline))+]
local meltextrastamptemp=$melt_final_extra_stamp-tmp$$
echo "///MELT extra time stamp $melt_final_extra_stamp" > $meltextrastamptemp
echo $GCCMELT_RUNTIME_DEPENDENCY_MD5SUM $GCCMELT_RUNTIME_DEPENDENCY >> $meltextrastamptemp
[+FOR melt_extra_file+]
$MD5SUM meltbuild-sources/[+base+].melt >> $meltextrastamptemp
$MD5SUM meltbuild-sources/[+base+].cc meltbuild-sources/[+base+]+[0-9][0-9].cc >> $meltextrastamptemp
[+FOR flavor IN quicklybuilt optimized debugnoline+]
$MD5SUM meltbuild-modules/[+base+].meltmod-$meltextra_[+varsuf+]_cumulmd5.[+flavor+].so >> $meltextrastamptemp
[+ENDFOR flavor+]
## meltbuild_do_extras end extra [+base+] [+(.(fromline))+]
[+ENDFOR melt_extra_file+]
## meltbuild_do_extras final [+(.(fromline))+]
echo "///end stamp $melt_final_extra_stamp" >> $meltextrastamptemp
$GCCMELT_MOVE_IF_CHANGE $meltextrastamptemp $melt_final_extra_stamp
meltbuild_info [+(.(fromline))+] times after extras at `date '+%x %H:%M:%S'`: ; times >&2
} ## end function meltbuild_do_extras [+(.(fromline))+]
## building extras [+(.(fromline))+]
if [ ! -f "$melt_final_extra_stamp" \
-o "$melt_final_extra_stamp" -ot "$melt_final_translator_stamp" \
-o "$melt_final_extra_stamp" -ot "$melt_final_library_stamp" \
[+FOR melt_extra_file+] -o "$melt_final_extra_stamp" -ot "$GCCMELT_MELTSOURCEDIR/[+base+].melt" \
[+ENDFOR melt_extra_file+] ]; then
meltbuild_info [+(.(fromline))+] building MELT extras
meltbuild_do_extras
else
meltbuild_info [+(.(fromline))+] not building MELT extra because of xtrastamp "$melt_final_extra_stamp"
fi
## done building extras [+(.(fromline))+]
################################################################
################################################################
#@ [+(.(fromline))+] runtime self check
## [+(.(fromline))+] FIXME: should skip that when cross-compiler MELT plugin..
if [ -z "$GCCMELT_RUNTIME_CC" ]; then
meltbuild_error [+(.(fromline))+] failed because no GCCMELT_RUNTIME_CC shell variable
exit 1
fi
meltcheckruntime_stamp=meltbuild-checkruntime.stamp
if [ ! -f $meltcheckruntime_stamp -o $meltcheckruntime_stamp -ot "$GCCMELT_RUNTIME_ARGS" \
-o $meltcheckruntime_stamp -ot "$GCCMELT_RUNTIME_CC" \
-o $meltcheckruntime_stamp -ot $melt_final_extra_stamp ]; then
#@ [+(.(fromline))+] checkruntime
if [ -f melt-no-check-runtime -o -n "$MELTGCC_NO_CHECK_RUNTIME" -o ! -f melt-runtime.ii ]; then
meltbuild_info [+(.(fromline))+] skipping check of MELT runtime
else
meltcheckruntime_args=meltbuild-checkruntime.args
meltcheckruntime_argstemp=$meltcheckruntime_args-tmp$$
echo ' -DGCCMELT_FROM_ARG="[+(.(fromline))+]"' ' -DGCCMELT_CHECKMELTRUNTIME' > $meltcheckruntime_argstemp
meltbuild_arg mode=meltframe >> $meltcheckruntime_argstemp
meltbuild_arg workdir=meltbuild-workdir >> $meltcheckruntime_argstemp
meltbuild_arg tempdir=meltbuild-tempdir >> $meltcheckruntime_argstemp
meltbuild_arg source-path=meltbuild-sources >> $meltcheckruntime_argstemp
meltbuild_arg module-path=meltbuild-modules >> $meltcheckruntime_argstemp
meltbuild_arg "module-cflags=\"$GCCMELT_COMPILER_FLAGS\"" >> $meltcheckruntime_argstemp
meltbuild_arg bootstrapping >> $meltcheckruntime_argstemp
echo ' -o /dev/null' >> $meltcheckruntime_argstemp
echo melt-runtime.ii >> $meltcheckruntime_argstemp
$GCCMELT_MOVE_IF_CHANGE $meltcheckruntime_argstemp $meltcheckruntime_args
[ -f "$meltcheckruntime_args" ] || meltbuild_error [+(.(fromline))+] missing check runtime args "$meltcheckruntime_args"
meltbuild_info [+(.(fromline))+] $meltcheckruntime_args is
cat $meltcheckruntime_args < /dev/null >&2
if [ -n "$MELTGCCBUILTIN_BUILD_WITH_CXX" ]; then
$GCCMELT_CC1PLUS_PREFIX $GCCMELT_CC1PLUS @$meltcheckruntime_args \
|| meltbuild_error [+(.(fromline))+] failed $GCCMELT_CC1PLUS with arguments @$meltcheckruntime_args
else
$GCCMELT_CC1PLUS_PREFIX $GCCMELT_CC1PLUS @$meltcheckruntime_args \
|| meltbuild_error [+(.(fromline))+] failed $GCCMELT_CC1PLUS with arguments @$meltcheckruntime_args
fi
meltbuild_info [+(.(fromline))+] done check runtime with $meltcheckruntime_args
fi
#@ [+(.(fromline))+] checkhello
meltcheckhelloworld_args=meltbuild-checkhelloworld.args
meltcheckhelloworld_argstemp=$meltcheckhelloworld_args-tmp$$
echo ' -DGCCMELT_FROM_ARG="[+(.(fromline))+]" -DGCCMELT_CHECKHELLO' > $meltcheckhelloworld_argstemp
meltbuild_arg mode=runfile >> $meltcheckhelloworld_argstemp
meltbuild_arg workdir=meltbuild-workdir >> $meltcheckhelloworld_argstemp
meltbuild_arg module-makefile=$GCCMELT_MODULE_MK >> $meltcheckhelloworld_argstemp
meltbuild_arg tempdir=meltbuild-tempdir >> $meltcheckhelloworld_argstemp
meltbuild_arg source-path=meltbuild-sources >> $meltcheckhelloworld_argstemp
meltbuild_arg module-path=meltbuild-modules >> $meltcheckhelloworld_argstemp
meltbuild_arg "module-cflags=\"$GCCMELT_COMPILER_FLAGS\"" >> $meltcheckhelloworld_argstemp
date +'(code_chunk hello%j #{puts("hello world from MELT %F @" __TIME__"\n")}#)' > meltbuild-hello.melt-tmp$$
$GCCMELT_MOVE_IF_CHANGE meltbuild-hello.melt-tmp$$ meltbuild-hello.melt
meltbuild_arg arg=meltbuild-hello.melt >> $meltcheckhelloworld_argstemp
echo ' meltbuild-empty-file.c -o /dev/null' >> $meltcheckhelloworld_argstemp
cat $GCCMELT_HELLOWORLD_ARGS < /dev/null >> $meltcheckhelloworld_argstemp
$GCCMELT_MOVE_IF_CHANGE $meltcheckhelloworld_argstemp $meltcheckhelloworld_args
[ -f "$meltcheckhelloworld_args" ] || meltbuild_error [+(.(fromline))+] missing check helloworld args "$meltcheckhelloworld_args"
meltbuild_info [+(.(fromline))+] $meltcheckhelloworld_args is
cat $meltcheckhelloworld_args < /dev/null >&2
$GCCMELT_CC1PLUS_PREFIX $GCCMELT_CC1PLUS @$meltcheckhelloworld_args \
|| meltbuild_error [+(.(fromline))+] running helloworld failed with arguments @$meltcheckhelloworld_args
meltbuild_info [+(.(fromline))+] done check helloworld with $meltcheckhelloworld_args
#@ [+(.(fromline))+] runtime stamp
meltcheckruntime_stamptemp=$meltcheckruntime_stamp-tmp$$
[ -f "$GCCMELT_RUNTIME_CC" ] || meltbuild_error [+(.(fromline))+] missing MELT runtime C++ file $GCCMELT_RUNTIME_CC
echo "/// MELT check runtime timestamp file $meltcheckruntime_stamp" > $meltcheckruntime_stamptemp
echo $GCCMELT_RUNTIME_DEPENDENCY_MD5SUM $GCCMELT_RUNTIME_DEPENDENCY >> $meltcheckruntime_stamptemp
$MD5SUM $GCCMELT_RUNTIME_CC < /dev/null >> $meltcheckruntime_stamptemp
$MD5SUM meltbuild-hello.melt < /dev/null >> $meltcheckruntime_stamptemp
[ -f "$melt_final_translator_stamp" ] || meltbuild_error [+(.(fromline))+] missing final translator stamp "$melt_final_translator_stamp"
[ -f "$melt_final_library_stamp" ] || meltbuild_error [+(.(fromline))+] missing final library stamp "$melt_final_library_stamp"
grep meltbuild-modules/ "$melt_final_translator_stamp" "$melt_final_library_stamp" < /dev/null >> $meltcheckruntime_stamptemp
echo "///end timestamp file $meltcheckruntime_stamp" >> $meltcheckruntime_stamptemp
echo
#@ [+(.(fromline))+] justcount
meltjustcount_args=meltbuild-justcount.args
meltjustcount_argstemp=$meltjustcount_args-tmp$$
echo ' -DGCCMELT_FROM_ARG="[+(.(fromline))+]" -DGCCMELT_JUSTCOUNT -fexceptions melt-runtime.ii ' > $meltjustcount_argstemp
meltbuild_arg mode=justcountipa >> $meltjustcount_argstemp
meltbuild_arg workdir=meltbuild-workdir >> $meltjustcount_argstemp
meltbuild_arg module-makefile=$GCCMELT_MODULE_MK >> $meltjustcount_argstemp
meltbuild_arg tempdir=meltbuild-tempdir >> $meltjustcount_argstemp
meltbuild_arg source-path=meltbuild-sources >> $meltjustcount_argstemp
meltbuild_arg module-path=meltbuild-modules >> $meltjustcount_argstemp
meltbuild_arg "module-cflags=\"$GCCMELT_COMPILER_FLAGS\"" >> $meltjustcount_argstemp
echo ' -O1 -o /dev/null' >> $meltjustcount_argstemp
cat $GCCMELT_JUSTCOUNT_ARGS < /dev/null >> $meltjustcount_argstemp
$GCCMELT_MOVE_IF_CHANGE $meltjustcount_argstemp $meltjustcount_args
[ -f "$meltjustcount_args" ] || meltbuild_error [+(.(fromline))+] missing check justcount args "$meltjustcount_args"
meltbuild_info [+(.(fromline))+] $meltjustcount_args is
cat $meltjustcount_args < /dev/null >&2
echo
$GCCMELT_CC1PLUS_PREFIX $GCCMELT_CC1PLUS @$meltjustcount_args \
|| meltbuild_error [+(.(fromline))+] running justcount failed with arguments @$meltjustcount_args
meltbuild_info [+(.(fromline))+] done check justcount with $meltjustcount_args
echo
$GCCMELT_MOVE_IF_CHANGE $meltcheckruntime_stamptemp $meltcheckruntime_stamp
meltbuild_info [+(.(fromline))+] done check runtime $meltcheckruntime_stamp
else
meltbuild_info [+(.(fromline))+] keeping runtime checks $meltcheckruntime_stamp
fi
if [ "$melt_overall_goal" = "checkruntime" ]; then
meltbuild_info [+(.(fromline))+] done checkruntime overall goal with stamp $meltcheckruntime_stamp
exit 0
fi
################################################################
#@ [+(.(fromline))+]
if [ "$melt_overall_goal" = "applications" ]; then
meltbuild_info [+(.(fromline))+] done applications overall goal with stamp $meltcheckruntime_stamp
exit 0
fi
################################################################
################################################################
### the generated documentation meltgendoc.texi [+ (. (fromline))+]
if [ ! -f meltgendoc.texi [+FOR melt_translator_file " \\\n"+] -o meltbuild-sources/[+base+].melt -nt meltgendoc.texi [+ENDFOR melt_translator_file+] \
[+FOR melt_library_file " \\\n"+] -o meltbuild-sources/[+base+].melt -nt meltgendoc.texi [+ENDFOR melt_library_file+] ]; then
meltbuild_info [+(.(fromline))+] generating meltgendoc.texi
meltgen_args=meltbuild-gendoc.args-tmp$$
echo ' -DGCCMELT_FROM_ARG="[+(.(fromline))+]"' > $meltgen_args
meltbuild_arg mode=makedoc >> $meltgen_args
meltbuild_arg output=meltgendoc.texi >> $meltgen_args
meltbuild_arg init=@$MELTGCCBUILTIN_DEFAULT_MODLIS.quicklybuilt >> $meltgen_args
meltbuild_arg workdir=meltbuild-workdir >> $meltgen_args
meltbuild_arg tempdir=meltbuild-tempdir >> $meltgen_args
meltbuild_arg source-path=meltbuild-sources >> $meltgen_args
meltbuild_arg module-path=meltbuild-modules >> $meltgen_args
meltbuild_arg "module-cflags=\"$GCCMELT_COMPILER_FLAGS\"" >> $meltgen_args
meltbuild_arg "module-makefile=\"$GCCMELT_MODULE_MK\"" >> $meltgen_args
meltbuild_arg bootstrapping >> $meltgen_args
meltbuild_arg arglist=[+FOR melt_translator_file ","+][+base+].melt[+ENDFOR melt_translator_file+],[+FOR melt_library_file ","+][+base+].melt[+ENDFOR melt_library_file+] >> $meltgen_args
echo meltbuild-empty-file.c >> $meltgen_args
$GCCMELT_MOVE_IF_CHANGE $meltgen_args meltbuild-gendoc.args
meltbuild_info [+(.(fromline))+] meltbuild-gendoc.args is
cat meltbuild-gendoc.args < /dev/null >&2
$GCCMELT_CC1PLUS_PREFIX $GCCMELT_CC1PLUS @meltbuild-gendoc.args \
|| meltbuild_error [+(.(fromline))+] "$GCCMELT_CC1PLUS" failed with arguments @meltbuild-gendoc.args
else
meltbuild_info [+(.(fromline))+] keeping meltgendoc.texi
fi
################
meltbuild_info [+(.(fromline))+] successfully done with times at `date '+%x %H:%M:%S'`: ; times >&2
################################################################
#@ [+(.(fromline))+]
if [ "$melt_overall_goal" = "gendoc" ]; then
meltbuild_info [+(.(fromline))+] done gendoc overall goal with stamp $melt_final_translator_stamp
exit 0
fi
## #@ [+(.(fromline))+] if we get here something is wrong in this script
meltbuild_error [+(.(fromline))+] unexpected MELT overall goal "$melt_overall_goal" buggy melt-build-script.tpl
#@ eof [+(.(fromline))+] end of generated melt-build-script.sh
|