Skip to content

Commit

Permalink
Fixed: Bundles and some local patchs for OCaml from 3.12.0 to 4.03.0
Browse files Browse the repository at this point in the history
- Menhir has been downgraded to 20140422: Menhir 20160504 makes use of
  constructs introduced in 4.02.0 like "match exception"
- Menhir, PCRE and parmap bundles have new Makefiles that allow us to
  compile them without ocamlbuild
- pycaml has a new Makefile that allows us to compile it without
  camlp4: we use the C preprocessor to handle #ifdef
- a subsidiary version of the Bytes module is provided to the PCRE
  bundle for OCaml prior to 4.02.0
- spatch --version no longer prints if the build is native or
  bytecode: the message relied on Dynlink.is_native that is not
  available if there is no dynlink
- unparse_c.ml makes use of String.map introduced in 4.00.0: an
  subsidiary implementation is provided if the builtin String.map
  is not available
- spgen/Makefile supposed that there is a valid dynlink path: it has
  been rewritten so that it does not try to link with dynlink if the
  latter is not available
  • Loading branch information
thierry-martinez committed May 27, 2016
1 parent 0c40930 commit 0e0cea3
Show file tree
Hide file tree
Showing 13 changed files with 1,825 additions and 215 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ distclean::
depend: Makefile.config version
@$(ECHO) "Constructing '.depend'"
@rm -f .depend
@set -e; for i in $(MAKELIBS) $(MAKESUBDIRS); do $(MAKE) -C $$i depend; done
set -e; for i in $(MAKELIBS) $(MAKESUBDIRS); do echo $$i; $(MAKE) -C $$i depend; done
$(OCAMLDEP_CMD) $(MLI_FILES) $(ML_FILES) > .depend

##############################################################################
Expand Down
115 changes: 115 additions & 0 deletions bundles/Makefile.bundles
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
MARKER=$(PACKAGE_DIR)/.marker

OCAMLFLAGS+=-I $(SRC_DIR)
OCAMLC_CMD= \
$(OCAMLC) $(OCAMLFLAGS) \
$(patsubst %,-custom -cclib -l%_stubs,$(LIBRARY)) \
$(EXTRACFLAGS)
OCAMLOPT_CMD= \
$(OCAMLOPT) $(OCAMLFLAGS) \
$(patsubst %,-cclib -l%_stubs,$(LIBRARY)) \
$(EXTRACFLAGS)
OCAMLMKLIB_CMD=$(OCAMLMKLIB) -linkall $(EXTRALNKFLAGS)
OCAMLDEP_CMD=$(OCAMLDEP) $(OCAMLFLAGS)

SIDEPRODUCTS+= \
$(INTERFACES:=.cmi) \
$(patsubst %,lib%_stubs.a,$(LIBRARY))

all: depend
@$(MAKE) all-build
all-build: all-build-targets $(OTHERS)
all-build-targets: \
$(patsubst %,$(SRC_DIR)/%.cma,$(ARCHIVE)) \
$(patsubst %,$(SRC_DIR)/%,$(SIDEPRODUCTS))
cp $^ .
- if [ -n "$(LIBRARY)" ]; then \
cp $(patsubst %,$(SRC_DIR)/dll%_stubs.so,$(LIBRARY)) .; \
fi

all.opt: depend
@$(MAKE) all-opt-build
all-opt-build: all-opt-build-targets $(OTHERS)
all-opt-build-targets: \
$(patsubst %,$(SRC_DIR)/%.cmxa,$(ARCHIVE)) \
$(patsubst %,$(SRC_DIR)/%.cmx,$(INTERFACES)) \
$(patsubst %,$(SRC_DIR)/%.a,$(LIBRARY)) \
$(patsubst %,$(SRC_DIR)/%,$(SIDEPRODUCTS))
cp $^ .
- if [ -n "$(LIBRARY)" ]; then \
cp $(patsubst %,$(SRC_DIR)/dll%_stubs.so,$(LIBRARY)) .; \
fi

