build: Prepare for kernel variants.

* configure: Fix detection of Arch, FreeBSD.
* lib/linux/x86-mes-gcc/exit-42.S: Move from ...
* lib/x86-mes-gcc/exit-42.S: ... here.
* lib/linux/x86-mes-gcc/hello-mes.S: Move from ...
* lib/x86-mes-gcc/hello-mes.S: ... here.
* lib/linux/x86-mes-mescc/exit-42.S: Move from ...
* lib/x86-mes-mescc/exit-42.S: ... here.
* lib/linux/x86-mes-mescc/hello-mes.S: Move from ...
* lib/x86-mes-mescc/hello-mes.S: ... here.
* lib/linux/x86-mes/elf32-0exit-42.hex2: Move from ...
* lib/x86-mes/elf32-0exit-42.hex2: ... here.
* lib/linux/x86-mes/elf32-0header.hex2: Move from ...
* lib/x86-mes/elf32-0header.hex2: ... here.
* lib/linux/x86-mes/elf32-0hello-mes.hex2: Move from ...
* lib/x86-mes/elf32-0hello-mes.hex2: ... here.
* lib/linux/x86-mes/elf32-body-exit-42.hex2: Move from ...
* lib/x86-mes/elf32-body-exit-42.hex2: ... here.
* lib/linux/x86-mes/elf32-body-hello-mes.hex2: Move from ...
* lib/x86-mes/elf32-body-hello-mes.hex2: ... here.
* lib/linux/x86-mes/elf32-footer-single-main.hex2: Move from ...
* lib/x86-mes/elf32-footer-single-main.hex2: ... here.
* lib/linux/x86-mes/elf32-header.hex2: Move from ...
* lib/x86-mes/elf32-header.hex2: ... here.
* lib/linux/x86_64-mes-gcc/exit-42.S: Move from ...
* lib/x86_64-mes-gcc/exit-42.S: ... here.
* lib/linux/x86_64-mes-gcc/hello-mes.S: Move from ...
* lib/x86_64-mes-gcc/hello-mes.S: ... here.
* lib/linux/x86_64-mes-mescc/exit-42.S: Move from ...
* lib/x86_64-mes-mescc/exit-42.S: ... here.
* lib/linux/x86_64-mes-mescc/hello-mes.S: Move from ...
* lib/x86_64-mes-mescc/hello-mes.S: ... here.
* lib/linux/x86_64-mes/elf64-0exit-42.hex2: Move from ...
* lib/x86_64-mes/elf64-0exit-42.hex2: ... here.
* lib/linux/x86_64-mes/elf64-0header.hex2: Move from ...
* lib/x86_64-mes/elf64-0header.hex2: ... here.
* lib/linux/x86_64-mes/elf64-0hello-mes.hex2: Move from ...
* lib/x86_64-mes/elf64-0hello-mes.hex2: ... here.
* lib/linux/x86_64-mes/elf64-body-exit-42.hex2: Move from ...
* lib/x86_64-mes/elf64-body-exit-42.hex2: ... here.
* lib/linux/x86_64-mes/elf64-body-hello-mes.hex2: Move from ...
* lib/x86_64-mes/elf64-body-hello-mes.hex2: ... here.
* lib/linux/x86_64-mes/elf64-footer-single-main.hex2: Move from ...
* lib/x86_64-mes/elf64-footer-single-main.hex2: ... here.
* lib/linux/x86_64-mes/elf64-header.hex2: Move from ...
* lib/x86_64-mes/elf64-header.hex2: ... here.
* module/mescc.scm (parse-opts): Support --kernel.
* module/mescc/mescc.scm (kernel-find): New function.
* module/mescc/mescc.scm (hex2->elf): Use it to find kernel-specific ELF
snippets.
* build-aux/install.sh.in: Install it.
This commit is contained in:
Jan Nieuwenhuizen 2019-12-11 07:16:46 +00:00
parent c673c9d303
commit 34106fc420
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
28 changed files with 55 additions and 32 deletions

View file

