* Make misc "Makefile.in" files respect a DESTDIR env variable
* Extended unixstyle-install.ss to support additional operations, no need for src/copytree.ss and can fix an installation with DESTDIR svn: r3470
This commit is contained in:
parent
5d0f80fdad
commit
1884ba9715
|
@ -14,6 +14,10 @@
|
||||||
;; - `make-install-copytree': copies some toplevel directories, skips .svn
|
;; - `make-install-copytree': copies some toplevel directories, skips .svn
|
||||||
;; and compiled subdirs, and rewrite config.ss, but no uninstaller (used by
|
;; and compiled subdirs, and rewrite config.ss, but no uninstaller (used by
|
||||||
;; `make install') (requres an additional `origtree' argument)
|
;; `make install') (requres an additional `origtree' argument)
|
||||||
|
;; - `make-install-destdir-fix': fixes paths in binaries, laucnhers, and
|
||||||
|
;; config.ss (used by `make install' to fix a DESTDIR) (requires exactly
|
||||||
|
;; the same args as `make-install-copytree' (prefixed) and requires a
|
||||||
|
;; proper DESTDIR setting)
|
||||||
;; * pltdir: The source plt directory
|
;; * pltdir: The source plt directory
|
||||||
;; * Path names that should be moved/copied (bin, collects, doc, lib, ...)
|
;; * Path names that should be moved/copied (bin, collects, doc, lib, ...)
|
||||||
|
|
||||||
|
@ -27,14 +31,11 @@
|
||||||
|
|
||||||
(define op (string->symbol (get-arg)))
|
(define op (string->symbol (get-arg)))
|
||||||
(define pltdir (get-arg))
|
(define pltdir (get-arg))
|
||||||
(define bindir (get-arg))
|
(define dirs (map (lambda (name) (list name (get-arg)))
|
||||||
(define collectsdir (get-arg))
|
'(bin collects doc lib includeplt libplt man #|src|#)))
|
||||||
(define docdir (get-arg))
|
|
||||||
(define libdir (get-arg))
|
(define (dir: name)
|
||||||
(define includepltdir (get-arg))
|
(cadr (or (assq name dirs) (error 'getdir "unknown dir name: ~e" name))))
|
||||||
(define libpltdir (get-arg))
|
|
||||||
(define mandir (get-arg))
|
|
||||||
;; (define srcdir (get-arg))
|
|
||||||
|
|
||||||
;; Configures level where we start owning stuff (in the sense that the
|
;; Configures level where we start owning stuff (in the sense that the
|
||||||
;; generated uninstaller will remove it, and the installation will remove
|
;; generated uninstaller will remove it, and the installation will remove
|
||||||
|
@ -46,7 +47,7 @@
|
||||||
;; encounter a directory that does not already exist. #f means that we never
|
;; encounter a directory that does not already exist. #f means that we never
|
||||||
;; own directories, only files.
|
;; own directories, only files.
|
||||||
(define (level-of dir)
|
(define (level-of dir)
|
||||||
(let ([dir (string->symbol (->string (basename dir)))])
|
(let ([dir (string->symbol (basename dir))])
|
||||||
(case dir
|
(case dir
|
||||||
[(bin) #f]
|
[(bin) #f]
|
||||||
[(collects) 1]
|
[(collects) 1]
|
||||||
|
@ -54,28 +55,63 @@
|
||||||
[(include) 1]
|
[(include) 1]
|
||||||
;; if shared libraries are used, then these files should be moved
|
;; if shared libraries are used, then these files should be moved
|
||||||
;; independently, as if they had a level of #f
|
;; independently, as if they had a level of #f
|
||||||
[(dir) 1]
|
[(lib) 1]
|
||||||
[(man) #f]
|
[(man) #f]
|
||||||
[(src) 1]
|
[(src) 1]
|
||||||
[(readme.txt) #f] ; moved last
|
[(readme.txt) #f] ; moved last
|
||||||
[else (error 'level-of "internal-error: unknown dir ~e" dir)])))
|
[else (error 'level-of "internal-error -- unknown dir: ~e" dir)])))
|
||||||
|
|
||||||
(define (->string x)
|
(define (make-path . args) ; like build-path but returns a string
|
||||||
(if (path? x) (path->string x) x))
|
(path->string (apply build-path args)))
|
||||||
|
|
||||||
(define (basename path)
|
(define (basename path) ; returns a string
|
||||||
(let-values ([(dir name dir?) (split-path path)]) name))
|
(let-values ([(dir name dir?) (split-path path)]) (path->string name)))
|
||||||
|
|
||||||
(define (dirname path)
|
(define (dirname path) ; returns a string
|
||||||
(let-values ([(dir name dir?) (split-path path)]) dir))
|
(let-values ([(dir name dir?) (split-path path)]) dir))
|
||||||
|
|
||||||
|
;; Copied from mzlib/list.ss, used in ls
|
||||||
|
(define (sort! lst less?)
|
||||||
|
(define (merge! a b)
|
||||||
|
(define (loop r a b r-a?) ; r-a? for optimization -- is r connected to a?
|
||||||
|
(if (less? (car b) (car a))
|
||||||
|
(begin (when r-a? (set-cdr! r b))
|
||||||
|
(if (null? (cdr b)) (set-cdr! b a) (loop b a (cdr b) #f)))
|
||||||
|
;; (car a) <= (car b)
|
||||||
|
(begin (unless r-a? (set-cdr! r a))
|
||||||
|
(if (null? (cdr a)) (set-cdr! a b) (loop a (cdr a) b #t)))))
|
||||||
|
(cond [(null? a) b]
|
||||||
|
[(null? b) a]
|
||||||
|
[(less? (car b) (car a))
|
||||||
|
(if (null? (cdr b)) (set-cdr! b a) (loop b a (cdr b) #f))
|
||||||
|
b]
|
||||||
|
[else ; (car a) <= (car b)
|
||||||
|
(if (null? (cdr a)) (set-cdr! a b) (loop a (cdr a) b #t))
|
||||||
|
a]))
|
||||||
|
(define (step n)
|
||||||
|
(cond [(> n 1) (let* (; let* not really needed with mzscheme's l->r eval
|
||||||
|
[j (quotient n 2)] [a (step j)] [b (step (- n j))])
|
||||||
|
(merge! a b))]
|
||||||
|
[(= n 1) (let ([p lst])
|
||||||
|
(set! lst (cdr lst))
|
||||||
|
(set-cdr! p '())
|
||||||
|
p)]
|
||||||
|
[else '()]))
|
||||||
|
(step (length lst)))
|
||||||
|
|
||||||
|
;; like directory-list, but returns a sorted list of strings (this is a lot
|
||||||
|
;; of code just to get the sorting, but it's better if an installer operates
|
||||||
|
;; in a deterministic way)
|
||||||
|
(define (ls . dir)
|
||||||
|
(sort! (map path->string (apply directory-list dir)) string<?))
|
||||||
|
|
||||||
;; convenient wrapper for a simple subprocess
|
;; convenient wrapper for a simple subprocess
|
||||||
(define (run cmd . args)
|
(define (run cmd . args)
|
||||||
(let-values
|
(let-values
|
||||||
([(p _1 _2 _3)
|
([(p _1 _2 _3)
|
||||||
(apply subprocess
|
(apply subprocess
|
||||||
(current-output-port) (current-input-port) (current-error-port)
|
(current-output-port) (current-input-port) (current-error-port)
|
||||||
(find-executable-path cmd) (map ->string args))])
|
(find-executable-path cmd) args)])
|
||||||
(subprocess-wait p)
|
(subprocess-wait p)
|
||||||
(unless (zero? (subprocess-status p))
|
(unless (zero? (subprocess-status p))
|
||||||
(error (format "~a: returned an error exit code"
|
(error (format "~a: returned an error exit code"
|
||||||
|
@ -86,8 +122,7 @@
|
||||||
(define (rm path)
|
(define (rm path)
|
||||||
(cond [(or (file-exists? path) (link-exists? path)) (delete-file path)]
|
(cond [(or (file-exists? path) (link-exists? path)) (delete-file path)]
|
||||||
[(directory-exists? path)
|
[(directory-exists? path)
|
||||||
(parameterize ([current-directory path])
|
(parameterize ([current-directory path]) (for-each rm (ls)))
|
||||||
(for-each rm (directory-list)))
|
|
||||||
(delete-directory path)]
|
(delete-directory path)]
|
||||||
[else #t])) ; shouldn't happen
|
[else #t])) ; shouldn't happen
|
||||||
|
|
||||||
|
@ -109,8 +144,7 @@
|
||||||
[(directory-exists? src)
|
[(directory-exists? src)
|
||||||
(make-directory dst) (time!)
|
(make-directory dst) (time!)
|
||||||
(parameterize ([current-directory src])
|
(parameterize ([current-directory src])
|
||||||
(for-each (lambda (p) (loop p (build-path dst p)))
|
(for-each (lambda (p) (loop p (make-path dst p))) (ls)))]
|
||||||
(directory-list)))]
|
|
||||||
[(file-exists? src) (copy-file src dst) (time!)]
|
[(file-exists? src) (copy-file src dst) (time!)]
|
||||||
[else (error 'cp "internal error: ~e" src)]))))
|
[else (error 'cp "internal error: ~e" src)]))))
|
||||||
|
|
||||||
|
@ -122,9 +156,9 @@
|
||||||
(lambda (e) #f)])
|
(lambda (e) #f)])
|
||||||
(rename-file-or-directory src dst) #t)
|
(rename-file-or-directory src dst) #t)
|
||||||
;; move failed: copy & remove
|
;; move failed: copy & remove
|
||||||
(with-handlers ([void (lambda (e)
|
(with-handlers ([exn? (lambda (e)
|
||||||
;; error => remove new copy (if can) and re-raise
|
;; error => remove new copy (if can) and re-raise
|
||||||
(with-handlers ([void (lambda (e) #f)])
|
(with-handlers ([exn? (lambda (e) #f)])
|
||||||
(rm dst)
|
(rm dst)
|
||||||
(raise e)))])
|
(raise e)))])
|
||||||
;; (cp src dst) (rm src)
|
;; (cp src dst) (rm src)
|
||||||
|
@ -147,62 +181,71 @@
|
||||||
(cp src dst)
|
(cp src dst)
|
||||||
(register-change! 'cp src dst))
|
(register-change! 'cp src dst))
|
||||||
|
|
||||||
(define ((bin-mover/copier move?) src dst)
|
(define (fix-executable file)
|
||||||
(define (binary-copy)
|
(define (fix-binary file)
|
||||||
;; never move -- modify a copy of the running mzscheme
|
(let-values ([(i o) (open-input-output-file file 'update)])
|
||||||
(copy-file src dst)
|
|
||||||
(let-values ([(i o) (open-input-output-file dst 'update)])
|
|
||||||
(let ([m (regexp-match-positions #rx#"coLLECTs dIRECTORy:" i)])
|
(let ([m (regexp-match-positions #rx#"coLLECTs dIRECTORy:" i)])
|
||||||
(unless m
|
(unless m
|
||||||
(error
|
(error
|
||||||
(format "could not find collection-path label in executable: ~a"
|
(format "could not find collection-path label in executable: ~a"
|
||||||
src)))
|
file)))
|
||||||
(file-position o (cdar m))
|
(file-position o (cdar m))
|
||||||
(display collectsdir o)
|
(display (dir: 'collects) o)
|
||||||
(write-byte 0 o)
|
(write-byte 0 o)
|
||||||
(write-byte 0 o)
|
(write-byte 0 o)
|
||||||
(close-input-port i)
|
(close-input-port i)
|
||||||
(close-output-port o))))
|
(close-output-port o))))
|
||||||
(define (script-copy)
|
(define (fix-script file)
|
||||||
(let* ([size (file-size src)]
|
(let* ([size (file-size file)]
|
||||||
[buf (with-input-from-file src (lambda () (read-bytes size)))]
|
[buf (with-input-from-file file (lambda () (read-bytes size)))]
|
||||||
[m (or (regexp-match-positions
|
[m (or (regexp-match-positions
|
||||||
#rx#"\n# {{{ bindir\n(.*?\n)# }}} bindir\n" buf)
|
#rx#"\n# {{{ bindir\n(.*?\n)# }}} bindir\n" buf)
|
||||||
(error (format "could not find binpath block in script: ~a"
|
(error (format "could not find binpath block in script: ~a"
|
||||||
src)))])
|
file)))])
|
||||||
(with-output-to-file dst
|
;; 'truncate file to keep it executable
|
||||||
|
(with-output-to-file file
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(write-bytes buf (current-output-port) 0 (caadr m))
|
(write-bytes buf (current-output-port) 0 (caadr m))
|
||||||
(printf "bindir=\"~a\"\n"
|
(printf "bindir=\"~a\"\n"
|
||||||
(regexp-replace* #rx"[\"`'$\\]" (->string bindir) "\\\\&"))
|
(regexp-replace* #rx"[\"`'$\\]" (dir: 'bin) "\\\\&"))
|
||||||
(write-bytes buf (current-output-port) (cdadr m)))
|
(write-bytes buf (current-output-port) (cdadr m)))
|
||||||
'truncate/replace)))
|
'truncate)))
|
||||||
(let ([magic (with-input-from-file src (lambda () (read-bytes 10)))])
|
(let ([magic (with-input-from-file file (lambda () (read-bytes 10)))])
|
||||||
(cond [(regexp-match #rx#"^\177ELF" magic) (binary-copy)]
|
(cond [(regexp-match #rx#"^\177ELF" magic)
|
||||||
[(regexp-match #rx#"^#!/bin/sh" magic) (script-copy)]
|
(let ([temp (format "~a-temp-for-install"
|
||||||
[else (error (format "unknown binary type: ~a" src))])
|
(regexp-replace* #rx"/" file "_"))])
|
||||||
(when move? (delete-file src))
|
(with-handlers ([exn? (lambda (e) (delete-file temp) (raise e))])
|
||||||
;; undo might move modified files, but the installer removes them anyway
|
;; always copy so we never change the running executable
|
||||||
(register-change! (if move? 'mv 'cp) src dst)
|
(rm temp)
|
||||||
(run "chmod" "+x" dst)))
|
(copy-file file temp)
|
||||||
|
(fix-binary temp)
|
||||||
|
(delete-file file)
|
||||||
|
(mv temp file)))]
|
||||||
|
[(regexp-match #rx#"^#!/bin/sh" magic)
|
||||||
|
(fix-script file)]
|
||||||
|
[else (error (format "unknown binary type: ~a" file))])))
|
||||||
|
|
||||||
|
(define (fix-executables . x)
|
||||||
|
(parameterize ([current-directory (if (pair? x) (car x) (dir: 'bin))])
|
||||||
|
(for-each (lambda (f) (when (file-exists? f) (fix-executable f))) (ls))))
|
||||||
|
|
||||||
;; remove and record all empty dirs
|
;; remove and record all empty dirs
|
||||||
(define (remove-empty-dirs dir)
|
(define (remove-empty-dirs dir)
|
||||||
(let loop ([dir dir] [recurse? #t])
|
(let loop ([dir dir] [recurse? #t])
|
||||||
(when (and (directory-exists? dir) (not (link-exists? dir)))
|
(when (and (directory-exists? dir) (not (link-exists? dir)))
|
||||||
(let ([ps (directory-list dir)])
|
(let ([ps (ls dir)])
|
||||||
(cond [(null? ps)
|
(cond [(null? ps)
|
||||||
(delete-directory dir)
|
(delete-directory dir)
|
||||||
(register-change! 'rd dir)]
|
(register-change! 'rd dir)]
|
||||||
[recurse?
|
[recurse?
|
||||||
(for-each (lambda (p) (loop (build-path dir p) #t)) ps)
|
(for-each (lambda (p) (loop (make-path dir p) #t)) ps)
|
||||||
(loop dir #f)] ; try again
|
(loop dir #f)] ; try again
|
||||||
;; get here only on the 2nd round, so we cannot remove it
|
;; get here only on the 2nd round, so we cannot remove it
|
||||||
)))))
|
)))))
|
||||||
|
|
||||||
;; called from an error handler, so avoid raising more errors
|
;; called from an error handler, so avoid raising more errors
|
||||||
(define (undo-changes)
|
(define (undo-changes)
|
||||||
(printf "...undoing changes\n")
|
(printf "*** Error: undoing changes...\n")
|
||||||
(for-each
|
(for-each
|
||||||
(lambda (p)
|
(lambda (p)
|
||||||
(apply (case (car p)
|
(apply (case (car p)
|
||||||
|
@ -224,7 +267,7 @@
|
||||||
path-changes))
|
path-changes))
|
||||||
|
|
||||||
(define (write-uninstaller)
|
(define (write-uninstaller)
|
||||||
(define uninstaller (build-path bindir "plt-uninstall"))
|
(define uninstaller (make-path (dir: 'bin) "plt-uninstall"))
|
||||||
(printf "Writing uninstaller at: ~a...\n" uninstaller)
|
(printf "Writing uninstaller at: ~a...\n" uninstaller)
|
||||||
(register-change! 'file uninstaller)
|
(register-change! 'file uninstaller)
|
||||||
(with-output-to-file uninstaller
|
(with-output-to-file uninstaller
|
||||||
|
@ -250,9 +293,15 @@
|
||||||
'replace)
|
'replace)
|
||||||
(run "chmod" "+x" uninstaller))
|
(run "chmod" "+x" uninstaller))
|
||||||
|
|
||||||
(define (write-config . compile?)
|
(define write-config
|
||||||
|
(case-lambda
|
||||||
|
[() (write-config #t (dir: 'collects))]
|
||||||
|
[(x) (if (boolean? x)
|
||||||
|
(write-config x (dir: 'collects))
|
||||||
|
(write-config #t x))]
|
||||||
|
[(compile? collectsdir)
|
||||||
(define (cpath . xs)
|
(define (cpath . xs)
|
||||||
(apply build-path collectsdir "config" xs))
|
(apply make-path collectsdir "config" xs))
|
||||||
(define (ftime file)
|
(define (ftime file)
|
||||||
(and (file-exists? file) (file-or-directory-modify-seconds file)))
|
(and (file-exists? file) (file-or-directory-modify-seconds file)))
|
||||||
(let* ([src (cpath "config.ss")]
|
(let* ([src (cpath "config.ss")]
|
||||||
|
@ -261,17 +310,18 @@
|
||||||
[src-time (ftime src)]
|
[src-time (ftime src)]
|
||||||
[zo-time (ftime zo)])
|
[zo-time (ftime zo)])
|
||||||
(printf "Rewriting configuration file at: ~a...\n" src)
|
(printf "Rewriting configuration file at: ~a...\n" src)
|
||||||
(parameterize ([current-library-collection-paths (list collectsdir)])
|
(parameterize ([current-library-collection-paths ; for configtab.ss
|
||||||
|
(list collectsdir)])
|
||||||
(with-output-to-file (cpath "config.ss")
|
(with-output-to-file (cpath "config.ss")
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(printf ";; automatically generated by unixstyle-install\n")
|
(printf ";; automatically generated by unixstyle-install\n")
|
||||||
(printf "(module config (lib \"configtab.ss\" \"setup\")\n")
|
(printf "(module config (lib \"configtab.ss\" \"setup\")\n")
|
||||||
(printf " (define doc-dir ~s)\n" docdir)
|
(printf " (define doc-dir ~s)\n" (dir: 'doc))
|
||||||
(when (eq? 'shared (system-type 'link)) ; never true for now
|
(when (eq? 'shared (system-type 'link)) ; never true for now
|
||||||
(printf " (define dll-dir ~s)\n" libdir))
|
(printf " (define dll-dir ~s)\n" (dir: 'lib)))
|
||||||
(printf " (define lib-dir ~s)\n" libpltdir)
|
(printf " (define lib-dir ~s)\n" (dir: 'libplt))
|
||||||
(printf " (define include-dir ~s)\n" includepltdir)
|
(printf " (define include-dir ~s)\n" (dir: 'includeplt))
|
||||||
(printf " (define bin-dir ~s)\n" bindir)
|
(printf " (define bin-dir ~s)\n" (dir: 'bin))
|
||||||
(printf " (define absolute-installation? #t))\n"))
|
(printf " (define absolute-installation? #t))\n"))
|
||||||
'truncate/replace)
|
'truncate/replace)
|
||||||
;; recompile & set times as if nothing happened (don't remove .dep)
|
;; recompile & set times as if nothing happened (don't remove .dep)
|
||||||
|
@ -285,7 +335,7 @@
|
||||||
(with-output-to-file zo
|
(with-output-to-file zo
|
||||||
(lambda () (write (compile (read-syntax))))
|
(lambda () (write (compile (read-syntax))))
|
||||||
'truncate/replace)))
|
'truncate/replace)))
|
||||||
(file-or-directory-modify-seconds zo zo-time))))))
|
(file-or-directory-modify-seconds zo zo-time)))))]))
|
||||||
|
|
||||||
;; creates a directory including its ancestors when needed
|
;; creates a directory including its ancestors when needed
|
||||||
(define (make-dir* dir)
|
(define (make-dir* dir)
|
||||||
|
@ -311,16 +361,14 @@
|
||||||
[(n) (error "Abort!")]
|
[(n) (error "Abort!")]
|
||||||
[else (loop)]))))))
|
[else (loop)]))))))
|
||||||
|
|
||||||
(define ((move/copy-tree move?) src dst . mover/copier)
|
(define ((move/copy-tree move?) src dst*)
|
||||||
|
(define dst (if (symbol? dst*) (dir: dst*) dst*))
|
||||||
(printf "~aing ~a -> ~a\n" (if move? "Mov" "Copy") src dst)
|
(printf "~aing ~a -> ~a\n" (if move? "Mov" "Copy") src dst)
|
||||||
(make-dir* (dirname dst))
|
(make-dir* (dirname dst))
|
||||||
(let loop ([src (simplify-path src #f)]
|
(let loop ([src (path->string (simplify-path src #f))]
|
||||||
[dst (simplify-path dst #f)]
|
[dst (path->string (simplify-path dst #f))]
|
||||||
[lvl (level-of src)]) ; see above
|
[lvl (level-of src)]) ; see above
|
||||||
(let ([doit (let ([doit (cond [(pair? mover/copier) (car mover/copier)]
|
(let ([doit (let ([doit (if move? mv* cp*)]) (lambda () (doit src dst)))]
|
||||||
[move? mv*]
|
|
||||||
[else cp*])])
|
|
||||||
(lambda () (doit src dst)))]
|
|
||||||
[src-d? (directory-exists? src)]
|
[src-d? (directory-exists? src)]
|
||||||
[dst-l? (link-exists? dst)]
|
[dst-l? (link-exists? dst)]
|
||||||
[dst-d? (directory-exists? dst)]
|
[dst-d? (directory-exists? dst)]
|
||||||
|
@ -335,10 +383,10 @@
|
||||||
[dst-d? (if (and src-d? (or (not lvl) (< 0 lvl)))
|
[dst-d? (if (and src-d? (or (not lvl) (< 0 lvl)))
|
||||||
;; recurse only when source is dir, & not too deep
|
;; recurse only when source is dir, & not too deep
|
||||||
(for-each (lambda (name)
|
(for-each (lambda (name)
|
||||||
(loop (build-path src name)
|
(loop (make-path src name)
|
||||||
(build-path dst name)
|
(make-path dst name)
|
||||||
(and lvl (sub1 lvl))))
|
(and lvl (sub1 lvl))))
|
||||||
(directory-list src))
|
(ls src))
|
||||||
(begin (ask-overwrite "dir" dst) (doit)))]
|
(begin (ask-overwrite "dir" dst) (doit)))]
|
||||||
[dst-f? (ask-overwrite "file" dst) (doit)]
|
[dst-f? (ask-overwrite "file" dst) (doit)]
|
||||||
[else (doit)]))))
|
[else (doit)]))))
|
||||||
|
@ -349,30 +397,28 @@
|
||||||
(define (move/copy-distribution move?)
|
(define (move/copy-distribution move?)
|
||||||
(define do-tree (move/copy-tree move?))
|
(define do-tree (move/copy-tree move?))
|
||||||
(current-directory pltdir)
|
(current-directory pltdir)
|
||||||
(when (ormap (lambda (p) (regexp-match #rx"[.]so" (->string p)))
|
(when (ormap (lambda (p) (regexp-match #rx"[.]so" p)) (ls "lib"))
|
||||||
(directory-list "lib"))
|
|
||||||
(error "Cannot handle distribution of shared-libraries (yet)"))
|
(error "Cannot handle distribution of shared-libraries (yet)"))
|
||||||
(with-handlers ([void (lambda (e) (undo-changes) (raise e))])
|
(with-handlers ([exn? (lambda (e) (undo-changes) (raise e))])
|
||||||
(do-tree "bin" bindir (bin-mover/copier move?))
|
(do-tree "bin" 'bin)
|
||||||
(do-tree "collects" collectsdir)
|
(do-tree "collects" 'collects)
|
||||||
(do-tree "doc" docdir)
|
(do-tree "doc" 'doc)
|
||||||
;; (do-tree libdir) ; shared stuff goes here
|
;; (do-tree ??? 'lib) ; shared stuff goes here
|
||||||
(do-tree "include" includepltdir)
|
(do-tree "include" 'includeplt)
|
||||||
(do-tree "lib" libpltdir)
|
(do-tree "lib" 'libplt)
|
||||||
(do-tree "man" mandir)
|
(do-tree "man" 'man)
|
||||||
;; (when (and (not (equal? srcdir "")) (directory-exists? "src"))
|
;; (when (and (not (equal? (dir: 'src) "")) (directory-exists? "src"))
|
||||||
;; (do-tree "src" srcdir))
|
;; (do-tree "src" 'src))
|
||||||
;; don't use the above -- it would be pointless to put the source tree in
|
;; don't use the above -- it would be pointless to put the source tree in
|
||||||
;; a place where it would not be usable.
|
;; a place where it would not be usable.
|
||||||
(when (and (directory-exists? "src") move?) (rm "src"))
|
(when (and (directory-exists? "src") move?) (rm "src"))
|
||||||
;; part of the distribution:
|
;; part of the distribution:
|
||||||
(when (file-exists? "readme.txt")
|
(when (file-exists? "readme.txt")
|
||||||
(do-tree "readme.txt" (build-path docdir "readme.txt")))
|
(do-tree "readme.txt" (make-path (dir: 'doc) "readme.txt")))
|
||||||
;; nothing should be left now if this was a move
|
;; nothing should be left now if this was a move
|
||||||
(when move?
|
(when (and move? (not (null? (ls))))
|
||||||
(let ([ps (map ->string (directory-list))])
|
(error (format "leftovers in source tree: ~s" (ls))))
|
||||||
(unless (null? ps)
|
(fix-executables)
|
||||||
(error (format "leftovers in source tree: ~s" ps)))))
|
|
||||||
(write-uninstaller)
|
(write-uninstaller)
|
||||||
(write-config))
|
(write-config))
|
||||||
(when move?
|
(when move?
|
||||||
|
@ -381,16 +427,36 @@
|
||||||
|
|
||||||
(define (make-install-copytree)
|
(define (make-install-copytree)
|
||||||
(define copytree (move/copy-tree #f))
|
(define copytree (move/copy-tree #f))
|
||||||
(define origtree (equal? "yes" (get-arg)))
|
(define origtree? (equal? "yes" (get-arg)))
|
||||||
|
(current-directory pltdir)
|
||||||
(set! skip-filter ; skip all dot-names, CVS and compiled subdirs
|
(set! skip-filter ; skip all dot-names, CVS and compiled subdirs
|
||||||
(lambda (p)
|
(lambda (p)
|
||||||
(regexp-match #rx"^(?:[.].*|CVS|compiled)$"
|
(regexp-match #rx"^(?:[.].*|CVS|compiled)$" (basename p))))
|
||||||
(->string (basename p)))))
|
(with-handlers ([exn? (lambda (e) (undo-changes) (raise e))])
|
||||||
(with-handlers ([void (lambda (e) (undo-changes) (raise e))])
|
(set! yes-to-all? #t) ; non-interactive
|
||||||
(copytree (build-path pltdir "collects") collectsdir)
|
(copytree "collects" 'collects)
|
||||||
(copytree (build-path pltdir "doc") docdir)
|
(copytree "doc" 'doc)
|
||||||
(copytree (build-path pltdir "man") mandir)
|
(copytree "man" 'man)
|
||||||
(write-config #f)))
|
(unless origtree? (write-config #f)))) ; don't recompile
|
||||||
|
|
||||||
|
(define (make-install-destdir-fix)
|
||||||
|
(define destdir (getenv "DESTDIR"))
|
||||||
|
(define destdirlen (and destdir (string-length destdir)))
|
||||||
|
(define origtree? (equal? "yes" (get-arg)))
|
||||||
|
(define (remove-dest p)
|
||||||
|
(let ([pfx (and (< destdirlen (string-length p))
|
||||||
|
(substring p 0 destdirlen))])
|
||||||
|
(if (equal? pfx destdir)
|
||||||
|
(regexp-replace #rx"^/+" (substring p destdirlen) "/")
|
||||||
|
(error (format "expecting a DESTDIR prefix of ~s in ~s" destdir p)))))
|
||||||
|
(unless destdir
|
||||||
|
(error "missing DESTDIR value for make-install-destdir-fix"))
|
||||||
|
(let (;; grab paths before we change them
|
||||||
|
[bindir (dir: 'bin)]
|
||||||
|
[collectsdir (dir: 'collects)])
|
||||||
|
(set! dirs (map (lambda (d) (list (car d) (remove-dest (cadr d)))) dirs))
|
||||||
|
(fix-executables bindir)
|
||||||
|
(unless origtree? (write-config collectsdir))))
|
||||||
|
|
||||||
;; --------------------------------------------------------------------------
|
;; --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -398,6 +464,7 @@
|
||||||
[(move) (move/copy-distribution #t)]
|
[(move) (move/copy-distribution #t)]
|
||||||
[(copy) (move/copy-distribution #f)]
|
[(copy) (move/copy-distribution #f)]
|
||||||
[(make-install-copytree) (make-install-copytree)]
|
[(make-install-copytree) (make-install-copytree)]
|
||||||
|
[(make-install-destdir-fix) (make-install-destdir-fix)]
|
||||||
[else (error (format "unknown verb: ~e" op))])
|
[else (error (format "unknown verb: ~e" op))])
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -32,12 +32,13 @@ mred3m-stub: @MAKE_MRED3M@
|
||||||
install:
|
install:
|
||||||
$(MAKE) plain-install
|
$(MAKE) plain-install
|
||||||
$(MAKE) setup-plt
|
$(MAKE) setup-plt
|
||||||
|
$(MAKE) fix-paths
|
||||||
|
|
||||||
plain-install:
|
plain-install:
|
||||||
$(MAKE) install-normal
|
$(MAKE) install-normal
|
||||||
|
|
||||||
install-normal:
|
install-normal:
|
||||||
mkdir -p $(prefix) $(ALLDIRINFO)
|
mkdir -p $(addprefix $(DESTDIR), $(prefix) $(ALLDIRINFO))
|
||||||
$(MAKE) mzinstall
|
$(MAKE) mzinstall
|
||||||
$(MAKE) mredinstall-stub
|
$(MAKE) mredinstall-stub
|
||||||
$(MAKE) copytree-stub
|
$(MAKE) copytree-stub
|
||||||
|
@ -46,7 +47,7 @@ install-normal:
|
||||||
mredinstall-stub: @MAKE_MREDINSTALL@
|
mredinstall-stub: @MAKE_MREDINSTALL@
|
||||||
|
|
||||||
setup-plt:
|
setup-plt:
|
||||||
$(bindir)/mzscheme -mvqM setup
|
$(DESTDIR)$(bindir)/mzscheme -mvqX "$(DESTDIR)$(collectsdir)" -M setup
|
||||||
|
|
||||||
plain-install-3m:
|
plain-install-3m:
|
||||||
$(MAKE) install-normal
|
$(MAKE) install-normal
|
||||||
|
@ -56,6 +57,7 @@ plain-install-3m:
|
||||||
install-3m:
|
install-3m:
|
||||||
$(MAKE) plain-install-3m
|
$(MAKE) plain-install-3m
|
||||||
$(MAKE) setup-plt
|
$(MAKE) setup-plt
|
||||||
|
$(MAKE) fix-paths
|
||||||
|
|
||||||
mredinstall3m-stub: @MAKE_MREDINSTALL3M@
|
mredinstall3m-stub: @MAKE_MREDINSTALL3M@
|
||||||
|
|
||||||
|
@ -99,4 +101,13 @@ copytree-stub: @MAKE_COPYTREE@
|
||||||
copytree:
|
copytree:
|
||||||
mzscheme/mzscheme -mvxqu \
|
mzscheme/mzscheme -mvxqu \
|
||||||
"$(srcdir)/../collects/setup/unixstyle-install.ss" \
|
"$(srcdir)/../collects/setup/unixstyle-install.ss" \
|
||||||
make-install-copytree "$(srcdir)/.." $(ALLDIRINFO) @INSTALL_ORIG_TREE@
|
make-install-copytree "$(srcdir)/.." \
|
||||||
|
$(addprefix $(DESTDIR), $(ALLDIRINFO)) @INSTALL_ORIG_TREE@
|
||||||
|
|
||||||
|
fix-paths:
|
||||||
|
if [ "$(DESTDIR)" != "" ]; then \
|
||||||
|
mzscheme/mzscheme -mvxqu \
|
||||||
|
"$(srcdir)/../collects/setup/unixstyle-install.ss" \
|
||||||
|
make-install-destdir-fix "$(srcdir)/.." \
|
||||||
|
$(addprefix $(DESTDIR), $(ALLDIRINFO)) @INSTALL_ORIG_TREE@; \
|
||||||
|
fi
|
||||||
|
|
10
src/README
10
src/README
|
@ -151,7 +151,15 @@ the Unix instructions below, but note the following:
|
||||||
|
|
||||||
For a --prefix build, this step also creates a "config.ss" module
|
For a --prefix build, this step also creates a "config.ss" module
|
||||||
in a "config" collection for a --prefix build, so that various PLT
|
in a "config" collection for a --prefix build, so that various PLT
|
||||||
tools and libraries can find the installation directories.
|
tools and libraries can find the installation directories. In
|
||||||
|
this case, you can also use a `DESTDIR' environment variable to
|
||||||
|
have the hierarchy constructed at a temporary place (useful for
|
||||||
|
packaging), for example: `make DESTDIR=/tmp/plt-build install'.
|
||||||
|
Note that if DESTDIR is used, the resulting installation will not
|
||||||
|
be functional until it is installed in the its intended place
|
||||||
|
(because at the end of this step, the generated "config.ss", the
|
||||||
|
binaries and the launchers will all get patched to point at the
|
||||||
|
installation paths, without the DESTDIR prefix).
|
||||||
|
|
||||||
Finally, this step compiles ".zo" bytecode files for installed
|
Finally, this step compiles ".zo" bytecode files for installed
|
||||||
Scheme source, and generates launcher programs like
|
Scheme source, and generates launcher programs like
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#
|
||||||
|
# Makefile for mred
|
||||||
|
#
|
||||||
|
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
|
@ -236,15 +239,16 @@ install-no-lib:
|
||||||
echo "no dynamic libs"
|
echo "no dynamic libs"
|
||||||
|
|
||||||
install-lib:
|
install-lib:
|
||||||
cd ..; $(ICP) mred/libmred.@LIBSFX@ "$(libdir)"
|
cd ..; $(ICP) mred/libmred.@LIBSFX@ "$(DESTDIR)$(libdir)"
|
||||||
|
|
||||||
install_wx_xt:
|
install_wx_xt:
|
||||||
cd ..; mkdir -p "$(bindir)"; rm -f "$(bindir)/mred"
|
cd ..; mkdir -p "$(DESTDIR)$(bindir)"
|
||||||
|
cd ..; rm -f "$(DESTDIR)$(bindir)/mred"
|
||||||
$(MAKE) @MRLIBINSTALL@
|
$(MAKE) @MRLIBINSTALL@
|
||||||
cd ..; $(ICP) mred/mred "$(bindir)"
|
cd ..; $(ICP) mred/mred "$(DESTDIR)$(bindir)"
|
||||||
$(MZSCHEME) -mvqu "$(srcdir)/../mzscheme/collects-path.ss" "$(prefix)/bin/mred@EXE_SUFFIX@" @COLLECTS_PATH@
|
$(MZSCHEME) -mvqu "$(srcdir)/../mzscheme/collects-path.ss" "$(DESTDIR)$(bindir)/mred@EXE_SUFFIX@" @COLLECTS_PATH@
|
||||||
|
|
||||||
BUILDINFO=$(libpltdir)/buildinfo
|
BUILDINFO="$(DESTDIR)$(libpltdir)/buildinfo"
|
||||||
|
|
||||||
MRFWDIR = @FRAMEWORK_INSTALL_DIR@/PLT_MrEd.framework
|
MRFWDIR = @FRAMEWORK_INSTALL_DIR@/PLT_MrEd.framework
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ mark:
|
||||||
$(MAKE) $(srcdir)/src/mzmark.c
|
$(MAKE) $(srcdir)/src/mzmark.c
|
||||||
|
|
||||||
headers:
|
headers:
|
||||||
./mzscheme -qr $(srcdir)/mkincludes.ss "$(includepltdir)" "$(srcdir)" .
|
./mzscheme -qr $(srcdir)/mkincludes.ss "$(DESTDIR)$(includepltdir)" "$(srcdir)" .
|
||||||
$(MAKE) $(srcdir)/../../collects/mzscheme/lib/mzdyn.c
|
$(MAKE) $(srcdir)/../../collects/mzscheme/lib/mzdyn.c
|
||||||
|
|
||||||
# mzdyn.c, used for MacOS "library"
|
# mzdyn.c, used for MacOS "library"
|
||||||
|
@ -266,7 +266,7 @@ clean@OSX@:
|
||||||
rm -rf PLT_MzScheme.framework
|
rm -rf PLT_MzScheme.framework
|
||||||
$(MAKE) clean@NOT_OSX@
|
$(MAKE) clean@NOT_OSX@
|
||||||
|
|
||||||
BUILDINFO="$(libpltdir)/buildinfo"
|
BUILDINFO="$(DESTDIR)$(libpltdir)/buildinfo"
|
||||||
ICP=@ICP@
|
ICP=@ICP@
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
@ -274,24 +274,24 @@ install:
|
||||||
$(MAKE) @MZINSTALLTARGET@
|
$(MAKE) @MZINSTALLTARGET@
|
||||||
|
|
||||||
install-3m-basic:
|
install-3m-basic:
|
||||||
cd ..; $(ICP) mzscheme/mzscheme3m $(bindir)/mzscheme3m
|
cd ..; $(ICP) mzscheme/mzscheme3m "$(DESTDIR)$(bindir)/mzscheme3m"
|
||||||
cd ..; $(ICP) mzscheme/mzdyn3m.o $(libpltdir)/mzdyn3m.o
|
cd ..; $(ICP) mzscheme/mzdyn3m.o "$(DESTDIR)$(libpltdir)/mzdyn3m.o"
|
||||||
./mzscheme -mvqu "$(srcdir)/collects-path.ss" "$(bindir)/mzscheme3m@EXE_SUFFIX@" @COLLECTS_PATH@
|
./mzscheme -mvqu "$(srcdir)/collects-path.ss" "$(DESTDIR)$(bindir)/mzscheme3m@EXE_SUFFIX@" @COLLECTS_PATH@
|
||||||
|
|
||||||
install-3m@NOT_OSX@:
|
install-3m@NOT_OSX@:
|
||||||
$(MAKE) install-3m-basic
|
$(MAKE) install-3m-basic
|
||||||
cd ..; $(ICP) mzscheme/libmzscheme3m.@LIBSFX@ "$(libdir)/libmzscheme3m.@LIBSFX@"
|
cd ..; $(ICP) mzscheme/libmzscheme3m.@LIBSFX@ "$(DESTDIR)$(libdir)/libmzscheme3m.@LIBSFX@"
|
||||||
|
|
||||||
# Prefix might be relative to srcdir, or it might be absolute, so we
|
# Prefix might be relative to srcdir, or it might be absolute, so we
|
||||||
# have to go up and install things from there.
|
# have to go up and install things from there.
|
||||||
|
|
||||||
unix-install:
|
unix-install:
|
||||||
cd ..; rm -f $(bindir)/mzscheme
|
cd ..; rm -f "$(DESTDIR)$(bindir)/mzscheme"
|
||||||
cd ..; $(ICP) mzscheme/libmzgc.@LIBSFX@ "$(libdir)/libmzgc.@LIBSFX@"
|
cd ..; $(ICP) mzscheme/libmzgc.@LIBSFX@ "$(DESTDIR)$(libdir)/libmzgc.@LIBSFX@"
|
||||||
cd ..; $(ICP) mzscheme/libmzscheme.@LIBSFX@ "$(libdir)/libmzscheme.@LIBSFX@"
|
cd ..; $(ICP) mzscheme/libmzscheme.@LIBSFX@ "$(DESTDIR)$(libdir)/libmzscheme.@LIBSFX@"
|
||||||
cd ..; $(ICP) mzscheme/mzscheme "$(bindir)/mzscheme"
|
cd ..; $(ICP) mzscheme/mzscheme "$(DESTDIR)$(bindir)/mzscheme"
|
||||||
cd ..; cp mzscheme/starter "$(libpltdir)/starter"
|
cd ..; cp mzscheme/starter "$(DESTDIR)$(libpltdir)/starter"
|
||||||
./mzscheme -mvqu "$(srcdir)/collects-path.ss" "$(bindir)/mzscheme@EXE_SUFFIX@" @COLLECTS_PATH@
|
./mzscheme -mvqu "$(srcdir)/collects-path.ss" "$(DESTDIR)$(bindir)/mzscheme@EXE_SUFFIX@" @COLLECTS_PATH@
|
||||||
cd ..; echo 'CC=@CC@' > $(BUILDINFO)
|
cd ..; echo 'CC=@CC@' > $(BUILDINFO)
|
||||||
cd ..; echo 'CFLAGS=@CFLAGS@ @PREFLAGS@ @COMPFLAGS@' >> $(BUILDINFO)
|
cd ..; echo 'CFLAGS=@CFLAGS@ @PREFLAGS@ @COMPFLAGS@' >> $(BUILDINFO)
|
||||||
cd ..; echo 'OPTIONS=@OPTIONS@' >> $(BUILDINFO)
|
cd ..; echo 'OPTIONS=@OPTIONS@' >> $(BUILDINFO)
|
||||||
|
@ -301,7 +301,7 @@ unix-install:
|
||||||
|
|
||||||
normal-install:
|
normal-install:
|
||||||
$(MAKE) unix-install
|
$(MAKE) unix-install
|
||||||
cd ..; cp mzscheme/mzdyn.o "$(libpltdir)/mzdyn.o"
|
cd ..; cp mzscheme/mzdyn.o "$(DESTDIR)$(libpltdir)/mzdyn.o"
|
||||||
|
|
||||||
MZFWDIR = @FRAMEWORK_INSTALL_DIR@/PLT_MzScheme.framework
|
MZFWDIR = @FRAMEWORK_INSTALL_DIR@/PLT_MzScheme.framework
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user