Allow optional bootstrapping of FlexDLL on Windows

Allows the four native Windows ports to compile FlexDLL and flexlink
"in-tree" by placing the sources in directory `flexdll` and issuing
`make -f Makefile.nt flexdll`

FlexDLL must still be installed somewhere in PATH before OCaml itself
can be compiled. The `flexdll` target leaves the OCaml build tree in a
sufficiently clean state to allow `world` to be run after installation
of FlexDLL.
master
David Allsopp 2016-01-02 08:37:20 +00:00
parent 87ef3070cd
commit 5da5d4ac7d
8 changed files with 88 additions and 10 deletions

3
.gitignore vendored
View File

@ -294,3 +294,6 @@
/yacc/ocamlyacc
/yacc/version.h
/yacc/.gdb_history
# Bootstrapped FlexDLL
flexdll/

View File

@ -18,6 +18,32 @@ include Makefile.shared
defaultentry:
@echo "Please refer to the installation instructions in file README.win32.adoc."
# FlexDLL sources missing error message
flexdll/Makefile:
@echo In order to bootstrap FlexDLL, you need to place the sources in flexdll.
@echo This can either be done by downloading a source tarball from
@echo \ http://alain.frisch.fr/flexdll.html
@echo or by cloning the git repository
@echo \ git clone https://github.com/alainfrisch/flexdll.git
@echo
@false
# Bootstrapping FlexDLL - leaves a bytecode flexlink in flexdll/
flexdll: flexdll/Makefile
cd byterun ; $(MAKEREC) BOOTSTRAPPING_FLEXLINK=yes ocamlrun$(EXE)
cp byterun/ocamlrun.exe boot/ocamlrun.exe
cd stdlib ; $(MAKEREC) COMPILER=../boot/ocamlc stdlib.cma std_exit.cmo
cd stdlib ; cp stdlib.cma std_exit.cmo *.cmi ../boot
cd flexdll ; $(MAKECMD) MSVC_DETECT=0 TOOLCHAIN=$(TOOLCHAIN) TOOLPREF=$(TOOLPREF) CHAINS=$(FLEXDLL_CHAIN) NATDYNLINK=false OCAMLOPT="../boot/ocamlrun ../boot/ocamlc -I ../boot" flexlink.exe support
# The executable header will not have been available - flexlink.exe is just the bytecode image
cd flexdll ; mv flexlink.exe flexlink
cd stdlib ; $(MAKEREC) FLEXLINK_CMD="../boot/ocamlrun ../flexdll/flexlink" camlheader
# Assemble flexlink.exe
cat stdlib/camlheader flexdll/flexlink > flexdll/flexlink.exe ; chmod +x flexdll/flexlink.exe ; rm flexdll/flexlink
# Tidy-up the OCaml build tree ready for the next stage
cd byterun ; $(MAKEREC) clean
$(MAKEREC) partialclean
# Recompile the system using the bootstrap compiler
all: runtime ocamlc ocamllex ocamlyacc ocamltools library ocaml \
otherlibraries $(OCAMLBUILDBYTE) $(WITH_DEBUGGER) \
@ -672,5 +698,6 @@ distclean:
.PHONY: ocamltoolsopt.opt ocamlyacc opt-core opt opt.opt otherlibraries
.PHONY: otherlibrariesopt promote promote-cross
.PHONY: restore runtime runtimeopt makeruntimeopt world world.opt
.PHONY: flexdll
include .depend

View File

@ -15,13 +15,20 @@ include Makefile.common
CFLAGS=-DOCAML_STDLIB_DIR='"$(LIBDIR)"' $(IFLEXDIR)
ifdef BOOTSTRAPPING_FLEXLINK
MAKE_OCAMLRUN=$(MKEXE_BOOT)
CFLAGS:=-DBOOTSTRAPPING_FLEXLINK $(CFLAGS)
else
MAKE_OCAMLRUN=$(MKEXE) -o $(1) $(2)
endif
DBGO=d.$(O)
OBJS=$(COMMONOBJS:.o=.$(O)) win32.$(O) main.$(O)
DOBJS=$(OBJS:.$(O)=.$(DBGO)) instrtrace.$(DBGO)
ocamlrun$(EXE): libcamlrun.$(A) prims.$(O)
$(MKEXE) -o ocamlrun$(EXE) prims.$(O) $(call SYSLIB,ws2_32) \
$(EXTRALIBS) libcamlrun.$(A)
$(call MAKE_OCAMLRUN,ocamlrun$(EXE),prims.$(O) libcamlrun.$(A) \
$(call SYSLIB,ws2_32) $(EXTRALIBS))
ocamlrund$(EXE): libcamlrund.$(A) prims.$(O) main.$(O)
$(MKEXE) -o ocamlrund$(EXE) $(BYTECCDBGCOMPOPTS) prims.$(O) \

View File

@ -19,6 +19,9 @@
/* <private> */
#include "../../config/m.h"
#include "../../config/s.h"
#ifdef BOOTSTRAPPING_FLEXLINK
#undef SUPPORT_DYNAMIC_LINKING
#endif
/* </private> */
#ifndef CAML_NAME_SPACE

View File

