Revision ad0c16675d221938530269610308cd5a2c142687 authored by Software Heritage on 17 October 2018, 13:20:37 UTC, committed by Software Heritage on 17 October 2018, 13:20:37 UTC
0 parent
Raw File
Makefile
# -*- makefile -*-
.PHONY: all clean debug doc .headers

OCAMLBUILD=ocamlbuild -use-ocamlfind
ODIR=`ocamlc -where`

# Menhir can be told to produce a parser that explains what
# it is doing.
MENHIROPT_COMMON=\
   -yaccflag --explain -yaccflag --inspection -yaccflag --table \
   -yaccflag --dump -tag debug

ifeq ($(DEBUGPARSING), yes)
  MENHIROPT=$(MENHIROPT_COMMON) -yaccflag --trace
else
  MENHIROPT=$(MENHIROPT_COMMON)
endif

OCAMLBUILDFLAGS_COMMON = $(MENHIROPT)

# In Emacs, use classic display to enable error jumping.
TERM = $(shell echo $$TERM)
ifeq ($(TERM), dumb)
 OCAMLBUILDFLAGS = $(OCAMLBUILDFLAGS_COMMON) -tag debug -classic-display
else
 OCAMLBUILDFLAGS = $(OCAMLBUILDFLAGS_COMMON)
endif

OCAMLBUILD = ocamlbuild -use-ocamlfind $(OCAMLBUILDFLAGS)

all:
	echo "(* This file is automatically generated. *)" > version.ml
	echo "let current=\"`cat ../VERSION`\"" >> version.ml
	if (which ocamlopt > /dev/null); then \
		echo "compilation to native code"; \
		$(OCAMLBUILD) morbigDriver.native \
			morbig.cma morbig.cmxa morbig.cmxs CAPI.native.o libmorbigcstub.a \
		&& cp `ocamlc -where`/libasmrun.a _build/libocaml.a; \
	else \
		echo "compilation to byte code" ;\
		$(OCAMLBUILD) morbigDriver.byte morbig.cma libmorbigcstub.a \
		&& cp `ocamlc -where`/libocamlrun.a _build/libocaml.a; \
	fi
	echo "create _build/libmorbigc.a"      > libmorbigc.mri
	echo "addlib _build/libocaml.a"       >> libmorbigc.mri
	echo "addlib $(ODIR)/libcamlstr.a"    >> libmorbigc.mri
	echo "addlib $(ODIR)/dynlink.a"       >> libmorbigc.mri
	echo "addlib _build/libmorbigcstub.a" >> libmorbigc.mri
	echo "addmod _build/CAPI.native.o"    >> libmorbigc.mri
	echo "save"                           >> libmorbigc.mri
	echo "end"                            >> libmorbigc.mri
	ar -M < libmorbigc.mri

debug:
	$(OCAMLBUILD) -tag debug morbigDriver.byte morbig.cma

clean:
	$(OCAMLBUILD) -clean
	rm -f libmorbigc.mri

doc:
	$(OCAMLBUILD) morbig.docdir/index.html

headers:
	headache -h .header *.ml *.mli *.mll *.mly
back to top