File: theme-d-user-guide.tex

package info (click to toggle)
theme-d 7.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,036 kB
  • sloc: lisp: 9,625; sh: 5,321; makefile: 715; ansic: 477
file content (1349 lines) | stat: -rw-r--r-- 55,563 bytes parent folder | download
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
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349

\documentclass[a4paper]{article} \usepackage{amsmath,amssymb,amsthm}
\usepackage[utf8]{inputenc}

\input commands.tex

\newcommand{\themeupstreamver}{7.2.4}
\newcommand{\debianrev}{{\rmfamily\textit{rev}}}
\newcommand{\themever}{\themeupstreamver-\debianrev}
\newcommand{\newver}{\themeupstreamver-\debianrev{}oldguile}
\newcommand{\themesrcpackage}{theme-d-\themeupstreamver.tar.xz}
\newcommand{\metavar}[1]{{\rmfamily{}\textit{#1}}}
\newcommand{\themerootdir}{\metavar{theme-d-root-dir}}
\newcommand{\themesourcedir}{\metavar{theme-d-source-dir}}
\newcommand{\themetestdir}{\metavar{theme-d-test-dir}}
\newcommand{\unitrootdir}{\metavar{unit-root-dir}}
\newcommand{\archsuffix}{\textit{\rmfamily{arch}}}
\newcommand{\mytilde}{\(\sim\)}

\begin{document}

\begin{titlepage}
    \title{\theme\ User Guide} \author{Tommi H\"oyn\"al\"anmaa} \maketitle
\end{titlepage}

\tableofcontents

\section{Copyright}

Copyright \copyright\ 2008-2025 Tommi Höynälänmaa

\vspace{0.5cm}

\noindent
See file \code{COPYING} for the license.

\section{General}

This guide covers only UNIX systems. The software has been tested in Debian and
Ubuntu. Many of the commands in this guide have to be run as root. A root
session is opened either with command \code{su root} or \code{sudo} depending
on your system. In Ubuntu the command is \code{sudo}.

Symbol \debianrev\ in the package names means the Debian revision of the
packages. It is typically 1 or 2. Symbol {\rmfamily\textit{arch}} means the
host system architecture, which can be obtained by command
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} dpkg-architecture -q DEB\_HOST\_ARCH
\end{codeblock}

The newest version of the software is built for Guile version 3.0.10. It is
possible to build \theme\ for Guile 3.0.7 but then you have to edit some
debianization files, see section \ref{sec:other-debian}.

% \section{Using a Prerelease}

% If you want to use Theme-D prerelease 6.0.0\(\sim\)pre7 follow the instructions
% in section \ref{sec:other-systems} or \ref{sec:local-mode} and replace
% \themeupstreamver\ with 6.0.0\(\sim\)pre7.

\section{Installation}

\subsection{Debian forky (testing) and sid (unstable) and Ubuntu Resolute}

\label{sec:debian-basic}

If you use Synaptic Package Manager install the following packages:
\begin{itemize}
    \item \code{theme-d-rte}
    \item \code{theme-d-translator}
    \item \code{theme-d-stdlib}
\end{itemize}
If you also want to have the documentation install package
\code{theme-d-doc}, too.  The bootstrapped \theme\ system is contained
in package \code{theme-d-bootstrap}.
In order to install the system from the
command line give the following command:
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} sudo apt-get install theme-d-rte
    theme-d-translator theme-d-stdlib
\end{codeblock}
\noindent
and optionally one or both of the commands
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} sudo apt-get install theme-d-doc \\
    \noindent
    \mbox{ } \hspace{0.5cm} sudo apt-get install theme-d-bootstrap
\end{codeblock}

\subsection{Debian trixie (stable) and bookworm (oldstable) and older versions of Ubuntu}

If you are satisfied with an older version of \theme\ follow the instructions
in section \ref{sec:debian-basic}. Otherwise install Guile 3.0 with command
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} sudo apt install guile-3.0
\end{codeblock}
Then follow section \ref{sec:other-debian} to build and install
\theme.

\subsection{Debian bullseye (oldoldstable)}

If you are satisfied with an older version of \theme\ follow the instructions
in section \ref{sec:debian-basic}. Otherwise
\begin{enumerate}
    \item
          Install Guile 3.0 version 3.0.8-2 to your system:
          Get files \code{guile-3.0\_3.0.8.orig.tar.xz} and
          \code{guile-3.0\_3.0.8-2.debian.tar.xz}
          from

          https://packages.debian.org/bookworm/guile-3.0.

          Give commands
          \begin{codeblock}
              \noindent
              \mbox{ } \hspace{0.5cm} sudo apt install build-essential gperf devscripts \\
              \noindent
              \mbox{ } \hspace{0.5cm} sudo apt-get build-dep guile-3.0 \\
          \end{codeblock}
          Create a new directory and copy the downloaded files there. Change
          the working directory to the new directory and give commands
          \begin{codeblock}
              \noindent
              \mbox{ } \hspace{0.5cm} tar xvf guile-3.0\_3.0.8.orig.tar.xz \\
              \noindent
              \mbox{ } \hspace{0.5cm} cd guile-3.0-3.0.8.orig \\
              \noindent
              \mbox{ } \hspace{0.5cm} tar xvf ../guile-3.0\_3.0.8-2.debian.tar.xz \\
              \noindent
              \mbox{ } \hspace{0.5cm} debuild -i -us -uc -b \\
              \noindent
              \mbox{ } \hspace{0.5cm} cd .. \\
              \noindent
              \mbox{ } \hspace{0.5cm} sudo dpkg -i guile-3.0-libs\_3.0.8-2\_\archsuffix.deb \\
              \noindent
              \mbox{ } \hspace{0.5cm} sudo dpkg -i guile-3.0\_3.0.8-2\_\archsuffix.deb \\
              \noindent
              \mbox{ } \hspace{0.5cm} sudo dpkg -i guile-3.0-dev\_3.0.8-2\_\archsuffix.deb \\
              \noindent
              \mbox{ } \hspace{0.5cm} sudo dpkg -i guile-3.0-doc\_3.0.8-2\_all.deb \\
          \end{codeblock}
          where the last command is optional.
    \item
          Then follow section \ref{sec:other-debian} to build and install
          \theme.
          %   If your computer has amd64 architecture you can instead obtain
          %   the amd64 binary packages from the \theme\ homepage
          %   http://www.iki.fi/tohoyn/theme-d/ and install them with commands
          %   \begin{codeblock}
          %       \noindent
          %       \mbox{ } \hspace{0.5cm} dpkg -i
          %       th-scheme-utilities\_\themever\_\archsuffix.deb \\
          %       \noindent
          %       \mbox{ } \hspace{0.5cm} dpkg -i
          %       libthemedsupport\_\themever\_\archsuffix.deb \\
          %       \noindent
          %       \mbox{ } \hspace{0.5cm} dpkg -i
          %       theme-d-rte\_\themever\_\archsuffix.deb \\
          %       \noindent
          %       \mbox{ } \hspace{0.5cm} dpkg -i
          %       theme-d-translator\_\themever\_\archsuffix.deb \\
          %       \noindent
          %       \mbox{ } \hspace{0.5cm} dpkg -i theme-d-stdlib\_\themever\_all.deb
          %       \\
          %       \noindent
          %       \mbox{ } \hspace{0.5cm} dpkg -i theme-d-doc\_\themever\_all.deb
          %       \\
          %       \noindent
          %       \mbox{ } \hspace{0.5cm} dpkg -i theme-d-bootstrap\_\themever\_all.deb
          %       \\
          %   \end{codeblock}
