Commit f7192bc0 authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Modified the main Makefile to allow all three targets (all, install,

uninstall) to work regardless of whether we are in a distributed package or in
the repository.
parent 1bd65ffa
# This is the main Makefile that is shipped as part of the source package.
# Keep in mind that the hierarchy that is shipped is not identical to the
# hierarchy within the svn repository: some sub-directories are not shipped;
# the documentation is pre-built.
# hierarchy within the git repository. Some sub-directories are not shipped.
# The documentation (manual.pdf, menhir.1) is pre-built and stored at the root.
# This Makefile can also be used directly in the repository. In that case,
# the documentation and demos are not installed.
# The hierarchy that is shipped includes:
# demos
......@@ -82,18 +86,28 @@ else
installation_libdir := $(libdir)
endif
# -------------------------------------------------------------------------
# The names of the modules in MenhirLib are obtained by reading the
# non-comment lines in menhirLib.mlpack.
MENHIRLIB_MODULES := $(shell grep -ve "^[ \t\n\r]*\#" src/menhirLib.mlpack)
# ----------------------------------------------------------------------------
# Compilation.
# The directory where things are built.
BUILDDIR := src/_stage2
# Installation time settings are recorded within src/installation.ml.
# This file is recreated every time so as to avoid becoming stale.
# ----------------------------------------------------------------------------
# Compilation.
.PHONY: all install uninstall
all:
# Installation time settings are recorded within src/installation.ml.
# This file is recreated every time so as to avoid becoming stale.
@ rm -f src/installation.ml
@ echo "let libdir = \"$(installation_libdir)\"" > src/installation.ml
@ if $(USE_OCAMLFIND) ; then \
......@@ -101,45 +115,34 @@ all:
else \
echo "let ocamlfind = false" >> src/installation.ml ; \
fi
# Compile the library modules and the Menhir executable.
@ $(MAKE) -C src library bootstrap
@ $(MAKE) $(BUILDDIR)/menhirLib.ml $(BUILDDIR)/menhirLib.mli
# -------------------------------------------------------------------------
# The names of the modules in MenhirLib are obtained by reading the
# non-comment lines in menhirLib.mlpack.
MENHIRLIB_MODULES := $(shell grep -ve "^[ \t\n\r]*\#" src/menhirLib.mlpack)
# The source file menhirLib.ml is created by concatenating all of the source
# files that make up MenhirLib. This file is not needed to compile Menhir or
# MenhirLib. It is installed at the same time as MenhirLib and is copied by
# Menhir when the user requests a self-contained parser (one that is not
# dependent on MenhirLib).
$(BUILDDIR)/menhirLib.ml:
@ rm -f $@
@ echo "Creating menhirLib.ml"
@ rm -f $(BUILDDIR)/menhirLib.ml
@ for m in $(MENHIRLIB_MODULES) ; do \
echo "module $$m = struct" >> $@ ; \
cat src/$$m.ml >> $@ ; \
echo "end" >> $@ ; \
echo "module $$m = struct" >> $(BUILDDIR)/menhirLib.ml ; \
cat src/$$m.ml >> $(BUILDDIR)/menhirLib.ml ; \
echo "end" >> $(BUILDDIR)/menhirLib.ml ; \
done
# The source file menhirLib.mli is created in the same way. If a module
# does not have an .mli file, then we assume that its .ml file contains
# type (and module type) definitions only, so we copy it instead of the
# (non-existent) .mli file.
$(BUILDDIR)/menhirLib.mli:
@ rm -f $@
@ echo "Creating menhirLib.mli"
@ rm -f $(BUILDDIR)/menhirLib.mli
@ for m in $(MENHIRLIB_MODULES) ; do \
echo "module $$m : sig" >> $@ ; \
echo "module $$m : sig" >> $(BUILDDIR)/menhirLib.mli ; \
if [ -f src/$$m.mli ] ; then \
cat src/$$m.mli >> $@ ; \
cat src/$$m.mli >> $(BUILDDIR)/menhirLib.mli ; \
else \
cat src/$$m.ml >> $@ ; \
cat src/$$m.ml >> $(BUILDDIR)/menhirLib.mli ; \
fi ; \
echo "end" >> $@ ; \
echo "end" >> $(BUILDDIR)/menhirLib.mli ; \
done
# -------------------------------------------------------------------------
......@@ -155,14 +158,12 @@ endif
# Installation.
install:
# Install the executable.
mkdir -p $(bindir)
mkdir -p $(libdir)
mkdir -p $(docdir)
mkdir -p $(mandir)
install $(BUILDDIR)/menhir.$(TARGET) $(bindir)/$(MENHIREXE)
# Install the library.
mkdir -p $(libdir)
install -m 644 $(MLYLIB) $(libdir)
cp -r $(DOCS) $(docdir)
cp -r $(MANS) $(mandir)
@if $(USE_OCAMLFIND) ; then \
echo Installing MenhirLib via ocamlfind. ; \
ocamlfind install menhirLib src/META $(patsubst %,$(BUILDDIR)/%,$(MENHIRLIB)) ; \
......@@ -170,13 +171,20 @@ install:
echo Installing MenhirLib manually. ; \
install -m 644 $(patsubst %,$(BUILDDIR)/%,$(MENHIRLIB)) $(libdir) ; \
fi
# Install the documentation, if it has been built.
if [ -f manual.pdf ] ; then \
mkdir -p $(docdir) ; \
mkdir -p $(mandir) ; \
cp -r $(DOCS) $(docdir) ; \
cp -r $(MANS) $(mandir) ; \
fi
uninstall:
rm -rf $(bindir)/$(MENHIREXE)
rm -rf $(libdir)
rm -rf $(docdir)
rm -rf $(mandir)/$(MANS)
@if $(USE_OCAMLFIND) ; then \
echo Un-installing MenhirLib via ocamlfind. ; \
ocamlfind remove menhirLib ; \
fi
rm -rf $(docdir)
rm -rf $(mandir)/$(MANS)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment