Skip to content

Commit

Permalink
Merge pull request #106 from lefessan/2018-01-14-dra27-windows-fixes
Browse files Browse the repository at this point in the history
Merge dra27 windows fixes
  • Loading branch information
lefessan authored Jan 14, 2018
2 parents 53bc963 + 0feda47 commit 292a938
Show file tree
Hide file tree
Showing 18 changed files with 143 additions and 61 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*.cm?
*.o
*.obj
*.a
*.lib
*.mldep
*.mlidep
*.byte
Expand Down
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ MAKE_CONFIG := autoconf/Makefile.config
include $(MAKE_CONFIG)

OBUILD_DSTDIR=_obuild
OCAMLC?=ocamlc
EXT_OBJ:=$(shell $(OCAMLC) -config | tr -d '\r' | sed -n -e "s/^ext_obj: //p")

# If you add a library ocplib-xxx:
# 1/ Update this list with xxx_SRCDIR=
Expand Down Expand Up @@ -178,13 +180,13 @@ OCP_BUILD_CMXS= $(OCP_BUILD_MLS:.ml=.cmx)
OCP_BUILD_CMOS= $(OCP_BUILD_MLS:.ml=.cmo)
OCP_BUILD_MLIS= $(OCP_BUILD_MLS:.ml=.mli)
OCP_BUILD_CMIS= $(OCP_BUILD_MLS:.ml=.cmi)
OCP_BUILD_STUBS= $(OCP_BUILD_CS:.c=.o)
OCP_BUILD_STUBS= $(OCP_BUILD_CS:.c=$(EXT_OBJ))
OCP_BUILD_TMPS= $(OCP_BUILD_MLYS:.mly=.mli) $(OCP_BUILD_MLYS:.mly=.ml) \
$(OCP_BUILD_MLLS:.mll=.ml) $(OCP_BUILD_ML4S:.ml4=.ml) \
$(OCP_BUILD_SRCDIR)/buildVersion.ml \
$(compat_SRCDIR)/ocpCompat.ml

OCP_BUILD_OS= $(OCP_BUILD_STUBS) $(OCP_BUILD_CMXS:.cmx=.o)
OCP_BUILD_OS= $(OCP_BUILD_STUBS) $(OCP_BUILD_CMXS:.cmx=$(EXT_OBJ))

all: build-ocps
@echo Libraries will be installed in ${ocamldir}
Expand Down Expand Up @@ -324,7 +326,7 @@ include .depend
OCP_BUILD:=$(OCP_BUILD_BOOTER)
include autoconf/Makefile.rules

.SUFFIXES: .ml .mll .mli .mly .c .o .cmo .cmi .cmx
.SUFFIXES: .ml .mll .mli .mly .c $(EXT_OBJ) .cmo .cmi .cmx

.mll.ml:
$(OCAMLLEX) $<
Expand All @@ -341,9 +343,9 @@ include autoconf/Makefile.rules
.ml.cmo:
$(OCAMLC) -c -o $*.cmo $(EXTERNAL_INCLUDES) $(INCLUDES) $<

.c.o:
$(OCAMLC) -c $(INCLUDES) $<
mv `basename $*.o` $*.o
.c$(EXT_OBJ):
$(OCAMLC) -c $(INCLUDES) -ccopt -DOCAML_VERSION=$(OCAMLVERSION_C) $<
mv `basename $*$(EXT_OBJ)` $*$(EXT_OBJ)