\end{enumerate}
%% where the last two commands are optional.

\subsection{Other UNIX Systems}

Follow the instructions in the next section.

\section{Building}

\subsection{Debian-based Systems}
\label{sec:other-debian}

These instructions apply to Debian-based Linux distributions such as Debian and
Ubuntu. You need Guile 3.0 version $>= 3.0.7$.

The default directory configuration of \theme\ is stored in file
\code{/etc/theme-d-config}. You may override this by defining environment
variable \code{THEME\_D\_CONFIG\_FILE} to be the path of your own configuration
file. The root directory of the \theme\ installation shall be called
\themerootdir. By default this is \code{/usr/share/theme-d} in Debian-based
installations and \code{/usr/local/share/theme-d} in other installations.

Build and install Theme-D with the following steps:

\begin{enumerate}
    \item
          Check if package \code{guile-3.0-dev} is installed with command
          \begin{codeblock}
              \noindent
              \mbox{ } \hspace{0.5cm} dpkg -s guile-3.0-dev
          \end{codeblock}
          If you don't have it install it with command
          \begin{codeblock}
              \noindent
              \mbox{ } \hspace{0.5cm} sudo apt-get install guile-3.0-dev
          \end{codeblock}
    \item
          If your home directory contains file \code{\mytilde/.theme-d-config}
          delete the file.
    \item
          Change to the directory where you want to unpack the \theme\ source
          code.
    \item
          Copy files \code{\themesrcpackage} and
          \code{theme-d\_\themever.debian.tar.xz} into that directory.
    \item
          Unpack \theme\ source code with command
          \begin{codeblock}
              \noindent
              \mbox{ } \hspace{0.5cm} tar xvf \themesrcpackage
          \end{codeblock}
    \item
          Change to the subdirectory \code{theme-d-\themeupstreamver}.
    \item
          Give command
          \begin{codeblock}
              \noindent
              \mbox{ } \hspace{0.5cm} tar xvf
              \code{../theme-d\_\themever.debian.tar.xz}
          \end{codeblock}
    \item
          If you use Guile 3.0.7 change \code{GUILE\_VERSION2} from
          \code{3.0.8} to \code{3.0.7} in \code{debian/rules} and
          conditions \code{(>= 3.0.8)} to \code{(>= 3.0.7)} in
          \code{debian/control}.
    \item
          Give commands
          \begin{codeblock}
              \noindent
              \mbox{ } \hspace{0.5cm} unset GUILE\_LOAD\_PATH \\
              \noindent
              \mbox{ } \hspace{0.5cm} unset GUILE\_LOAD\_COMPILED\_PATH \\
              \noindent
              \mbox{ } \hspace{0.5cm} dpkg-buildpackage -b --no-sign \\
              \noindent
              \mbox{ } \hspace{0.5cm} cd .. \\
              \noindent
              \mbox{ } \hspace{0.5cm} dpkg -i
              th-scheme-utilities\_\themever\_\archsuffix.deb \\
              \noindent
              \mbox{ } \hspace{0.5cm} dpkg -i
              libthemedsupport\_\themever\_\archsuffix.deb \\
              \noindent
              \mbox{ } \hspace{0.5cm} dpkg -i
              theme-d-rte\_\themever\_\archsuffix.deb \\
              \noindent
              \mbox{ } \hspace{0.5cm} dpkg -i
              theme-d-translator\_\themever\_\archsuffix.deb \\
              \noindent
              \mbox{ } \hspace{0.5cm} dpkg -i theme-d-stdlib\_\themever\_all.deb
              \\
          \end{codeblock}
          where \textit{arch} is the name of your processor
          architecture. These commands have to be run as root.
    \item
          If you want to install the \theme\ documentation give command
          \begin{codeblock}
              \noindent
              \mbox{ } \hspace{0.5cm} dpkg -i theme-d-doc\_\themever\_all.deb
          \end{codeblock}
          as root.
    \item
          If you want to install the \theme\ bootstrapped environment give
          command
          \begin{codeblock}
              \noindent
              \mbox{ } \hspace{0.5cm} dpkg -i theme-d-bootstrap\_\themever\_all.deb
          \end{codeblock}
          as root.
\end{enumerate}

\subsection{Other UNIX Systems}
\label{sec:other-systems}

