From b96a9fcedd34d3c34c0222c5c7b2c1fe80d00f37 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Sat, 30 Jul 2016 01:48:27 -0400 Subject: [PATCH] Added Cyc_compilation_environment() --- Makefile | 9 ++++++--- Makefile.config | 6 +++--- include/cyclone/runtime.h | 1 + runtime.c | 28 ++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index c8369d9e..f10eefab 100644 --- a/Makefile +++ b/Makefile @@ -62,9 +62,9 @@ libcyclone.so.1: runtime.c include/cyclone/runtime.h gcc -shared -Wl,-soname,libcyclone.so.1 -o libcyclone.so.1.0.1 runtime.o libcyclone.a: runtime.c include/cyclone/runtime.h include/cyclone/types.h gc.c dispatch.c - echo $(CC_PROG) - echo $(CC_EXEC) - echo $(CC_LIB) +# echo $(CC_PROG) +# echo $(CC_EXEC) +# echo $(CC_LIB) $(CC) $(CFLAGS) -c -Iinclude dispatch.c -o dispatch.o $(CC) $(CFLAGS) -std=gnu99 -c -Iinclude gc.c -o gc.o $(CC) $(CFLAGS) -c -Iinclude \ @@ -72,6 +72,9 @@ libcyclone.a: runtime.c include/cyclone/runtime.h include/cyclone/types.h gc.c d -DCYC_INSTALL_LIB=\"$(LIBDIR)\" \ -DCYC_INSTALL_INC=\"$(INCDIR)\" \ -DCYC_INSTALL_SLD=\"$(DATADIR)\" \ + -DCYC_CC_PROG=\"$(CC_PROG)\" \ + -DCYC_CC_EXEC=\"$(CC_EXEC)\" \ + -DCYC_CC_LIB=\"$(CC_LIB)\" \ runtime.c -o runtime.o $(AR) rcs libcyclone.a runtime.o gc.o dispatch.o # Instructions from: http://www.adp-gmbh.ch/cpp/gcc/create_lib.html diff --git a/Makefile.config b/Makefile.config index fb67ba2e..2ee0576a 100644 --- a/Makefile.config +++ b/Makefile.config @@ -3,9 +3,9 @@ CFLAGS ?= -g -Wall CC ?= cc -CC_PROG ?= "$(CC) %src-file% $(CFLAGS) -c -o %exec-file%.o" -CC_EXEC ?= "$(CC) %exec-file%.o %objs% -pthread -lcyclone -lck -lm $(CFLAGS) -o %exec-file%" -CC_LIB ?= "$(CC) %src-file% $(CFLAGS) -c -o %exec-file%.o" +CC_PROG ?= "$(CC) ~src-file~ $(CFLAGS) -c -o ~exec-file~.o" +CC_EXEC ?= "$(CC) ~exec-file~.o ~obj-files~ -pthread -lcyclone -lck -lm $(CFLAGS) -o ~exec-file~" +CC_LIB ?= "$(CC) ~src-file~ $(CFLAGS) -c -o ~exec-file~.o" AR ?= ar #CD ?= cd diff --git a/include/cyclone/runtime.h b/include/cyclone/runtime.h index b3fbd248..0d4ac141 100644 --- a/include/cyclone/runtime.h +++ b/include/cyclone/runtime.h @@ -201,6 +201,7 @@ object Cyc_substring(void *data, object cont, object str, object start, object Cyc_string_ref(void *data, object str, object k); object Cyc_string_set(void *data, object str, object k, object chr); object Cyc_installation_dir(void *data, object cont, object type); +void Cyc_compilation_environment(void *data, object cont, object var); object Cyc_command_line_arguments(void *data, object cont); object Cyc_system(object cmd); object Cyc_char2integer(object chr); diff --git a/runtime.c b/runtime.c index 571dd29d..f2bf7cb0 100644 --- a/runtime.c +++ b/runtime.c @@ -1730,6 +1730,34 @@ object Cyc_installation_dir(void *data, object cont, object type) } } +/** + * Retrieve a value set during Cyclone compilation + */ +void Cyc_compilation_environment(void *data, object cont, object var) +{ + if (Cyc_is_symbol(var) == boolean_t){ + if (strncmp(((symbol) var)->pname, "cc-prog", 8) == 0) { + char buf[1024]; + snprintf(buf, sizeof(buf), "%s", CYC_CC_PROG); + make_string(str, buf); + return_closcall1(data, cont, &str); + } else if (strncmp(((symbol) var)->pname, "cc-exec", 8) == 0) { + char buf[1024]; + snprintf(buf, sizeof(buf), "%s", CYC_CC_EXEC); + make_string(str, buf); + return_closcall1(data, cont, &str); + } else if (strncmp(((symbol) var)->pname, "cc-lib", 7) == 0) { + char buf[1024]; + snprintf(buf, sizeof(buf), "%s", CYC_CC_LIB); + make_string(str, buf); + return_closcall1(data, cont, &str); + } + } + Cyc_rt_raise2(data, + "Cyc-compilation-environment - unrecognized symbol", + var); +} + /** * Perform same role as the CHICKEN function: *