forked from daly/axiom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.pamphlet
1524 lines (1313 loc) · 43.5 KB
/
Makefile.pamphlet
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
\documentclass{article}
\usepackage{axiom}
\begin{document}
\title{The Top Level Makefile}
\author{Timothy Daly}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\newpage
\section{General Makefile Structure}
Makefiles are responsible for four things. First, they have to set up
the output directory structure so that all of the build machinery
can assume it exists. Second, they have to build all of the files
in their own directory. Third, they have to invoke Make on each
of their subdirectories. This forms a natural tree walk of the
directory structure. Fourth, they have to explain all of the details
about the directory, the files it manages and its subdirectories.
The clean stanza has been modified to be more effective. Previously
it walked the Makefile hierarchy trying to clean subdirectories. This
method often fails for various reasons (e.g. permissions, incomplete
builds, etc). Now we simply remove the created files directly.
\newpage
\subsection{The Top Level Makefile}
We have added a stanza to separate the build of documents from the build
of source files. As much as possible we would like to do the document
builds in parallel with the source builds. We kick off a make for the
documents in the background and then kick off a make in the foreground
for the source code. This is independent of using make in parallel and
instead uses the shell to fork the processes. We have not had much luck
getting make to build in parallel reliably.
Note that make cannot handle recursively calling itself in the same
directory so we have to expand the serial forms inline. Cheesy.
<<parallel>>=
all: noweb ${MNT}/${SYS}/bin/document
@ echo p1 making a parallel system build
@ echo 1 making a ${SYS} system, PART=${PART} SUBPART=${SUBPART}
@ echo 2 Environment ${ENV}
@ ${TANGLE} -t8 -RMakefile.${SYS} Makefile.pamphlet >Makefile.${SYS}
@ ${DOCUMENT} Makefile
@ mkdir -p ${MNT}/${SYS}/doc/src
@ cp Makefile.dvi ${MNT}/${SYS}/doc/src/root.Makefile.dvi
@ if [ "${RUNTYPE}" = "parallel" ] ; then \
( echo p4 starting parallel make of input files ; \
${ENV} ${MAKE} input ${NOISE} & ) ; \
else \
if [ "${BUILD}" = "full" ] ; then \
( echo s4 starting serial make of input files ; \
mkdir -p ${MNT}/${SYS}/doc/src/input ; \
cd ${MNT}/${SYS}/doc/src/input ; \
cp ${SRC}/scripts/tex/axiom.sty . ; \
for i in `ls ${SRC}/input/*.input.pamphlet` ; do \
if [ .${NOISE} = . ] ; \
then \
latex $$i ; \
else \
( echo p4a making $$i ; \
latex $$i >${TMP}/trace ) ; \
fi ; \
done ; \
rm -f *~ ; \
rm -f *.pamphlet~ ; \
rm -f *.log ; \
rm -f *.tex ; \
rm -f *.toc ; \
rm -f *.aux ) ; fi ; \
fi
@ if [ "${RUNTYPE}" = "parallel" ] ; then \
( echo s2 starting parallel make of books ; \
echo s3 ${SPD}/books/Makefile from \
${SPD}/books/Makefile.pamphlet ; \
cd ${SPD}/books ; \
${DOCUMENT} Makefile ; \
cp Makefile.dvi ${MNT}/${SYS}/doc/src/books.Makefile.dvi ; \
${ENV} ${MAKE} & ) ; \
else \
( echo s2 starting serial make of books ; \
echo s3 ${SPD}/books/Makefile from \
${SPD}/books/Makefile.pamphlet ; \
cd ${SPD}/books ; \
${DOCUMENT} Makefile ; \
cp Makefile.dvi ${MNT}/${SYS}/doc/src/books.Makefile.dvi ; \
if [ "${BUILD}" = "full" ] ; then \
${ENV} ${MAKE} ; fi ) ; \
fi
@ echo p7 starting make of src
@ ${ENV} $(MAKE) -f Makefile.${SYS}
@ echo 3 finished system build on `date` | tee >lastBuildDate
input:
@ echo p9 making input documents
@ if [ "${BUILD}" = "full" ] ; then \
( mkdir -p ${MNT}/${SYS}/doc/src/input ; \
cd ${MNT}/${SYS}/doc/src/input ; \
cp ${SRC}/scripts/tex/axiom.sty . ; \
for i in `ls ${SRC}/input/*.input.pamphlet` ; \
do latex $$i ; \
done ; \
rm -f *~ ; \
rm -f *.pamphlet~ ; \
rm -f *.log ; \
rm -f *.tex ; \
rm -f *.toc ; \
rm -f *.aux ) ; fi
@
<<*>>=
<<ENVDEFAULTS>>
<<ENV>>
<<parallel>>
<<book>>
<<noweb>>
<<literate commands>>
<<install>>
document: noweb ${MNT}/${SYS}/bin/document
@ echo 4 making a ${SYS} system, PART=${PART} SUBPART=${SUBPART}
@ echo 5 Environment ${ENV}
@ ${TANGLE} -t8 -RMakefile.${SYS} Makefile.pamphlet >Makefile.${SYS}
@ ${ENV} $(MAKE) -f Makefile.${SYS} document
@echo 6 finished system build on `date` | tee >lastBuildDate
clean:
@ echo 7 making a ${SYS} system, PART=${PART} SUBPART=${SUBPART}
@ echo 8 Environment ${ENV}
@ rm -f src/algebra/book*pamphlet
@ rm -f src/algebra/*.spad
@ rm -f src/interp/book*pamphlet
@ rm -f axiom.sty
@ rm -f books/Makefile
@ rm -f books/Makefile.dvi
@ rm -f books/axiom.sty
@ rm -f src/algebra/axiom.sty
@ rm -f lsp/axiom.sty
@ rm -f src/axiom.sty
@ rm -f src/clef/axiom.sty
@ rm -f src/etc/axiom.sty
@ rm -f src/doc/axiom.sty
@ rm -f src/lib/axiom.sty
@ rm -f src/share/axiom.sty
@ rm -f src/scripts/axiom.sty
@ rm -f src/input/axiom.sty
@ rm -f src/interp/axiom.sty
@ rm -f lsp/Makefile.dvi
@ rm -f lsp/Makefile
@ rm -rf lsp/gcl*
@ rm -f noweb
@ rm -f trace
@ rm -f Makefile.${SYS}
@ rm -f Makefile.dvi
@ rm -rf int
@ rm -rf obj
@ rm -rf mnt
@ for i in `find . -name "*~"` ; do rm -f $$i ; done
@ for i in `find src -name "Makefile"` ; do rm -f $$i ; done
@ for i in `find src -name "Makefile.dvi"` ; do rm -f $$i ; done
@ rm -f lastBuildDate
@
\subsection{Literate Commands}
Since this is the first build message that gets generated we echo
the ENV variable for debugging purposes. We use the specific file,
Makefile in the mnt/sys/bin directory as the trigger to prevent
duplicate execution of this stanza.
<<literate commands>>=
${MNT}/${SYS}/bin/document:
@echo 0 ${ENV}
@echo 10 copying ${SRC}/scripts to ${MNT}/${SYS}/bin
@cp -pr ${SRC}/scripts/* ${MNT}/${SYS}/bin
@
\subsection{Environment}
\subsubsection{VERSION}
The VERSION variable is a unique string intended to show up
in the banner at startup time. I can be anything but is intended
to be a unique way of identifying the CVS version so we can
reference bug reports to versions.
The VERSION variable is used in the [[src/interp/Makefile]]
to set a lisp variable [[boot::*build-version*]]. This variable
is used by the {\tt yearweek} function to construct the banner.
The banner also contains a build timestamp so we can determine
when the image is compiled. We touch the file
called [[${MNT}/${SYS}/timestamp]] and using a formatted form
of its file information. See the YEARWEEK variable in the
[[src/interp/Makefile.pamphlet]] and the {\tt yearweek} function in
[[src/interp/util.lisp.pamphlet]].
\subsubsection{SPAD}
The SPAD environment variable is normally specified.
It is expected to be a path to the top level directory of the
shipped system. For example, if we want to build a linux system
the SPAD variable should look like:
\begin{verbatim}
`pwd`/new/mnt/{\bf linux}
\end{verbatim}
\subsubsection{SYS}
From the SPAD variable we look at the last directory name
and create a version of Axiom for that system. The SYS
environment variable is the last directory name in the SPAD
variable.
\subsubsection{SPD}
The SPD variable is taken to be the current working directory
where this Makefile lives. This is obviously the root of the whole
system source tree. All Makefiles form environment variables based
on this value.
Next we see the six top-level directories discussed above being
defined using the SPD variable.
\subsubsection{LSP}
This variable specifies where the LSP subdirectory lives.
It is normally a directory at the top level of the system but
we do not assume that to be true. Other lisps might require it
to be elsewhere.
\subsubsection{GCLDIR}
This file contained the only mention of the AKCLDIR variable which
gives the path to the version of AKCL. Now that the system is running
on GCL this variable has been renamed to GCLDIR. This cannot be eliminated
entirely because the system uses this variable to look up a file
called collectfn.lsp which is part of the GCL distribution. This
file lookup is in conditional lisp code so other lisps will not
see the file load. The collectfn.lsp code is used by GCL to generate
the ``.fn'' files which are used to optimize function calling.
Also, [[lsp/sys-proclaims.lisp]] is a file generated
during the GCL build which contains type information about lisp
functions, allowing fast-function calling behavior.
When defining the environment, the SPD variable is defined as the
current directory. SYS is taken as the last non-directory part of
the environment variable [[$AXIOM]] (e.g. if [[$AXIOM=/(a-path)/mnt/linux]]
then [[SYS=linux]]). It is {\bf mandatory} that [[$AXIOM]] does
{\bf not} contain any trailing slash, because the {\tt notdir} function
will return the string following the final slash and would thus return
the empty string.
\subsubsection{SRC}
The SRC subdirectory is a hand-generated, read-only top level
directory containing the source code. This is assumed to be completely
system-independent and, in general, it can reside on a CD or NFS
mounted file system. This is useful for building several different
kinds of systems (as specified by the SYS variable from a single
source tree.
\subsubsection{INT}
The INT subdirectory is a machine-generated, system-independent
top-level directory containing source code. Axiom builds from literate
sources. This work only needs to be done once at the first build. The
INT directory is a cache of work. It can be erased at will.
However steps such as generating lisp code from spad code, while
done by machine, are system-independent. Therefore this subdirectory,
once built, can reside with the SRC subdirectory on CD or NFS as a
read-only branch.
\subsubsection{OBJ}
The OBJ subdirectory is a machine-generated, system-dependent
top level directory containing things like compiler binaries. The
OBJ directory is a cache of work. It can be erased at will.
Because it is system-dependent it needs to be written at build
time by compilers for each specific system.
\subsubsection{MNT}
The MNT subdirectory is a complete, working copy of Axiom.
This directory contains everything that is needed to run Axiom and
can be copied anywhere. Everything in this directory takes its required
information from the [[$AXIOM]] shell variable. Once this directory is
copied the SRC, INT, and OBJ subdirectories can be erased.
\subsubsection{ZIPS}
The ZIPS subdirectory contains particular versions of subsystems
that Axiom needs in tar-gzip format. The Makefiles will unpack them.
It also contains patch files to these subsystems. The Makefile will
apply those patches. Then it will configure and build the required
subsystems.
\subsubsection{TMP}
The TMP directory is used in place of normal unix tmp in order to
avoid writing outside of our build tree.
Note that TMP is a workspace in the OBJ directory. It is
working space for temporary files since we cannot assume that
we can write outside our own tree. Output from commands like
the {\tt document} command will generally be written to the
TMP/trace file. If the build seems to hang while making a
document file then check this file. It will contain the output
of the latex command and the likely error in the tex file.
\subsubsection{SPADBIN}
The SPADBIN directory is the path to the executable
binary directory of the shipped system. The directory contains
all of the executable commands, such as the {\tt document}
command. The {\tt document} command lives in the SRC/SCRIPTS
subdirectory and will be copied to SPADBIN before we start
walking the build subtree.
\subsubsection{INC}
The INC directory contains all the include files for the C
programs.
\subsubsection{The NOISE variable }
The NOISE variable is used in the calls to the document
command. In general, where the document command is called in
the Makefiles it is called with the following form:
\begin{verbatim}
${SPADBIN}/document ${NOISE} foo
\end{verbatim}
with the default value of NOISE being:
\begin{verbatim}
NOISE="-o ${TMP}/trace"
\end{verbatim}
The reason NOISE exists is that the latex command will
generate a page of output which is uninteresting during the
make. However if there is a latex syntax error in a pamphlet
file the make will continue past the error due to the nonstopmode
flag. To see the actual error message rerun the make as:
\begin{verbatim}
make NOISE=
\end{verbatim}
\subsubsection{PART and SUBPART}
Because of the size of this build we do everything possible to
minimize the work necessary to rebuild. In order to allow
finer control of the build we have two options that can be
specified. The first is the PART variable. The second
is the SUBPART variable. The PART variable basically
specifies which directory we wish to build.
Setting the PART as:
\begin{verbatim}
PART=foo
\end{verbatim}
will look for a stanza in the Makefile as:
\begin{verbatim}
\${PART}dir
\end{verbatim}
which expands to:
\begin{verbatim}
foodir
\end{verbatim}
Variable PART can be specified (environment or command-line) as
one of:
\begin{verbatim}
(all | lib | install | lisp | interp | comp | graph | hyper
| clef | input | sman | boot | include | doc | algebra )
\end{verbatim}
It is possible to be more specific with a directory using SUBPART.
\subsubsection{DESTDIR and COMMAND}
The install directory is [[/usr/local/axiom]] by default
but this can be changed on the command line by typing:
\begin{verbatim}
make DESTDIR=/yourabsolutepath COMMAND=fullPathAndCommand install
\end{verbatim}
The COMMAND string has been modified to use the DESTDIR
variable so we can properly find the axiom command.
The DOCUMENT variable is now set to replace the direct call
to the document command. This will allow it to be
changed on the command line.
\section{The Environment}
<<ENVDEFAULTS>>=
VERSION:="Axiom (May 2012)"
##### special paths
SPD:=$(shell pwd)
SRC:=${SPD}/src
LSP:=${SPD}/lsp
INT:=${SPD}/int
OBJ:=${SPD}/obj
MNT:=${SPD}/mnt
TMP:=${OBJ}/tmp
ZIPS:=${SPD}/zips
BOOKS:=${SPD}/books
SPAD:=${SPD}/mnt/${SYS}
SRCDIRS:="interpdir sharedir algebradir etcdir clefdir docdir \
graphdir smandir hyperdir browserdir inputdir"
SYS:=$(notdir $(AXIOM))
DAASE:=${SRC}/share
SPADBIN:=${MNT}/${SYS}/bin
DOCUMENT:=${SPADBIN}/document
##### installation paths
DESTDIR:=/usr/local/axiom
COMMAND:=${DESTDIR}/mnt/${SYS}/bin/axiom
##### functions we need
AWK:=gawk
PATCH:=patch
RANLIB:=ranlib
TAR:=tar
TOUCH:=touch
UNCOMPRESS:=gunzip
##### noweb
TANGLE:=${SPADBIN}/lib/notangle
WEAVE:=${SPADBIN}/lib/noweave
##### lisp related variables
BYE:=bye
<<GCLVERSION>>
GCLDIR:=${LSP}/${GCLVERSION}
<<GCLOPTS-LOCBFD>>
LISP:=lsp
##### C related variables
INC:=${SPD}/src/include
PLF:=LINUXplatform
CCF:="-O2 -fno-strength-reduce -Wall -D_GNU_SOURCE -D${PLF} -I/usr/X11/include"
CC:=gcc
XLIB:=/usr/X11R6/lib
#LDF:=" -L/usr/X11R6/lib -L/usr/lib ${XLIB}/libXpm.a -lXpm"
LDF:=" -L/usr/X11R6/lib -L/usr/lib -lXpm"
O:=o
##### command line control
NOISE:="-o ${TMP}/trace"
PART:= cprogs
SUBPART:= everything
RUNTYPE:=serial
# can be richtests, catstests, regresstests (see src/input/Makefile)
TESTSET:=alltests
BUILD:=full
@
\subsection{The ENV variable}
<<ENV>>=
ENV:= \
AWK=${AWK} \
BOOKS=${BOOKS} \
BUILD=${BUILD} \
BYE=${BYE} \
CC=${CC} \
CCF=${CCF} \
COMMAND=${COMMAND} \
DAASE=${DAASE} \
DESTDIR=${DESTDIR} \
DOCUMENT=${DOCUMENT} \
GCLDIR=${GCLDIR} \
GCLOPTS=${GCLOPTS} \
GCLVERSION=${GCLVERSION} \
INC=${INC} \
INT=${INT} \
LDF=${LDF} \
LISP=${LISP} \
LSP=${LSP} \
MNT=${MNT} \
NOISE=${NOISE} \
O=${O} \
OBJ=${OBJ} \
PART=${PART} \
PATCH=${PATCH} \
PLF=${PLF} \
RANLIB=${RANLIB} \
RUNTYPE=${RUNTYPE} \
SPAD=${SPAD} \
SPADBIN=${SPADBIN} \
SPD=${SPD} \
SRC=${SRC} \
SRCDIRS=${SRCDIRS} \
SUBPART=${SUBPART} \
SYS=${SYS} \
TANGLE=${TANGLE} \
TAR=${TAR} \
TESTSET=${TESTSET} \
TMP=${TMP} \
TOUCH=${TOUCH} \
UNCOMPRESS=${UNCOMPRESS} \
VERSION=${VERSION} \
WEAVE=${WEAVE} \
XLIB=${XLIB} \
ZIPS=${ZIPS}
@
\subsection{rootdirs}
Note that the -p (parent) option to mkdir will make all intermediate
directories as well if they don't exist.
We need [[${MNT}/${SYS}/doc/src]] so the various Makefile.dvi files
can be copied.
We need to make the [[${MNT}/${SYS}/bin/lib]] path because on certain
systems, such as freebsd, we do not build noweb. The noweb stanza
would normally create this but might not have been executed.
<<rootdirs>>=
rootdirs: ${MNT}/${SYS}/bin/document
@echo 11 checking directory structure
@echo 12 Environment: ${ENV}
@mkdir -p ${INT}
@mkdir -p ${OBJ}/${SYS}
@mkdir -p ${TMP}
@mkdir -p ${MNT}/${SYS}/bin/lib
@mkdir -p ${MNT}/${SYS}/doc/src
# @cp -pr ${SRC}/scripts/* ${MNT}/${SYS}/bin
@
\subsection{book}
This stanza constructs the book from the original pamphlet file.
At this time there is no difference between the pamphlet file
and straight latex (intentionally). Thus we just need to make
sure the correct directories are in place, copy the files, and
run latex over the pamphlet file.
<<book>>=
book:
@ echo 79 building the book as ${MNT}/${SYS}/doc/book.dvi
@ mkdir -p ${TMP}
@ mkdir -p ${MNT}/${SYS}/doc
@ cp ${SRC}/doc/book.pamphlet ${MNT}/${SYS}/doc
@ cp -pr ${SRC}/doc/ps ${MNT}/${SYS}/doc
@ (cd ${MNT}/${SYS}/doc ; \
if [ .${NOISE} = . ] ; then \
( latex book.pamphlet --interaction nonstopmode ; \
latex book.pamphlet --interaction nonstopmode ) ; \
else \
( latex book.pamphlet --interaction nonstopmode >${TMP}/trace ; \
latex book.pamphlet --interaction nonstopmode >${TMP}/trace ) ; \
fi ; \
rm book.pamphlet ; \
rm book.toc ; \
rm book.log ; \
rm book.aux )
@ echo 80 The book is at ${MNT}/${SYS}/doc/book.dvi
@
\subsection{noweb}
Note that this stanza echos a line into a file called noweb.
Makefile semantics says that when this file exists we will
skip this stanza. So in a clean system where the noweb file
does not exist we will execute this once and never again
(unless someone deletes the noweb file).
Never add anything after the colon otherwise the noweb
build will depend on it rather than the noweb flag file
in the current directory.
We have added a patch to the [[${SPAD}/obj/noweb/src/c/modules.c]]
file that causes noweb to output undefined chunk names exactly
as they exist in the original file. This gets around the most
common failure of boxing up a file into a pamphlet. The patch
file lives in the [[ZIPS]] directory and will be applied
after noweb is untarred but before the make occurs.
We have added a patch to the [[${SPAD}/obj/noweb/src/Makefile]]
which does two things. First it uses [[${TMP}/null]] rather than
[[/dev/null]] as we do not wish to write outside our own build tree.
We also patch the use of [[make]] to use [[${MAKE}]]. BSD style
systems use [[gmake]] rather than [[make]] so we need to pass this
information from above for the build to succeed.
\subsection{Noweb patch skipped}
We tried to applied this noweb patch but the function [[tempfile]]
used in all of the patches does not exist therefore this patch
has been removed pending a fix. The referenced patch files still
exist in the zips directory.
\begin{verbatim}
The [[mv noweb.src.awkname.patch]] file,
the [[noweb.src.awk.totex.nw.patch]] file,
the [[noweb.src.lib.toascii.patch]] file,
the [[noweb.src.shell.cpif.patch]] file,
the [[noweb.src.shell.nonu.patch]] file,
the [[noweb.src.shell.roff.nw.patch]] file,
the [[noweb.src.shell.noroff.patch]] file,
the [[noweb.src.shell.toroff.patch]] file,
the [[noweb.src.lib.toascii.nw.patch]] file, and
the [[noweb.src.shell.roff.mm.patch]] file remove
the insecure temp file problem.
We removed the same patch to
[[noweb.src.lib.toascii.patch]]
because this is not a source file.
\end{verbatim}
<<noweb>>=
noweb:
@echo 13 making noweb
@mkdir -p ${OBJ}/noweb
@mkdir -p ${TMP}
@mkdir -p ${MNT}/${SYS}/bin/lib
@( cd ${OBJ}/noweb ; \
tar -zxf ${ZIPS}/noweb-2.10a.tgz ; \
cd ${OBJ}/noweb/src/c ; \
${PATCH} <${ZIPS}/noweb.modules.c.patch ; \
cd ${OBJ}/noweb/src ; \
${PATCH} <${ZIPS}/noweb.src.Makefile.patch ; \
./awkname ${AWK} ; \
${ENV} ${MAKE} BIN=${MNT}/${SYS}/bin/lib LIB=${MNT}/${SYS}/bin/lib \
MAN=${MNT}/${SYS}/bin/man \
TEXINPUTS=${MNT}/${SYS}/bin/tex all install >${TMP}/trace )
@echo The file marks the fact that noweb has been made > noweb
nowebclean:
@echo 14 cleaning ${OBJ}/noweb
@rm -rf ${OBJ}/noweb
@rm -f noweb
@
\subsection{src}
We should recompile the world with the .fn information but not here.
\begin{verbatim}
( for i in `find . -name "*.lsp"` ; \
do echo $$i ; touch $$i ; done )
( for i in `find . -name "*.lisp"` ; \
do echo $$i ; touch $$i ; done )
@echo 15a remaking ${SRC}/interp for performance
@(cd src ; ${ENV} ${MAKE} )
\end{verbatim}
<<src>>=
srcdir: rootdirs ${SPD}/src/Makefile
@echo 15 making ${SPD}/src
@( cd src ; ${ENV} ${MAKE} )
${SPD}/src/Makefile: ${SPD}/src/Makefile.pamphlet
@echo 16 making ${SPD}/src/Makefile from ${SPD}/src/Makefile.pamphlet
( cd src ; \
${DOCUMENT} Makefile ; \
cp Makefile.dvi ${MNT}/${SYS}/doc/src/src.Makefile.dvi )
libspadclean:
@echo 17 cleaning ${OBJ}/${SYS}/lib
@rm -rf ${OBJ}/${SYS}/lib
@( cd src ; ${DOCUMENT} Makefile )
@( cd src ; ${ENV} ${MAKE} clean )
@rm -f ${SPD}/src/Makefile ${SPD}/src/Makefile.dvi
@
\subsection{src setup}
<<srcsetup>>=
srcsetup: rootdirs ${SPD}/src/Makefile
@echo 18 making ${SPD}/src
@( cd src ; ${ENV} ${MAKE} setup )
@
\subsection{lsp}
We delegate the details of constructing common lisp to the Makefiles in
the subtree. We need only ensure that the Makefiles are up to date.
When we first make GCL we the src/Makefile will create a marker file
called gcldir. This file has the same name as the stanza to create
GCL and thus will prevent GCL from rebuilding. We need to do this
since we have no control over the GCL makefiles.
The [[${OBJ}/${SYS}/bin]] directory is where the lisps get built.
\subsubsection{LSPMakefile}
We need to specialize the Makefile stanza based on the version
of Lisp we plan to use. At the moment there are 3 GCL versions
which run Axiom: 2.4.1, 2.5, and 2.6 These are incompatible versions
so we have different patches against them. The details are in
the lsp/Makefile.pamphlet file. Here we just decide which section
to choose. The default is 2.4.1 but if the GCLVERSION is changed
then the Makefile is rewritten to extract the later version.
It looks for a chunk name that matches the version number.
<<LSPMakefile>>=
${LSP}/Makefile: ${LSP}/Makefile.pamphlet
@echo 20 making ${LSP}/Makefile from ${LSP}/Makefile.pamphlet
@( cd lsp ; \
${DOCUMENT} Makefile ; \
if [ "${GCLVERSION}" != "gcl-2.4.1" ] ; then \
${TANGLE} -t8 -R"${GCLVERSION}" Makefile.pamphlet >Makefile ; \
fi )
@cp Makefile.dvi ${MNT}/${SYS}/doc/src
@
Here we add [[mkdir -p ${OBJ}/${SYS}/lsp]] because we need to rename the
[[gcl_collectfn.lsp]] back to collectfn.lsp. We also start adding support
for [[sys-proclaim.lsp]] and other dynamically collected proclaim information.
The [[obj/sys/bin]] dir is necessary to keep the compiled lisp image.
The [[obj/sys/lsp]] dir is necessary to keep collectfn and sys-proclaims.
The collectfn.lsp file is a special extension to GCL to collect type
information during a compile-file. This information gets written out
to a [[.fn]] file. These [[.fn]] files can be loaded and written out
as a file containing proclaims information. If this proclaims information
is available at compile time then the resulting function calls are much
more efficient. The [[sys-proclaims]] file contains type information
about standard common lisp function calls.
<<lsp>>=
lspdir: rootdirs ${MNT}/${SYS}/bin/document ${LSP}/Makefile
@echo 19 making ${LSP}
@mkdir -p ${OBJ}/${SYS}/bin
@mkdir -p ${OBJ}/${SYS}/lsp
@echo =====================================
@echo lsp BUILDING GCL COMMON LISP
@echo =====================================
@(cd lsp ; ${ENV} ${MAKE} gcldir ) 1>/dev/null 2>/dev/null
# @(cd lsp ; ${ENV} ${MAKE} ccldir )
<<LSPMakefile>>
lspclean:
@echo 21 cleaning ${OBJ}/${SYS}/ccl
@rm -rf ${LSP}/${GCLVERSION}
@rm -rf ${INT}/ccl
@rm -rf ${OBJ}/${SYS}/ccl
@rm -rf ${LSP}/gcldir
@rm -f ${LSP}/Makefile ${LSP}/Makefile.dvi
@
\subsection{install}
<<install>>=
install:
@echo 78 installing Axiom in ${DESTDIR}
@mkdir -p ${DESTDIR}
@cp -pr ${MNT} ${DESTDIR}
@echo '#!/bin/sh -' >${COMMAND}
@echo AXIOM=${DESTDIR}/mnt/${SYS} >>${COMMAND}
@echo export AXIOM >>${COMMAND}
@echo PATH='$${AXIOM}/bin':'$${PATH}' >>${COMMAND}
@echo export PATH >>${COMMAND}
@cat ${INT}/sman/axiom >>${COMMAND}
@chmod +x ${COMMAND}
@echo 79 Axiom installation finished.
@echo
@echo Please add $(shell dirname ${COMMAND}) to your PATH variable
@echo Start Axiom with the command $(shell basename ${COMMAND})
@echo
@
\subsection{document}
Each file in the system is in pamphlet form. This stanza, which is not
executed by default, will walk the directories generating the
documentation for each file. These are dvi files and since they are
system-independent and machine-generated they live in the [[INT]]
subdirectory. In particular, we will build an [[INT/DOC]] subtree
mirroring the [[LSP]] and [[SRC]] subtrees. The [[INT/DOC]]
subtree can be removed with no ill effect. Since all of the pamphlet
files live in either the [[LSP]] or [[SRC]] subdirectories we make
sure the [[INT/DOC/LSP]] and [[INT/DOC/SRC]] directories exist.
<<document>>=
document: rootdirs
@echo 22 documenting files
@mkdir -p ${INT}/doc/lsp
@mkdir -p ${INT}/doc/src
@(cd lsp ; ${ENV} ${MAKE} document )
@(cd src ; ${ENV} ${MAKE} document )
@
\subsection{clean}
<<clean>>=
clean:
@ echo 7 making a ${SYS} system, PART=${PART} SUBPART=${SUBPART}
@ echo 8 Environment ${ENV}
@ rm -f lsp/Makefile.dvi
@ rm -f lsp/Makefile
@ rm -f noweb
@ rm -f trace
@ rm -f *~
@ rm -f Makefile.${SYS}
@ rm -rf ${MNT}
@ rm -rf int
@ rm -rf obj
@ rm -rf mnt
@ for i in `find src -name "Makefile"` ; do rm -f $i ; done
@ for i in `find src -name "Makefile.dvi"` ; do rm -f $i ; done
@
\section{The Platform Makefiles}
The Top Level Makefile examines the SPAD variable to determine
the target build platform. It sets up the general structure
of the world. Then it invokes one of these platform Makefiles.
Each of these Makefiles sets several
environment variables that are specific to this platform.
\subsubsection{The [[LDF]] variable }
The LDF variable is the generic loader flags. This gives information
about where various libraries are located on specific platforms. On
linux, for instance, the library [[libXpm.a]] is used by the graphics
routines. This library is usually found in [[/usr/X11R6/bin/libXpm.a]].
Thus, on the linux platform LDF is defined as
\begin{verbatim}
LDF=" -L/usr/X11R6/lib -L/usr/lib ${XLIB}/libXpm.a -lXpm"
\end{verbatim}
\subsubsection{The [[AWK]] variable }
On most systems the gnu toolset is the default. Thus we can just use
'awk' and the program works. However, on some systems we need to
specify that we are using the gnu toolset, and we need to use
[[gawk]] instead of [[awk]].
\subsubsection{The [[PATCH]] variable }
On most systems the gnu toolset is the default. Thus we can just use
'patch' and the program works. However, on some systems we need to
specify that we are using the gnu toolset, and we need to use
[[gpatch]] instead of [[patch]].
\subsubsection{The [[O]] variable }
Various Common Lisp systems prefer certain filename extensions.
This defaults to ``o'' so a compile of foo.lisp becomes foo.o
but other systems prefer .fasl so a compile of foo.lisp becomes
foo.fasl. Change this based on the target lisp.
\subsubsection{The [[LISP]] variable }
There are 3 kinds of "lisp" files in the Axiom build process.
The first are the "clisp" files. These are common lisp files
generated by the boot compiler. The second are the "lisp" files.
These are hand written common lisp code. The third are the "lsp"
files. These are files generated by GNU Common Lisp. The LISP
variable is used to name the third kind of files as this may
change when the underlying common lisp is changed.
\subsubsection{The [[DAASE]] variable}
Axiom uses 5 files, the *.daase files, which are called ``the
databases''. They contain cross-reference, signatures,
and other information needed by the interpreter and compiler.
When the system is being built from scratch these databases
need to exist. However, they get dynamically rebuilt after
the algebra files are compiled. The bootstrap versions of these
databases live in the [[src/share]] subdirectory. Axiom will
use the value of the shell variable [[DAASE]] to find its
databases. If this variable is unbound it uses the standard
[[${MNT}/${SYS}]] path. Note that Axiom will append the string
[[/algebra]] to the value of [[DAASE]]. The default value setting
given here is:
[[DAASE=${SRC}/share]]
so [[${SRC}/share/algebra/*.daase]] will be the
Axiom bootstrap database files.
\subsubsection{The XLIB variable}
The XLIB variable tells us where the X11 libraries live.
Axiom needs to use libXpm.a to build the graph subdirectory.
\subsubsection{The [[SRCDIRS]] variable}
The [[SRCDIRS]] variable is used in the [[src/Makefile.pamphlet]]
to decide what directories to build on a given platform. This is
needed at the moment because certain functions do not yet work on
all platforms.
\subsubsection{The [[GCLVERSION]] variable }
[[GCLVERSION]] is the name of the GCL version. The one we used to
build the original version of the system is gcl-2.4.1. The system
will attempt to untar a file in the [[ZIPS]] directory with the
name [[GCLVERSION.tgz]], cd to the [[GCLVERSION]] subdirectory and
do a [[./configure]] followed by a [[make]].
The GCLVERSION variable is also used to make the GCLDIR variable.
GCLDIR tells depsys where GCL lives. The depsys image needs to
load a file from GCL (cmpnew/collectfn.lsp) which is used to generate
optimizations for function calling in Axiom. This is handled automatically
by changing this variable.
If GCLVERSION is ``gcl-system'', then GCL is not built locally,
and it is assumed that the ``gcl'' command is available off the path.
IF this GCL is unsuitable for building Axiom then very bad things
will happen.
NOTE WELL: IF YOU CHANGE THIS YOU SHOULD ERASE THE lsp/Makefile FILE.
This will cause the build to remake the lsp/Makefile from the
lsp/Makefile.pamphlet file and get the correct version. If you
forget to erase the lsp/Makefile the wrong patches will be applied.
<<GCLVERSION>>=
#GCLVERSION=gcl-2.4.1
#GCLVERSION=gcl-2.5
#GCLVERSION=gcl-2.5.2
#GCLVERSION=gcl-2.6.1
#GCLVERSION=gcl-2.6.2
#GCLVERSION=gcl-2.6.2a
#GCLVERSION=gcl-2.6.3
#GCLVERSION=gcl-2.6.5
#GCLVERSION=gcl-2.6.6
#GCLVERSION=gcl-2.6.7pre
#GCLVERSION=gcl-2.6.7
#GCLVERSION=gcl-2.6.8pre
#GCLVERSION=gcl-2.6.8pre2
#GCLVERSION=gcl-2.6.8pre3
#GCLVERSION=gcl-2.6.8pre4
GCLVERSION=gcl-2.6.8pre7
@
\subsubsection{The [[GCLOPTS]] configure variable}
The [[GCLOPTS]] lisp requires some parameters
for building which vary from system
to system. We create an environment variable here so we can add options
to the configure command in the [[lsp/Makefile.pamphlet]].
<<GCLOPTS>>=
GCLOPTS="--enable-vssize=65536*2 --enable-statsysbfd \
--enable-maxpage=256*1024 --disable-xgcl --disable-tkconfig"
@
It turns out that we can successfully build GCL on many more systems
if we set the [[GCLOPTS]] to build a local [[BFD]].
We are failing during build because "directoryp is undefined" along
with the message
\begin{verbatim}
Error: Cannot get relocated section contents
\end{verbatim}
<<GCLOPTS-LOCBFD>>=
GCLOPTS="--enable-vssize=65536*2 --enable-locbfd --disable-dynsysbfd \
--disable-statsysbfd --enable-maxpage=512*1024 --disable-xgcl \
--disable-tkconfig"
@
For the gcl-2.6.8pre7 version we move to using the custreloc option.
<<GCLOPTS-CUSTRELOC>>=
GCLOPTS="--enable-vssize=65536*2 --disable-locbfd --disable-dynsysbfd \
--disable-statsysbfd --enable-maxpage=512*1024 --disable-xgcl \
--disable-tkconfig --enable-custreloc --disable-tkconfig"
@
For the MACOSX port we need the following options. The ``--disable-nls'' means
that we will not be supporting natural language internationalization.
The ``--enable-maxpage'' has been eliminated because it causes build failures.
The ``--enable-machine'' parameter appears to be used by configure from the
setting of the ``canonical'' variable, which is in turn set by a shell script.
We need to add ``--enable-locbfd'' and ``--disable-dlopen'' due to the error
``unexec: not enough room for load commands for new \_\_DATA segments''.
<<GCLOPTS-MACPORT>>=
GCLOPTS="--enable-vssize=65536*2 --disable-nls --disable-locbfd \
--disable-statsysbfd --enable-custreloc --disable-tkconfig \
--enable-machine=powerpc-macosx --disable-xgcl --disable-dlopen"
@
\subsection{Makefile.freebsd}
<<Makefile.freebsd>>=
<<ENVDEFAULTS>>
PLF=BSDplatform
CCF="-O2 -pipe -fno-strength-reduce -Wall -D_GNU_SOURCE \
-D${PLF} -I/usr/X11R6/include -I/usr/local/include"
LDF="-L/usr/X11R6/lib -L/usr/local/lib"
<<GCLOPTS-CUSTRELOC>>
<<ENV>>
all: rootdirs noweb srcsetup lspdir srcdir
@echo 45 Makefile.FreeBSD called
@echo 46 Environment : ${ENV}
@echo 47 finished system build on `date` | tee >lastBuildDate
@- grep "result FAILED" int/input/*.regress
<<rootdirs>>
<<noweb>>
<<literate commands>>
<<srcsetup>>
<<src>>
<<lsp>>
<<document>>
<<clean>>
@
\subsection{Makefile.windows}
This is for the Windows port. We assume that the build will be done
using GCC under MSYS.
We've modified the [[GCLOPTS]] variable from the standard config in
two ways. First we add [[--enable-debug]] so more information is
available for testing and second we removed [[--enable-statsysbfd]].
<<Makefile.windows>>=
<<ENVDEFAULTS>>
AWK=awk
PLF=MSYSplatform
CCF="-O2 -Wall -D_GNU_SOURCE -D${PLF}"
SRCDIRS="bootdir interpdir sharedir algebradir etcdir docdir inputdir"
<<GCLOPTS-CUSTRELOC>>
<<ENV>>
all: rootdirs noweb srcsetup lspdir srcdir
@echo 45 Makefile.windows called
@echo 46 Environment : ${ENV}
@echo 47 finished system build on `date` | tee >lastBuildDate
@- grep "result FAILED" int/input/*.regress
<<rootdirs>>
<<noweb>>