plan9 build now uses static libs by default

This commit is contained in:
Alex Shinn 2012-05-06 23:08:47 +09:00
parent d2b3983e31
commit 92801f22ce
8 changed files with 94 additions and 19 deletions

10
eval.c
View file

@ -1073,11 +1073,15 @@ sexp sexp_close_port_op (sexp ctx, sexp self, sexp_sint_t n, sexp port) {
}
#if SEXP_USE_STATIC_LIBS
#ifndef PLAN9
#include "clibs.c"
static sexp_library_entry_t *sexp_find_static_library(const char *file)
#else
struct sexp_library_entry_t sexp_static_libraries[];
#endif
static struct sexp_library_entry_t *sexp_find_static_library(const char *file)
{
size_t base_len;
sexp_library_entry_t *entry;
struct sexp_library_entry_t *entry;
if (file[0] == '.' && file[1] == '/')
file += 2;
@ -1090,7 +1094,7 @@ static sexp_library_entry_t *sexp_find_static_library(const char *file)
return NULL;
}
static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
sexp_library_entry_t *entry = sexp_find_static_library(sexp_string_data(file));
struct sexp_library_entry_t *entry = sexp_find_static_library(sexp_string_data(file));
if (! entry)
return sexp_compile_error(ctx, "couldn't find builtin library", file);
return entry->init(ctx, NULL, 3, env, sexp_version, SEXP_ABI_IDENTIFIER);

View file

