build: Have configure prefer $CC over gcc; tcc over gcc, gcc over cc.
Reported by Vagrant Cascadian. * configure (string->version): Prefer for most-dotted string. Fixes makeinfo version. (check-program-version): Prefer displaying of command, if single word. (main): Check for $CC --version, $CC -v. Prefer $CC over gcc; tcc over gcc, gcc over cc.
This commit is contained in:
parent
36b2857d5b
commit
e984f7213f
56
configure
vendored
56
configure
vendored
|
@ -155,7 +155,7 @@ MES_ARENA=100000000 exec ${SCHEME-guile} -L . --no-auto-compile -e '(configure)'
|
|||
(data dependency-data)
|
||||
(version-found dependency-version-found))
|
||||
|
||||
(define* (make-dep name #:key (version '(0)) optional? (version-option "--version") (commands (list name)) file-name data)
|
||||
(define* (make-dep name #:key (version '()) optional? (version-option "--version") (commands (list name)) file-name data)
|
||||
(let* ((env-var (getenv (name->shell-name name)))
|
||||
(commands (if env-var (cons env-var commands) commands)))
|
||||
(make-dependency name version optional? version-option commands file-name data #f)))
|
||||
|
@ -186,7 +186,12 @@ MES_ARENA=100000000 exec ${SCHEME-guile} -L . --no-auto-compile -e '(configure)'
|
|||
(let ((split (string-tokenize string
|
||||
(char-set-adjoin char-set:digit #\.))))
|
||||
(and (pair? split)
|
||||
(let* ((version (sort split (lambda (a b) (> (string-length a) (string-length b)))))
|
||||
(let* ((version (sort split (lambda (a b)
|
||||
(let ((len-a (length (string-split a #\.)))
|
||||
(len-b (length (string-split b #\.))))
|
||||
(cond ((> len-a len-b) #t)
|
||||
((< len-a len-b) #f)
|
||||
(else (> (string-length a) (string-length b))))))))
|
||||
(version (car version))
|
||||
(version (string-tokenize version
|
||||
(char-set-complement (char-set #\.)))))
|
||||
|
@ -198,16 +203,17 @@ MES_ARENA=100000000 exec ${SCHEME-guile} -L . --no-auto-compile -e '(configure)'
|
|||
(version-option (dependency-version-option dependency))
|
||||
(commands (dependency-commands dependency)))
|
||||
(let loop ((commands commands))
|
||||
(if (null? commands) dependency
|
||||
(if (or (null? commands)
|
||||
(not (car commands))) dependency
|
||||
(let ((command (car commands)))
|
||||
(stdout "checking for ~a~a... " name
|
||||
(stdout "checking for ~a~a... " (if (string-index command #\space) name command)
|
||||
(if (null? expected) ""
|
||||
(format #f " [~a]" (version->string expected))))
|
||||
(let* ((output (gulp-pipe (string-append command " " (if version-option version-option ""))))
|
||||
(actual (string->version output))
|
||||
(pass? (and actual (tuple< expected actual)))
|
||||
(dependency (set-field dependency (dependency-version-found) actual)))
|
||||
(stdout "~a ~a\n" (if pass? (if (pair? actual) "" " yes")
|
||||
(stdout "~a ~a\n" (if pass? (if (pair? actual) "" "yes")
|
||||
(if actual " no, found" "no"))
|
||||
(or (version->string actual) ""))
|
||||
(if pass? (let ((file-name (or (PATH-search-path command)
|
||||
|
@ -437,9 +443,9 @@ Some influential environment variables:
|
|||
(stderr "configure args=~s\n" args))
|
||||
(for-each (lambda (v) (apply setenv (string-split v #\=))) vars)
|
||||
(let* ((cross? (not (equal? host-type build-type)))
|
||||
(gcc (or (getenv "CC") (if cross? (string-append host-type "-" "gcc") "gcc")))
|
||||
(tcc (or (getenv "TCC") "tcc"))
|
||||
(mescc (or (getenv "MESCC") "mescc"))
|
||||
(gcc (if cross? (string-append host-type "-" "gcc") "gcc"))
|
||||
(tcc (if cross? (string-append host-type "-" "tcc") "tcc"))
|
||||
(mescc (if cross? (string-append host-type "-" "mescc") "mescc"))
|
||||
(deps (fold (lambda (program results)
|
||||
(cons (check-program-version program) results))
|
||||
'()
|
||||
|
@ -451,14 +457,18 @@ Some influential environment variables:
|
|||
(make-dep "mes" #:version '(0 20) #:optional? #t)
|
||||
(make-dep "guix" #:version '(0 13) #:optional? #t)
|
||||
(make-dep "ar" #:version '(2 10) #:optional? #t)
|
||||
(make-dep "sh" #:version '(0) #:optional? #t)
|
||||
(make-dep "sh" #:optional? #t)
|
||||
(make-dep "bash" #:version '(2 0) #:optional? #t)
|
||||
(make-dep "guild" #:version '(2 0) #:commands '("guild" "guile-tools" "true"))
|
||||
(make-dep "cc" #:commands (list gcc "cc" tcc mescc) #:optional? #t)
|
||||
(make-dep "tcc" #:commands (list tcc "tcc") #:optional? #t #:version-option "-v")
|
||||
(make-dep "mescc" #:commands (list mescc "mescc") #:optional? #t)
|
||||
(make-dep "CC" #:commands `(,(getenv "CC")) #:optional? #t)
|
||||
(make-dep "CC-v" #:commands `(,(getenv "CC")) #:optional? #t #:version-option "-v")
|
||||
(make-dep "cc" #:commands '("cc") #:optional? #t)
|
||||
(make-dep "gcc" #:commands `(,gcc "gcc") #:optional? #t)
|
||||
(make-dep "mescc" #:commands `(,mescc "mescc") #:optional? #t)
|
||||
(make-dep "tcc" #:commands `(,tcc "tcc") #:optional? #t #:version-option "-v")
|
||||
(make-dep "cc-v" #:commands '("cc") #:optional? #t #:version-option "-v")
|
||||
(make-dep "make" #:optional? #t #:commands '("gmake" "make"))
|
||||
(make-dep "makeinfo" #:optional? #t)
|
||||
(make-dep "makeinfo" #:version '(6) #:optional? #t)
|
||||
(make-dep "dot" #:version-option "-V" #:optional? #t)
|
||||
(make-dep "help2man" #:version '(1 47) #:optional? #t)
|
||||
(make-dep "perl" #:version '(5) #:optional? #t))))
|
||||
|
@ -467,8 +477,12 @@ Some influential environment variables:
|
|||
deps)
|
||||
deps))
|
||||
(guile (or guile "guile"))
|
||||
(cc (or (file-name "cc" deps)
|
||||
(cc (or (file-name "CC" deps)
|
||||
(file-name "CC-v" deps)
|
||||
(file-name "tcc" deps)
|
||||
(file-name "gcc" deps)
|
||||
(file-name "cc" deps)
|
||||
(file-name "cc-v" deps)
|
||||
(file-name "mescc" deps)))
|
||||
(deps (if cc
|
||||
(cons* (check-header-c cc (make-dep "limits.h"))
|
||||
|
@ -494,15 +508,15 @@ Some influential environment variables:
|
|||
deps))
|
||||
(mesc? (file-name "cc is MES C" deps))
|
||||
(deps (if cc
|
||||
(cons (check-compile-c cc (make-dep "cc is Tiny CC" #:data "#if !defined (__TINYC__)
|
||||
(cons (check-compile-c cc (make-dep "cc is Tiny C" #:data "#if !defined (__TINYC__)
|
||||
#error no tinycc
|
||||
#endif
|
||||
"))
|
||||
deps)
|
||||
deps))
|
||||
(tcc? (file-name "cc is Tiny CC" deps))
|
||||
(tcc? (file-name "cc is Tiny C" deps))
|
||||
(deps (if cc
|
||||
(cons (check-link-c cc (make-dep "if cc can create executables" #:data "int main () {return 0;}"))
|
||||
(cons (check-link-c cc (make-dep "whether cc can create executables" #:data "int main () {return 0;}"))
|
||||
deps)
|
||||
deps))
|
||||
(system-libc? (and with-system-libc? (file-name "if cc can create executables" deps)))
|
||||
|
@ -521,7 +535,7 @@ Some influential environment variables:
|
|||
(cut member <> '("pc" "portbld" "unknown")))
|
||||
(cdr host-type-list))))
|
||||
(mes-kernel (if (string-prefix? "freebsd" mes-kernel) "freebsd" mes-kernel))
|
||||
(compiler (cond (gcc? "gcc") (tcc? "gcc") (else "mescc")))
|
||||
(mes-compiler (cond (gcc? "gcc") (tcc? "gcc") (else "mescc")))
|
||||
(mes-system (string-join (list mes-cpu mes-kernel "mes") "-"))
|
||||
(bash (or (and (file-exists? "/bin/bash") "/bin/bash")
|
||||
(file-name "bash" deps)
|
||||
|
@ -572,7 +586,7 @@ See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system)
|
|||
|
||||
("@bootstrap@" . ,(if with-bootstrap? "true" "false"))
|
||||
("@courageous@" . ,(if with-courage? "true" "false"))
|
||||
("@compiler@" . ,compiler)
|
||||
("@compiler@" . ,mes-compiler)
|
||||
("@mes_bits@" . ,mes-bits)
|
||||
("@mes_kernel@" . ,mes-kernel)
|
||||
("@mes_cpu@" . ,mes-cpu)
|
||||
|
@ -606,7 +620,7 @@ See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system)
|
|||
|
||||
("@AR@" . ,(or (file-name "ar" deps) ""))
|
||||
("@BASH@" . ,bash)
|
||||
("@CC@" . ,(or (file-name "cc" deps) (file-name "tcc" deps) ""))
|
||||
("@CC@" . ,cc)
|
||||
("@DIFF@" . ,(or (file-name "diff" deps) (string-append abs-top-builddir "/pre-inst-env diff.scm")))
|
||||
("@DOT@" . ,(or (file-name "dot" deps) ""))
|
||||
("@GIT@" . ,(or (file-name "git" deps) ""))
|
||||
|
@ -682,7 +696,7 @@ See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system)
|
|||
(let ((make (and=> (file-name "make" deps) basename)))
|
||||
(display (string-append "
|
||||
GNU Mes is configured for
|
||||
compiler: " compiler "
|
||||
compiler: " mes-compiler "
|
||||
cpu: " mes-cpu "
|
||||
bits: " mes-bits "
|
||||
libc: " mes-libc "
|
||||
|
|
Loading…
Reference in a new issue