]> git.mdlowis.com Git - archive/tide-ocaml.git/commitdiff
reworked makefile to support native or bytecode executable
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 22 Aug 2017 15:24:33 +0000 (11:24 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 22 Aug 2017 15:24:33 +0000 (11:24 -0400)
Makefile
env.ml
envprims.c
tide [deleted file]
tide.ml

index 750fca84da61d576edec6a56e6b0d3ea936e27a3..5d3082a8a99b7f96a54db71fbac9cee90e79de58 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,25 +1,43 @@
-OC = ocamlopt
-OCMKLIB = ocamlmklib
-
+# Toolchain Configuration
+#-------------------------------------------------------------------------------
+ifeq ($(NATIVE), 1)
+    OC         = ocamlopt
+    OCFLAGS    =
+    MKLIB      = ocamlmklib
+    MKLIBFLAGS = -custom
+    OBJEXT     = cmx
+    LIBEXT     = cmxa
+else
+    OC         = ocamlc
+    OCFLAGS    =
+    MKLIB      = ocamlmklib
+    MKLIBFLAGS = -custom
+    OBJEXT     = cmo
+    LIBEXT     = cma
+endif
+
+# Target Definitions
+#-------------------------------------------------------------------------------
 .PHONY: all clean
 
-env.cmxa: env.cmx envprims.o
-tide: env.cmxa tide.cmx
-
 all: tide
 
 clean:
-       $(RM) *.cm* *.o *.a
+       $(RM) tide *.cm* *.o *.a
+
+env.$(LIBEXT): env.$(OBJEXT) envprims.o
+tide: env.$(LIBEXT) tide.$(OBJEXT)
 
+# Implicit Rule Definitions
+#-------------------------------------------------------------------------------
 %:
-       $(OC) -o $@ $^ -I .
+       $(OC) $(OCFLAGS) -o $@ $^ -I .
 
-%.cmxa:
-       $(OCMKLIB) -custom -o $* $^
+%.$(LIBEXT):
+       $(MKLIB) $(MKLIBFLAGS) $(OCFLAGS) -o $* $^
 
-%.cmx: %.ml
-       $(OC) -c -o $@ $^
+%.$(OBJEXT): %.ml
+       $(OC) $(OCFLAGS) -c -o $@ $^
 
 %.o: %.c
        $(OC) $(OCFLAGS) -c -o $@ $^
-
diff --git a/env.ml b/env.ml
index 0dd6c1781dc576fe936b99d9f8237e2f069a4b2d..3e7cb788e7044bcbd04a639e0950a6a04fb48c67 100644 (file)
--- a/env.ml
+++ b/env.ml
@@ -1,4 +1,4 @@
 (* Environment variable management routines *)
-external set : string -> string -> int = "caml_env_set"
-external get : string -> string = "caml_env_get"
-external unset : string -> int = "caml_env_unset"
+external set : string -> string -> int = "env_set"
+external get : string -> string = "env_get"
+external unset : string -> int = "env_unset"
index 882c1946293980cfd5eac653015a946f6633b930..f37e47b941920b256ddee5ce8c0fc476c6947720 100644 (file)
@@ -5,19 +5,19 @@
 #include <caml/custom.h>
 #include <stdlib.h>
 
-CAMLprim value caml_env_set(value var, value val) {
+CAMLprim value env_set(value var, value val) {
     CAMLparam2(var, val);
     puts("foo");
     CAMLreturn(Val_int(0));
 }
 
-CAMLprim value caml_env_get(value var) {
+CAMLprim value env_get(value var) {
     CAMLparam1(var);
     puts("bar");
     CAMLreturn(caml_copy_string(""));
 }
 
-CAMLprim value caml_env_unset(value var) {
+CAMLprim value env_unset(value var) {
     CAMLparam1(var);
     puts("baz");
     CAMLreturn(Val_int(0));
diff --git a/tide b/tide
deleted file mode 100755 (executable)
index 0b32a2d..0000000
Binary files a/tide and /dev/null differ
diff --git a/tide.ml b/tide.ml
index f2fe74081a142fbc8cc0d1d2cf2e4165dcd52d38..e6b98c478634b4e859ae8d13c4c7b3b0eba14672 100644 (file)
--- a/tide.ml
+++ b/tide.ml
@@ -1,4 +1,5 @@
 open Env
+open Printf
 
 let () =
   let foo = Env.set "foo" "bar" in