@ -109,13 +109,22 @@ NATIVECCLIBS=-lws2_32
CPP=$(BYTECC) -E
### Flexlink
FLEXLINK=flexlink -chain mingw -stack 16777216 -link -static-libgcc
FLEXDIR:=$(shell $(FLEXLINK) -where)
FLEXLINK_CMD=flexlink
FLEXDLL_CHAIN=mingw
FLEXLINK=$(FLEXLINK_CMD) -chain $(FLEXDLL_CHAIN) -stack 16777216 -link -static-libgcc
FLEXDIR:=$(shell $(FLEXLINK) -where 2>/dev/null)
ifeq ($(FLEXDIR),)
IFLEXDIR=
else
IFLEXDIR=-I"$(FLEXDIR)"
endif
MKDLL=$(FLEXLINK)
MKEXE=$(FLEXLINK) -exe
MKMAINDLL=$(FLEXLINK) -maindll
### Native command to build ocamlrun.exe without flexlink
MKEXE_BOOT=$(BYTECC) -o $(1) $(2)
### How to build a static library
MKLIB=rm -f $(1); $(TOOLPREF)ar rc $(1) $(2); $(RANLIB) $(1)
#ml let mklib out files opts = Printf.sprintf "rm -f %s && %sar rcs %s %s %s" out toolpref opts out files;;

View File

@ -109,13 +109,22 @@ NATIVECCLIBS=-lws2_32
CPP=$(BYTECC) -E
### Flexlink
FLEXLINK=flexlink -chain mingw64 -stack 33554432
FLEXDIR:=$(shell $(FLEXLINK) -where)
FLEXLINK_CMD=flexlink
FLEXDLL_CHAIN=mingw64
FLEXLINK=$(FLEXLINK_CMD) -chain $(FLEXDLL_CHAIN) -stack 33554432
FLEXDIR:=$(shell $(FLEXLINK) -where 2>/dev/null)
ifeq ($(FLEXDIR),)
IFLEXDIR=
else
IFLEXDIR=-I"$(FLEXDIR)"
endif
MKDLL=$(FLEXLINK)
MKEXE=$(FLEXLINK) -exe
MKMAINDLL=$(FLEXLINK) -maindll
### Native command to build ocamlrun.exe without flexlink
MKEXE_BOOT=$(BYTECC) -o $(1) $(2)
### How to build a static library
MKLIB=rm -f $(1); $(TOOLPREF)ar rc $(1) $(2); $(RANLIB) $(1)
#ml let mklib out files opts = Printf.sprintf "rm -f %s && %sar rcs %s %s %s" out toolpref opts out files;;

View File

@ -100,13 +100,23 @@ NATIVECCLIBS=advapi32.lib ws2_32.lib
CPP=cl -nologo -EP
### Flexlink
FLEXLINK=flexlink -merge-manifest -stack 16777216
FLEXDIR:=$(shell $(FLEXLINK) -where)
FLEXLINK_CMD=flexlink
FLEXDLL_CHAIN=msvc
FLEXLINK=$(FLEXLINK_CMD) -merge-manifest -stack 16777216
FLEXDIR:=$(shell $(FLEXLINK) -where 2>/dev/null)
ifeq ($(FLEXDIR),)
IFLEXDIR=
else
IFLEXDIR=-I"$(FLEXDIR)"
endif
MKDLL=$(FLEXLINK)
MKEXE=$(FLEXLINK) -exe
MKMAINDLL=$(FLEXLINK) -maindll
### Native command to build ocamlrun.exe without flexlink
MERGEMANIFESTEXE=test ! -f $(1).manifest || mt -nologo -outputresource:$(1) -manifest $(1).manifest && rm -f $(1).manifest
MKEXE_BOOT=$(BYTECC) /Fe$(1) $(2) /link /subsystem:console && ($(MERGEMANIFESTEXE))
### How to build a static library
MKLIB=link -lib -nologo -out:$(1) $(2)
#ml let mklib out files opts = Printf.sprintf "link -lib -nologo -out:%s %s %s" out opts files;;

View File

@ -104,13 +104,23 @@ NATIVECCLIBS=advapi32.lib ws2_32.lib $(EXTRALIBS)
CPP=cl -nologo -EP
### Flexlink
FLEXLINK=flexlink -x64 -merge-manifest -stack 33554432
FLEXDIR:=$(shell $(FLEXLINK) -where)
FLEXLINK_CMD=flexlink
FLEXDLL_CHAIN=msvc64
FLEXLINK=$(FLEXLINK_CMD) -x64 -merge-manifest -stack 33554432
FLEXDIR:=$(shell $(FLEXLINK) -where 2>/dev/null)
ifeq ($(FLEXDIR),)
IFLEXDIR=
else
IFLEXDIR=-I"$(FLEXDIR)"
endif
MKDLL=$(FLEXLINK)
MKEXE=$(FLEXLINK) -exe
MKMAINDLL=$(FLEXLINK) -maindll
### Native command to build ocamlrun.exe without flexlink
MERGEMANIFESTEXE=test ! -f $(1).manifest || mt -nologo -outputresource:$(1) -manifest $(1).manifest && rm -f $(1).manifest
MKEXE_BOOT=$(BYTECC) /Fe$(1) $(2) /link /subsystem:console && ($(MERGEMANIFESTEXE))
### How to build a static library
MKLIB=link -lib -nologo -machine:AMD64 /out:$(1) $(2)
#ml let mklib out files opts = Printf.sprintf "link -lib -nologo -machine:AMD64 -out:%s %s %s" out opts files;;