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
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\
-g\
${srcdest}lib/$mes_cpu-mes-$compiler/exit-42.S\
${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/exit-42.S\
-o exit-42
trace "TEST exit-42"
@ -78,12 +78,12 @@ else
stage0_cpu_flag="--architecture $stage0_cpu";
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\
$stage0_cpu_flag\
--BaseAddress 0x1000000\
-f ${srcdest}lib/$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-0header.hex2\
-f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0exit-42.hex2\
--exec_enable\
-o 0exit-42
@ -92,13 +92,13 @@ trace "TEST 0exit-42"
[ $r != 42 ] && echo " => $r"
[ $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\
$stage0_cpu_flag\
--BaseAddress 0x1000000\
-f ${srcdest}lib/$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_cpu-mes/elf$mes_bits-footer-single-main.hex2\
-f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-header.hex2\
-f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-body-exit-42.hex2\
-f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-footer-single-main.hex2\
--exec_enable\
-o body-exit-42
@ -108,10 +108,10 @@ trace "TEST body-exit-42"
[ $r = 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\
-g\
${srcdest}lib/$mes_cpu-mes-$compiler/hello-mes.S\
${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/hello-mes.S\
-o hello-mes
trace "TEST hello-mes"
@ -119,12 +119,12 @@ trace "TEST hello-mes"
[ $r != 0 ] && echo " => $r"
[ $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\
$stage0_cpu_flag\
--BaseAddress 0x1000000\
-f ${srcdest}lib/$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-0header.hex2\
-f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0hello-mes.hex2\
--exec_enable\
-o 0hello-mes
@ -133,13 +133,13 @@ trace "TEST 0hello-mes"
[ $r != 0 ] && echo " => $r"
[ $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\
$stage0_cpu_flag\
--BaseAddress 0x1000000\
-f ${srcdest}lib/$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_cpu-mes/elf$mes_bits-footer-single-main.hex2\
-f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-header.hex2\
-f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-body-hello-mes.hex2\
-f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-footer-single-main.hex2\
--exec_enable\
-o body-hello-mes

View file

@ -97,6 +97,7 @@ mkdir -p $DESTDIR$libdir
mkdir -p $DESTDIR$pkgdatadir
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_kernel/$mes_cpu-mes | tar -${v}xf- -C $DESTDIR$libdir
if test -z "$srcdest"; then
tar -cf- $__exclude_go module | tar -${v}xf- -C $DESTDIR$pkgdatadir
else

11
configure vendored
View file

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

View file

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

View file

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

View file

@ -22,7 +22,11 @@
(cond-expand
(mes)
(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")
(if (string-prefix? "@prefix" "@prefix@")
@ -41,6 +45,9 @@
(define %arch (if (string-prefix? "@mes_cpu" "@mes_cpu@") %arch
"@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")
(lambda (x) (equal? x "true")))
(if (string-prefix? "@numbered_arch" "@numbered_arch@") #f
@ -51,6 +58,7 @@
(setenv "%libdir" %libdir)
(setenv "%version" %version)
(setenv "%arch" %arch)
(setenv "%kernel" %kernel)
(setenv "%numbered_arch" (if %numbered-arch? "true" "false"))
(cond-expand