\begin{enumerate}
    \item
          If your home directory contains file \code{\mytilde/.theme-d-config}
          delete the file.
    \item
          Install Guile 3.0 if you don't have it already. Check the
          version of the Guile development environment with command
          \begin{codeblock}
              \noindent
              \mbox{ } \hspace{0.5cm} pkg-config --modversion guile-3.0
          \end{codeblock}
          See \myurl{http://www.gnu.org/software/guile/}.
    \item
          Create some directory and unpack \theme\ package there with command
          \begin{codeblock}
              \noindent
              \mbox{ } \hspace{0.5cm} tar xvf
              \metavar{theme-package-path}/\themesrcpackage
          \end{codeblock}
          The subdirectory \code{theme-d-\themeupstreamver} of the directory
          where you unpacked \theme\ shall be called \themesourcedir.
    \item
          Give commands
          \begin{codeblock}
              \noindent
              \mbox{ } \hspace{0.5cm} unset GUILE\_LOAD\_PATH \\ \mbox{
              } \hspace{0.5cm} unset GUILE\_LOAD\_COMPILED\_PATH
          \end{codeblock}
          In case you don't use a \code{sh} compatible shell these commands
          may be different or you may just ignore them.
    \item
          Change to the the subdirectory \themesourcedir.
    \item
          Give command
          \begin{codeblock}
              \noindent
              \mbox{ } \hspace{0.5cm} ./configure
          \end{codeblock}
          You may give the following options to command \code{./configure}:
          \begin{itemize}
              \item \code{--with-guile={\rmfamily{\textit{version}}}} : Specify
                    the Guile version explicitly. Currently only version 3.0 is supported.
              \item \code{--with-guile-program={\rmfamily{\textit{file}}}} :
                    Specify the Guile program used by the software explicitly. The
                    default is \code{/usr/bin/guile-{\rmfamily\textit{version}}}.
              \item \code{--with-guile-header-dir={\rmfamily{\textit{directory}}}} :
                    Specify the directory where to find header file \code{libguile.h}
                    for \code{libthemesupport} C compilation.
                    The default is not to specify the directory explicitly.
              \item \code{--with-extension-dir={\rmfamily{\textit{directory}}}} :
                    Specify the directory where to install Guile extensions.
              \item \code{--with-guile-module-dir={\rmfamily{\textit{directory}}}} :
                    Specify the directory where to install Guile modules.
              \item \code{--with-guile-comp-module-dir={\rmfamily{\textit{directory}}}} :
                    Specify the directory where to install compiled Guile modules.
              \item \code{--with-conf-dir={\rmfamily{\textit{directory}}}} :
                    Specify the directory where to install the global Theme-D
                    configuration file. Default is \code{/etc}.
              \item \code{--disable-xlat-opt-compilation} : Use Guile
                    optimization level 1 for compiling the Theme-D translator.
              \item \code{--disable-rte-opt-compilation} :
                    Use Guile optimization level 1 for the runtime environment compilation.
              \item \code{--without-support-library} : Don't use the
                    \code{libthemedsupport} library.
              \item \code{--disable-extra-math} : Don't include the
                    \code{(standard-library extra-math)} module in your installation.
              \item \code{--disable-posix-math} : Don't include the
                    \code{(standard-library posix-math)} module in your installation.
          \end{itemize}
          If you use option \code{--without-support-library} option you also
          have to use options \code{--disable-extra-math} and
          \code{--disable-posix-math}.
    \item
          Change to the the subdirectory \themesourcedir\ and give command
          \begin{codeblock}
              \noindent
              \mbox{ } \hspace{0.5cm} make
          \end{codeblock}
          in order to prepare the code for installation.  Install \theme\ by
          giving command
          \begin{codeblock}
              \noindent
              \mbox{ } \hspace{0.5cm} make install-complete
          \end{codeblock}
          as root.
          %% Finally, give command
          %% \begin{codeblock}
          %%   \noindent
          %%   \mbox{ } \hspace{0.5cm} make compile-scheme-code
          %% \end{codeblock}
\end{enumerate}

\subsection{Using the Software without Installation}
\label{sec:local-mode}

This sofware may also be used without installing it. This is useful if you
develop \theme\ itself.

\begin{enumerate}
    \item
          Install Guile 3.0 in case you do not have it already. See

          \vspace{0.3cm}
          \noindent
          \mbox{ } \hspace{0.5cm} \myurl{http://www.gnu.org/software/guile/}
          \vspace{0.3cm}

    \item
          Create some directory and unpack \theme\ package there with command
          \begin{codeblock}
              \noindent
              \mbox{ } \hspace{0.5cm} tar xvf
              \metavar{theme-package-path}/\themesrcpackage
          \end{codeblock}
    \item
          Go into the the subdirectory \code{theme-d-\themeupstreamver} of the directory
          created in the previous step. Give commands
          \begin{codeblock}
              \noindent
              \mbox{ } \hspace{0.5cm} ./configure \\
              \noindent
              \mbox{ } \hspace{0.5cm} make
          \end{codeblock}
          See section \ref{sec:other-systems} for the configure options.
\end{enumerate}

In order to use \theme\ change to the subdirectory \code{meta} and give command
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} ./uninstalled-env bash
\end{codeblock}
Now the commands \code{theme-d-compile}, \code{theme-d-link}, and
\code{run-theme-d-program} are available for you.

%% \subsection{Support for Racket}
%% \label{sec:racket-install}

%% If you want to use Racket as the target platform (i.e. the platform
%% where you run your \theme\ programs) you have to install Racket
%% package \code{theme-d-racket}. To do this obtain the file
%% \code{theme-d-racket.zip} and give command
%% \begin{codeblock}
%%   \noindent
%%   \mbox{ } \hspace{0.5cm} raco pkg install theme-d-racket.zip
%% \end{codeblock}

\section{Removing the Software}

\subsection{Debian-based Systems}

Give commands
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} dpkg --purge theme-d-stdlib \\
    \noindent
    \mbox{ } \hspace{0.5cm} dpkg --purge theme-d-translator \\
    \noindent
    \mbox{ } \hspace{0.5cm} dpkg --purge theme-d-rte \\
    \noindent
    \mbox{ } \hspace{0.5cm} dpkg --purge libthemedsupport \\
    \noindent
    \mbox{ } \hspace{0.5cm} dpkg --purge th-scheme-utilities \\
\end{codeblock}
as root.  In order to remove the \theme\ documentation give command
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} dpkg --purge theme-d-doc \\
\end{codeblock}
as root.
The bootstrapped environment can be removed with command
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} dpkg --purge theme-d-bootstrap \\
\end{codeblock}

\subsection{Other Systems}

Give command
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} make uninstall-complete
\end{codeblock}
as root in directory \themesourcedir.

\section{File Extensions}

\theme\ source files have the following extensions:
\begin{itemize}
    \item \code{.thp} for proper programs
    \item \code{.ths} for scripts
    \item \code{.thi} for interfaces
    \item \code{.thb} for bodies
\end{itemize}
\theme\ compiled pseudocode files have the following extensions:
\begin{itemize}
    \item \code{.tcp} for proper programs
    \item \code{.tcs} for scripts
    \item \code{.tci} for interfaces
    \item \code{.tcb} for bodies
\end{itemize}
The auxiliary module files use extension \code{.aux}.

\section{Unit Root Directories}

When you define a unit with full name
\begin{codeblock}
    (\metavar{dir-1} ... \metavar{dir-n} \metavar{unit-name})
\end{codeblock}
the module must have filename \metavar{unit-name} with proper
extension (see the previous section) and it must be located in
subdirectory
\begin{codeblock}
    \metavar{dir-1}/.../\metavar{dir-n}/
\end{codeblock}
of some directory \unitrootdir. The directory \unitrootdir\ is called
a \defterm{unit root directory}.  If a unit name has only one
component you may omit the parentheses from the unit name.  When you
compile of link a \theme\ unit you must specify one or more unit root
directories where the imported modules are searched.  These are called
the \defterm{module search directories}.  You should always have
directory \themerootdir/\code{theme-d-code} among the module search
directories so that the standard libraries are found by the compiler
and by the linker.

