Permalink
Fetching contributors…
Cannot retrieve contributors at this time
72 lines (52 sloc) 1.6 KB
# -*- makefile -*-
GENERATED = src/indentVersion.ml src/compat.ml
NAME = 'ocp-indent'
VERSION != awk -F'[(,)]' '/AC_INIT/ { print $$3 }' configure.ac
BEST != if ocamlopt 2>/dev/null; then echo native; else echo byte; fi
OCAML_MAJOR != ocaml -vnum | sed 's/\..*//'
COMPAT_DIR = src/ocaml_$(OCAML_MAJOR)/
OCAMLBUILD = ocamlbuild -I src -use-ocamlfind
LIB = ocp-indent-lib
PKGS = cmdliner,findlib,dynlink
BINS = ocp-indent.byte
LIBS = $(LIB).cma
ifeq ($(BEST),native)
LIBS += $(LIB).cmxa $(LIB).a $(LIB).cmxs
BINS += ocp-indent.native
endif
.PHONY: all
all: $(LIBS) $(BINS) ocp-indent.1
.PHONY: man
man: ocp-indent.1
ocp-indent.1: ocp-indent.$(BEST)
./ocp-indent.$(BEST) --help=groff >$@
ocp-indent.byte:
$(OCAMLBUILD) indentMain.byte -pkgs $(PKGS)
ln -f _build/src/indentMain.byte $@
ocp-indent.native:
$(OCAMLBUILD) indentMain.native -pkgs $(PKGS)
ln -f _build/src/indentMain.native $@
src/compat.ml:
cp $(COMPAT_DIR)/compat.ml src/
src/indentVersion.ml:
echo 'let version = "'$(VERSION)'"' > $@
src/approx_common.ml: src/approx_common.mli
cp $< $@
$(LIB).cma $(LIB).cmxa $(LIB).a $(LIB).cmxs: $(GENERATED)
$(OCAMLBUILD) -use-ocamlfind $@
.PHONY: clean
clean:
rm -rf $(GENERATED) META _build
rm -rf $(BINS) ocp-indent.1
META:
mkdir -p _build/src
echo 'name = "'$(NAME)'"' >$@
echo 'version = "'$(VERSION)'"' >> $@
echo 'archive(byte) = "'$(LIB)'.cma"' >> $@
echo 'archive(native) = "'$(LIB)'.cmxa"' >> $@
.PHONY: install
install: META $(LIBS) $(BINS)
ocamlfind remove $(NAME) || true
ocamlfind install $(NAME) \
$(LIBS:%=_build/src/%) $(BINS) META \
_build/src/*.{mli,cmi,cmt,cmti,annot}