From ff49fd6796e883d20d56c3b1e7fc4e9cae2df279 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Fri, 17 Jul 2015 23:19:06 -0400 Subject: [PATCH] WIP --- Makefile | 2 +- runtime.c | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 11c86d00..0c6feafa 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ libcyclone.so.1: runtime.c runtime.h gcc -shared -Wl,-soname,libcyclone.so.1 -o libcyclone.so.1.0.1 runtime.o libcyclone.a: runtime.c runtime.h dispatch.c $(CC) -g -c dispatch.c -o dispatch.o - $(CC) -g -c -DCYC_INSTALL_DIR=\"$(PREFIX)\" -DCYC_INSTALL_SLD=\"/share/cyclone\" runtime.c -o runtime.o + $(CC) -g -c -DCYC_INSTALL_DIR=\"$(PREFIX)\" -DCYC_INSTALL_LIB=\"$(LIBDIR)\" -DCYC_INSTALL_INC=\"$(INCDIR)\" -DCYC_INSTALL_SLD=\"$(DATADIR)\" runtime.c -o runtime.o $(AR) rcs libcyclone.a runtime.o dispatch.o # Instructions from: http://www.adp-gmbh.ch/cpp/gcc/create_lib.html # Note compiler will have to link to this, eg: diff --git a/runtime.c b/runtime.c index f253041e..c7779d00 100644 --- a/runtime.c +++ b/runtime.c @@ -943,12 +943,23 @@ string_type Cyc_substring(object str, object start, object end) { * This is configured via the makefile during a build. */ string_type Cyc_installation_dir(object type) { - // TODO: need to handle 'inc 'lib 'sld and return appropriate dir. - // EG: if 'sld, return (CYC_INSTALL_DIR "/" CYC_SLD_DIR) - // need to use directives from makefile if (Cyc_is_symbol(type) == boolean_t && strncmp(((symbol)type)->pname, "sld", 5) == 0) { - make_string(str, CYC_INSTALL_SLD); // TODO: prepend INSTALL_DIR + "/" + char buf[1024]; + snprintf(buf, sizeof(buf), "%s", CYC_INSTALL_SLD); + make_string(str, buf); + return str; + } else if (Cyc_is_symbol(type) == boolean_t && + strncmp(((symbol)type)->pname, "lib", 5) == 0) { + char buf[1024]; + snprintf(buf, sizeof(buf), "%s", CYC_INSTALL_LIB); + make_string(str, buf); + return str; + } else if (Cyc_is_symbol(type) == boolean_t && + strncmp(((symbol)type)->pname, "inc", 5) == 0) { + char buf[1024]; + snprintf(buf, sizeof(buf), "%s", CYC_INSTALL_INC); + make_string(str, buf); return str; } else { make_string(str, CYC_INSTALL_DIR);