@ -61,10 +61,10 @@ case "$mes_cpu" in
;; ;;
esac esac
trace "CCLD ${srcdest}lib/$mes_cpu-mes-$compiler/exit-42.S" $CC\ trace "CCLD ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/exit-42.S" $CC\
-nostdlib\ -nostdlib\
-g\ -g\
${srcdest}lib/$mes_cpu-mes-$compiler/exit-42.S\ ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/exit-42.S\
-o exit-42 -o exit-42
trace "TEST exit-42" trace "TEST exit-42"
@ -78,12 +78,12 @@ else
stage0_cpu_flag="--architecture $stage0_cpu"; stage0_cpu_flag="--architecture $stage0_cpu";
fi fi
trace "HEX2 ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0exit-42.hex2" $HEX2\ trace "HEX2 ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0exit-42.hex2" $HEX2\
--LittleEndian\ --LittleEndian\
$stage0_cpu_flag\ $stage0_cpu_flag\
--BaseAddress 0x1000000\ --BaseAddress 0x1000000\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0header.hex2\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0header.hex2\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0exit-42.hex2\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0exit-42.hex2\
--exec_enable\ --exec_enable\
-o 0exit-42 -o 0exit-42
@ -92,13 +92,13 @@ trace "TEST 0exit-42"
[ $r != 42 ] && echo " => $r" [ $r != 42 ] && echo " => $r"
[ $r = 42 ] [ $r = 42 ]
trace "HEX2 ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-body-exit-42.hex2" $HEX2\ trace "HEX2 ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-body-exit-42.hex2" $HEX2\
--LittleEndian\ --LittleEndian\
$stage0_cpu_flag\ $stage0_cpu_flag\
--BaseAddress 0x1000000\ --BaseAddress 0x1000000\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-header.hex2\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-header.hex2\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-body-exit-42.hex2\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-body-exit-42.hex2\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-footer-single-main.hex2\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-footer-single-main.hex2\
--exec_enable\ --exec_enable\
-o body-exit-42 -o body-exit-42
@ -108,10 +108,10 @@ trace "TEST body-exit-42"
[ $r = 42 ] [ $r = 42 ]
### FIXME: c&p from exit-42 ### FIXME: c&p from exit-42
trace "CCLD ${srcdest}lib/$mes_cpu-mes-$compiler/hello-mes.S" $CC\ trace "CCLD ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/hello-mes.S" $CC\
-nostdlib\ -nostdlib\
-g\ -g\
${srcdest}lib/$mes_cpu-mes-$compiler/hello-mes.S\ ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/hello-mes.S\
-o hello-mes -o hello-mes
trace "TEST hello-mes" trace "TEST hello-mes"
@ -119,12 +119,12 @@ trace "TEST hello-mes"
[ $r != 0 ] && echo " => $r" [ $r != 0 ] && echo " => $r"
[ $r = 0 ] [ $r = 0 ]
trace "HEX2 ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0hello-mes.hex2" $HEX2\ trace "HEX2 ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0hello-mes.hex2" $HEX2\
--LittleEndian\ --LittleEndian\
$stage0_cpu_flag\ $stage0_cpu_flag\
--BaseAddress 0x1000000\ --BaseAddress 0x1000000\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0header.hex2\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0header.hex2\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0hello-mes.hex2\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0hello-mes.hex2\
--exec_enable\ --exec_enable\
-o 0hello-mes -o 0hello-mes
@ -133,13 +133,13 @@ trace "TEST 0hello-mes"
[ $r != 0 ] && echo " => $r" [ $r != 0 ] && echo " => $r"
[ $r = 0 ] [ $r = 0 ]
trace "HEX2 ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-body-hello-mes.hex2" $HEX2\ trace "HEX2 ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-body-hello-mes.hex2" $HEX2\
--LittleEndian\ --LittleEndian\
$stage0_cpu_flag\ $stage0_cpu_flag\
--BaseAddress 0x1000000\ --BaseAddress 0x1000000\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-header.hex2\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-header.hex2\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-body-hello-mes.hex2\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-body-hello-mes.hex2\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-footer-single-main.hex2\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-footer-single-main.hex2\
--exec_enable\ --exec_enable\
-o body-hello-mes -o body-hello-mes

View file

@ -97,6 +97,7 @@ mkdir -p $DESTDIR$libdir
mkdir -p $DESTDIR$pkgdatadir mkdir -p $DESTDIR$pkgdatadir
tar -cf- -C ${srcdir}/include . | tar -${v}xf- -C $DESTDIR$includedir tar -cf- -C ${srcdir}/include . | tar -${v}xf- -C $DESTDIR$includedir
tar -cf- -C ${srcdir}/lib $mes_cpu-mes | tar -${v}xf- -C $DESTDIR$libdir tar -cf- -C ${srcdir}/lib $mes_cpu-mes | tar -${v}xf- -C $DESTDIR$libdir
tar -cf- -C ${srcdir}/lib $mes_kernel/$mes_cpu-mes | tar -${v}xf- -C $DESTDIR$libdir
if test -z "$srcdest"; then if test -z "$srcdest"; then
tar -cf- $__exclude_go module | tar -${v}xf- -C $DESTDIR$pkgdatadir tar -cf- $__exclude_go module | tar -${v}xf- -C $DESTDIR$pkgdatadir
else else

11
configure vendored
View file