\section{Compiling a \theme\ Unit}
\label{sec:compilation}

Give command
\begin{codeblock}
    theme-d-compile \metavar{options} \metavar{unit-name}
\end{codeblock}
where \metavar{unit-name} is the file name of the \theme\ unit.
Options are
\begin{itemize}
    \item \code{--module-path=} \metavar{paths} or \code{-m}
          \metavar{paths} : Module search paths separated with :'s
    \item \code{--output=} \metavar{output-filename} or \code{-o}
          \metavar{output-filename} : The output filename
    \item \code{--unit-type=} \metavar{unit-type} or \code{-u}
          \metavar{unit-type} : The unit type (\code{proper-program},
          \code{script}, \code{interface}, or \code{body})
    \item \code{--message-level=} \metavar{message-level} or \code{-l}
          \metavar{message-level} : Compiler message level, integer number
          from 0 to 3.
    \item \code{--expand-only} : Do only macro expansion on the source.
    \item \code{--no-expansion} : Compile the source without macro
          expansion.
    \item \code{--backtrace} : Print backtrace on compilation error.
    \item \code{--pretty-print} : Pretty print the pseudocode output.
    \item \code{--no-verbose-errors} : Less information in the error
          messages.
    \item \code{--show-modules} : Show information about loading modules.
    \item \code{--version} : Show Theme-D version number and exit.
\end{itemize}

By default the unit type is computed from the source file extension. The
default module search path is \code{\themerootdir:.}. If you use option
\code{-m} you may include the \theme\ default module search path in your custom
path by adding an extra ``:'' in the beginning of the new path, e.g.
\code{:my-path1:my-path2}. The default target file path is obtained by removing
the path and the extension from the source filename and appending the
appropriate extension to the result. The default message level is 1. Message
level 0 means no output at all except in case of error. Message level 1
displays also message on successful compilation or linking. Message level 2
displays some debug information and level 3 a lot of debug information. When
\code{--expand-only} is set the default target filename is
\code{myunit.expanded.thx} for source file \code{myunit.thx}.

Suppose that you have your own \theme\ code at directory
\metavar{my-theme-d-dir} and you have a program called \code{(mod-1 ... mod-n)}
at location
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} mod-1/.../mod-n.thp
\end{codeblock}
\noindent
In order to compile the program give commands
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} cd \metavar{my-theme-d-dir} \\
    \noindent
    \mbox{ } \hspace{0.5cm} theme-d-compile \code{mod-1/.../mod-n.thp}
\end{codeblock}
Suppose that you have a module (an interface and a body) with name
\code{(mod-1 ... mod-n)} in files \code{mod-1/.../mod-n.thi} and
\code{mod-1/.../mod-n.thb}.  In order to compile the module give
commands
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} cd \metavar{my-theme-d-dir} \\
    \noindent
    \mbox{ } \hspace{0.5cm} theme-d-compile \code{mod-1/.../mod-n.thi}
    \\
    \noindent
    \mbox{ } \hspace{0.5cm} theme-d-compile \code{mod-1/.../mod-n.thb}
\end{codeblock}
If you want to have the compiled files in the same subdirectory where
the source files are, which is usually the case, give commands
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} cd \metavar{my-theme-d-dir} \\
    \noindent
    \mbox{ } \hspace{0.5cm} theme-d-compile -o
    \code{mod-1/.../mod-n.tci} \bl \\
    \noindent
    \mbox{ } \hspace{0.8cm} \code{mod-1/.../mod-n.thi} \\
    \noindent
    \mbox{ } \hspace{0.5cm} theme-d-compile -o
    \code{mod-1/.../mod-n.tcb} \bl \\
    \noindent
    \mbox{ } \hspace{0.8cm} \code{mod-1/.../mod-n.thb}
\end{codeblock}

If you use \theme\ without installing it you have to use command
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{1.0cm}
    \code{MYPATH/theme-d-VERSION/theme-d/translator/theme-d-compile.scm}
\end{codeblock}
instead of \code{theme-d-compile}. Here \code{MYPATH} is the path
where you have unpacked \theme.

\section{Linking a \theme\ Unit}
\label{sec:linking}

A \theme\ unit can be linked either monolithically or modularly. In
monolithic linking a \theme\ program is linked into a single Guile bytecode
file. In modular linking \theme\ units are linked to separate Guile bytecode
modules. For a \theme\ module \code{MYMODULE} the target interface module is
named \code{\_\_intf\_MYMODULE.go} and the target body module
\code{\_\_impl\_MYMODULE.go}. The auxiliary module files are named
\code{\_\_intf\_MYMODULE.aux} and \code{\_\_impl\_MYMODULE.aux}.
\theme\ dynamical plugin features can only be used with modular
linking,

In order to link a \theme\ program monolithically give command
\begin{codeblock}
    theme-d-link \metavar{options} \metavar{program-name}
\end{codeblock}
where \metavar{program-name} is the file name of the \theme\ program.
In order to link a \theme\ unit to a Guile module give command
\begin{codeblock}
    theme-d-link \metavar{options} \metavar{program-name}
