* libc/include/assert.h: New file.
* libc/include/ctype.h: New file.
* libc/include/errno.h: New file.
* libc/include/fcntl.h: New file.
* libc/include/limits.h: New file.
* libc/include/mlibc.h: New file.
* libc/include/stdio.h: New file.
* libc/include/stdlib: New file.
* libc/include/string.h: New file.
* libc/include/unistd.h: New file.
* libc/mlibc.c: Remove declarations.
* make/bin.make (INCLUDES): Factor out standard includes.
* make/bin-mlibc.make: New file.
* scaffold/scaffold.make: Use it.
* src/src.make: Use it.
* module/language/c99/compiler.mes (ast-info): Handle more function declarations.
* scaffold/cons-mes.c: Remove mlibc definitionsa and mlibc.c include.
Instead include <mlibc.h>.
* scaffold/hello.c: Likewise.
* scaffold/m.c: Likewise.
* scaffold/malloc.c: Likewise.
* scaffold/micro-mes.c: Likewise.
* scaffold/mini-mes.c: Likewise.
* scaffold/t.c: Likewise.
* scaffold/tiny-mes.c: Likewise.
* src/gc.c: Likewise.
* src/lib.c: Likewise.
* src/math.c: Likewise.
* src/mes.c: Likewise.
* src/posix.c: Likewise.
* src/reader.c: Likewise.
default: all
MES_DEBUG:=1
-CFLAGS:=--std=gnu99 -O0 -g
+CFLAGS:=--std=gnu99 -O0 -g --include mlibc.c
OUT:=out
SUBDIRS:=\
--- /dev/null
+/* -*-comment-start: "//";comment-end:""-*-
+ * Mes --- Maxwell Equations of Software
+ * Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
+ *
+ * This file is part of Mes.
+ *
+ * Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mes. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __ASSERT_H
+#define __ASSERT_H 1
+
+#if __GNUC__ && POSIX
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include_next <assert.h>
+#else // ! (__GNUC__ && POSIX)
+#define assert(x) ((x) ? (void)0 : assert_fail (#x))
+#endif // ! (__GNUC__ && POSIX)
+
+#endif // __ASSERT_H
--- /dev/null
+/* -*-comment-start: "//";comment-end:""-*-
+ * Mes --- Maxwell Equations of Software
+ * Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
+ *
+ * This file is part of Mes.
+ *
+ * Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mes. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __CTYPE_H
+#define __CTYPE_H 1
+
+#if __GNUC__ && POSIX
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include_next <ctype.h>
+
+#else // ! (__GNUC__ && POSIX)
+int isdigit (int);
+#endif // ! (__GNUC__ && POSIX)
+
+#endif // __CTYPE_H
--- /dev/null
+/* -*-comment-start: "//";comment-end:""-*-
+ * Mes --- Maxwell Equations of Software
+ * Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
+ *
+ * This file is part of Mes.
+ *
+ * Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mes. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __ERRNO_H
+#define __ERRNO_H 1
+
+#if __GNUC__ && POSIX
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include_next <errno.h>
+#endif // ! (__GNUC__ && POSIX)
+
+#endif // __ERRNO_H
--- /dev/null
+/* -*-comment-start: "//";comment-end:""-*-
+ * Mes --- Maxwell Equations of Software
+ * Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
+ *
+ * This file is part of Mes.
+ *
+ * Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mes. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __FCNTL_H
+#define __FCNTL_H 1
+
+#if __GNUC__ && POSIX
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include_next <fcntl.h>
+
+#else // ! (__GNUC__ && POSIX)
+#define O_RDONLY 0
+int open (char const *s, int mode);
+#endif // ! (__GNUC__ && POSIX)
+
+#endif // __FCNTL_H
--- /dev/null
+/* -*-comment-start: "//";comment-end:""-*-
+ * Mes --- Maxwell Equations of Software
+ * Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
+ *
+ * This file is part of Mes.
+ *
+ * Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mes. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __LIMITS_H
+#define __LIMITS_H 1
+
+#if __GNUC__ && POSIX
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include_next <limits.h>
+
+#else // ! (__GNUC__ && POSIX)
+#define INT_MIN -2147483648
+#define INT_MAX 2147483647
+#endif // ! (__GNUC__ && POSIX)
+
+#endif // __LIMITS_H
--- /dev/null
+/* -*-comment-start: "//";comment-end:""-*-
+ * Mes --- Maxwell Equations of Software
+ * Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
+ *
+ * This file is part of Mes.
+ *
+ * Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mes. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __MLIBC_H
+#define __MLIBC_H
+
+char const* itoa (int);
+
+#endif //__MLIBC_H
+/* -*-comment-start: "//";comment-end:""-*-
+ * Mes --- Maxwell Equations of Software
+ * Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
+ *
+ * This file is part of Mes.
+ *
+ * Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mes. If not, see <http://www.gnu.org/licenses/>.
+ */
#ifndef __STDIO_H
#define __STDIO_H 1
+char **g_environment;
+int g_stdin;
+
+#define EOF -1
+#define STDIN 0
+#define STDOUT 1
+#define STDERR 2
+
int printf (char const* format, ...);
+#if __GNUC__ && POSIX
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include_next <stdio.h>
+
+int fdputs (char const* s, int fd);
+
+#undef puts
+#define puts(x) fdputs(x, STDOUT)
+#define eputs(x) fdputs(x, STDERR)
+#define fputs fdputs
+
+#ifdef putc
+#undef putc
+#endif
+
+int getchar ();
+
+int fdputc (int c, int fd);
+
+#define fputc fdputc
+#define ungetc fdungetc
+int fdungetc (int c, int fd);
+
+#else // !POSIX
+
+#undef fputs
+#undef fdputs
+int fdputs (char const* s, int fd);
+
+#endif // __GNUC__ && POSIX
+
#endif // __STDIO_H
--- /dev/null
+/* -*-comment-start: "//";comment-end:""-*-
+ * Mes --- Maxwell Equations of Software
+ * Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
+ *
+ * This file is part of Mes.
+ *
+ * Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mes. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __STDLIB_H
+#define __STDLIB_H 1
+
+#if __GNUC__ && POSIX
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include_next <stdlib.h>
+#else // !(__GNUC__ && POSIX)
+
+#ifndef __SIZE_T
+#define __SIZE_T
+typedef long size_t;
+#endif
+
+void *malloc (size_t);
+void exit (int);
+#endif // !(__GNUC__ && POSIX)
+
+#endif // __STDLIB_H
+
--- /dev/null
+/* -*-comment-start: "//";comment-end:""-*-
+ * Mes --- Maxwell Equations of Software
+ * Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
+ *
+ * This file is part of Mes.
+ *
+ * Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mes. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __STRING_H
+#define __STRING_H 1
+
+#if __GNUC__ && POSIX
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include_next <string.h>
+
+#else // ! (__GNUC__ && POSIX)
+
+#ifndef __SIZE_T
+#define __SIZE_T
+typedef long size_t;
+#endif
+
+size_t strlen (char const*);
+int strcmp (char const*, char const*);
+int strncmp (char const*, char const*, size_t);
+#endif // ! (__GNUC__ && POSIX)
+
+#endif // __STRING_H
--- /dev/null
+/* -*-comment-start: "//";comment-end:""-*-
+ * Mes --- Maxwell Equations of Software
+ * Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
+ *
+ * This file is part of Mes.
+ *
+ * Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mes. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __UNISTD_H
+#define __UNISTD_H 1
+
+#if __GNUC__ && POSIX
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include_next <unistd.h>
+
+#else // ! (__GNUC__ && POSIX)
+
+#ifndef __SIZE_T
+#define __SIZE_T
+typedef long size_t;
+#endif
+
+int read (int fd, void* buf, size_t n);
+int write (int fd, char const* s, int n);
+#endif // ! (__GNUC__ && POSIX)
+
+#endif // __UNISTD_H
char **g_environment = 0;
int g_stdin = 0;
-#define EOF -1
-#define STDIN 0
-#define STDOUT 1
-#define STDERR 2
+#include <stdio.h>
+#include <mlibc.h>
#if __GNUC__ && !POSIX
-#define O_RDONLY 0
-#define INT_MIN -2147483648
-#define INT_MAX 2147483647
-
-typedef long size_t;
-void *malloc (size_t i);
-int open (char const *s, int mode);
-int read (int fd, void* buf, size_t n);
-int write (int fd, char const* s, int n);
+#include <stdlib.h>
void
exit (int code)
char const* itoa (int);
int
-strncmp (char const* a, char const* b, int length)
+strncmp (char const* a, char const* b, size_t length)
{
while (*a && *b && *a == *b && --length) {a++;b++;}
return *a - *b;
}
#if POSIX
-
#define _GNU_SOURCE
#include <assert.h>
-#include <ctype.h>
-#include <errno.h>
#include <fcntl.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#endif // POSIX
-#undef puts
-#define puts(x) fdputs(x, STDOUT)
-#define eputs(x) fdputs(x, STDERR)
-#define fputs fdputs
int
fdputs (char const* s, int fd)
{
return 0;
}
-#ifdef putc
-#undef putc
-#endif
-#define fputc fdputc
+#if POSIX
+
int
fdputc (int c, int fd)
{
return i;
}
-#define ungetc fdungetc
int
fdungetc (int c, int fd)
{
ungetc_buf[++ungetc_char] = c;
return c;
}
-#else
-#define fputs fdputs
-int
-fdputs (char const* s, int fd)
-{
- int i = strlen (s);
- write (fd, s, i);
- return 0;
-}
-
-#endif
+#endif // POSIX
);
exit (r);
}
-#endif
+#endif // __GNUC__
--- /dev/null
+C_FLAGS:=-nostdinc --include mstart.c -fno-builtin
+LD_FLAGS:=-nostdlib
+CROSS:=$(CC32:%gcc=%)
+
+include make/bin.make
CLEAN+=$(O_FILES) $(OUT)/$(TARGET)
DIST-CLEAN+=$(D_FILES)
+INCLUDES+=libc/include libc $(OUT)/$(DIR)
+
$(OUT)/$(TARGET): ld:=$(CROSS)LD
$(OUT)/$(TARGET): LD:=$(CROSS)$(LD)
$(OUT)/$(TARGET): CC:=$(CROSS)$(CC)
(let ((types (.types info)))
(clone info #:types (cons (cons name (assoc-ref types type)) types))))
+ ;; int foo ();
+ ((decl (decl-spec-list (type-spec (fixed-type ,type))) (init-declr-list (init-declr (ftn-declr (ident ,name) (param-list . ,param-list)))))
+ info)
+
+ ;; void foo ();
+ ((decl (decl-spec-list (type-spec (void))) (init-declr-list (init-declr (ftn-declr (ident ,name) (param-list . ,param-list)))))
+ info)
+
+ ;; void foo (*);
+ ((decl (decl-spec-list (type-spec (void))) (init-declr-list (init-declr (ptr-declr (pointer) (ftn-declr (ident ,name) (param-list . ,param-list))))))
+ info)
+
+ ;; char const* itoa ();
+ ((decl (decl-spec-list (type-spec (fixed-type ,type)) (type-qual ,qual)) (init-declr-list (init-declr (ptr-declr (pointer) (ftn-declr (ident ,name) (param-list . ,param-list))))))
+ info)
+
;; printf (char const* format, ...)
- ((decl (decl-spec-list (type-spec (fixed-type ,type))) (init-declr-list (init-declr (ftn-declr (ident ,name) (param-list ,param-list (ellipsis))))))
+ ((decl (decl-spec-list (type-spec (fixed-type ,type))) (init-declr-list (init-declr (ftn-declr (ident ,name) (param-list ,param-list . (ellipsis))))))
info)
;; int i = 0, j = 0;
#error "POSIX not supported"
#endif
-#if __MESC__
-char **g_environment;
-int g_stdin = 0;
-#define assert(x) ((x) ? (void)0 : assert_fail (#x))
-#endif
-
-#if !__MESC__
-#include "mlibc.c"
-#endif
+#include <stdio.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mlibc.h>
char arena[2000];
return 0;
}
-#if !__MESC__
-#include "mstart.c"
-#endif
-
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
*/
-#if __MESC__
-char **g_environment;
-int g_stdin = 0;
-#define assert(x) ((x) ? (void)0 : assert_fail (#x))
-#endif
-
-#if !__MESC__
-#include "mlibc.c"
-#endif
+#include <mlibc.h>
int
main (int argc, char *argv[])
if (argc > 1 && !strcmp (argv[1], "--help")) {puts ("argc > 1 && --help\n"); return argc;}
return 42;
}
-
-#if !__MESC__ && !POSIX
-#include "mstart.c"
-#endif
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
*/
-#if __MESC__
-char **g_environment;
-int g_stdin = 0;
-#define assert(x) ((x) ? (void)0 : assert_fail (#x))
-#endif
-
-#if !__MESC__
-#include "mlibc.c"
-#endif
+#include <mlibc.h>
int
main (int argc, char *argv[])
}
return c;
}
-
-#if !__MESC__ && !POSIX
-#include "mstart.c"
-#endif
#error "POSIX not supported"
#endif
-#if __MESC__
-int g_stdin = 0;
-#define assert(x) ((x) ? (void)0 : assert_fail (#x))
-#endif
-
-#if !__MESC__
-#include "mlibc.c"
-#endif
+#include <mlibc.h>
int
main (int argc, char *argv[])
}
return 0;
}
-
-#if __GNUC__
-#include "mstart.c"
-#endif
#error "POSIX not supported"
#endif
-#if __MESC__
-char **g_environment;
-int g_stdin = 0;
-#define assert(x) ((x) ? (void)0 : assert_fail (#x))
-#endif
-
-#if !__MESC__
-#include "mlibc.c"
-#endif
+#include <mlibc.h>
typedef int SCM;
int i = argc;
return i;
}
-
-#if !__MESC__
-#include "mstart.c"
-#endif
#error "POSIX not supported"
#endif
-#if __MESC__
-char **g_environment;
-int g_stdin = 0;
-#define assert(x) ((x) ? (void)0 : assert_fail (#x))
-#endif
-
-#if !__MESC__
-#include "mlibc.c"
-#endif
+#include <stdio.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mlibc.h>
int ARENA_SIZE = 100000;
int MAX_ARENA_SIZE = 40000000;
int
main (int argc, char *argv[])
{
- eputs ("Hello mini-mes!\n");
-#if _POSIX_SOURCE
- g_debug = getenv ("MES_DEBUG");
- if (g_debug) {eputs ("MODULEDIR=");eputs (MODULEDIR);eputs ("\n");}
- if (getenv ("MES_ARENA")) ARENA_SIZE = atoi (getenv ("MES_ARENA"));
-#endif
- g_debug = 1;
- if (argc > 1 && !strcmp (argv[1], "--help")) return puts ("Usage: mes [--dump|--load] < FILE");
- if (argc > 1 && !strcmp (argv[1], "--version")) {puts ("Mes ");puts (VERSION);return 0;};
- g_stdin = STDIN;
+ char *p;
+ if (p = getenv ("MES_DEBUG")) g_debug = atoi (p);
+ if (g_debug) {eputs (";;; MODULEDIR=");eputs (MODULEDIR);eputs ("\n");}
+ if (p = getenv ("MES_MAX_ARENA")) MAX_ARENA_SIZE = atoi (p);
+ if (p = getenv ("MES_ARENA")) ARENA_SIZE = atoi (p);
+ if (argc > 1 && !strcmp (argv[1], "--help")) return puts ("Usage: mes [--dump|--load] < FILE\n");
+ if (argc > 1 && !strcmp (argv[1], "--version")) {puts ("Mes ");puts (VERSION);puts ("\n");return 0;};
r0 = mes_environment ();
SCM program = bload_env (r0);
SCM lst = cell_nil;
-#if !__MESC__
for (int i=argc-1; i>=0; i--) lst = cons (MAKE_STRING (cstring_to_list (argv[i])), lst);
-#endif
r0 = acons (cell_symbol_argv, lst, r0);
push_cc (r2, cell_unspecified, r0, cell_unspecified);
if (g_debug)
}
return 0;
}
-
-#if !__MESC__
-#include "mstart.c"
-#endif
TARGET:=m.mlibc
C_FILES:=$(DIR)/m.c
-INCLUDES:=libc
-C_FLAGS:=-nostdinc
-LD_FLAGS:=-nostdlib
-CROSS:=$(CC32:%gcc=%)
-include make/bin.make
+include make/bin-mlibc.make
TARGET:=m.mlibc
EXPECT:=255
TARGET:=hello.mlibc
C_FILES:=$(DIR)/hello.c
-INCLUDES:=libc
-C_FLAGS:=-nostdinc -g
-LD_FLAGS:=-nostdlib -g
-CROSS:=$(CC32:%gcc=%)
-include make/bin.make
+include make/bin-mlibc.make
TARGET:=hello.mlibc
EXPECT:=42
TARGET:=micro-mes.mlibc
C_FILES:=$(DIR)/micro-mes.c
-INCLUDES:=libc
-C_FLAGS:=-nostdinc
-LD_FLAGS:=-nostdlib
-CROSS:=$(CC32:%gcc=%)
-include make/bin.make
+include make/bin-mlibc.make
TEST:=micro-mes.mlibc-check
$(TEST): $(OUT)/micro-mes.mlibc
TARGET:=tiny-mes.mlibc
C_FILES:=$(DIR)/tiny-mes.c
-INCLUDES:=libc
-C_FLAGS:=-nostdinc
-LD_FLAGS:=-nostdlib
-CROSS:=$(CC32:%gcc=%)
-include make/bin.make
+include make/bin-mlibc.make
TARGET:=tiny-mes.mlibc
include make/check.make
TARGET:=cons-mes.mlibc
C_FILES:=$(DIR)/cons-mes.c
-INCLUDES:=libc
-C_FLAGS:=-nostdinc
-LD_FLAGS:=-nostdlib
DEFINES:=VERSION='"$(VERSION)"'
-CROSS:=$(CC32:%gcc=%)
-include make/bin.make
+include make/bin-mlibc.make
TARGET:=cons-mes.mlibc
include make/check.make
TARGET:=t.mlibc
C_FILES:=$(DIR)/t.c
-INCLUDES:=libc
-C_FLAGS:=-nostdinc
-LD_FLAGS:=-nostdlib
-CROSS:=$(CC32:%gcc=%)
-include make/bin.make
+include make/bin-mlibc.make
TARGET:=t.mlibc
include make/check.make
+CROSS:=$(CC32:%gcc=%)
+#$(OUT)/$(DIR)/mini-mes.$(CROSS)o: $(SNARF.MES)
$(OUT)/mini-mes: $(SNARF.MES)
TARGET:=mini-mes.mlibc
C_FILES:=$(DIR)/mini-mes.c
-DEFINES:=FIXED_PRIMITIVES=1 VERSION='"$(VERSION)"' PREFIX='"$(PREFIX)"'
-INCLUDES:=libc src $(OUT)/src
-C_FLAGS:=-nostdinc
-LD_FLAGS:=-nostdlib
-CROSS:=$(CC32:%gcc=%)
-include make/bin.make
+DEFINES:=FIXED_PRIMITIVES=1 VERSION='"$(VERSION)"' MODULEDIR='"$(MODULEDIR)"' PREFIX='"$(PREFIX)"'
+INCLUDES:=src $(OUT)/src
+include make/bin-mlibc.make
TEST:=mini-mes.mlibc-check
$(TEST): $(OUT)/mini-mes.mlibc
include make/check.make
# scripts/mescc.mes
-
+ifeq ($(MES_SKIP_MES),)
TARGET:=m.mes
C_FILES:=$(DIR)/m.c
include make/mescc-mes.make
TARGET:=t.mes
include make/check.make
+endif
ifneq ($(BOOTSTRAP),)
$(OUT)/mini-mes.mes: module/mes/read-0-32.mo
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
*/
-#if __MESC__
-int g_stdin = 0;
-#define assert(x) ((x) ? (void)0 : assert_fail (#x))
-#endif
-
-#if !__MESC__
-#include "mlibc.c"
-#endif
+#include <mlibc.h>
+#include <assert.h>
+#include <stdlib.h>
struct scm {
int type;
return 22;
}
-
-#if !POSIX && !__MESC__
-#include "mstart.c"
-#endif
#error "POSIX not supported"
#endif
-#if __MESC__
-char **g_environment;
-int g_stdin = 0;
-#define assert(x) ((x) ? (void)0 : assert_fail (#x))
-#endif
-
-#if !__MESC__
-#include "mlibc.c"
-#endif
+#include <mlibc.h>
char arena[300];
return 0;
}
-
-#if !__MESC__
-#include "mstart.c"
-#endif
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <errno.h>
+
SCM
gc_up_arena () ///((internal))
{
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
*/
+#if !__MESC__
+#define fputs fdputs
+#endif
+
int g_depth;
SCM fdisplay_ (SCM, int);
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <limits.h>
+
SCM
greater_p (SCM x) ///((name . ">") (arity . n))
{
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
*/
-#if __MESC__
-char **g_environment;
-int g_stdin = 0;
-#define assert(x) ((x) ? (void)0 : assert_fail (#x))
-#endif
-
-#if !__MESC__
-#include "mlibc.c"
-#endif
+#include <stdio.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mlibc.h>
int ARENA_SIZE = 100000;
int MAX_ARENA_SIZE = 20000000;
}
return 0;
}
-
-#if !_POSIX_SOURCE && !__MESC__
-#include "mstart.c"
-#endif
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <fcntl.h>
+
int
ungetchar (int c)
{
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
*/
-// #if _POSIX_SOURCE
-// #undef fputs
-// #undef fdputs
-// #undef fdputc
-// #endif
+#include <ctype.h>
SCM
___end_of_mes___ ()
include make/reset.make
-# a full 32 bit cross compiler with glibc
-# CROSS:=$(CC32:%gcc=%)
# TARGET:=$(CROSS)mes
-# $(OUT)/$(DIR)/mes.$(CROSS)o: $(SNARF.MES)
-# C_FILES:=$(DIR)/mes.c
-# DEFINES:=FIXED_PRIMITIVES=1 MES_FULL=1 POSIX=1 VERSION='"$(VERSION)"' MODULEDIR='"$(MODULEDIR)"' PREFIX='"$(PREFIX)"'
-# INCLUDES:=libc $(OUT)/src
-# include make/bin.make
-
-# a simple non-glibc cross compiler, using mlibc.
CROSS:=$(CC32:%gcc=%)
-TARGET:=$(CROSS)mes
+$(OUT)/$(CROSS)%: $(OUT)/%.mlibc
+ @ln -sf $(<F) $@
+
+TARGET:=mes.mlibc
$(OUT)/$(DIR)/mes.$(CROSS)o: $(SNARF.MES)
C_FILES:=$(DIR)/mes.c
DEFINES:=FIXED_PRIMITIVES=1 MES_FULL=1 VERSION='"$(VERSION)"' MODULEDIR='"$(MODULEDIR)"' PREFIX='"$(PREFIX)"'
-INCLUDES:=libc $(OUT)/src
-C_FLAGS:=-nostdinc
-LD_FLAGS:=-nostdlib
-include make/bin.make
+include make/bin-mlibc.make
TARGET:=mes.guile
$(OUT)/mes.mes: module/mes/read-0-32.mo