Skip to content

Commit

Permalink
Switch to dune.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodolphe Lepigre committed Mar 12, 2019
1 parent 535df10 commit 219e1b6
Show file tree
Hide file tree
Showing 60 changed files with 76 additions and 2,264 deletions.
5 changes: 3 additions & 2 deletions .gitignore
@@ -1,7 +1,8 @@
*~
#*
*.pmi
main.native
_build/
pml2/config.ml
pml.install
src/config.ml
*/*.merlin
local/
77 changes: 17 additions & 60 deletions GNUmakefile
Expand Up @@ -14,62 +14,26 @@ endif
EMACSDIR = $(PREFIX)/emacs/site-lisp
VIMDIR = $(HOME)/.vim

# Check for required binaries.
ifeq (, $(shell which ocamlbuild 2> /dev/null))
$(error "ocamlbuild is required... (try 'opam install ocamlbuild')")
endif
ifeq (, $(shell which ocamlfind 2> /dev/null))
$(error "ocamlfind is required... (try 'opam install ocamlfind')")
endif
ifeq (, $(shell which pa_ocaml 2> /dev/null))
$(error "pa_ocaml is required... (try 'opam install earley-ocaml')")
endif

# Check for required libraries.
ifeq (, $(shell ocamlfind query -format %p bindlib 2> /dev/null))
$(error "bindlib is required... (try 'opam install bindlib')")
endif
ifeq (, $(shell ocamlfind query -format %p earley 2> /dev/null))
$(error "earley is required... (try 'opam install earley earley-ocaml')")
endif

# Compilation commands and flags
OCAMLBUILD = ocamlbuild -use-ocamlfind -r -quiet
DOCFLAGS = -docflags -hide-warnings

# Version.
VERSION = devel

# Main target.
.PHONY: all
all: main.native lib check

# Documentation targets.
.PHONY: doc
doc: util_doc kernel_doc
all: bin

.PHONY: util_doc
util_doc: _build/util/util.docdir/index.html
_build/util/util.docdir/index.html: $(UTILFILES)
$(OCAMLBUILD) $(DOCFLAGS) util/util.docdir/index.html
.PHONY: bin
bin: src/config.ml
@dune build

.PHONY: kernel_doc
kernel_doc: _build/kernel/kernel.docdir/index.html
_build/kernel/kernel.docdir/index.html: $(KERNELFILES)
$(OCAMLBUILD) $(DOCFLAGS) kernel/kernel.docdir/index.html
# Documentation target.
.PHONY: doc
doc:
@dune build @doc

# Configuration file.
pml2/config.ml: GNUmakefile
src/config.ml: GNUmakefile
@echo "let path = [\"$(LIBDIR)/pml2\"]" > $@

ML_FILES = $(wildcard */*.ml) pml2/config.ml

# Compilation of PML2.
main.native: _build/pml2/main.native
_build/pml2/main.native: $(ML_FILES)
@rm -f main.native
$(OCAMLBUILD) pml2/main.native

# Checks on the source code.
check:
# FIXMES/TODOS
Expand All @@ -90,14 +54,14 @@ check:
# Lib target (PML handles the dependencies).
.PHONY: lib
LIB_FILES = $(wildcard lib/*.pml)
lib: main.native $(LIB_FILES)
@for f in $(LIB_FILES); do ./main.native --quiet $$f || break ; done
lib: bin $(LIB_FILES)
@for f in $(LIB_FILES); do dune exec -- pml --quiet $$f || break ; done

# Test target.
.PHONY: test
TEST_FILES = $(wildcard examples/*.pml test/*.pml test/*/*.pml)
test: main.native lib $(TEST_FILES)
@for f in $(TEST_FILES); do echo $$f; ./main.native --quiet $$f || break ; done
test: bin lib $(TEST_FILES)
@for f in $(TEST_FILES); do echo $$f; dune exec -- pml --quiet $$f || break ; done

# target to mesure time
.PHONY: time
Expand All @@ -107,7 +71,7 @@ time:

# Cleaning targets.
clean: libclean
@ocamlbuild -clean
@dune clean

libclean:
@find . -name \*.pmi -exec rm {} \;
Expand All @@ -120,7 +84,7 @@ distclean: clean
@find . -type f -name "*~" -exec rm {} \;
@find . -type f -name \#\* -exec rm {} \;
@find . -type f -name .\#\* -exec rm {} \;
@rm -f pml2/config.ml
@rm -f src/config.ml

# Install for the vim mode (in the user's directory).
.PHONY: install_vim
Expand Down Expand Up @@ -151,15 +115,8 @@ endif

# Install.
.PHONY: install
PML_FILES = $(wildcard lib/*.pml)
PMI_FILES = $(PML_FILES:.pml=.pmi)
install: main.native lib install_emacs install_vim
install -d $(BINDIR)
install -m 755 $< $(BINDIR)/pml2
@echo -e "\e[36m\"pml2\" binary installed.\e[39m"
install -d $(LIBDIR)/pml2/lib
install -p -m 644 $(PML_FILES) $(PMI_FILES) $(LIBDIR)/pml2/lib
@echo -e "\e[36mPML library installed.\e[39m"
install: bin
@dune install

# Release.
.PHONY: release
Expand Down
10 changes: 0 additions & 10 deletions _tags

This file was deleted.

4 changes: 4 additions & 0 deletions dune
@@ -0,0 +1,4 @@
; Add project-wide flags here.
(env
(dev (flags :standard -w -27-9-35-50-32-39))
(release (flags :standard -w -27-9-35-50-32-39)))
1 change: 1 addition & 0 deletions dune-project
@@ -0,0 +1 @@
(lang dune 1.2)

0 comments on commit 219e1b6

Please sign in to comment.