Use replace to build mescc.scm.

This commit is contained in:
Andrius Štikonas 2022-06-25 23:38:34 +01:00
parent a0cb0dfd60
commit 511a0f71c5
4 changed files with 17 additions and 63 deletions

View File

@ -1,56 +0,0 @@
; SPDX-FileCopyrightText: Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
; SPDX-FileCopyrightText: 2021 fosslinux <fosslinux@aussies.space>
;
; SPDX-License-Identifier: GPL-3.0-or-later
(cond-expand
(mes)
(guile
(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" "/usr")
""
"/usr")))
(define %includedir (or (getenv "includedir")
(string-append %prefix "/include")))
(define %libdir (or (getenv "libdir")
(string-append %prefix "/lib")))
(define %version (if (string-prefix? "@VERSION" "0.24") "git"
"0.22"))
(define %arch (if (string-prefix? "@mes_cpu" "x86") %arch
"x86"))
(define %kernel (if (string-prefix? "@mes_kernel" "linux") %kernel
"linux"))
(define %numbered-arch? (if (getenv "numbered_arch") (and=> (getenv "numbered_arch")
(lambda (x) (equal? x "true")))
(if (string-prefix? "@numbered_arch" "false") #f
(equal? "false" "true"))))
(setenv "%prefix" %prefix)
(setenv "%includedir" %includedir)
(setenv "%libdir" %libdir)
(setenv "%version" %version)
(setenv "%arch" %arch)
(setenv "%kernel" %kernel)
(setenv "%numbered_arch" (if %numbered-arch? "true" "false"))
(cond-expand
(mes
(mes-use-module (mescc))
(mescc:main (command-line)))
(guile
(use-modules (mescc))))
(define (main args)
(mescc:main args))

View File

@ -1,6 +1,6 @@
91d889ddfe7c5ae2ade03fdcfc7ddb1dce234db8628228e67906a66bf78c1f56 /usr/bin/mes
f1541ae5e2e008deeaf636869556debb5fa9e9608c787c7203761d83f23c9c05 /usr/bin/mes-m2
0c7738c6640e7f3f2256c271a0eefa438fee6ffa043e756edc007e166bed48f5 /usr/bin/mescc.scm
479dfbba269954ec120d9bf0976fe168eaef017a92e3c1ca9ecc197b76ad1825 /usr/bin/mescc.scm
4feafab424611c976dc4628aa862e37b4e92b5869aebbcf7655e684c3f589041 /usr/lib/x86-mes/crt1.s
69e9ec2ee2ebf065575cdaf878629178b85330257dde0da790a428c0280d1ecb /usr/lib/x86-mes/crt1.o
c9944a799d584abfa76f385c14ac0caf6f46d03b34bf2712493602b12826c6b2 /usr/lib/x86-mes/x86.M1

View File

@ -1,6 +1,6 @@
#!/bin/sh
# SPDX-FileCopyrightText: 2020-2021 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-FileCopyrightText: 2020-2022 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-FileCopyrightText: 2020-2022 fosslinux <fosslinux@aussies.space>
#
# SPDX-License-Identifier: GPL-3.0-or-later
@ -14,9 +14,6 @@ MES_STACK=6000000
MES=${bindir}/mes-m2
libdir=${MES_PREFIX}/lib
cp files/mescc.scm ${bindir}/
chmod 755 ${bindir}/mescc.scm
# Unpack
mkdir src build
cd src
@ -48,6 +45,18 @@ kaem --verbose --strict --file kaem.run
cp bin/mes-m2 ${bindir}/mes-m2
chmod 755 ${bindir}/mes-m2
# Create mescc.scm
mescc_in=scripts/mescc.scm.in
replace --file ${mescc_in} --output ${mescc_in} --match-on @prefix@ --replace-with ${prefix}
replace --file ${mescc_in} --output ${mescc_in} --match-on @VERSION@ --replace-with ${MES_VERSION}
replace --file ${mescc_in} --output ${mescc_in} --match-on @mes_cpu@ --replace-with ${ARCH}
replace --file ${mescc_in} --output ${mescc_in} --match-on @mes_kernel@ --replace-with linux
mescc_scm=${bindir}/mescc.scm
cp ${mescc_in} ${mescc_scm}
chmod 755 ${mescc_scm}
# Recompile Mes and Mes C library using mes-m2 bootstrapped Mes
alias mescc="${MES} -e main ${bindir}/mescc.scm -D HAVE_CONFIG_H=1 -I include -I include/linux/x86 -c"
@ -231,7 +240,7 @@ mescc src/symbol.c
mescc src/vector.c
# Link everything into new mes executable
${MES} -e main ${bindir}/mescc.scm -- -L ${libdir} -nostdlib -o ${bindir}/mes -L . crt1.o builtins.o cc.o core.o display.o eval-apply.o gc.o globals.o hash.o lib.o math.o mes.o module.o posix.o reader.o stack.o string.o struct.o symbol.o vector.o -lc -lmescc
${MES} -e main ${mescc_scm} -- -L ${libdir} -nostdlib -o ${bindir}/mes -L . crt1.o builtins.o cc.o core.o display.o eval-apply.o gc.o globals.o hash.o lib.o math.o mes.o module.o posix.o reader.o stack.o string.o struct.o symbol.o vector.o -lc -lmescc
# Make directories
mkdir ${prefix}/lib/linux ${incdir}/mes ${incdir}/sys ${incdir}/linux

View File

@ -11,7 +11,8 @@ set -ex
# Environmental variables needed for mes
NYACC_PKG=nyacc-1.00.2
MES_PKG=mes-0.24
MES_VERSION=0.24
MES_PKG=mes-${MES_VERSION}
MES_PKG_DIR=mes-aa5f1533e1736a89e60d2c34c2a0ab3b01f8d037
MES_PREFIX=${sysa}/${MES_PKG}/build/${MES_PKG_DIR}
GUILE_LOAD_PATH=${MES_PREFIX}/mes/module:${MES_PREFIX}/module:${sysa}/${MES_PKG}/build/${NYACC_PKG}/module