\end{codeblock}
where \metavar{program-name} is the file name of the \theme\ unit
and \metavar{options} contains \code{--module}.
Available options are
\begin{itemize}
    \item \code{--module-path=} \metavar{paths} or \code{-m}
          \metavar{paths} : Module search paths separated with :'s
    \item \code{--guile-target-path=} \metavar{paths} :
          Guile target module search paths separated with :'s
    \item \code{--empty-guile-target-path} :
          Set Guile target module search path to be empty.
    \item \code{--full-module-path=} \metavar{paths} or \code{-M}
          \metavar{paths} :
          Equivalent to
          \begin{codeblock}
              --module-path=\metavar{paths} --guile-target-path=\metavar{paths}.
          \end{codeblock}
    \item \code{--unit-type=} \metavar{unit-type} :
          Specify the unit type explicitly. Argument \metavar{unit-type}
          has to be one of \code{proper-program}, \code{script},
          \code{body}, or \code{interface}.
    \item \code{--output=} \metavar{output-filename} or \code{-o}
          \metavar{output-filename} : The output filename.
    \item \code{--intermediate-file=} \metavar{filename} or \code{-n}
          \metavar{filename} : The intermediate filename.
    \item \code{--intermediate-language=} \metavar{language} or \code{-i}
          \metavar{language} : The language used for the intermediate file.
    \item \code{-x} \metavar{module}: Link (load) the module into the
          target program.
          %% \item \code{-y} \metavar{module}: Link (load) the module into the
          %%   target program using a relative path. This option is available only
          %%   for Racket.
    \item \code{--message-level=} \metavar{message-level} or \code{-l}
          \metavar{message-level} : Linker message level, integer number from
          0 to 3.
    \item \code{--no-final-compilation} : Do not compile the linker result
          file with \code{guild compile}.
    \item \code{--no-strip} : Do not strip away unused code.
    \item \code{--no-optimization} : Do not optimize linker output.
    \item \code{--no-factorization} : Do not factorize the type
          expressions out of procedure implementations.
    \item \code{--no-weak-assertions} : Do not check ordinary assertions.
          Strong assertions are always checked.
    \item \code{--backtrace} : Print backtrace on linking error.
    \item \code{--pretty-print} : Pretty print the linker output.
    \item \code{--no-verbose-errors} : Less information in the error
          messages.
    \item \code{--keep-intermediate} : Keep the intermediate Tree-IL or
          Scheme file
    \item \code{--link-to-cache} : Link the target file into the Guile
          cache.
    \item \code{--runtime-pretty-backtrace} : Generate the code to support
          runtime pretty printed backtraces.
    \item \code{--no-unlinked-procedure-names} : Do not generate code for
          reporting unlinked procedure names.
    \item \code{--module-debug-output} : Print debug messages when a
          module body linkage is started and ended.
    \item \code{--show-inst-number} : Print the expression numbers of the
          processed expressions in parametrized type instantiation.
    \item \code{--check-all-primitives} : Check that primitive procedure
          result values match the result types for all primitives, including
          those defined with \code{unchecked-prim-proc}.
    \item \code{--duplicates=} \metavar{symbols} : Set the values passed
          to \code{default-duplicate-binding-handler} in the target
          program. If there are several symbols enclose them in quotes.
    \item \code{--split} : Split the linker output.
    \item \code{--split-dir=} \metavar{dir} : Set the directory where to
          put the split linker output.
    \item \code{--split-basename=} \metavar{name} : Set the basename for
          split linker output files.
    \item \code{--guile-opt-level=} \metavar{level} : Set the optimization
          level for the final Guile compilation. The default is 1.
    \item \code{--extra-guild-options=} \metavar{options} : Define the
          extra options passed to \code{guild} when compiling the intermediate
          code to Guile bytecode.
    \item \code{--plugin} :
          Link a module body to a plugin. This option implies \code{--module}.
    \item \code{--version} : Show Theme-D version number and exit.
\end{itemize}

The available intermediate languages are:
\begin{itemize}
    \item \code{tree-il-3.0} : Guile 3.0 Tree-IL.
    \item \code{guile-3.0} : Guile Scheme 3.0.
\end{itemize}
You may use aliases \code{tree-il} and \code{guile}.
Using intermediate language \code{guile0} is equivalent to options
\code{-i guile --no-optimization}.
The option \code{--no-optimization} has no effect for the Tree-IL target
platform. It is always optimized.
By default \theme\ linker produces a Guile objcode file. Actually, \theme\
makes a Guile Tree-IL or Scheme file and uses Guile to make an objcode file
from that. The default intermediate language is Tree-IL. Note that many
optimizations are performed only with Tree-IL. If you want to optimize your
code for speed you should link your program without pretty backtraces when you
no longer need them for debugging. If you use Tree-IL as the intermediate
language pretty printing may cause the linker to crash with large programs. The
syntax of the module name in the \code{-x} option is \code{"(mod1 ... modn)"}.
%% The syntax of module names in the \code{-x} and \code{-y} options
%% depends on the intermediate language. It is \code{"(mod1 ... modn)"}
%% for Guile and \code{mod1/.../modn} for Racket. If you use the
%% \code{-y} option for linking a module (available only for Racket) the
%% module is imported with a \code{require} form so that the module name
%% is enclosed in double quotes. See the Racket documentation how this
%% works.

If you use option \code{--module-path} or \code{-m} you may include the \theme\
default module search path in your custom path by an extra ``:'' in the path as
in compilation. Suppose that you have your own \theme\ code at directory
\metavar{my-theme-d-dir} and you have a program called \code{(mod-1 ... mod-n)}
at location \code{mod-1/.../mod-n.thp}. In order to link the program give
commands
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} cd \metavar{my-theme-d-dir} \\
    \noindent
    \mbox{ } \hspace{0.5cm} theme-d-link \code{mod-1/.../mod-n.thp}
\end{codeblock}
The previous commands place the linked file into the root of
subdirectory \metavar{my-theme-d-dir}. If you want to place the linked
file in the same directory where the source files are use the
following commands:
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} cd \metavar{my-theme-d-dir} \\
    \noindent
    \mbox{ } \hspace{0.5cm} theme-d-link -o \code{mod-1/.../mod-n.go}
    \bl \\
    \noindent
    \mbox{ } \hspace{0.8cm} \code{mod-1/.../mod-n.thp}
\end{codeblock}

If you have so big program that your system hangs with it it is useful to split
the linker output to several intermediate files. You can do this by giving
option \code{--split} to the linker. The linker output files are placed on a
separate subdirectory. By default this subdirectory is called
\textit{program}\texttt{.compiled}. You can change the directory name with
option \code{--split-dir}. You can also change the basename of the output files
with option \code{--split-basename}. Note that script
\code{run-split-theme-d-program} does not work if you change the basename.

If option \code{--no-final-compilation} is not given the Tree-IL or Scheme file
generated by the linker is compiled to Guile bytecode with command \code{guild
    compile}. Option \code{--guile-opt-level} specifies the optimization level of
the final Guile compilation. Option \code{-O\textit{{\rmfamily level}}} is
passed to program \code{guild}. The default optimization level is 1. Note that
invoking the Guile optimization of \code{letrec} expressions requires the
optimization level to be at least 2. The Guile target path is used to set the
value of environment variable \code{GUILE\_LOAD\_COMPILED\_PATH} to the
\code{guild} command.

\section{Running a \theme\ Program}
\label{sec:running}

When you use Guile as the target platform \theme\ programs can be run with
command
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} run-theme-d-program \metavar{metaarg}
    ... \metavar{programfile} \metavar{programarg} ...
\end{codeblock}
where \metavar{metaarg} are the arguments passed to the script
\code{run-theme-d-program}, \metavar{programfile} is the filename of
the linked \theme\ program, and \metavar{programarg} are the
arguments passed to the program.
Suppose you have your linked \theme\ program in file
\code{myprog.go}. You can run this program with command
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} run-theme-d-program myprog.go
\end{codeblock}
When you use Guile as the target platform it is also possible to link
you \theme\ program into a \code{.scm} intermediate file and run it
with command
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} guile -e main -s \metavar{programfile}.scm
    \metavar{programarg} ...
