Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix configuration and build system for native Windows #2939

Merged
merged 7 commits into from
Jun 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.sh text eol=lf
configure text eol=lf
configure.ac text eol=lf
check_linker text eol=lf
*.m4 text eol=lf

# Treat patches as binary for safety
Expand Down
11 changes: 9 additions & 2 deletions Makefile.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ LIBEXT := $(if $(USE_BYTE),.cma,.cmxa)

PACKS = @OCAML_PKG_unix@ @OCAML_PKG_bigarray@ @OCAML_PKG_extlib@ @OCAML_PKG_re@ @OCAML_PKG_re_glob@ @OCAML_PKG_cmdliner@ @OCAML_PKG_ocamlgraph@ @OCAML_PKG_cudf@ @OCAML_PKG_dose3_common@ @OCAML_PKG_dose3_algo@ @OCAML_PKG_jsonm@ @OCAML_PKG_opam_file_format@

OCAMLDEPARGS = @OCAMLDEPARGS@

OCAMLFIND = @OCAMLFIND@
OCAML = @OCAML@
OCAMLC = @OCAMLC@
Expand All @@ -24,7 +26,12 @@ OCAMLYACC = @OCAMLYACC@
OCAMLMKLIB = @OCAMLMKLIB@
OCAMLDOC = @OCAMLDOC@

WIN32 = @WIN32@
CC = @CC@
AR = @AR@

EXE = @EXE@
WIN32 = @WIN32@

PATH:=@PATH_PREPEND@$(PATH)

export OCAMLVERSION OCAMLFIND OCAML OCAMLC OCAMLOPT OCAMLDEP OCAMLLEX OCAMLYACC OCAMLMKLIB OCAMLDOC EXE
export OCAMLVERSION OCAMLFIND OCAML OCAMLC OCAMLOPT OCAMLDEP OCAMLLEX OCAMLYACC OCAMLMKLIB OCAMLDOC EXE CC AR PATH
53 changes: 4 additions & 49 deletions OCamlMakefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ endif

#################### variables depending on your OCaml-installation

SYSTEM := $(shell ocamlc -config 2>/dev/null | grep system | sed 's/system: //')
SYSTEM := $(shell ocamlc -config 2>/dev/null | sed -n -e 's/^system: //p ')
# This may be
# - mingw
# - mingw64
Expand All @@ -124,27 +124,13 @@ SYSTEM := $(shell ocamlc -config 2>/dev/null | grep system | sed 's/system: //')
ifeq ($(SYSTEM),$(filter $(SYSTEM),mingw mingw64))
MINGW=1
endif
ifeq ($(SYSTEM),win32)
ifeq ($(SYSTEM),$(filter $(SYSTEM),win32 win64))
MSVC=1
endif

ifdef MINGW
export MINGW
WIN32 := 1
# The default value 'cc' makes 'ocamlc -cc "cc"' raises the error 'The
# NTVDM CPU has encountered an illegal instruction'.
ifndef CC
MNO_CYGWIN := $(shell gcc -Wextra -v --help 2>/dev/null | grep -q '\-mno-cygwin'; echo $$?)
CC := gcc
else
MNO_CYGWIN := $(shell $$CC -Wextra -v --help 2>/dev/null | grep -q '\-mno-cygwin'; echo $$?)
endif
# We are compiling with cygwin tools:
ifeq ($(MNO_CYGWIN),0)
CFLAGS_WIN32 := -mno-cygwin
endif
# The OCaml C header files use this flag:
CFLAGS += -D__MINGW32__
endif
ifdef MSVC
export MSVC
Expand Down Expand Up @@ -206,15 +192,6 @@ ifndef RPATH_FLAG
endif
export RPATH_FLAG

ifndef MSVC
ifndef PIC_CFLAGS
PIC_CFLAGS := -fPIC
endif
ifndef PIC_CPPFLAGS
PIC_CPPFLAGS := -DPIC
endif
endif

export PIC_CFLAGS
export PIC_CPPFLAGS

Expand Down Expand Up @@ -973,40 +950,18 @@ endif
.rep .zog .glade

ifndef STATIC
ifdef MINGW
# From OCaml 3.11.0, ocamlmklib is available on windows
OCAMLMLIB_EXISTS = $(shell which $(OCAMLMKLIB))
ifeq ($(strip $(OCAMLMLIB_EXISTS)),)
$(DLLSONAME): $(OBJ_LINK)
$(CC) $(CFLAGS) $(CFLAGS_WIN32) $(OBJ_LINK) -shared -o $@ \
$(wildcard $(foreach dir,$(LIBDIRS),$(CLIBS:%=$(dir)/lib%.a))) \
'$(OCAMLLIBPATH)/ocamlrun.a' \
-Wl,--whole-archive \
-Wl,--export-all-symbols \
-Wl,--allow-multiple-definition \
-Wl,--enable-auto-import
else
ifdef MSVC
$(DLLSONAME): $(OBJ_LINK)
$(OCAMLMKLIB) $(INCFLAGS) $(CLIBFLAGS) \
-o $(CLIB_BASE) $(OBJ_LINK) $(CLIBS:%=-l%) \
$(CFRAMEWORKS:%=-framework %) \
-o $(CLIB_BASE) $(OBJ_LINK) $(CLIBS:%=%.lib) $(CFRAMEWORKS:%=-framework %) \
$(OCAMLMKLIB_FLAGS)
endif
else
ifdef MSVC
$(DLLSONAME): $(OBJ_LINK)
link /NOLOGO /DLL /OUT:$@ $(OBJ_LINK) \
$(wildcard $(foreach dir,$(LIBDIRS),$(CLIBS:%=$(dir)/%.lib))) \
'$(OCAMLLIBPATH)/ocamlrun.lib'

else
$(DLLSONAME): $(OBJ_LINK)
$(OCAMLMKLIB) $(INCFLAGS) $(CLIBFLAGS) \
-o $(CLIB_BASE) $(OBJ_LINK) $(CLIBS:%=-l%) $(CFRAMEWORKS:%=-framework %) \
$(OCAMLMKLIB_FLAGS)
endif
endif
endif

ifndef LIB_PACK_NAME
$(RESULT).cma: $(REAL_IMPL_INTF) $(MAKEDLL) $(EXTRADEPS) $(RESULTDEPS)
Expand Down
Loading