build: Install and installed-run fixes.

* guile/mescc.scm (%datadir,%docdir,%moduledir,%version): Remove.
* scripts/mescc.mes: Likewise.
* module/language/c99/compiler.mes: Likewise.
 (%prefix): Prefer environment setting.
 (c99-input->full-ast): Remove unnecessary includes.
 Remove unnecessary defines.
* make.scm (%scm-files): Add mes/guile.scm.
 (src/mes.gcc, src/mes.mlibc-gcc, src/mes.guile):  Update  MODULEDIR,
 add -I src.
* src/mes.c (load_env): Use temporary variable for MODULEDIR concatenation.
  (bload_env): Likewise.
This commit is contained in:
Jan Nieuwenhuizen 2017-07-26 15:42:44 +02:00
parent 62e7809725
commit 4b1de28449
5 changed files with 20 additions and 48 deletions

View file

@ -45,16 +45,8 @@ GUILE='~/src/guile-1.8/build/pre-inst-guile --debug -q' guile/mescc.scm
#:use-module (srfi srfi-26) #:use-module (srfi srfi-26)
#:export (main)) #:export (main))
(define %prefix (if (string-prefix? "@PREFIX" "@PREFIX@") "" "@PREFIX@")) (define %prefix (if (string-prefix? "@PREFIX" "@PREFIX@") (or (getenv "PREFIX") "") "@PREFIX@"))
(define %datadir (if (string-prefix? "@DATADIR" "@DATADIR@") "" "@DATADIR@"))
(define %docdir (if (string-prefix? "@DOCDIR" "@DOCDIR@") "doc/" "@DOCDIR@"))
(define %moduledir "module/")
(define %version (if (string-prefix? "@VERSION" "@VERSION@") "git" "@VERSION@"))
(module-define! (resolve-module '(language c99 compiler)) '%datadir %datadir)
(module-define! (resolve-module '(language c99 compiler)) '%docdir %docdir)
(module-define! (resolve-module '(language c99 compiler)) '%moduledir %moduledir)
(module-define! (resolve-module '(language c99 compiler)) '%prefix %prefix) (module-define! (resolve-module '(language c99 compiler)) '%prefix %prefix)
(module-define! (resolve-module '(language c99 compiler)) '%version %version)
(define (parse-opts args) (define (parse-opts args)
(let* ((option-spec (let* ((option-spec

View file

@ -19,6 +19,7 @@ exec ${GUILE-guile} --no-auto-compile -L . -L guile -C . -C guile -s "$0" ${1+"$
"mes/as.scm" "mes/as.scm"
"mes/bytevectors.scm" "mes/bytevectors.scm"
"mes/elf.scm" "mes/elf.scm"
"mes/guile.scm"
"mes/M1.scm")) "mes/M1.scm"))
(define %go-files (map (compose (cut string-append <> ".go") (cut string-drop-right <> 4)) %scm-files)) (define %go-files (map (compose (cut string-append <> ".go") (cut string-drop-right <> 4)) %scm-files))
(setenv "srcdir" ".") (setenv "srcdir" ".")
@ -300,23 +301,26 @@ exec ${GUILE-guile} --no-auto-compile -L . -L guile -C . -C guile -s "$0" ${1+"$
"MES_FULL=1" "MES_FULL=1"
"POSIX=1" "POSIX=1"
,(string-append "VERSION=\"" %version "\"") ,(string-append "VERSION=\"" %version "\"")
,(string-append "MODULEDIR=\"" (string-append %moduledir "/") "\"") ,(string-append "MODULEDIR=\"" (string-append %prefix (if (string-null? %prefix) "" "/") %moduledir "/") "\"")
,(string-append "PREFIX=\"" %prefix "\"")))) ,(string-append "PREFIX=\"" %prefix "\""))
#:includes '("src")))
(add-target (bin.gcc "src/mes.c" #:libc #f (add-target (bin.gcc "src/mes.c" #:libc #f
#:dependencies mes-snarf-targets #:dependencies mes-snarf-targets
#:defines `("FIXED_PRIMITIVES=1" #:defines `("FIXED_PRIMITIVES=1"
"MES_FULL=1" "MES_FULL=1"
,(string-append "VERSION=\"" %version "\"") ,(string-append "VERSION=\"" %version "\"")
,(string-append "MODULEDIR=\"" (string-append %moduledir "/") "\"") ,(string-append "MODULEDIR=\"" (string-append %prefix (if (string-null? %prefix) "" "/") "/" %moduledir "/") "\"")
,(string-append "PREFIX=\"" %prefix "\"")))) ,(string-append "PREFIX=\"" %prefix "\""))
#:includes '("src")))
(add-target (bin.mescc "src/mes.c" #:dependencies mes-snarf-targets (add-target (bin.mescc "src/mes.c" #:dependencies mes-snarf-targets
#:defines `("FIXED_PRIMITIVES=1" #:defines `("FIXED_PRIMITIVES=1"
"MES_FULL=1" "MES_FULL=1"
,(string-append "VERSION=\"" %version "\"") ,(string-append "VERSION=\"" %version "\"")
,(string-append "MODULEDIR=\"" (string-append %moduledir "/") "\"") ,(string-append "MODULEDIR=\"" (string-append %prefix (if (string-null? %prefix) "" "/") %moduledir "/") "\"")
,(string-append "PREFIX=\"" %prefix "\"")))) ,(string-append "PREFIX=\"" %prefix "\""))
#:includes '("src")))
(define mes-tests (define mes-tests
'("tests/read.test" '("tests/read.test"

View file

@ -48,42 +48,20 @@
(define (stderr string . rest) (define (stderr string . rest)
(apply logf (cons* (current-error-port) string rest))) (apply logf (cons* (current-error-port) string rest)))
(define %datadir (if (string-prefix? "@DATADIR" "@DATADIR@") "" "@DATADIR@")) (define %prefix (if (string-prefix? "@PREFIX" "@PREFIX@") (or (getenv "PREFIX") "") "@PREFIX@"))
(define %docdir (if (string-prefix? "@DOCDIR" "@DOCDIR@") "doc/" "@DOCDIR@"))
(define %moduledir "module/")
(define %prefix (if (string-prefix? "@PREFIX" "@PREFIX@") "" "@PREFIX@"))
(define %version (if (string-prefix? "@VERSION" "@VERSION@") "git" "@VERSION@"))
(define mes? (pair? (current-module))) (define mes? (pair? (current-module)))
(define* (c99-input->full-ast #:key (defines '()) (includes '())) (define* (c99-input->full-ast #:key (defines '()) (includes '()))
(let ((include (if (equal? %prefix "") "mlibc/include" (string-append %prefix "/share/mlibc/include")))) (let ((include (if (equal? %prefix "") "mlibc/include" (string-append %prefix "/share/mlibc/include"))))
(parse-c99 (parse-c99
#:inc-dirs (append includes (cons* "." "mlibc" "src" "out" "out/src" include (or (and=> (getenv "C_INCLUDE_PATH") (cut string-split <> #\:)) '()))) #:inc-dirs (append includes (cons* include "mlibc/include" "mlibc" (or (and=> (getenv "C_INCLUDE_PATH") (cut string-split <> #\:)) '())))
#:cpp-defs `( #:cpp-defs `(
"POSIX=0" "POSIX=0"
"_POSIX_SOURCE=0" "_POSIX_SOURCE=0"
"__MESC__=1" "__MESC__=1"
"EOF=-1"
"STDIN=0"
"STDOUT=1"
"STDERR=2"
"INT_MIN=-2147483648"
"INT_MAX=2147483647"
"NULL=0"
"FIXED_PRIMITIVES=1"
,(if mes? "__MESC_MES__=1" "__MESC_MES__=0") ,(if mes? "__MESC_MES__=1" "__MESC_MES__=0")
,@defines)
,(string-append "DATADIR=\"" %datadir "\"")
,(string-append "DOCDIR=\"" %docdir "\"")
,(string-append "PREFIX=\"" %prefix "\"")
,(string-append "MODULEDIR=\"" %moduledir "\"")
,(string-append "VERSION=\"" %version "\"")
,@defines
)
#:mode 'code))) #:mode 'code)))
(define (ast-strip-comment o) (define (ast-strip-comment o)

View file

@ -49,11 +49,7 @@ exit $r
(format (current-error-port) "mescc.mes...\n") (format (current-error-port) "mescc.mes...\n")
(define %datadir (if (string-prefix? "@DATADIR" "@DATADIR@") "" "@DATADIR@")) (define %prefix (if (string-prefix? "@PREFIX" "@PREFIX@") (or (getenv "PREFIX") "") "@PREFIX@"))
(define %docdir (if (string-prefix? "@DOCDIR" "@DOCDIR@") "doc/" "@DOCDIR@"))
(define %moduledir "module/")
(define %prefix (if (string-prefix? "@PREFIX" "@PREFIX@") "" "@PREFIX@"))
(define %version (if (string-prefix? "@VERSION" "@VERSION@") "git" "@VERSION@"))
(define (parse-opts args) (define (parse-opts args)
(let* ((option-spec (let* ((option-spec

View file

@ -1240,7 +1240,8 @@ load_env (SCM a) ///((internal))
{ {
r0 = a; r0 = a;
g_stdin = open ("module/mes/read-0.mes", O_RDONLY); g_stdin = open ("module/mes/read-0.mes", O_RDONLY);
g_stdin = g_stdin >= 0 ? g_stdin : open (MODULEDIR "mes/read-0.mes", O_RDONLY); char *read0 = MODULEDIR "mes/read-0.mes";
g_stdin = g_stdin >= 0 ? g_stdin : open (read0, O_RDONLY);
if (!g_function) r0 = mes_builtins (r0); if (!g_function) r0 = mes_builtins (r0);
r2 = read_input_file_env (r0); r2 = read_input_file_env (r0);
g_stdin = STDIN; g_stdin = STDIN;
@ -1253,7 +1254,8 @@ bload_env (SCM a) ///((internal))
#if __MESC__ #if __MESC__
char *mo = "mes/read-0-32.mo"; char *mo = "mes/read-0-32.mo";
g_stdin = open ("module/mes/read-0-32.mo", O_RDONLY); g_stdin = open ("module/mes/read-0-32.mo", O_RDONLY);
g_stdin = g_stdin >= 0 ? g_stdin : open (MODULEDIR "mes/read-0-32.mo", O_RDONLY); char *read0 = MODULEDIR "mes/read-0-32.mo";
g_stdin = g_stdin >= 0 ? g_stdin : open (read0, O_RDONLY);
#else #else
char *mo ="mes/read-0.mo"; char *mo ="mes/read-0.mo";
g_stdin = open ("module/mes/read-0.mo", O_RDONLY); g_stdin = open ("module/mes/read-0.mo", O_RDONLY);