\end{codeblock}
or
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{0.5cm} guile -s \metavar{programfile}.scm
    \metavar{programarg} ...
\end{codeblock}
for scripts.

%% If you use Racket as the target platform you can run \theme\ programs
%% with command
%% \begin{codeblock}
%%   \noindent
%%   \mbox{ } \hspace{0.5cm} racket -t myprog.rkt -m \metavar{programarg} ...
%% \end{codeblock}
%% or
%% \begin{codeblock}
%%   \noindent
%%   \mbox{ } \hspace{0.5cm} racket -t myprog.rkt \metavar{programarg} ...
%% \end{codeblock}
%% for scripts.

If you need to import your own Scheme files into the \theme\ runtime
environment (because of the foreign function interface) you can do this by
defining the environment variable \code{THEME\_D\_CUSTOM\_CODE}. Separate the
file names with :'s. However, it is recommended to use option \code{-x} for
this.

The program \code{run-theme-d-program} accepts the following arguments:
\begin{itemize}
    \item \code{--no-verbose-errors} : No verbose information about errors
          (exceptions).
    \item \code{--backtrace} : Display backtrace on error.
    \item \code{--pretty-backtrace} : Display pretty printed backtrace
          on error.
    \item \code{--version} : Show Theme-D version number and exit.
\end{itemize}
Note that the \code{--pretty-backtrace} option works only if you have
linked your \theme\ program with option
\code{--runtime-pretty-backtrace}.

In order to run a \theme\ program with split linker output give command
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{1.0cm}
    run-split-theme-d-program \metavar{dir-name}
\end{codeblock}
where \metavar{dir-name} is the directory where the linker output is
generated.

In order to run a modularly linked \theme\ program give command
\begin{codeblock}
    \noindent
    \mbox{ } \hspace{1.0cm}
    run-theme-d-program-m -g \metavar{guile-target-path} \metavar{program}
\end{codeblock}
where \metavar{program} is a \code{.go} file created by the linker and
\metavar{guile-target-path} is the path used to search Guile modules.
Normally you should use path \code{\metavar{root-dir}:} where \metavar{root-dir}
is the unit root directory of your program. Note that you don't need to include
Guile cache directories into the Guile target path.

The pretty printed runtime backtrace has the following format: \vspace{0.5cm}
\par \noindent
\hspace{0.5cm}\textit{number} \textit{kind} \textit{name}
\textit{module} \\
\par \noindent
\hspace{0.5cm}\(\vdots\) \\
\mbox{ }
\vspace{0.2cm} \\
%%\par\noindent
where \textit{kind} is the kind of the called procedure, \textit{name} is the
name of the procedure and \textit{module} is the module where the procedure has
been defined. The \textit{kind} may take the following values:
\begin{itemize}
    \item \texttt{toplevel}: A toplevel procedure
    \item \texttt{local}: A local procedure
    \item \texttt{instance}: An instance of a parametrized procedure
    \item \texttt{zero}: A procedure used to generate the zero value of
          a class
\end{itemize}

\section{\theme\ Configuration File}

The \theme\ configuration file is searched according to the following rules:
\begin{itemize}
    \item Use the value of environment variable \code{THEME\_D\_CONFIG\_FILE} is it is
          defined.
    \item Use file \code{.theme-d-config} in the user's home directory if present.
    \item Otherwise use file \code{/etc/theme-d-config}.
\end{itemize}
The installation procedure sets up the configuration file. Normally
you don't have to edit it.

The configuration file has the following format:
\begin{codeblock}
    \par \noindent \mbox{  } \hspace{0.5cm}
    (theme-d (\textit{\rmfamily{}var-name} \textit{\rmfamily{}var-value})...)
\end{codeblock}
All string type variable values must be enclosed in quotes. Boolean
and integer values must not be enclosed in quotes
The variables defined in the configuration file are:
\begin{itemize}
    \item \code{guile-version}: The Guile version used by \theme. This
          is a string.
    \item \code{translator-dir}: The location of the compiler and
          linker implementations.
    \item \code{runtime-dir}: The location of the
          \theme\ runtime environment.
    \item \code{lib-dir}: The location of the \theme\ standard library.
    \item \code{examples-dir}: The location of the \theme\ examples.
    \item \code{tests-dir}: The location of the \theme\ tests.
    \item \code{tools-dir}: The location of the \theme\ tools.
    \item \code{bootstrap-dir}: The location of the \theme\ bootstrap
          environment sources.
    \item \code{compiler-path} \theme\ compiler path (a \code{.scm}
          file).
    \item \code{linker-path} \theme\ linker path (a \code{.scm}
          file).
    \item \code{run-path} \theme\ run script path path (a \code{.scm}
          file).
    \item \code{use-support-lib?}: \true\ if the support library is
          used. This is a boolean value.
\end{itemize}
The values of the configuration variables can be fetched with command
\begin{codeblock}
    \par \noindent \mbox{  } \hspace{0.5cm}
    get-theme-d-config-var \metavar{config-var-name}
\end{codeblock}
\noindent
where \metavar{config-var-name} is the name of the configuration
variable.

\section{Distributing Linked \theme\ Programs}

If your target environment has \theme\ installed it is sufficient to distribute
only the linked \code{.go} file. If your target system is using a Debian-based
Linux system (e.g. Debian or Ubuntu) and you don't want to install whole
\theme\ into it the easiest way to ensure that all the necessary files are
present is to install packages \code{theme-d-rte}, \code{th-scheme-utilities},
and \code{libthemedsupport} into the target system.

If you are using Guile in a non-Debian system you have to ensure that the
following files are present in the Guile library path:
\begin{itemize}
    \item \code{theme-d/runtime/params.go}
    \item \code{theme-d/runtime/runtime-theme-d-environment.go}
    \item \code{theme-d/runtime/theme-d-stdlib-support.go}
\end{itemize}
You also need to distribute one of the following files:
\begin{itemize}
    \item \code{theme-d/runtime/theme-d-support-all.go}
    \item \code{theme-d/runtime/theme-d-support-no-extra.go}
    \item \code{theme-d/runtime/theme-d-support-no-posix.go}
    \item \code{theme-d/runtime/theme-d-alt-support.go}
\end{itemize}
and create symbolic link \code{theme-d/runtime/theme-d-support.go}
pointing to it. If your program uses modular linking you also have to distribute
files \code{standard-library/\_\_intf\_*.go}, \code{standard-library/\_\_intf\_*.aux},
files \code{standard-library/\_\_impl\_*.go}, and
\code{standard-library/\_\_impl\_*.aux}.

