summaryrefslogtreecommitdiffstats
path: root/build
blob: 293ccbcaca4171e975c01c67d58f44ad6139d473 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#! /bin/sh
:;exec ./scmlit -no-init-file -f $0 -e"(bi)" build "$@"
;;;; "build" Script for compiling SCM.
;; Copyright (C) 1994-2006 Free Software Foundation, Inc.
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as
;; published by the Free Software Foundation, either version 3 of the
;; License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public
;; License along with this program.  If not, see
;; <http://www.gnu.org/licenses/>.

(require 'getopt)
(require 'getopt-parameters)
(require-if 'compiling 'posix)
(require-if 'compiling 'fluid-let)
(require-if 'compiling 'read-command)
(require-if 'compiling 'common-list-functions)

(load (in-vicinity (program-vicinity) "build.scm"))
;@
(define (make-features-txi)
  (call-with-output-file "features.txi"
    (lambda (port)
      (((open-table build 'features) 'for-each-row-in-order)
       (lambda (row)
	 (apply (lambda (name spec documentation)
		  (display "@item " port) (display name port) (newline port)
		  (display "@cindex " port) (display name port) (newline port)
		  (display documentation port) (newline port) (newline port))
		row))))))
;@
(define (print-manifest port)
  (display "@multitable @columnfractions .22 .78" port) (newline port)
  (((open-table build 'manifest) 'for-each-row-in-order)
   (lambda (row)
     (apply (lambda (file format category documentation)
	      (display (string-append "@item @code{" file) port)
	      (display "}" port) (newline port)
	      (display (string-append "@tab " documentation) port)
	      (newline port))
	    row)))
  (display "@end multitable" port) (newline port))

(define (append-info-node path node afile)
  (let ((cat (open-file afile "a")))
    (do ((n (+ -1 2) (+ -1 n)))
	((negative? n) (close-port cat))
      (newline cat)))
  (system (string-append "info -f " path " -n '" node "' -o - >> " afile)))
;@
(define (make-readme)
  (require 'posix)
  (let ((pipe (open-output-pipe "makeinfo --no-headers -o README"))
	(scm-info (read-version
		   (in-vicinity (implementation-vicinity) "patchlvl.h"))))
    (if (not pipe) (slib:error 'make-readme 'couldn't 'open 'pipe))
    (display "\
This directory contains the distribution of scm" pipe)
    (display scm-info pipe)
    (display ".  SCM conforms to
Revised^5 Report on the Algorithmic Language Scheme and the IEEE P1178
specification.  SCM runs under Amiga, Atari-ST, MacOS, MS-DOS, OS/2,
NOS/VE, Unicos, VMS, Unix and similar systems.  SCM supports the SLIB
Scheme library; both SCM and SLIB are GNU packages.

@center @url{http://swiss.csail.mit.edu/~jaffer/SCM}

@section Manifest
"
	     pipe)
    (print-manifest pipe)
    (close-port pipe)
    (set! scm-info (string-append "scm-" scm-info ".info"))
    (append-info-node scm-info "SLIB" "README")
    (append-info-node scm-info "Making SCM" "README")
    (append-info-node scm-info "Editing Scheme Code" "README")
    (append-info-node scm-info "Problems Compiling" "README")
    (append-info-node scm-info "Problems Linking" "README")
    (append-info-node scm-info "Problems Running" "README")
    (append-info-node scm-info "Testing" "README")))

(define build:csv (make-command-server build '*commands*))
(define (build-from-argv)
  (define command (string->symbol (list-ref *argv* *optind*)))
  (define getopt- getopt--)
  (require 'fluid-let)
  (fluid-let ((getopt--
	       (lambda (optstring)
		 (let* ((opt (getopt- (string-append optstring "f:-:"))))
		   (cond ((eqv? #\f opt)
			  (let ()
			    (require 'read-command)
			    (require 'common-list-functions)
			    (set! *argv* (append (butnthcdr *optind* *argv*)
						 (read-options-file *optarg*)
						 (nthcdr *optind* *argv*))))))
		   opt))))
    (cond
     ((pair? *argv*)
      (set! *optind* (+ 1 *optind*))
      (build:csv
       command
       (lambda (comname comval options positions arities types
			defaulters checks aliases)
	 (let* ((params (getopt->parameter-list options arities types aliases))
		(fparams (and params (fill-empty-parameters defaulters params))))
	   (cond ((not (list? params))
		  ;;(slib:warn 'build-from-argv 'not-parameters? fparams)
		  #f)
		 ((not (check-parameters checks fparams))
		  (slib:warn 'build-from-argv 'check-parameters 'failed)
		  #f)
		 ((not (check-arities (map arity->arity-spec arities) fparams))
		  (slib:error 'build-from-argv 'bad 'arity fparams) #f)
		 (else (comval fparams))))))))))
;@
(define (build-from-whole-argv argv)
  (if (string? argv)
      (let ()
	(require 'read-command)
	(set! argv (call-with-input-string argv read-command))))
  (set! *optind* 0)
  (set! *optarg* #f)
  (set! *argv* argv)
  (build-from-argv))

;;;@ Used when invoked as script
(define (bi) (exit (and (build-from-argv) #t)))
;@
(define b build-from-whole-argv)
;@
(define (b*)
  (require 'read-command)
  (do ((e (read-command) (read-command)))
      ((eof-object? e))
    (cond ((null? e))
	  (else
	   (cond ((not (string-ci=? (car e) "build"))
		  (set! e (cons "build" e))))
	   (write (build-from-whole-argv e))
	   (newline)))
    (display "build> ")
    (force-output)))

(cond (*interactive*
       (display "type (b \"build <command-line>\") to build") (newline)
       (display "type (b*) to enter build command loop") (newline)))

;;; Local Variables:
;;; mode:scheme
;;; End: