diff options
| author | Stephen Kell | 2014-10-04 17:18:48 +0100 |
|---|---|---|
| committer | Stephen Kell | 2014-10-04 17:18:48 +0100 |
| commit | f2b2b02654caf2e11ccef6cb459ecd27611c23a4 (patch) | |
| tree | 0f198b7f47f6a14131dd0f44b392ed178ef74d5c | |
| parent | 87d5696867883fb6e16d1106c12a17baf0eebc94 (diff) | |
Add alternative non-opam Makefile in src/.
| -rw-r--r-- | src/Makefile-non-opam | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/src/Makefile-non-opam b/src/Makefile-non-opam new file mode 100644 index 00000000..6c23c732 --- /dev/null +++ b/src/Makefile-non-opam @@ -0,0 +1,153 @@ +THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST)) +srcdir := $(realpath $(dir $(THIS_MAKEFILE))) + +BITSTRING ?= $(srcdir)/contrib/bitstring +BATTERIES ?= $(srcdir)/contrib/batteries-included/_build/src +UINT ?= $(srcdir)/contrib/ocaml-uint/_build/lib + +LEM ?= ~/bitbucket/lem/lem +LEMLIB ?= ~/bitbucket/lem/ocaml-lib/_build/ +OCAMLFLAGS += -I $(LEMLIB)/../ocaml-lib/_build # FIXME + +.PHONY: all sail test clean doc lib power test_power test_idempotence contrib install_elf +all: sail lib doc +full: all power test test +sail: sail.native sail_lib.cma sail_lib.cmxa +interpreter: _build/lem_interp/extract.cmxa _build/lem_interp/extract.cma +sail.native sail_lib.cma sail_lib.cmxa: + ocamlbuild sail.native sail_lib.cma sail_lib.cmxa +_build/lem_interp/extract.cmxa: + ocamlbuild lem_interp/extract.cmxa +_build/lem_interp/extract.cma: + ocamlbuild lem_interp/extract.cma +test: sail interpreter + ocamlbuild test/run_tests.native + ./run_tests.native +contrib: + cd contrib && ./checkout.sh +install_elf: + cp -p ../../system-v-abi/src/*.lem elf_model/ + cp -p ../../system-v-abi/src/*.ml elf_model/ + +%.ml: %.lem + $(LEM) -outdir $$(dirname "$<") -ocaml -only_changed_output "$<" +# HACK: special case for bitstring_local +elf_model/bitstring_local.ml: elf_model/bitstring.lem + $(LEM) -outdir $$(dirname "$<") -ocaml -only_changed_output "$<" +# HACK: why doesn't ocamldep know this one? +elf_model/show.cmx: elf_model/missing_pervasives.cmx + +ELF_LEM_SRC := $(addprefix elf_model/,missing_pervasives.lem show.lem endianness.lem bitstring.lem elf_types.lem elf_interpreted_segment.lem elf_header.lem elf_file1.lem elf_program_header_table.lem elf_executable_file2.lem elf_section_header_table.lem elf_executable_file3.lem string_table.lem elf_executable_file4.lem elf_executable_file5.lem sail_interface.lem main.lem) +vpath _build/%.lem . +vpath _build/%.cmx . + +CAMLP4FLAGS += -I $(srcdir)/contrib/bitstring/ +CAMLP4FLAGS += -I $(srcdir)/contrib/bitstring/_ +CAMLP4FLAGS += bitstring.cma +CAMLP4FLAGS += bitstring_persistent.cma +CAMLP4FLAGS += pa_bitstring.cmo + +# HACK: rewrite for bitstring_local +ELF_ML_LEM := $(filter-out elf_model/bitstring.ml,$(patsubst %.lem,%.ml,$(ELF_LEM_SRC))) elf_model/bitstring_local.ml +ELF_ML_SRC := $(addprefix elf_model/,error.ml ml_bindings.ml) +ELF_ML := $(ELF_ML_SRC) $(ELF_ML_LEM) +ELF_ML_DEPS := $(patsubst %.ml,%.d,$(ELF_ML)) +ELF_CMX := $(patsubst %.ml,%.cmx,$(ELF_ML)) + +$(ELF_CMX): OCAMLFLAGS += \ +-I $(BITSTRING) -pp 'camlp4o $(CAMLP4FLAGS)' \ +-I $(BATTERIES) \ +-I $(UINT) \ +-I elf_model + +$(ELF_ML_DEPS): OCAMLFLAGS += \ +-I $(BITSTRING) -pp 'camlp4o $(CAMLP4FLAGS)' \ +-I $(BATTERIES) \ +-I $(UINT) \ +-I $(srcdir)/elf_model + +$(ELF_ML_DEPS): %.d: %.ml + ocamlfind ocamldep -native $(OCAMLFLAGS) "$<" > "$@" || (rm -f "$@"; false) + +ifneq ($(MAKECMDGOALS),clean) +-include $(ELF_ML_DEPS) +endif + +elf_extract.cmxa: OCAMLFLAGS += \ +-I $(BITSTRING) -package bitstring,bitstring.syntax -syntax bitstring \ +-I $(BATTERIES) -package batteries \ +-I $(UINT) -package bitstring \ +-pp 'camlp4 $(CAMLP4FLAGS)' \ +-I $(LEMLIB)/../ocaml-lib/_build + +LEM_CMX := $(addprefix $(LEMLIB)/../ocaml-lib/,nat_num.cmx lem.cmx lem_function.cmx lem_list.cmx) + +%.cmx: %.ml + ocamlfind ocamlopt $(OCAMLFLAGS) -c "$<" + +elf_model/elf_extract.cmxa: $(ELF_CMX) + ocamlfind ocamlopt $(OCAMLFLAGS) -a -o "$@" $+ + +elf: $(ELF_CMX) $(LEM_CMX) elf_model/elf_extract.cmxa + +_build/test/power.lem: sail.native test/power.sail + mkdir -p _build/test + cp -p test/* _build/test/ + cd _build/test && \ + ../../sail.native -lem_ast power.sail + +pprint/src/_build/PPrintLib.cmxa: + $(MAKE) -C $(srcdir)/pprint/src + +_build/test/run_power.native: OCAMLFLAGS += \ +-I $(LEMLIB) \ +-I $(srcdir)/_build/lem_interp/ \ +-I $(srcdir)/elf_model/ \ +-I $(UINT) + +_build/test/run_power.native: OCAMLLIBS += \ +$(LEMLIB)/extract.cmxa + +_build/test/power.ml: _build/test/power.lem + cd _build/test && $(LEM) -ocaml -only_changed_output -lib $(srcdir)/lem_interp/ power.lem + touch "$@" # HACK HACK HACK! why didn't lem update the timestamp? + +_build/test/run_power.native: pprint/src/_build/PPrintLib.cmxa _build/lem_interp/extract.cmxa elf_model/elf_extract.cmxa _build/test/power.ml test/run_power.ml + cd _build/test && \ + ocamlopt $(OCAMLFLAGS) $(OCAMLLIBS) $(addprefix $(srcdir)/,$+) -o run_power.native + +power: run_power.native + +run_power.native: _build/test/run_power.native + ln -fs _build/test/run_power.native run_power.native + +test_power: power + ./run_power.native --file ../../../rsem/idl/power/binary/main.bin + +test_power_interactive: power + ./run_power.native --interactive --file ../../../rsem/idl/power/binary/main.bin + +test_power_interactive_srcs: + ebig ~/rsem/idl/power/generated/power.sail ../../../rsem/idl/power/binary/hello.c ../../../rsem/idl/power/binary/hello.s + +# or test/power.sail for cut-down one + +test_idempotence: sail + @cd test; for file in *.sail; do \ + ./idempotence.sh $$file; echo ;\ + done + +clean: + #-ocamlbuild -clean + -rm -rf _build *.native + -rm -rf $(srcdir)/elf_model/*.o $(srcdir)/elf_model/*.cmx $(srcdir)/elf_model/*.cmi $(ELF_ML_LEM) $(ELF_ML_DEPS) + -rm -rf html-doc + -rm -rf tex-doc + -rm -rf lem lib + -rm -rf sail.docdir + +doc: + ocamlbuild sail.docdir/index.html + +lib: + ocamlbuild pretty_print.cmxa pretty_print.cma |
