Commit 7244cb30 authored by fpottier's avatar fpottier

More Makefile adjustments.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/menhir@333 0f8b5475-4b4e-0410-85a8-ee3154a6bfe7
parent 255324a1
......@@ -6,21 +6,14 @@
SHELL := bash
.PHONY: test bootstrap all package check export godi clean
.PHONY: all test clean package check export godi
# -------------------------------------------------------------------------
# Compiling.
# A dummy entry.
all:
$(MAKE) $(MFLAGS) -C src -f GNUmakefile
# -------------------------------------------------------------------------
# Bootstraping.
bootstrap:
$(MAKE) $(MFLAGS) -C src -f GNUmakefile bootstrap
@echo Please go down into src/ if you wish to compile Menhir.
# -------------------------------------------------------------------------
......@@ -35,9 +28,9 @@ test:
clean:
@ for i in bench demos src ; do \
$(MAKE) $(MFLAGS) -C $$i $@ ; \
$(MAKE) -C $$i $@ ; \
done
$(MAKE) $(MFLAGS) -rs -C doc $@
$(MAKE) -rs -C doc $@
# -------------------------------------------------------------------------
......@@ -73,7 +66,7 @@ GODIVA := $(GODI_HOME)/bin/godiva
# This does not include the src/ and doc/ directories, which require
# special treatment.
DISTRIBUTED_FILES := AUTHORS CHANGES INSTALLATION LICENSE Makefile Makefile.arch demos
DISTRIBUTED_FILES := AUTHORS CHANGES INSTALLATION LICENSE Makefile demos
# Some source files carry the "library" license, while others carry
# the regular "source code" license.
......@@ -94,7 +87,7 @@ package: clean
@ rm -fr $(PACKAGE)
@ mkdir -p $(PACKAGE)/src
@ cp -fr $(DISTRIBUTED_FILES) $(PACKAGE)
@ cp -fr src/*.ml{,i,y,l} src/Makefile src/META $(PACKAGE)/src
@ cp -fr src/*.ml{,i,y,l,pack} src/Makefile src/_tags src/META $(PACKAGE)/src
@ $(MAKE) -C $(PACKAGE)/demos clean
# Insert headers.
@ echo "-> Inserting headers."
......@@ -112,7 +105,7 @@ package: clean
@ echo "-> Generating the documentation."
@ cp -r doc $(PACKAGE)
@ echo '\gdef\menhirversion{$(DATE)}' > $(PACKAGE)/doc/version.tex
@ make -rs -C $(PACKAGE)/doc clean pdf
@ make -C $(PACKAGE)/doc clean all
@ mv $(PACKAGE)/doc/main.pdf $(PACKAGE)/manual.pdf
@ mv $(PACKAGE)/doc/menhir.1 $(PACKAGE)/
@ rm -rf $(PACKAGE)/doc
......
......@@ -12,6 +12,18 @@
# ----------------------------------------------------------------------------
# The following variables must/can be configured.
ifndef PREFIX
$(error Please define PREFIX)
endif
ifndef TARGET
TARGET := native
endif
# ----------------------------------------------------------------------------
# By default, we attempt to use ocamlfind (if present in the PATH), but it it
# is possible to prevent that externally by setting USE_OCAMLFIND to false.
......@@ -23,17 +35,19 @@ endif
# A few settings differ on Windows versus Unix.
include Makefile.arch
ifeq "$(shell ocamlc -config | grep ccomp_type)" "ccomp_type: msvc"
MENHIREXE := menhir.exe
OBJ := obj
# LIBSUFFIX := lib
else
MENHIREXE := menhir
OBJ := o
# LIBSUFFIX := a
endif
# ----------------------------------------------------------------------------
# Installation paths.
# TEMPORARY GODIVA and Linux do not agree on the standard paths...
ifndef PREFIX
$(error Please define PREFIX)
endif
bindir := ${PREFIX}/bin
docdir := ${PREFIX}/share/doc/menhir
libdir := ${PREFIX}/share/menhir
......@@ -68,27 +82,29 @@ all:
else \
echo "let ocamlfind = false" >> src/installation.ml ; \
fi
$(MAKE) $(MFLAGS) -C src -f Makefile
$(MAKE) $(MFLAGS) -C src -f Makefile $(MENHIRLIB)
$(MAKE) -C src library bootstrap
# ----------------------------------------------------------------------------
# Installation.
# The directory where things have been built (by make all, above).
BUILDDIR := src/_stage2
install: all
mkdir -p $(bindir)
mkdir -p $(libdir)
mkdir -p $(docdir)
mkdir -p $(mandir)
install src/$(MENHIREXE) $(bindir)
install $(BUILDDIR)/menhir.native $(bindir)/$(MENHIREXE)
install -m 644 $(MLYLIB) $(libdir)
cp -r $(DOCS) $(docdir)
cp -r $(MANS) $(mandir)
@cd src && if $(USE_OCAMLFIND) ; then \
@if $(USE_OCAMLFIND) ; then \
echo Installing MenhirLib via ocamlfind. ; \
ocamlfind install menhirLib META $(MENHIRLIB) ; \
ocamlfind install menhirLib src/META $(patsubst %,$(BUILDDIR)/%,$(MENHIRLIB)) ; \
else \
echo Installing MenhirLib manually. ; \
install -m 644 $(MENHIRLIB) $(libdir) ; \
install -m 644 $(patsubst %,$(BUILDDIR)/%,$(MENHIRLIB)) $(libdir) ; \
fi
uninstall:
......
# If ocaml reports that Sys.os_type is Unix, we assume Unix, otherwise
# we assume Windows.
ifeq "$(shell rm -f ./o.ml && echo print_endline Sys.os_type > ./o.ml && ocaml ./o.ml && rm -f ./o.ml)" "Unix"
MENHIREXE := menhir
OBJ := o
else
MENHIREXE := menhir.exe
OBJ := obj
endif
# This is a development Makefile, which is not shipped.
# Prevent an immediate attempt to build .depend when "make bootstrap"
# is run.
COLD += bootstrap api
# Option 1: incremental development. This assumes that a ./menhir
# executable already exists. (If that is not the case, bootstrap
# first.) To use it, we set a few variables, include the user
# Makefile, and build menhir.{byte,opt}.
all: menhir.byte menhir.opt
PARSER := fancy-parser
MENHIR := ./menhir
PGEN = $(shell ([ -f $(MENHIR) ] && echo $(MENHIR) $(PGFLAGS)) \
|| $(error "$(MENHIR) not found. \
Please bootstrap first (make bootstrap)."))
.PHONY: api clean
-include Makefile
OFLAGS += -dtypes
# Option 2: bootstrapping. This must be used when the src/ directory
# is clean. After creating installation.ml, we just run the normal
# bootstrapping process, as described by the user Makefile.
.PHONY: bootstrap
bootstrap: installation.ml
$(MAKE) -f Makefile
# ----------------------------------------------------------------------------
# When developing, the standard library path is the current directory.
# ocamlfind is not assumed.
......@@ -38,6 +12,7 @@ installation.ml:
echo "let libdir = \""`pwd`"/\"" > $@
echo "let ocamlfind = false" >> $@
# ----------------------------------------------------------------------------
# Pretty-printing the MenhirLib.Convert API.
api: convert.mli.html
......@@ -46,5 +21,5 @@ api: convert.mli.html
caml2html -nf $<
clean::
rm -f *.{ml,mli}.html
rm -f *.mli.html
......@@ -26,7 +26,7 @@ OCAMLBUILD := ocamlbuild -classic-display -use-ocamlfind -j 0
# Typing "make" will perform just stage 1. This is enough to ensure that
# the source code is correct.
everyday: stage1
everyday: installation.ml stage1
# ----------------------------------------------------------------------------
# Building MenhirLib.
......@@ -85,5 +85,5 @@ stage3:
# ----------------------------------------------------------------------------
# Cleaning up.
clean:
clean::
rm -rf .versioncheck _build _stage1 _stage2 _stage3
#!/bin/bash
make
make library
mkdir -p lib
ln -sf `pwd`/menhirLib.{cmi,cmo,cmx,o} lib
ln -sf `pwd`/_build/menhirLib.{cmi,cmo,cmx,o} lib
cd ../demos/calc
make clean
make MENHIR=../../src/menhir PGFLAGS="--infer -v --table -lc 1 --comment" INCLUDE="-I ../../src/lib" OLNKFLAGS="menhirLib.cmx" && \
make MENHIR=../../src/_stage1/menhir.native PGFLAGS="--infer -v --table -lc 1 --comment" INCLUDE="-I ../../src/lib" OLNKFLAGS="menhirLib.cmx" && \
echo Compilation successful, running ./calc: && \
./calc
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