1 change: 1 addition & 0 deletions autoconf/Makefile.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ OPAM_REPO_OFFICIAL_REMOTE=@OPAM_REPO_OFFICIAL_REMOTE@
OPAM_REPO_FORK_REMOTE=@OPAM_REPO_FORK_REMOTE@
DOWNLOAD_URL_PREFIX=@DOWNLOAD_URL_PREFIX@
OCAMLVERSION=@OCAMLVERSION@
OCAMLVERSION_C=@OCAMLVERSION_C@
OCAMLC=@OCAMLC@
OCAMLOPT=@OCAMLOPT@
OCAMLDEP=@OCAMLDEP@
Expand Down
1 change: 1 addition & 0 deletions autoconf/config.ocp2gen.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ autoconf = {
opam_repo_fork_remote="@OPAM_REPO_FORK_REMOTE@";
download_url_prefix="@DOWNLOAD_URL_PREFIX@";
conf_ocamlversion="@OCAMLVERSION@";
conf_ocamlversion_c="@OCAMLVERSION_C@";
conf_ocamlc="@OCAMLC@";
conf_ocamlopt="@OCAMLOPT@";
conf_ocamldep="@OCAMLDEP@";
Expand Down
1 change: 1 addition & 0 deletions autoconf/config.ocpgen.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ opam_repo_official_remote="@OPAM_REPO_OFFICIAL_REMOTE@"
opam_repo_fork_remote="@OPAM_REPO_FORK_REMOTE@"
download_url_prefix="@DOWNLOAD_URL_PREFIX@"
conf_ocamlversion="@OCAMLVERSION@"
conf_ocamlversion_c="@OCAMLVERSION_C@"
conf_ocamlc="@OCAMLC@"
conf_ocamlopt="@OCAMLOPT@"
conf_ocamldep="@OCAMLDEP@"
Expand Down
42 changes: 36 additions & 6 deletions autoconf/configure
Original file line number Diff line number Diff line change
Expand Up @@ -598,13 +598,18 @@ OCAMLYACC
OCAMLLEXDOTOPT
OCAMLLEX
OCAMLBIN
OCAMLVERSION_C
CONFIGURE_ARGS
metadir
ocamldir
OCAMLFIND
OCAML_USE_POSIX_TYPES
AWK
OCAML_POINT_VERSION
OCAML_MINOR_VERSION
OCAML_MAJOR_VERSION
SED
OCAML_OS_TYPE
OCAMLBUILD
OCAMLDOC
OCAMLMKLIB
Expand Down Expand Up @@ -2696,7 +2701,7 @@ fi
if test "$OCAMLC" != "no"; then
OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p'`
OCAMLVERSION=`$OCAMLC -v | tr -d '\015' | sed -n -e 's|.*version* *\(.*\)$|\1|p'`
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: OCaml version is $OCAMLVERSION" >&5
$as_echo "OCaml version is $OCAMLVERSION" >&6; }
# If OCAMLLIB is set, use it
Expand Down Expand Up @@ -2810,7 +2815,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find ocamlopt; bytecode compilation only." >&5
$as_echo "$as_me: WARNING: Cannot find ocamlopt; bytecode compilation only." >&2;}
else
TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
TMPVERSION=`$OCAMLOPT -v | tr -d '\015' | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: versions differs from ocamlc; ocamlopt discarded." >&5
$as_echo "versions differs from ocamlc; ocamlopt discarded." >&6; }
Expand Down Expand Up @@ -2916,7 +2921,7 @@ else
fi
if test "$OCAMLCDOTOPT" != "no"; then
TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
TMPVERSION=`$OCAMLCDOTOPT -v | tr -d '\015' | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: versions differs from ocamlc; ocamlc.opt discarded." >&5
$as_echo "versions differs from ocamlc; ocamlc.opt discarded." >&6; }
Expand Down Expand Up @@ -3020,7 +3025,7 @@ else
fi
if test "$OCAMLOPTDOTOPT" != "no"; then
TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
TMPVERSION=`$OCAMLOPTDOTOPT -v | tr -d '\015' | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: version differs from ocamlc; ocamlopt.opt discarded." >&5
$as_echo "version differs from ocamlc; ocamlopt.opt discarded." >&6; }
Expand Down Expand Up @@ -3317,7 +3322,7 @@ else
fi
if test "$OCAMLDEPDOTOPT" != "no"; then
TMPVERSION=`$OCAMLDEPDOTOPT -version | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
TMPVERSION=`$OCAMLDEPDOTOPT -version | tr -d '\015' | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: version differs from ocamlc; ocamldep.opt discarded." >&5
$as_echo "version differs from ocamlc; ocamldep.opt discarded." >&6; }
Expand Down Expand Up @@ -3703,6 +3708,21 @@ else
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking OCaml Sys.os_type" >&5
$as_echo_n "checking OCaml Sys.os_type... " >&6; }
cat > conftest.ml <<EOF
print_string(Sys.os_type);;
EOF
OCAML_OS_TYPE=`$OCAML conftest.ml`
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAML_OS_TYPE" >&5
$as_echo "$OCAML_OS_TYPE" >&6; }
if test "${OCAML_OS_TYPE}" = "Win32" ; then
OCAMLLIB="$(echo "${OCAMLLIB}" | tr -d '\015' | sed -e 's|\\|/|g')"
fi
ROOTDIR=$(dirname $(pwd))
Expand Down Expand Up @@ -3794,9 +3814,13 @@ $as_echo_n "checking Point version... " >&6; }
$as_echo "$AX_POINT_VERSION" >&6; }
OCAML_MAJOR_VERSION=$AX_MAJOR_VERSION
OCAML_MINOR_VERSION=$AX_MINOR_VERSION
OCAML_POINT_VERSION=$AX_POINT_VERSION
OCAMLVERSION_C=$OCAML_MAJOR_VERSION$OCAML_MINOR_VERSION$OCAML_POINT_VERSION
if test "$OCAMLC" = "no"; then
as_fn_error $? "You must install the OCaml compiler" "$LINENO" 5
fi
Expand Down Expand Up @@ -4037,7 +4061,11 @@ fi
if test "${OCAMLFIND}" != "no"; then
metadir="$(${OCAMLFIND} -printconf destdir)"
if test "${OCAML_OS_TYPE}" = "Win32" ; then
metadir="$(${OCAMLFIND} -printconf destdir | tr -d '\015' | sed -e 's|\\|/|g')"
else
metadir="$(${OCAMLFIND} -printconf destdir)"
fi
echo "initializing metadir from ocamlfind config"
fi
Expand Down Expand Up @@ -4079,6 +4107,7 @@ fi
# checking for ocamllex
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}ocamllex", so it can be a program name with args.
Expand Down Expand Up @@ -4519,6 +4548,7 @@ x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version
ac_config_files="$ac_config_files Makefile.config config.ocpgen config.ocp2gen ocaml-config.h"
Expand Down
19 changes: 15 additions & 4 deletions autoconf/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ AC_ARG_ENABLE(bin-annot,
AC_PROG_CC

AC_PROG_OCAML
AC_CHECK_OCAML_OS_TYPE
if test "${OCAML_OS_TYPE}" = "Win32" ; then
OCAMLLIB="$(echo "${OCAMLLIB}" | tr -d '\015' | sed -e 's|\\|/|g')"
fi

ROOTDIR=$(dirname $(pwd))

AX_SPLIT_VERSION(OCAMLVERSION)
OCAML_MAJOR_VERSION=$AX_MAJOR_VERSION
OCAML_MINOR_VERSION=$AX_MINOR_VERSION
OCAML_POINT_VERSION=$AX_POINT_VERSION
AC_SUBST(OCAML_MAJOR_VERSION,$AX_MAJOR_VERSION)
AC_SUBST(OCAML_MINOR_VERSION,$AX_MINOR_VERSION)
AC_SUBST(OCAML_POINT_VERSION,$AX_POINT_VERSION)
OCAMLVERSION_C=$OCAML_MAJOR_VERSION$OCAML_MINOR_VERSION$OCAML_POINT_VERSION

if test "$OCAMLC" = "no"; then
AC_MSG_ERROR([You must install the OCaml compiler])
Expand Down Expand Up @@ -70,7 +75,11 @@ metadir='${ocamldir}'

AC_PROG_FINDLIB
if test "${OCAMLFIND}" != "no"; then
metadir="$(${OCAMLFIND} -printconf destdir)"
if test "${OCAML_OS_TYPE}" = "Win32" ; then
metadir="$(${OCAMLFIND} -printconf destdir | tr -d '\015' | sed -e 's|\\|/|g')"
else
metadir="$(${OCAMLFIND} -printconf destdir)"
fi
echo "initializing metadir from ocamlfind config"
fi

Expand Down Expand Up @@ -106,6 +115,7 @@ AC_SUBST(metadir)

AC_SUBST(CONFIGURE_ARGS)
AC_SUBST(OCAMLVERSION)
AC_SUBST(OCAMLVERSION_C)
AC_SUBST(OCAMLLIB)
AC_SUBST(OCAMLOPT)
AC_SUBST(OCAMLDEP)
Expand Down Expand Up @@ -162,6 +172,7 @@ AC_SUBST(OPAM_REPO_OFFICIAL_REMOTE)
AC_SUBST(OPAM_REPO_FORK_REMOTE)
AC_SUBST(DOWNLOAD_URL_PREFIX)
AC_SUBST(OCAMLVERSION)
AC_SUBST(OCAMLVERSION_C)
AC_SUBST(OCAMLC)
AC_SUBST(OCAMLOPT)
AC_SUBST(OCAMLDEP)
Expand Down
10 changes: 5 additions & 5 deletions autoconf/generated.files
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
.travis-install.sh 9bfd3722ac873da3f33d69fd670659b2
.travis.yml fa9f32e8d6f50113a91f7fc9c2ca886b
autoconf/.gitignore 00973f185af428536c3caff11a53626d
autoconf/Makefile.config.in 6789c79863a0489e31002d9f9e840d57
autoconf/Makefile.config.in 32d42663ea49bf281090e8c00d7f313c
autoconf/Makefile.rules c9e85dee44380b1a855cb2d49da44d54
autoconf/build.ocp 9d81103f0dd977b6414645b9ab29c713
autoconf/config.ocp2gen.in 4c0a6254516ad9a97b3a6dca69213442
autoconf/config.ocpgen.in da3aeece4aac95639ba15bb1995715d7
autoconf/config.ocp2gen.in 3a8917bdb961d9e59c36ca60d9ff96fd
autoconf/config.ocpgen.in 2bf3c3d333ef7ce7f09cc7a9addb4496
autoconf/config.ocpgen2.in 9a995bcba87527893659a1d970826a84
autoconf/configure.ac a99aa0ae322289cea4c709f503885f38
autoconf/configure.ac b0ff912b81ca3b534b2fc129f60a405e
autoconf/m4/ax_compare_version.m4 ebb455a7fd6a8ba9a4e38a25c8f0b686
autoconf/m4/ocaml.m4 bffe7da970a9e23a89b611c00360f36f
autoconf/m4/ocaml.m4 b3841cddbff929a11a3665288e0ff305
autoconf/ocaml-config.h.in 361f7d5a23b30c6c49756a9e34c2dcf9
autoconf/travis-ci.sh e22cfae9156c383ce5a4abf646798a17
autoconf/travis-install.sh 9bfd3722ac873da3f33d69fd670659b2
Expand Down
12 changes: 6 additions & 6 deletions autoconf/m4/ocaml.m4
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ AC_DEFUN([AC_PROG_OCAML],
AC_CHECK_TOOL([OCAMLC],[ocamlc],[no])
if test "$OCAMLC" != "no"; then
OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p'`
OCAMLVERSION=`$OCAMLC -v | tr -d '\015' | sed -n -e 's|.*version* *\(.*\)$|\1|p'`
AC_MSG_RESULT([OCaml version is $OCAMLVERSION])
# If OCAMLLIB is set, use it
if test "$OCAMLLIB" = ""; then
Expand All @@ -33,7 +33,7 @@ AC_DEFUN([AC_PROG_OCAML],
if test "$OCAMLOPT" = "no"; then
AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.])
else
TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
TMPVERSION=`$OCAMLOPT -v | tr -d '\015' | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
AC_MSG_RESULT([versions differs from ocamlc; ocamlopt discarded.])
OCAMLOPT=no
Expand All @@ -47,7 +47,7 @@ AC_DEFUN([AC_PROG_OCAML],
# checking for ocamlc.opt
AC_CHECK_TOOL([OCAMLCDOTOPT],[ocamlc.opt],[no])
if test "$OCAMLCDOTOPT" != "no"; then
TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
TMPVERSION=`$OCAMLCDOTOPT -v | tr -d '\015' | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
AC_MSG_RESULT([versions differs from ocamlc; ocamlc.opt discarded.])
else
Expand All @@ -59,7 +59,7 @@ AC_DEFUN([AC_PROG_OCAML],
if test "$OCAMLOPT" != "no" ; then
AC_CHECK_TOOL([OCAMLOPTDOTOPT],[ocamlopt.opt],[no])
if test "$OCAMLOPTDOTOPT" != "no"; then
TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
TMPVERSION=`$OCAMLOPTDOTOPT -v | tr -d '\015' | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
AC_MSG_RESULT([version differs from ocamlc; ocamlopt.opt discarded.])
else
Expand All @@ -82,7 +82,7 @@ AC_DEFUN([AC_PROG_OCAML],
if test "$OCAMLDEP" != "no" ; then
AC_CHECK_TOOL([OCAMLDEPDOTOPT],[ocamldep.opt],[no])
if test "$OCAMLDEPDOTOPT" != "no"; then
TMPVERSION=`$OCAMLDEPDOTOPT -version | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
TMPVERSION=`$OCAMLDEPDOTOPT -version | tr -d '\015' | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
AC_MSG_RESULT([version differs from ocamlc; ocamldep.opt discarded.])
else
Expand Down Expand Up @@ -132,7 +132,7 @@ AC_DEFUN([AC_PROG_CAMLP4],
# checking for camlp4
AC_CHECK_TOOL([CAMLP4],[camlp4],[no])
if test "$CAMLP4" != "no"; then
TMPVERSION=`$CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p'`
TMPVERSION=`$CAMLP4 -v 2>&1| tr -d '\015' | sed -n -e 's|.*version *\(.*\)$|\1|p'`
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
AC_MSG_RESULT([versions differs from ocamlc])
CAMLP4=no
Expand Down
9 changes: 9 additions & 0 deletions libs/ocplib-compat/3.12.1/ocpCompat.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ module String = struct
let lowercase_ascii = lowercase
let uppercase_ascii = uppercase
let capitalize_ascii = capitalize

(* added in 4.00 *)
let map f s =
let l = length s in
if l = 0 then s else begin
let r = create l in
for i = 0 to l - 1 do unsafe_set r i (f(unsafe_get s i)) done;
r
end
end

module Char = struct
Expand Down
3 changes: 2 additions & 1 deletion libs/ocplib-file/fileGen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ let dirname t =
let add_basename_string dir basename =
match dir.file_basename with
| "" | "/" | "\\" ->
dir.file_basename ^ basename
dir.file_partition ^ dir.file_basename ^ basename
| _ ->
dir.file_string ^ FileOS.dir_separator_string ^ basename

Expand Down Expand Up @@ -302,6 +302,7 @@ let of_unix_string s =
let of_win32_string s =
let s1, s2 = OcpString.cut_at s ':' in
let ss = if s1 == s then s else s2 in
let ss = String.map (function '/' -> '\\' | c -> c) ss in
let part = if s1 == s then "" else (String.lowercase s1) ^ ":" in
let path = OcpString.split ss '\\' in
of_path part path
Expand Down
9 changes: 4 additions & 5 deletions libs/ocplib-unix/build.ocp2
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,15 @@ begin
"minUnix.ml", with_ocp_pp;
"minUnix_c.c";
"onlyUnix.ml", with_ocp_pp;
"onlyUnix_c.c";
"onlyUnix_c.c", { ccopt = "-DOCAML_VERSION=" + String_concat(ocaml_major_version) + String_concat(ocaml_minor_version) + String_concat(ocaml_point_version); };
"onlyWin32.ml"; "onlyWin32_c.c";
];

if( system = "win64" ) {
ocaml.requires = [ "unix" ];
ocaml.link = [ "-cclib"; "user32.lib"; ];
} else {
(* We require "Unix", but do not use it directly !!! *)
ocaml.requires = [ "unix" ] + string_compat;

if( system = "win64" ) {
ocaml.link = [ "-cclib"; "user32.lib"; ];
}

ocaml.requires += [ "ocp-pp" ];
Expand Down
Loading

0 comments on commit 292a938

Please sign in to comment.