ocaml-native-lib/Makefile

34 lines
853 B
Makefile

BUILD:=_build
OCAML_ROOT:=$(shell ocamlopt -where)
OCAMLOPT_FLAGS:=-output-complete-obj
.PHONY: ocaml
ocaml:
dune build --verbose ocaml/hello.exe.o
ar -rs $(BUILD)/libfoo.a _build/default/ocaml/hello.exe.o
ocaml-manual:
mkdir -p $(BUILD)
ocamlopt $(OCAMLOPT_FLAGS) ocaml/hello.ml -o $(BUILD)/hello_obj.o
ocamlopt $(OCAMLOPT_FLAGS) ocaml/bye.ml -o $(BUILD)/bye_obj.o
ar -rs $(BUILD)/libfoo.a $(BUILD)/hello_obj.o $(BUILD)/bye_obj.o
.PHONY: c
c:
gcc -c c/main.c -I$(OCAML_ROOT) -o $(BUILD)/main.o
gcc -o $(BUILD)/test.exe $(BUILD)/main.o -L$(OCAML_ROOT) -L$(BUILD) -lfoo -lm -ldl -lasmrun
cpp:
g++ -c c/main.cpp -I$(OCAML_ROOT) -o $(BUILD)/main.o
g++ -o $(BUILD)/test.exe $(BUILD)/main.o -L$(OCAML_ROOT) -L$(BUILD) -lfoo -lm -ldl -lasmrun
run:
$(BUILD)/test.exe
clean:
dune clean
rm -rf $(BUILD)
bootstrap:
opam install . --deps-only