diff --git a/Makefile b/Makefile index 4d3d361..671e17b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ PREFIX=/usr/local -VERSION=0.12.1 +VERSION=0.0.1 CCONFIG=-std=c11 -Werror -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -fPIC -I. \ -fsanitize=signed-integer-overflow -fno-sanitize-recover -fvisibility=hidden -fdollars-in-identifiers LTO=-flto=auto -fno-fat-lto-objects -Wl,-flto @@ -49,4 +49,14 @@ clean: %.1: %.1.md pandoc --lua-filter=.pandoc/bold-code.lua -s $< -t man -o $@ +install: tomo libtomo.so + mkdir -p -m 755 "$(PREFIX)/man/man1" "$(PREFIX)/bin" "$(PREFIX)/lib" "$(PREFIX)/share/tomo/modules" + cp -v tomo.h "$(PREFIX)/include/" + cp -v libtomo.so "$(PREFIX)/lib/" + rm -f "$(PREFIX)/bin/tomo" + cp -v tomo "$(PREFIX)/bin/" + +uninstall: + rm -rvf "$(PREFIX)/bin/tomo" "$(PREFIX)/lib/libtomo.so" "$(PREFIX)/share/tomo"; \ + .PHONY: all clean install uninstall test tags diff --git a/README.md b/README.md index 950dff4..0a6d729 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,25 @@ Check out the [test/](test/) folder to see some examples. ## Dependencies -Tomo uses the [Boehm garbage collector](https://www.hboehm.info/gc/) for -runtime garbage collection (which is available from your package manager of -choice, for example: `pacman -S gc`). +Tomo has a very small set of dependencies: + +- The [Boehm garbage collector](https://www.hboehm.info/gc/) for runtime + garbage collection. +- [libunistring](https://www.gnu.org/software/libunistring/) for unicode + string support. +- a C compiler +- and libc/libm, which should definitely already be installed. + +Both of which should be available on your package manager of choice (for +example, `pacman -S gc libunistring`). + +## Building + +The Tomo compiler can be compiled with either GCC or Clang by running `make`. + +## Running + +You can run a Tomo program by running `./tomo program.tm`. By default, this +will use your environment's `$CC` variable to select which C compiler to use. +If no C compiler is specified, it will default to `tcc` (Tiny C Compiler), +which is exceptionally fast. diff --git a/builtins/types.h b/builtins/types.h index d26c86b..f62e37e 100644 --- a/builtins/types.h +++ b/builtins/types.h @@ -63,6 +63,7 @@ typedef struct TypeInfo { extern const TypeInfo TypeInfo_info; extern const TypeInfo Void; extern const TypeInfo Abort; +#define Void_t void CORD Type__as_text(const void *typeinfo, bool colorize, const TypeInfo *type); CORD Func__as_text(const void *fn, bool colorize, const TypeInfo *type); diff --git a/tomo.h b/tomo.h index 9337d74..7f4a625 100644 --- a/tomo.h +++ b/tomo.h @@ -26,20 +26,6 @@ #include "builtins/text.h" #include "builtins/types.h" -#define Void_t void - -CORD as_cord(void *x, bool use_color, const char *fmt, ...); - -#define StrF(...) ({ CORD $c; CORD_sprintf(&$c, __VA_ARGS__); $c; }) -#define $var(var, val) __typeof(val) var = val -#define $cord(x) _Generic(x, bool: x ? "yes" : "no", \ - int8_t: StrF("%d", x), \ - int16_t: StrF("%d", x), \ - int32_t: StrF("%d", x), int64_t: StrF("%ld", x), \ - double: StrF("%g", x), float: StrF("%g", x), \ - CORD: x, \ - array_t: as_cord($stack(x), false, "[ ]"), \ - default: "???") #define $heap(x) (__typeof(x)*)memcpy(GC_MALLOC(sizeof(x)), (__typeof(x)[1]){x}, sizeof(x)) #define $stack(x) (__typeof(x)*)((__typeof(x)[1]){x}) #define $tagged(obj_expr, type_name, tag_name) ({ __typeof(obj_expr) $obj = obj_expr; \