@ -516,12 +516,11 @@ Some influential environment variables:
(mes-bits (if (member mes-cpu '("x86_64")) "64" (mes-bits (if (member mes-cpu '("x86_64")) "64"
"32")) "32"))
(mes-libc (if system-libc? "system" "mes")) (mes-libc (if system-libc? "system" "mes"))
(mes-kernel (car (filter
(kernel-list (filter (compose not (cut member <> '("pc" "unknown"))) (cdr host-type-list))) (compose not
(mes-kernel (cond ((or (equal? '("linux" "gnu") kernel-list) (cut member <> '("pc" "portbld" "unknown")))
(equal? "linux" (car kernel-list))) "linux") (cdr host-type-list))))
((equal? '( "gnu") kernel-list) "gnu") (mes-kernel (if (string-prefix? "freebsd" mes-kernel) "freebsd" mes-kernel))
(else "unknown")))
(compiler (if gcc? "gcc" "mescc")) (compiler (if gcc? "gcc" "mescc"))
(mes-system (string-join (list mes-cpu mes-kernel "mes") "-")) (mes-system (string-join (list mes-cpu mes-kernel "mes") "-"))
(bash (or (and (file-exists? "/bin/bash") "/bin/bash") (bash (or (and (file-exists? "/bin/bash") "/bin/bash")

View file

@ -37,6 +37,7 @@
(define-macro (mes-use-module . rest) #t))) (define-macro (mes-use-module . rest) #t)))
(define %host-arch (or (getenv "%arch") %arch)) (define %host-arch (or (getenv "%arch") %arch))
(define %host-kernel (or (getenv "%kernel") "linux")) ;; FIXME
(define %prefix (or (getenv "%prefix") "mes")) (define %prefix (or (getenv "%prefix") "mes"))
(define %includedir (or (getenv "%includedir") "include")) (define %includedir (or (getenv "%includedir") "include"))
(define %libdir (or (getenv "%libdir") ".")) (define %libdir (or (getenv "%libdir") "."))
@ -102,6 +103,7 @@ C99 compiler in Scheme for bootstrapping the GNU system.
Options: Options:
--align align globals --align align globals
--arch=ARCH compile for ARCH [~a] --arch=ARCH compile for ARCH [~a]
--kernel=ARCH compile for KERNEL [~a]
-dumpmachine display the compiler's target machine -dumpmachine display the compiler's target machine
--base-address=ADRRESS --base-address=ADRRESS
use BaseAddress ADDRESS [0x1000000] use BaseAddress ADDRESS [0x1000000]
@ -141,7 +143,7 @@ Environment variables:
Report bugs to: bug-mes@gnu.org Report bugs to: bug-mes@gnu.org
GNU Mes home page: <http://gnu.org/software/mes/> GNU Mes home page: <http://gnu.org/software/mes/>
General help using GNU software: <http://gnu.org/gethelp/> General help using GNU software: <http://gnu.org/gethelp/>
" %host-arch) " %host-arch %host-kernel)
(exit (or (and usage? 2) 0))) (exit (or (and usage? 2) 0)))
options)))) options))))
@ -167,6 +169,8 @@ General help using GNU software: <http://gnu.org/gethelp/>
(options (acons 'libdir %libdir options)) (options (acons 'libdir %libdir options))
(arch (option-ref options 'arch %host-arch)) (arch (option-ref options 'arch %host-arch))
(options (if arch (acons 'arch arch options) options)) (options (if arch (acons 'arch arch options) options))
(kernel (option-ref options 'kernel %host-kernel))
(options (acons 'kernel kernel options))
(numbered-arch? (option-ref options 'numbered-arch? %numbered-arch?)) (numbered-arch? (option-ref options 'numbered-arch? %numbered-arch?))
(options (acons 'numbered-arch? numbered-arch? options)) (options (acons 'numbered-arch? numbered-arch? options))
(dumpmachine? (option-ref options 'dumpmachine #f)) (dumpmachine? (option-ref options 'dumpmachine #f))

View file

@ -203,9 +203,11 @@
(hex2 (or (getenv "HEX2") "hex2")) (hex2 (or (getenv "HEX2") "hex2"))
(base-address (option-ref options 'base-address "0x1000000")) (base-address (option-ref options 'base-address "0x1000000"))
(machine (arch-get-machine options)) (machine (arch-get-machine options))
(elf-footer (or elf-footer (elf-footer
(arch-find options (string-append (or elf-footer
"elf" machine "-footer-single-main.hex2")))) (kernel-find
options
(string-append "elf" machine "-footer-single-main.hex2"))))
(start-files (if (or (option-ref options 'nostartfiles #f) (start-files (if (or (option-ref options 'nostartfiles #f)
(option-ref options 'nostdlib #f)) '() (option-ref options 'nostdlib #f)) '()
`("-f" ,(arch-find options "crt1.o")))) `("-f" ,(arch-find options "crt1.o"))))
@ -213,7 +215,9 @@
"--LittleEndian" "--LittleEndian"
,@(arch-get-architecture options) ,@(arch-get-architecture options)
"--BaseAddress" ,base-address "--BaseAddress" ,base-address
"-f" ,(arch-find options (string-append "elf" machine "-header.hex2")) "-f" ,(kernel-find
options
(string-append "elf" machine "-header.hex2"))
,@start-files ,@start-files
,@(append-map (cut list "-f" <>) hex2-files) ,@(append-map (cut list "-f" <>) hex2-files)
"-f" ,elf-footer "-f" ,elf-footer
@ -258,7 +262,7 @@
(define (find-library options ext o) (define (find-library options ext o)
(arch-find options (string-append "lib" o ext))) (arch-find options (string-append "lib" o ext)))
(define* (arch-find options file-name) (define* (arch-find options file-name #:key kernel)
(let* ((srcdest (or (getenv "srcdest") "")) (let* ((srcdest (or (getenv "srcdest") ""))
(srcdir-lib (string-append srcdest "lib")) (srcdir-lib (string-append srcdest "lib"))
(arch (string-append (arch-get options) "-mes")) (arch (string-append (arch-get options) "-mes"))
@ -267,6 +271,8 @@
(option-ref options 'libdir "lib") (option-ref options 'libdir "lib")
(filter-map (multi-opt 'library-dir) options))) (filter-map (multi-opt 'library-dir) options)))
(arch-file-name (string-append arch "/" file-name)) (arch-file-name (string-append arch "/" file-name))
(arch-file-name (if kernel (string-append kernel "/" arch-file-name)
arch-file-name))
(verbose? (count-opt options 'verbose))) (verbose? (count-opt options 'verbose)))
(let ((file (search-path path arch-file-name))) (let ((file (search-path path arch-file-name)))
(when (and verbose? (> verbose? 1)) (when (and verbose? (> verbose? 1))
@ -276,6 +282,11 @@
(or file (or file
(error (format #f "mescc: file not found: ~s" arch-file-name)))))) (error (format #f "mescc: file not found: ~s" arch-file-name))))))
(define (kernel-find options file-name)
(let ((kernel (option-ref options 'kernel "linux")))
(or (arch-find options file-name #:kernel kernel)
(arch-find options file-name))))
(define (assert-system* . args) (define (assert-system* . args)
(let ((status (apply system* args))) (let ((status (apply system* args)))
(when (not (zero? status)) (when (not (zero? status))
@ -293,7 +304,7 @@
(define (mescc:get-host options) (define (mescc:get-host options)
(let ((cpu (arch-get options)) (let ((cpu (arch-get options))
(kernel "linux")) (kernel (option-ref options 'kernel "linux")))
(string-join (list cpu kernel "mes") "-"))) (string-join (list cpu kernel "mes") "-")))
(define (arch-get-info options) (define (arch-get-info options)

View file

@ -22,7 +22,11 @@
(cond-expand (cond-expand
(mes) (mes)
(guile (guile
(define %arch (car (string-split %host-type #\-))))) (define %arch (car (string-split %host-type #\-)))
(define %kernel (car (filter
(compose not
(lambda (x) (member x '("pc" "portbld" "unknown"))))
(cdr (string-split %host-type #\-)))))))
(define %prefix (or (getenv "MES_PREFIX") (define %prefix (or (getenv "MES_PREFIX")
(if (string-prefix? "@prefix" "@prefix@") (if (string-prefix? "@prefix" "@prefix@")
@ -41,6 +45,9 @@
(define %arch (if (string-prefix? "@mes_cpu" "@mes_cpu@") %arch (define %arch (if (string-prefix? "@mes_cpu" "@mes_cpu@") %arch
"@mes_cpu@")) "@mes_cpu@"))
(define %kernel (if (string-prefix? "@mes_kernel" "@mes_kernel@") %kernel
"@mes_kernel@"))
(define %numbered-arch? (if (getenv "numbered_arch") (and=> (getenv "numbered_arch") (define %numbered-arch? (if (getenv "numbered_arch") (and=> (getenv "numbered_arch")
(lambda (x) (equal? x "true"))) (lambda (x) (equal? x "true")))
(if (string-prefix? "@numbered_arch" "@numbered_arch@") #f (if (string-prefix? "@numbered_arch" "@numbered_arch@") #f
@ -51,6 +58,7 @@
(setenv "%libdir" %libdir) (setenv "%libdir" %libdir)
(setenv "%version" %version) (setenv "%version" %version)
(setenv "%arch" %arch) (setenv "%arch" %arch)
(setenv "%kernel" %kernel)
(setenv "%numbered_arch" (if %numbered-arch? "true" "false")) (setenv "%numbered_arch" (if %numbered-arch? "true" "false"))
(cond-expand (cond-expand