clean:
rm -f .depend $(ARCHIVE:=.cma) $(ARCHIVE:=.cmxa) $(SIDEPRODUCTS)
rm -f $(INTERFACES:=.cmx) $(LIBRARY:=.a)
rm -f $(patsubst %,$(SRC_CIR)/%.ml,$(PRODUCTS)) $(OTHERS)
rm -f $(patsubst %,dll%_stubs.so,$(LIBRARY))
rm -f $(patsubst %,$(SRC_DIR)/%.cmi,$(MODULES))
rm -f $(patsubst %,$(SRC_DIR)/%.cmx,$(MODULES))
rm -f $(patsubst %,$(SRC_DIR)/%.cmo,$(MODULES))

distclean: clean
rm -rf $(PACKAGE_DIR)
rm -f .prepare

depend: .depend

.depend: .prepare $(patsubst %,$(SRC_DIR)/%.ml,$(PRODUCTS))
$(OCAMLDEP_CMD) $(SRC_DIR)/*.ml >.depend

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

$(MARKER): $(TARBALL)
$(TAR) xfz $<
touch $@

$(TARBALL):
@echo \
"$@ not found. Please download it and drop it in this directory ($(pwd))."
@false

$(SRC_DIR)/$(ARCHIVE).cma: $(patsubst %,$(SRC_DIR)/%.cmo,$(OBJS))
$(OCAMLC_CMD) -a $^ -o $@

$(SRC_DIR)/$(ARCHIVE).cmxa: $(patsubst %,$(SRC_DIR)/%.cmx,$(OBJS))
$(OCAMLOPT_CMD) -a $^ -o $@

$(SRC_DIR)/lib$(LIBRARY)_stubs.a: \
$(patsubst %,$(SRC_DIR)/%_stubs.o,$(C_OBJS))
$(OCAMLMKLIB_CMD) -o $(SRC_DIR)/$(LIBRARY)_stubs $^

%.ml: %.mll
$(OCAMLLEX) $< -o $@

%.ml: %.mly
$(OCAMLYACC) $<

%.cmi: %.mli
$(OCAMLC_CMD) -c $< -o $@

%.cmo: %.ml
$(OCAMLC_CMD) -c $< -o $@

%.cmx: %.ml
$(OCAMLOPT_CMD) -c $< -o $@

%.o: %.c
$(OCAMLC_CMD) -ccopt -fPIC $< -o $@
# Workaround for what looks like a bug with object compilation...
- mv $(notdir $@) $@

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

ifeq ($(MAKECMDGOALS),all-build)
include .depend
endif

ifeq ($(MAKECMDGOALS),all-opt-build)
include .depend
endif
87 changes: 57 additions & 30 deletions bundles/menhirLib/Makefile
Original file line number Diff line number Diff line change
@@ -1,46 +1,73 @@
# Bundles the original menhirLib package without modifications.
# This Makefile integrates its build process with coccinelle.

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

VERSION=20160504
MENHIRDIR=menhir-$(VERSION)
MENHIRMARKER=$(MENHIRDIR)/.marker
PACKAGE_DIR=menhir-$(MENHIR_VERSION)
TARBALL=menhir-$(MENHIR_VERSION).tar.gz
MODULES= \
Fix IO installation keyword lineCount positions stringSet version \
settings printer action mark stringMap misc breadth codeBits gSet \
compressedBitSet option dot error parameters parserAux parser lexer \
tarjan unionFind parameterizedGrammar partialGrammar time preFront \
tokenType interface lexdep lexmli infer listMonad \
nonTerminalDefinitionInlining reachability unparameterizedPrinter \
front gMap patricia grammar codePieces item derivation menhirLib \
lr0 slr lr1 lr1partial conflict invariant codeBackend coqBackend \
pprint cst traverse inliner referenceInterpreter sentenceParser \
sentenceLexer interpret tableBackend back menhir
PRODUCTS=lexer lexdep lexmli parser sentenceLexer sentenceParser
SIDEPRODUCTS=menhir menhirLib.cmi menhirLib.cmx menhirLib.cmo menhirLib.o
OTHERS=share/menhir/standard.mly
SRC_DIR=$(PACKAGE_DIR)/src

all all.opt: .prepare menhir
OCAMLLDFLAGS=unix.cmxa

# prepares the source bundle for building.
.prepare: $(MENHIRMARKER)
touch .prepare
MENHIRLIB_MODULES= \
infiniteArray packedIntArray rowDisplacement engineTypes engine \
tableFormat tableInterpreter convert

clean:
rm -rf menhir menhirLib.* share
- $(MAKE) -C $(MENHIRDIR) clean
include ../Makefile.bundles

distclean: clean
rm -rf $(MENHIRDIR)
rm -f .prepare
depend: .depend
@$(MAKE) all-build

$(MENHIRMARKER): $(MENHIRDIR).tar.gz
$(TAR) xfvz $<
.prepare: $(MARKER)
echo "let libdir = \"$(shell pwd\)\"" > $(SRC_DIR)/installation.ml
echo "let ocamlfind = false" >> $(SRC_DIR)/installation.ml
touch $@

$(MENHIRDIR).tar.gz:
@echo "$@ not found. Please download it and drop it in this directory ($(pwd))."
@false
%.cmo: %.ml
if echo $(MENHIRLIB_MODULES) | grep -w $(notdir $(basename $<)); then \
$(OCAMLC_CMD) -for-pack MenhirLib -c $< -o $@; \
else \
$(OCAMLC_CMD) -c $< -o $@; \
fi

.PHONY: all all.opt clean distclean depend
%.cmx: %.ml
if echo $(MENHIRLIB_MODULES) | grep -w $(notdir $(basename $<)); then \
$(OCAMLOPT_CMD) -for-pack MenhirLib -c $< -o $@; \
else \
$(OCAMLOPT_CMD) -c $< -o $@; \
fi

depend: $(MENHIRMARKER) menhir
$(SRC_DIR)/menhir: $(patsubst %,$(SRC_DIR)/%.cmx,$(MODULES))
$(OCAMLOPT_CMD) $(OCAMLLDFLAGS) $^ -o $@

menhir:
unset OCAMLLIB && $(MAKE) -C $(MENHIRDIR) PREFIX=$(CURDIR) all
cp $(MENHIRDIR)/src/_stage2/menhir.native menhir
cp $(MENHIRDIR)/src/_stage2/menhirLib.* .
share/menhir/standard.mly: $(SRC_DIR)/standard.mly
mkdir -p share/menhir/
cp $(MENHIRDIR)/src/standard.mly share/menhir/
cp $< $@

include ../../Makefile.common
$(SRC_DIR)/menhirLib.cmx: \
$(patsubst %,$(SRC_DIR)/%.cmx,$(MENHIRLIB_MODULES))
$(OCAMLOPT_CMD) -pack $^ -o $@

$(SRC_DIR)/menhirLib.cmo: \
$(patsubst %,$(SRC_DIR)/%.cmo,$(MENHIRLIB_MODULES))
$(OCAMLC_CMD) -pack $^ -o $@

$(SRC_DIR)/parser.mly: $(SRC_DIR)/yacc-parser.mly
cp $< $@

menhir: $(SRC_DIR)/menhir
cp $< $@
Binary file added bundles/menhirLib/menhir-20140422.tar.gz
Binary file not shown.
8 changes: 0 additions & 8 deletions bundles/menhirLib/menhirLib.mlpack

This file was deleted.

50 changes: 12 additions & 38 deletions bundles/parmap/Makefile
Original file line number Diff line number Diff line change
@@ -1,46 +1,20 @@
# This Makefile serves as a wrapper to bundle the
# parmap package without modifications.

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

OCAMLCFLAGS ?= -g
OPTFLAGS ?= -g

PARMAP_VERSION=1.0-rc7.1
PARMAP_DIR=parmap.$(PARMAP_VERSION)
PARMAP_ARCHIVE=parmap.1.0-rc7.1+opam.tar.gz
PARMAP_MARKER=$(PARMAP_DIR)/.marker

all all.opt: $(PARMAP_MARKER)
unset OCAMLLIB && cd $(PARMAP_DIR) && \
$(MAKE) && \
cd ..
mv $(PARMAP_DIR)/_build/* .

clean:
- cd $(PARMAP_DIR) && \
$(MAKE) clean && \
cd ..
rm -f *.a *.o *.ml* *.c *.h *.so _* *.cm* *.annot *.clib *build ocamlc.where
PACKAGE_DIR=parmap.$(PARMAP_VERSION)
TARBALL=parmap.1.0-rc7.1+opam.tar.gz
MODULES=bytearray parmap_utils setcore parmap
OBJS=$(MODULES)
INTERFACES=$(OBJS)
C_OBJS=bytearray setcore
ARCHIVE=parmap
LIBRARY=parmap
SRC_DIR=$(PACKAGE_DIR)

distclean:
rm -fr $(PARMAP_DIR)
rm -f *.a *.o *.ml* *.c *.h *.so _* *.cm* *.annot *.clib *build ocamlc.where
include ../Makefile.bundles

depend: $(PARMAP_MARKER)

.PHONY: all all.opt clean disclean depend

$(PARMAP_MARKER): $(PARMAP_ARCHIVE)
$(TAR) xfz $<
unset OCAMLLIB && cd $(PARMAP_DIR) && \
./configure && \
cd ..
.prepare: $(MARKER)
cd $(SRC_DIR) && ./configure
touch $@

$(PARMAP_ARCHIVE):
@echo "$@ not found. Please download it and drop it in this directory ($(pwd))."
@false
76 changes: 28 additions & 48 deletions bundles/pcre/Makefile
Original file line number Diff line number Diff line change
@@ -1,54 +1,34 @@
# This Makefile serves as a wrapper to bundle the
# pcre module without modifications.

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

PCRE_VERSION=7.2.3
PCRE_ARCHIVE=mmottl-pcre-ocaml-v7.2.3-0-g258b72c.tar.gz
PCRE_DIR=mmottl-pcre-ocaml-258b72c
PCRE_LIB=$(PCRE_DIR)/lib
PCRE_MARKER=$(PCRE_DIR)/.marker

all: $(PCRE_MARKER)
@$(MAKE) all-build
all-build: $(PCRE_MARKER) pcre.cma
all.opt: $(PCRE_MARKER)
@$(MAKE) all-opt-build
all-opt-build: $(PCRE_MARKER) pcre.cmxa

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

clean:
rm -f dllpcre_stubs.so libpcre_stubs.a pcre_stubs.o \
pcre.cma pcre.cmi pcre.cmo \
pcre.a pcre.cmx pcre.cmxa pcre.o pcre.annot
- $(MAKE) -C $(PCRE_DIR) clean

distclean: clean
rm -rf $(PCRE_DIR)
rm -f .prepare

depend: $(PCRE_MARKER)

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

# prepare the pcre directory
$(PCRE_MARKER): $(PCRE_ARCHIVE)
$(TAR) xfvz $<
bytes=$(shell \
if [ "$$OCAMLVERSION" "<" 4.02.0 ]; then \
echo bytes; \
fi \
$)

PACKAGE_DIR=mmottl-pcre-ocaml-258b72c
TARBALL=mmottl-pcre-ocaml-v7.2.3-0-g258b72c.tar.gz
MODULES=pcre_compat pcre bytes
OBJS=$(bytes) pcre_compat pcre
INTERFACES=pcre
C_OBJS=pcre
ARCHIVE=pcre
LIBRARY=pcre
SRC_DIR=$(PACKAGE_DIR)/lib

EXTRACFLAGS=$(PCRE_CFLAGS:%=-ccopt %) $(PCRE_LIBS:%=-cclib %)
EXTRALNKFLAGS=$(PCRE_LIBS:%=-ldopt %)

include ../Makefile.bundles

.prepare: $(MARKER)
if [ "$$OCAMLVERSION" "<" 4.02.0 ]; then \
cp $(SRC_DIR)/pcre_compat312.ml $(SRC_DIR)/pcre_compat.ml; \
cp bytes_compat.ml $(SRC_DIR)/bytes.ml; \
else \
cp $(SRC_DIR)/pcre_compat402.ml $(SRC_DIR)/pcre_compat.ml; \
fi
touch $@

$(PCRE_ARCHIVE):
@echo "$@ not found. Please download it and drop it in this directory ($(pwd))."
@false

pcre.cma pcre.cmxa:
cd $(PCRE_DIR); ./configure
unset OCAMLLIB && $(MAKE) -C $(PCRE_DIR)
cp $(PCRE_DIR)/_build/lib/* .

include ../../Makefile.common
5 changes: 5 additions & 0 deletions bundles/pcre/bytes_compat.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include String

external unsafe_to_string: t -> string = "%identity"

external unsafe_of_string: string -> t = "%identity"
Loading

0 comments on commit 0e0cea3

Please sign in to comment.