From: Michael D. Lowis Date: Tue, 22 Aug 2017 15:24:33 +0000 (-0400) Subject: reworked makefile to support native or bytecode executable X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=38b26f23410c5a61402e9d5811ff34afab1b8731;p=archive%2Ftide-ocaml.git reworked makefile to support native or bytecode executable --- diff --git a/Makefile b/Makefile index 750fca8..5d3082a 100644 --- 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 0dd6c17..3e7cb78 100644 --- 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" diff --git a/envprims.c b/envprims.c index 882c194..f37e47b 100644 --- a/envprims.c +++ b/envprims.c @@ -5,19 +5,19 @@ #include #include -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 index 0b32a2d..0000000 Binary files a/tide and /dev/null differ diff --git a/tide.ml b/tide.ml index f2fe740..e6b98c4 100644 --- a/tide.ml +++ b/tide.ml @@ -1,4 +1,5 @@ open Env +open Printf let () = let foo = Env.set "foo" "bar" in