@ -255,6 +255,11 @@ struct sexp_gc_var_t {
struct sexp_gc_var_t *next;
};
struct sexp_library_entry_t { /* for static builds */
const char *name;
sexp_init_proc init;
};
struct sexp_type_struct {
sexp_tag_t tag;
short field_base, field_eq_len_base, field_len_base, field_len_off;

View file

@ -1,6 +1,9 @@
(cond-expand
(plan9)
(else
(c-system-include "time.h")
(c-system-include "sys/time.h")
(c-system-include "sys/time.h")))
(define-c-struct tm
predicate: tm?

View file

@ -2,9 +2,14 @@
/* Copyright (c) 2011-2012 Alex Shinn. All rights reserved. */
/* BSD-style license: http://synthcode.com/license.txt */
#include <time.h>
#include <chibi/eval.h>
#ifndef PLAN9
#include <time.h>
#else
typedef long time_t;
#endif
/* TODO: Check a leap second table file at appropriate intervals. */
static time_t leap_seconds_since_epoch = 24;

View file

@ -1,9 +1,14 @@
/* bit.c -- bitwise operators */
/* Copyright (c) 2009-2011 Alex Shinn. All rights reserved. */
/* Copyright (c) 2009-2012 Alex Shinn. All rights reserved. */
/* BSD-style license: http://synthcode.com/license.txt */
#include <chibi/eval.h>
#ifndef PLAN9
#include <limits.h>
#else
#define CHAR_BIT 8
#endif
#if SEXP_USE_BIGNUMS
#include <chibi/bignum.h>

View file

@ -1,13 +1,15 @@
/* env.c -- SRFI-98 environment interface */
/* Copyright (c) 2009-2011 Alex Shinn. All rights reserved. */
/* Copyright (c) 2009-2012 Alex Shinn. All rights reserved. */
/* BSD-style license: http://synthcode.com/license.txt */
#ifdef __APPLE__
#include <crt_externs.h>
#define environ (*_NSGetEnviron())
#else
#ifndef PLAN9
extern char **environ;
#endif
#endif
#include <chibi/eval.h>
@ -25,6 +27,7 @@ sexp sexp_get_environment_variables (sexp ctx, sexp self, sexp_sint_t n) {
sexp_gc_var3(res, name, val);
sexp_gc_preserve3(ctx, res, name, val);
res = SEXP_NULL;
#ifndef PLAN9
env = environ;
for (i=0; env[i]; i++) {
cname = env[i];
@ -36,6 +39,7 @@ sexp sexp_get_environment_variables (sexp ctx, sexp self, sexp_sint_t n) {
res = sexp_cons(ctx, val, res);
}
}
#endif
sexp_gc_release3(ctx);
return res;
}

55
mkfile
View file

@ -4,14 +4,52 @@ BIN=/$objtype/bin
TARG=chibi-scheme
MODDIR=/sys/lib/chibi-scheme
CPPFLAGS= -Iinclude -DPLAN9 -DSEXP_USE_STRING_STREAMS=0 -DSEXP_USE_GREEN_THREADS=0
CFLAGS= -p $CPPFLAGS
CHIBI=./$O.out
GENSTATIC=./tools/chibi-genstatic
OFILES=sexp.$O eval.$O main.$O
CPPFLAGS= -Iinclude -DPLAN9 -DSEXP_USE_GREEN_THREADS=0
CFLAGS= -p $CPPFLAGS
CFLAGS_STATIC=$CFLAGS -DSEXP_USE_STATIC_LIBS
OFILES=sexp.$O eval.$O main.$O $STATIC
HFILES=include/chibi/sexp.h include/chibi/eval.h include/chibi/features.h include/chibi/install.h
CLEANFILES=tests/basic/*.out tests/basic/*.err
EXCLUDE=srfi.18 srfi.27 chibi.filesystem chibi.io \
chibi.net chibi.process chibi.stty chibi.system \
chibi.time
CHIBI_LIBS = lib/chibi/filesystem.c lib/chibi/process.c \
lib/chibi/time.c lib/chibi/system.c lib/chibi/stty.c \
lib/chibi/weak.c lib/chibi/heap-stats.c lib/chibi/disasm.c \
lib/chibi/net.c
CHIBI_IO_COMPILED_LIBS = lib/chibi/io/io.c
CHIBI_OPT_COMPILED_LIBS = lib/chibi/optimize/rest.c \
lib/chibi/optimize/profile.c
COMPILED_LIBS = $CHIBI_COMPILED_LIBS $CHIBI_IO_COMPILED_LIBS \
$CHIBI_OPT_COMPILED_LIBS \
lib/srfi/33/bit.c lib/srfi/39/param.c \
lib/srfi/69/hash.c lib/srfi/95/qsort.c lib/srfi/98/env.c \
lib/scheme/time.c
</sys/src/cmd/mkone
clean:
rm -f $CLEANFILES
clibs.$O: clibs.c
$TARG: $O.out
rm $OFILES
mk 'CFLAGS=$CFLAGS_STATIC' clibs.$O $OFILES
mk 'CFLAGS=$CFLAGS_STATIC' 'STATIC=clibs.$O' default
target: $O.out
mv $O.out $TARG
%.c: %.stub
$CHIBI ./tools/chibi-ffi $stem.stub
include/chibi/install.h: mkfile
echo '#define sexp_default_module_path "'$MODDIR'"' > include/chibi/install.h
echo '#define sexp_so_extension ".no-such-file"' >> include/chibi/install.h
@ -19,10 +57,21 @@ include/chibi/install.h: mkfile
echo '#define sexp_version "'`{cat VERSION}'"' >> include/chibi/install.h
echo '#define sexp_release_name "'`{cat RELEASE}'"' >> include/chibi/install.h
dist-clean: clean
rm -f include/chibi/install.h clibs.c
install:V: $BIN/$TARG
test -d $MODDIR || mkdir -p $MODDIR
{cd lib; tar c .} | {cd $MODDIR ; tar x }
clibs.c:V: $GENSTATIC $CHIBI $COMPILED_LIBS
du -a lib | sed 's/^[0-9]*[ ]*//' | grep '\.sld$' | \
$CHIBI $GENSTATIC \
-x srfi.27 -x srfi.18 -x chibi.filesystem -x chibi.io \
-x chibi.net -x chibi.process -x chibi.stty -x chibi.system \
-x chibi.time \
> ,clibs.c && mv ,clibs.c clibs.c
test:V:
./$O.out -xscheme tests/r5rs-tests.scm

View file

@ -214,12 +214,12 @@
(newline)
(for-each include-c-lib c-libs)
(newline)
(display "typedef struct {\n")
(display " const char *name;\n")
(display " sexp_init_proc init;\n")
(display "} sexp_library_entry_t;\n")
(newline)
(display "static sexp_library_entry_t sexp_static_libraries[] = {\n")
;; (display "typedef struct {\n")
;; (display " const char *name;\n")
;; (display " sexp_init_proc init;\n")
;; (display "} sexp_library_entry_t;\n")
;; (newline)
(display "struct sexp_library_entry_t sexp_static_libraries[] = {\n")
(for-each init-c-lib c-libs)
(display " { NULL, NULL }\n")
(display "};\n\n")))