In order to find the library path give command
\begin{codeblock}
    \par \noindent \mbox{  } \hspace{0.5cm}
    pkg-config --variable=siteccachedir guile-\textit{\rmfamily version}
\end{codeblock}
Normally you should use file \code{theme-d-support-all.go}. If you
don't use the \theme\ support library you must use
\code{theme-d-alt-support.go}. If you distribute a \code{.go} file you
also need to have \code{run-theme-d-program.scm} in the target system.
These files are licensed under GNU Lesser General Public License.

If you use the support library the library \code{libthemedsupport} has to be
installed in the target system. The use of the support library is recommended.

\section{Bootstrapping \theme}

The \theme\ source package and Debian package \code{theme-d-bootstrap} contain a
bootstrapped version of Theme-D, i.e.
Theme-D compiler and linker implemented with \theme\ itself.
To install the bootstrap environment change to the directory where you want to
install it and give command
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    setup-theme-d-bootstrap-env
\end{codeblock}
Note that you must have either \theme\ installed on your system or use
the uninstalled version of the software, see section
\ref{sec:local-mode}.

First you have to build \theme\ written in itself using compiler and linker
written in Guile. Change to the \code{theme-d-bootstrap} directory and give the
following commands:
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    cd build1/theme-d-in-theme-d \\
    \noindent \mbox{ } \hspace{0.5cm}
    make -f user.mk
\end{codeblock}
or if you want to use modular linking
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    cd build1/theme-d-in-theme-d \\
    \noindent \mbox{ } \hspace{0.5cm}
    LINK\_MODULES=1 make -f user.mk
\end{codeblock}
Then you build \theme using the compiler and linker built in the
previous step:
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    cd ../../bootstrap/theme-d-in-theme-d \\
    \noindent \mbox{ } \hspace{0.5cm}
    make -f user.mk
\end{codeblock}
or if you want to use modular linking
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    cd ../../bootstrap/theme-d-in-theme-d \\
    \noindent \mbox{ } \hspace{0.5cm}
    LINK\_MODULES=1 make -f user.mk
\end{codeblock}
If you use modular linking with \code{build1} you have to define variable
\code{MODULAR\_TRANSLATOR} with \code{bootstrap}, e.g.
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    cd ../../bootstrap/theme-d-in-theme-d \\
    \noindent \mbox{ } \hspace{0.5cm}
    MODULAR\_TRANSLATOR=1 LINK\_MODULES=1 make -f user.mk
\end{codeblock}
Now you have the bootstrapped \theme\ compiler and linker in files
\code{theme-d-compile-b.go} and \code{theme-d-link-b.go} in subdirectory
\code{theme-d-bootstrap/bootstrap/theme-d-in-theme-d}. We denote the path to
this directory by
\code{BOOTSTRAPPATH}.
You can use these
programs with commands
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    run-theme-d-program BOOTSTRAPPATH/theme-d-compile-b.go
    ARGUMENTS
\end{codeblock}
and
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    run-theme-d-program BOOTSTRAPPATH/theme-d-link-b.go ARGUMENTS
\end{codeblock}
or if you use modular linking
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    run-theme-d-program-m -g BOOTSTRAPPATH2: $\backslash$ \\
    \noindent \mbox{ } \hspace{1.0cm}
    BOOTSTRAPPATH2/theme-d-in-theme-d/theme-d-compile-b.go ARGUMENTS
\end{codeblock}
and
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    run-theme-d-program-m -g BOOTSTRAPPATH2: $\backslash$ \\
    \noindent \mbox{ } \hspace{1.0cm}
    BOOTSTRAPPATH2/theme-d-in-theme-d/theme-d-link-b.go ARGUMENTS
\end{codeblock}
where \code{BOOTSTRAPPATH2} is the path to directory \code{bootstrap}.


\section{Compiling, Linking, and Running Test and Example Programs}

In order to install the \theme\ testing environment change to the directory
where you want the environment to be installed and give command
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    setup-theme-d-test-env
\end{codeblock}
This directory shall be
called \themetestdir\ in the sequel. The test programs are located in
subdirectory \code{test-env/theme-d-code/tests} and the example
programs in \code{test-env/theme-d-code/examples}. Subdirectory
\code{tools} contains scripts to run tests.

The example programs are built by giving command \code{make -f user.mk} in
subdirectory \code{test-env/theme-d-code/examples}. If you want to use modular
linking use command
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    LINK\_MODULES=1 make -f user.mk
\end{codeblock}

The example programs are
run with command \code{run-theme-d-program {\rmfamily\textit{program}}.go}.

If \code{testX} is a program compile it with command
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    theme-d-compile -m ..: testX.thp
\end{codeblock}
and link with command
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    theme-d-link -m ..: testX.tcp
\end{codeblock}
or
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    theme-d-link --module -M ..: testX.tcp
\end{codeblock}
in directory \code{\themetestdir/test-env/theme-d-code/tests}.

If \code{testX} is a module compile it with commands
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    theme-d-compile -m ..: testX.thi \\
    \noindent \mbox{ } \hspace{0.5cm}
    theme-d-compile -m ..: testX.thb
\end{codeblock}
in directory \code{\themetestdir/test-env/theme-d-code/tests}.
If you use modular linking you also have to link the units with commands
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    theme-d-link --module -M ..: testX.tci \\
    \noindent \mbox{ } \hspace{0.5cm}
    theme-d-link --module -M ..: testX.tcb
\end{codeblock}

Note that some test programs import test modules in which case you must compile
the modules before the program that uses them. When a test program imports
several test modules compile first all the interfaces of the imported modules
and then all the bodies of the imported modules. Compile the interfaces in the
order they are numbered. Note also that some test programs require the examples
to be built.

In order to run a test \code{testX} give commands
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    run-theme-d-program testX.go
\end{codeblock}
or
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    run-theme-d-program-m -g ..: testX.go
\end{codeblock}
in directory \code{\themetestdir/test-env/theme-d-code/tests}.

If you want to build all the tests at once build the examples first. Then
change to the directory \code{\themetestdir/test-env/testing}. Compile the
tests with command
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    ./compile-tests.scm
\end{codeblock}
\noindent
Then you can link the programs monolithically with command
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    ./link-test-programs.scm
\end{codeblock}
or link all units modularly with command
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    ./link-to-modules.scm
\end{codeblock}
\noindent
Then run the linked programs with command
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    ./run-test-programs.scm
\end{codeblock}
in case of monolithic linking and
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    ./run-test-programs-m.scm
\end{codeblock}
in case of modular linking.
The compilation results can be checked with command
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    ./check-test-compilation.scm
\end{codeblock}
Results of monolithic linking and running can be checked with
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    ./check-test-program-linking.scm \\
    \noindent \mbox{ } \hspace{0.5cm}
    ./check-test-runs.scm
