Skip to content

Commit

Permalink
Fixed: Menhir bundle
Browse files Browse the repository at this point in the history
Bundled menhir is now built by its official Makefile and is used to
compile the .mly file.

Bundled menhir has been updated to the last distributed version
(20160504).
  • Loading branch information
thierry-martinez committed May 25, 2016
1 parent 3523632 commit f465973
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 85 deletions.
93 changes: 12 additions & 81 deletions bundles/menhirLib/Makefile
Original file line number Diff line number Diff line change
@@ -1,47 +1,23 @@
# Bundles the original menhirLib package without modifications.
# This Makefile integrates its build process with coccinelle.

# the build process is conventional build of the ml files, with
# the exception that all modules are packed as a submodule of
# a master module "MenhirLib" instead of an archive file.

ifneq ($(MAKECMDGOALS),distclean)
include ../../Makefile.config
-include ../../Makefile.local
endif

OCAMLCFLAGS ?= -g
OPTFLAGS ?= -g

VERSION=20120123
VERSION=20160504
MENHIRDIR=menhir-$(VERSION)
MENHIRLIB=$(MENHIRDIR)/src
MENHIRMARKER=$(MENHIRLIB)/.marker

OCAMLC_CMD=$(OCAMLC) $(OCAMLCFLAGS) -I $(MENHIRLIB)
OCAMLOPT_CMD=$(OCAMLOPT) $(OPTFLAGS) -I $(MENHIRLIB)
OCAMLDEP_CMD=$(OCAMLDEP) -I $(MENHIRLIB)
MENHIRMARKER=$(MENHIRDIR)/.marker

all: .depend
@$(MAKE) all-build
all-build: .depend menhirLib.cma META

all.opt: .depend
@$(MAKE) all-opt-build
all-opt-build: .depend menhirLib.cmxa META
all all.opt: .prepare menhir

# prepares the source bundle for building.
.prepare: $(MENHIRMARKER)
touch .prepare

clean:
rm -f menhirLib.cma menhirLib.cmxa META \
$(MENHIRLIB)/*.cm[ioxa] \
$(MENHIRLIB)/*.o \
$(MENHIRLIB)/*.annot \
$(MENHIRLIB)/engineTypes.mli $(MENHIRLIB)/tableFormat.mli \
menhirLib.cm[ioxa] menhirLib.[oa] \
.depend
rm -rf menhir menhirLib.* share

distclean: clean
rm -rf $(MENHIRDIR)
Expand All @@ -55,60 +31,15 @@ $(MENHIRDIR).tar.gz:
@echo "$@ not found. Please download it and drop it in this directory ($(pwd))."
@false

.PHONY: all all.opt all-build all-opt-build clean distclean depend depend-build

# Sources needed for coccinelle
MODULES=infiniteArray packedIntArray rowDisplacement engineTypes \
engine tableFormat tableInterpreter convert

MLI=$(MODULES:%=$(MENHIRLIB)/%.mli)
SRC=$(MODULES:%=$(MENHIRLIB)/%.ml)

# Link
menhirLib.cma: .depend $(MLI:.mli=.cmi) $(SRC:.ml=.cmo)
$(OCAMLC_CMD) -pack -o menhirLib.cmo $(SRC:.ml=.cmo)
$(OCAMLC_CMD) -a -o menhirLib.cma menhirLib.cmo

menhirLib.cmxa: .depend $(MLI:.mli=.cmi) $(SRC:.ml=.cmx)
$(OCAMLOPT) -pack -o menhirLib.cmx $(SRC:.ml=.cmx)
$(OCAMLOPT) -a -o menhirLib.cmxa menhirLib.cmx

# Generic rules
.SUFFIXES: .ml .mli .cmo .cmi .cmx
.PRECIOUS: $(MLI)

.ml.mli:
$(OCAMLC_CMD) -for-pack MenhirLib -i $< > $@
.PHONY: all all.opt clean distclean depend

.mli.cmi:
$(OCAMLC_CMD) -for-pack MenhirLib -c $<
depend: $(MENHIRMARKER) menhir

.ml.cmo:
$(OCAMLC_CMD) -for-pack MenhirLib -c $<

.ml.cmx:
$(OCAMLOPT_CMD) -for-pack MenhirLib -c $<

META: $(MENHIRLIB)/META
cp $< $@

# the 'depend' target
.depend depend: $(MENHIRMARKER)
@$(MAKE) depend-build

depend-build: $(MENHIRMARKER) $(SRC) $(MLI)
$(OCAMLDEP_CMD) $(MENHIRLIB)/*.mli $(MENHIRLIB)/*.ml > .depend

# extra dependencies that are needed to generate mli files
# that are needed for ocamldep
$(MENHIRLIB)/tableFormat.mli: $(MENHIRLIB)/packedIntArray.cmi $(MENHIRLIB)/engineTypes.cmi

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),distclean)
ifneq ($(MAKECMDGOALS),depend-build)
-include .depend
endif
endif
endif
menhir:
make -C $(MENHIRDIR) PREFIX=$(CURDIR) all
cp $(MENHIRDIR)/src/_stage2/menhir.native menhir
cp $(MENHIRDIR)/src/_stage2/menhirLib.* .
mkdir -p share/menhir/
cp $(MENHIRDIR)/src/standard.mly share/menhir/

include ../../Makefile.common
Binary file added bundles/menhirLib/menhir-20160504.tar.gz
Binary file not shown.
7 changes: 3 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,13 @@ AS_IF([test "x$OCAML_PKG_dynlink" != xno -a -f "$PATH_dynlink/dynlink.cmxa"],
dnl menhir handling
dnl variables:
dnl with_menhir: whether or not menhir must be used
AC_COCCI_TOOL([MENHIR],[menhir],[$COCCI_SRCDIR/setup/fake-menhir.sh menhir])
AC_COCCI_TOOL([MENHIR],[menhir],[$COCCI_SRCDIR/bundles/menhirLib/menhir])
AS_IF([test "x$SUBSTITUTED_MENHIR" = xyes],
[dnl
AC_MSG_NOTICE([pregenerated parsers will be required as substitute for Menhir])
AC_SUBST([MAKE_menhirLib], [$COCCI_SRCDIR/bundles/menhirLib/])
],
[dnl
rm -f parsing_cocci/parser_cocci_menhir.ml parsing_cocci/parser_cocci_menhir.mli
AC_MSG_NOTICE([Deleted pre-generated parsers, will be re-built])
AC_MSG_NOTICE([system menhir will be used])
])


Expand Down

0 comments on commit f465973

Please sign in to comment.