aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2009-09-30 00:36:47 +0000
committerdos-reis <gdr@axiomatics.org>2009-09-30 00:36:47 +0000
commit808c5e28c0e8bc7a397eb2ffd1e77ee7a53061a6 (patch)
tree0f75d1b6419a308c4bd90a71d841bbf91ce8b27e /src
parent9bef621350fff8de58a30cada7c1a64d76b778fb (diff)
downloadopen-axiom-808c5e28c0e8bc7a397eb2ffd1e77ee7a53061a6.tar.gz
* driver/Makefile.in (open-axiom): Link against core runtime.
* driver/main.c (publish_systemdir): Rework. * include/cfuns.h (oa_setenv): Declare. * lib/cfuns-c.c (oa_setenv): Define.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/driver/Makefile.in6
-rw-r--r--src/driver/main.c15
-rw-r--r--src/include/cfuns.h1
-rw-r--r--src/lib/cfuns-c.c19
5 files changed, 33 insertions, 15 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 4addb0d3..4d4e1d51 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2009-09-29 Gabriel Dos Reis <gdr@cse.tamu.edu>
+
+ * driver/Makefile.in (open-axiom): Link against core runtime.
+ * driver/main.c (publish_systemdir): Rework.
+ * include/cfuns.h (oa_setenv): Declare.
+ * lib/cfuns-c.c (oa_setenv): Define.
+
2009-09-29 Gabriel Dos Reis <gdr@cs.tamu.edu>
* algebra/xpoly.spad.pamphlet (OrderedFreeMonoid): Really make an
diff --git a/src/driver/Makefile.in b/src/driver/Makefile.in
index f64cfab0..0141482e 100644
--- a/src/driver/Makefile.in
+++ b/src/driver/Makefile.in
@@ -1,4 +1,4 @@
-# Copyright (C) 2007-2008, Gabriel Dos Reis.
+# Copyright (C) 2007-2009, Gabriel Dos Reis.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,8 @@ open_axiom_SOURCES = main.c utils.c
open_axiom_objects = $(open_axiom_SOURCES:.c=.lo)
+open_axiom_LDADD = -L$(axiom_target_libdir) $(oa_c_libs)
+
.PHONY: all all-ax all-driver
all: all-ax
@@ -59,7 +61,7 @@ utils.lo: utils.h
main.lo: utils.h
open-axiom$(EXEEXT): $(open_axiom_objects)
- $(LINK) -o $@ $(open_axiom_objects)
+ $(LINK) -o $@ $(open_axiom_objects) $(open_axiom_LDADD)
mostlyclean-local:
@rm -f $(axiom_objects)
diff --git a/src/driver/main.c b/src/driver/main.c
index eb0a3dcb..14762979 100644
--- a/src/driver/main.c
+++ b/src/driver/main.c
@@ -51,21 +51,10 @@
static void
publish_systemdir(const char* dir)
{
-#ifdef __WIN32__
- if (SetEnvironmentVariable(OPENAXIOM_GLOBAL_ENV, dir) == 0) {
- perror("SetEnvironmentVariable");
+ if (!oa_setenv(OPENAXIOM_GLOBAL_ENV, dir)) {
+ perror("publish_systemdir");
abort();
}
-#else /* __WIN32__ */
- const int env_length = sizeof (OPENAXIOM_GLOBAL_ENV)
- + 1 /* room for '=' */
- + strlen(dir);
- char* env = (char*) malloc (env_length);
- strcpy(env, OPENAXIOM_GLOBAL_ENV);
- env[sizeof OPENAXIOM_GLOBAL_ENV - 1] = '=';
- strcpy(env + sizeof(OPENAXIOM_GLOBAL_ENV), dir);
- if (putenv(env) != 0) abort();
-#endif /* __WIN32__ */
}
diff --git a/src/include/cfuns.h b/src/include/cfuns.h
index 46f4cad5..4c84a6c0 100644
--- a/src/include/cfuns.h
+++ b/src/include/cfuns.h
@@ -55,6 +55,7 @@ OPENAXIOM_EXPORT int oa_rename(const char*, const char*);
OPENAXIOM_EXPORT int oa_mkdir(const char*);
OPENAXIOM_EXPORT int oa_system(const char*);
OPENAXIOM_EXPORT char* oa_getenv(const char*);
+OPENAXIOM_EXPORT int oa_setenv(const char*, const char*);
OPENAXIOM_EXPORT int oa_getpid(void);
OPENAXIOM_EXPORT char* oa_getcwd(void);
OPENAXIOM_EXPORT int oa_access_file_for_read(const char*);
diff --git a/src/lib/cfuns-c.c b/src/lib/cfuns-c.c
index 63758092..7562874a 100644
--- a/src/lib/cfuns-c.c
+++ b/src/lib/cfuns-c.c
@@ -552,6 +552,25 @@ oa_getenv(const char* var)
#endif
}
+/* Set the value of environment variable VAR to VAL.
+ Return 1 on success, and 0 otherwise. */
+OPENAXIOM_EXPORT int
+oa_setenv(const char* var, const char* val)
+{
+#ifdef __WIN32__
+ return SetEnvironmentVariable(var, val);
+#else
+ const int var_length = strlen(var);
+ const int val_length = strlen(val);
+ char* str = (char*) malloc(var_length + 1 + val_length + 1);
+ strcpy(str, var);
+ str[var_length] = '=';
+ strcpy(str + var_length + 1, val);
+ str[var_length + 1 + val_length] = '\0';
+ return !putenv(str);
+#endif
+}
+
OPENAXIOM_EXPORT char*
oa_getcwd(void)