\end{codeblock}
and for modular linking and running with
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    ./check-test-module-linking.scm \\
    \noindent \mbox{ } \hspace{0.5cm}
    ./check-test-runs-m.scm
\end{codeblock}
\noindent
All these scripts
are located in directory \code{\themetestdir/testing}.

You can generate the test output into the subdirectory \code{output} with
command
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    ./run-test-programs-w-output.scm
\end{codeblock}
or
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    ./run-test-programs-w-output-m.scm
\end{codeblock}
in case of modular linking.
Use command \code{./compare-output.sh} to compare the output files
with the correct ones.  The correct outputs of the tests can be found
in subdirectory \code{tests} in files \code{test*.out}.  The outputs
of tests \code{test450} and \code{test756} may vary because of output
buffering.  The computed hash values in test \code{test587} and the
order of elements in hash tables in tests \code{test826} and
\code{test827} may also vary.
The backtrace in \code{test764} and the path in \code{test598} may be
different in different runs. The values of environment variable
\code{HOME} printed by \code{test820} are different in different
systems.  For modular linking, different outputs are reported for test cases
\code{test132}, \code{test135}, \code{test136}, \code{test173}, and
\code{test472} due to different internal variable names.

If you want to build the examples with the bootstrapped compiler and linker set
the environment variables \code{THEME\_D\_COMPILE} to
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    run-theme-d-program MYPATH/theme-d-in-theme-d/theme-d-compile-b.go
\end{codeblock}
and
\code{THEME\_D\_LINK} to
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    run-theme-d-program MYPATH/theme-d-in-theme-d/theme-d-link-b.go
\end{codeblock}
or in case of modular linking to
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    run-theme-d-program-m -g MYPATH $\backslash$ \\
    \noindent \mbox{ } \hspace{0.8cm}
    MYPATH/theme-d-in-theme-d/theme-d-compile-b.go
\end{codeblock}
and
\begin{codeblock}
    \noindent \mbox{ } \hspace{0.5cm}
    run-theme-d-program-m -g MYPATH $\backslash$ \\
    \noindent \mbox{ } \hspace{0.8cm}
    MYPATH/theme-d-in-theme-d/theme-d-link-b.go
\end{codeblock}
Here \code{MYPATH} is either directory \code{build1} or \code{bootstrap} in the
bootstrapped environment.
If you want to use the bootstrapped compiler give option
\code{-b MYPATH/theme-d-in-theme-d/theme-d-compile-b.go}
or
\code{-B MYPATH}
to command
\code{compile-tests.scm}.
If your bootstrapper compiler uses split linking give option
\code{-s MYPATH/theme-d-in-theme-d/theme-d-compile-b.build}.

Programs \code{compile-tests.scm}, \code{link-test-programs.scm},
and \code{link-to-modules.scm} accept the following options:
\begin{itemize}
    \item \code{-b} \metavar{bootstrap-path}: Use the
          bootstrapped compiler or linker. The argument is the path to file
          \code{theme-d-compile-b.go} or \code{theme-d-link-b.go}.
    \item \code{-B} \metavar{bootstrap-dir}: Use the
          modularly linked bootstrapped compiler or linker. The argument shall be
          either directory \code{build1} or \code{bootstrap} in the bootstrapped
          environment.
    \item \code{-s} \metavar{split-dir}:
          Use the compiler or linker linked with split linking.
\end{itemize}
Programs \code{link-test-programs.scm}
and \code{link-to-modules.scm} accept also the following options:
\begin{itemize}
    \item \code{-i} \metavar{backend} : Select the linker backend. The
          value of \metavar{backend} has to be either \code{tree-il},
          \code{guile}, or \code{guile0}. Value \code{guile0} means the
          nonoptimized Guile backend. The default value is \code{tree-il}.
    \item \code{-k} : Do not delete the intermediate file (\code{.tree-il}
          or \code{.scm}).
\end{itemize}
Command \code{compile-tests.scm} passes the contents of environment variable
\code{EXTRA\_COMP\_OPTIONS} to the compiler. Command
\code{link-test-programs.scm} passes the contents of environment variable
\code{EXTRA\_LINK\_OPTIONS} to the linker.

If you want to clean the testing environment in order to rebuild and rerun the
examples and the tests give command \code{./clean-test-env.sh} in the
subdirectory \code{testing}. If you want to keep the compilation output but
clean the other files use command \code{./link-clean-test.env.sh}.


\section{Computing Makefile Dependencies}

The software includes three scripts to compute makefile dependencies for \theme\
files:
\code{compute-theme-d-pcode-deps} for
\theme\ pseudocode files (\code{*.tc?}),
\code{compute-theme-d-program-deps} for monolithically linked programs
(\code{*.go}),
and
\code{compute-theme-d-module-deps} for modularly linked modules (\code{*.go}).
Each of these commands takes two arguments: the source code file (\code{*.th?})
for which to compute the dependencies and the unit path to specify the units
included in the dependency computation. Only dependencies with the specified
unit path are included. The unit path is computed from the unit name by dropping
the last symbol. For example, set the second argument to \code{examples} for the
example programs.


\section{Other Things}

An Emacs mode for \theme\ can be found at \code{tools/theme-d.el}. There are
some example programs in subdirectory \code{theme-d-code/examples} in the
\theme\ source package. You can compile, link, and run them following the
instructions given in sections \ref{sec:compilation}, \ref{sec:linking}, and
\ref{sec:running}. If you install the \theme\ Debian package twice the
configuration file \code{theme-d-config} may not be installed. This problem is
solved by uninstalling \theme\ and installing it again.

\theme\ translator uses the following notation for printing pair and
tuple types:
\code{(:pair \objectvar{r} \objectvar{s})}
is printed as
\code{\{ \objectvar{r} . \objectvar{s} \}}
and
\code{(:tuple \indexedobjectvar{t}{1}
    ... \indexedobjectvar{t}{n})} is printed as
\code{\{\indexedobjectvar{t}{1} ... \indexedobjectvar{t}{n}\}}. Note
that this notation is not accepted in \theme\ code.

\section{Comments}

The linker requires that the compiled modules are placed in a proper
subdirectory hierarchy under some directory among the module search
directories. This condition is fulfilled if you define the module search
directories to include all the unit root directories used by your source files
and put the compiled files into same directories with the source files.

\end{document}