summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--INSTALL9
-rw-r--r--Makefile40
-rw-r--r--Makefile.nt38
-rw-r--r--README.win326
-rw-r--r--config/Makefile.mingw32
-rw-r--r--config/Makefile.msvc38
-rw-r--r--config/Makefile.msvc6425
-rwxr-xr-xconfigure46
-rw-r--r--otherlibs/bigarray/Makefile2
-rw-r--r--stdlib/Makefile.nt2
-rw-r--r--stdlib/headernt.c4
-rw-r--r--tools/Makefile9
-rw-r--r--tools/ocamlmklib.mlp49
13 files changed, 212 insertions, 88 deletions
diff --git a/INSTALL b/INSTALL
index 3a72ea009..a1f06f4fb 100644
--- a/INSTALL
+++ b/INSTALL
@@ -185,6 +185,11 @@ An alternative, and faster approach to steps 2 to 5 is
The result is equivalent to "make world opt opt.opt", but this may
fail if anything goes wrong in native-code generation.
+Another alternative, is to use the experimental build system that use
+ocamlbuild instead of make (it replaces steps 2 to 5):
+
+ ./build/fastworld.sh
+
6- You can now install the Objective Caml system. This will create the
following commands (in the binary directory selected during
autoconfiguration):
@@ -214,6 +219,10 @@ From the top directory, become superuser and do:
umask 022 # make sure to give read & execute permission to all
make install
+ In the ocamlbuild setting instead of make install do:
+
+ ./build/install.sh
+
7- Installation is complete. Time to clean up. From the toplevel
directory, do "make clean".
diff --git a/Makefile b/Makefile
index cc3e91f0a..f33abeb04 100644
--- a/Makefile
+++ b/Makefile
@@ -124,7 +124,7 @@ defaultentry:
# Recompile the system using the bootstrap compiler
all: runtime ocamlc ocamllex ocamlyacc ocamltools library ocaml \
- otherlibraries camlp4out $(DEBUGGER) ocamldoc
+ otherlibraries ocamlbuild.byte camlp4out $(DEBUGGER) ocamldoc
# The compilation of ocaml will fail if the runtime has changed.
# Never mind, just do make bootstrap to reach fixpoint again.
@@ -228,8 +228,8 @@ opt: runtimeopt ocamlopt libraryopt otherlibrariesopt
# Native-code versions of the tools
opt.opt: checkstack runtime core ocaml opt-core ocamlc.opt otherlibraries \
- camlp4out $(DEBUGGER) ocamldoc ocamlopt.opt otherlibrariesopt \
- ocamllex.opt ocamltoolsopt.opt camlp4opt ocamldoc.opt
+ ocamlbuild.byte camlp4out $(DEBUGGER) ocamldoc ocamlopt.opt otherlibrariesopt \
+ ocamllex.opt ocamltoolsopt.opt ocamlbuild.native camlp4opt ocamldoc.opt
# Installation
install: FORCE
@@ -258,10 +258,10 @@ install: FORCE
done
cd ocamldoc; $(MAKE) install
if test -f ocamlopt; then $(MAKE) installopt; else :; fi
- cd camlp4; $(MAKE) install
if test -f debugger/ocamldebug; then (cd debugger; $(MAKE) install); \
else :; fi
cp config/Makefile $(LIBDIR)/Makefile.config
+ ./build/partial-install.sh
# Installation of the native-code compiler
installopt:
@@ -605,25 +605,25 @@ alldepend::
# Camlp4
-camlp4/build/camlp4_config.ml: config/Makefile utils/config.ml
- (echo 'let prefix = "$(PREFIX)"'; \
- echo 'let bindir = "$(BINDIR)"'; \
- echo 'let mandir = "$(MANDIR)"'; \
- echo 'let libdir = "$(LIBDIR)"'; \
- grep ast utils/config.ml) > camlp4/build/camlp4_config.ml
-
+camlp4out: ocamlc otherlibraries ocamlbuild-partial-boot ocamlbuild.byte
+ ./build/camlp4-byte-only.sh
+camlp4opt: ocamlopt otherlibrariesopt ocamlbuild-partial-boot ocamlbuild.native
+ ./build/camlp4-native-only.sh
partialclean::
- rm -f camlp4/build/camlp4_config.ml
-beforedepend:: camlp4/build/camlp4_config.ml
+ rm -rf _build/camlp4
+
+# Ocamlbuild
-camlp4out: ocamlc camlp4/build/camlp4_config.ml
- cd camlp4; $(MAKE) all
-camlp4opt: ocamlopt
- cd camlp4; $(MAKE) opt
+ocamlbuild.byte: ocamlc otherlibraries ocamlbuild-partial-boot
+ ./build/ocamlbuild-byte-only.sh
+ocamlbuild.native: ocamlopt otherlibrariesopt ocamlbuild-partial-boot
+ ./build/ocamlbuild-native-only.sh
partialclean::
- cd camlp4; $(MAKE) clean
-alldepend::
- cd camlp4; $(MAKE) depend
+ rm -rf _build/ocamlbuild
+
+.PHONY: ocamlbuild-partial-boot
+ocamlbuild-partial-boot:
+ ./build/partial-boot.sh
# Check that the stack limit is reasonable.
diff --git a/Makefile.nt b/Makefile.nt
index 3b29b3c6c..60d8db6f4 100644
--- a/Makefile.nt
+++ b/Makefile.nt
@@ -114,7 +114,7 @@ defaultentry:
@echo "Please refer to the installation instructions in file README.win32."
# Recompile the system using the bootstrap compiler
-all: runtime ocamlc ocamllex ocamlyacc ocamltools library ocaml otherlibraries ocamldoc.byte camlp4out win32gui
+all: runtime ocamlc ocamllex ocamlyacc ocamltools library ocaml otherlibraries ocamldoc.byte ocamlbuild.byte camlp4out win32gui
# The compilation of ocaml will fail if the runtime has changed.
# Never mind, just do make bootstrap to reach fixpoint again.
@@ -202,7 +202,7 @@ opt: runtimeopt ocamlopt libraryopt otherlibrariesopt
# Native-code versions of the tools
opt.opt: ocamlc.opt ocamlopt.opt ocamllex.opt ocamltoolsopt.opt \
- camlp4opt ocamldoc.opt
+ ocamlbuild.native camlp4opt ocamldoc.opt
# Installation
install: installbyt installopt
@@ -228,7 +228,7 @@ installbyt:
mkdir -p $(STUBLIBDIR)
for i in $(OTHERLIBRARIES); do $(MAKEREC) -C otherlibs/$$i install; done
cd win32caml ; $(MAKE) install
- cd camlp4 ; make install
+ ./build/partial-install.sh
cp config/Makefile $(LIBDIR)/Makefile.config
cp README $(DISTRIB)/Readme.general.txt
cp README.win32 $(DISTRIB)/Readme.windows.txt
@@ -564,25 +564,25 @@ alldepend::
# Camlp4
-camlp4/build/camlp4_config.ml: config/Makefile utils/config.ml
- (echo 'let prefix = "$(PREFIX)"'; \
- echo 'and bindir = "$(BINDIR)"'; \
- echo 'and mandir = "$(MANDIR)"'; \
- echo 'and libdir = "$(LIBDIR)"'; \
- grep 'ast.*magic_number' utils/config.ml) > camlp4/build/camlp4_config.ml
-
+camlp4out: ocamlc otherlibraries ocamlbuild-partial-boot ocamlbuild.byte
+ ./build/camlp4-byte-only.sh
+camlp4opt: ocamlopt otherlibrariesopt ocamlbuild-partial-boot ocamlbuild.native
+ ./build/camlp4-native-only.sh
partialclean::
- rm -f camlp4/build/camlp4_config.ml
-beforedepend:: camlp4/build/camlp4_config.ml
+ rm -rf _build/camlp4
+
+# Ocamlbuild
-camlp4out: ocamlc camlp4/build/camlp4_config.ml
- cd camlp4; $(MAKE) all
-camlp4opt: ocamlopt
- cd camlp4; $(MAKE) opt
+ocamlbuild.byte: ocamlc otherlibraries ocamlbuild-partial-boot
+ ./build/ocamlbuild-byte-only.sh
+ocamlbuild.native: ocamlopt otherlibrariesopt ocamlbuild-partial-boot
+ ./build/ocamlbuild-native-only.sh
partialclean::
- cd camlp4; $(MAKE) clean
-alldepend::
- cd camlp4; $(MAKE) depend
+ rm -rf _build/ocamlbuild
+
+.PHONY: ocamlbuild-partial-boot
+ocamlbuild-partial-boot:
+ ./build/partial-boot.sh
# The Win32 toplevel GUI
diff --git a/README.win32 b/README.win32
index dc526fe97..762b06c04 100644
--- a/README.win32
+++ b/README.win32
@@ -124,7 +124,7 @@ Normally, the only variables that need to be changed are
PREFIX where to install everything
TK_ROOT where TCL/TK was installed
-Finally, use "make -f Makefile.nt" to build the system, e.g.
+Finally, use "make -f Makefile.nt" to build the system, e.g.
make -f Makefile.nt world
make -f Makefile.nt bootstrap
@@ -132,6 +132,10 @@ Finally, use "make -f Makefile.nt" to build the system, e.g.
make -f Makefile.nt opt.opt
make -f Makefile.nt install
+Alternatively you can use the experimental build procdure using ocamlbuild:
+
+ ./build/fastworld.sh
+ ./build/install.sh
NOTES:
diff --git a/config/Makefile.mingw b/config/Makefile.mingw
index 013351c75..3b62eac80 100644
--- a/config/Makefile.mingw
+++ b/config/Makefile.mingw
@@ -41,6 +41,33 @@ S=s
SO=s.o
DO=d.o
EXE=.exe
+EXT_DLL=.dll
+EXT_OBJ=.$(O)
+EXT_LIB=.$(A)
+EXT_ASM=.$(S)
+MANEXT=1
+SHARPBANGSCRIPTS=false
+PTHREAD_LINK=
+X11_INCLUDES=
+X11_LINK=
+DBM_INCLUDES=
+DBM_LINK=
+BYTECCRPATH=
+SUPPORTS_SHARED_LIBRARIES=true
+SHAREDCCCOMPOPTS=
+MKSHAREDLIBRPATH=
+NATIVECCPROFOPTS=
+NATIVECCRPATH=
+ASFLAGS=
+ASPP=
+ASPPFLAGS=
+ASPPPROFFLAGS=
+PROFILING=noprof
+DYNLINKOPTS=
+DEBUGGER=
+CC_PROFILE=
+SYSTHREAD_SUPPORT=true
+EXTRALIBS=
########## Configuration for the bytecode compiler
@@ -65,17 +92,22 @@ CPP=$(BYTECC) -E
### How to build an EXE
MKEXE=$(BYTECC) -o $(1) $(2)
+#ml let mkexe out files opts = Printf.sprintf "%s -o %s %s %s" bytecc out opts files;;
### How to build a DLL
MKDLL=$(BYTECC) -shared -o $(1) -Wl,--out-implib,$(2) $(3)
+#ml let mkdll out implib files opts = Printf.sprintf "%s -shared -o %s -Wl,--out-implib,%s %s %s" bytecc out implib files opts;;
### How to build a static library
MKLIB=rm -f $(1); ar rcs $(1) $(2)
+#ml let mklib out files opts = Printf.sprintf "rm -f %s && ar rcs %s %s %s" out opts out files;;
### Canonicalize the name of a system library
SYSLIB=-l$(1)
+#ml let syslib x = "-l"^x;;
### The ranlib command
+RANLIB=ranlib
RANLIBCMD=ranlib
############# Configuration for the native-code compiler
diff --git a/config/Makefile.msvc b/config/Makefile.msvc
index 6a17c5a1b..739b2475c 100644
--- a/config/Makefile.msvc
+++ b/config/Makefile.msvc
@@ -41,6 +41,32 @@ S=asm
SO=s.obj
DO=d.obj
EXE=.exe
+EXT_DLL=.dll
+EXT_OBJ=.$(O)
+EXT_LIB=.$(A)
+EXT_ASM=.$(S)
+MANEXT=1
+SHARPBANGSCRIPTS=false
+PTHREAD_LINK=
+X11_INCLUDES=
+X11_LINK=
+DBM_INCLUDES=
+DBM_LINK=
+BYTECCRPATH=
+SUPPORTS_SHARED_LIBRARIES=true
+SHAREDCCCOMPOPTS=
+NATIVECCPROFOPTS=
+NATIVECCRPATH=
+ASFLAGS=
+ASPP=
+ASPPFLAGS=
+ASPPPROFFLAGS=
+PROFILING=noprof
+DYNLINKOPTS=
+DEBUGGER=
+CC_PROFILE=
+SYSTHREAD_SUPPORT=true
+EXTRALIBS=
########## Configuration for the bytecode compiler
@@ -64,24 +90,28 @@ NATIVECCLIBS=advapi32.lib
CPP=cl /nologo /EP
### How to merge a .manifest (if any) in a .exe or .dll
-MERGEMANIFEST=\
- test ! -f $(1).manifest || \
- mt -nologo -outputresource:$(1) -manifest $(1).manifest && \
- rm -f $(1).manifest
+MERGEMANIFEST=test ! -f $(1).manifest || mt -nologo -outputresource:$(1) -manifest $(1).manifest && rm -f $(1).manifest
+#ml let mergemanifest out = Printf.sprintf "test ! -f %s.manifest || mt -nologo -outputresource:%s -manifest %s.manifest && rm -f %s.manifest" out out out out;;
### How to build an EXE
MKEXE=$(BYTECC) /Fe$(1) $(2) && ($(MERGEMANIFEST))
+#ml let mkexe out files opts = Printf.sprintf "%s /Fe%s %s %s && (%s)" bytecc out opts files (mergemanifest out);;
### How to build a DLL
MKDLL=link /nologo /dll /out:$(1) /implib:$(2) $(3) && ($(MERGEMANIFEST))
+#ml let mkdll out implib files opts = Printf.sprintf "link /nologo /dll /out:%s /implib:%s %s %s && (%s)" out implib opts files (mergemanifest out);;
### 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;;
+MKSHAREDLIBRPATH=
### Canonicalize the name of a system library
SYSLIB=$(1).lib
+#ml let syslib x = x ^ ".lib";;
### The ranlib command
+RANLIB=
RANLIBCMD=
############# Configuration for the native-code compiler
diff --git a/config/Makefile.msvc64 b/config/Makefile.msvc64
index 42cffd653..8054788a3 100644
--- a/config/Makefile.msvc64
+++ b/config/Makefile.msvc64
@@ -42,6 +42,31 @@ SO=s.obj
DO=d.obj
DBGO=dbg.obj
EXE=.exe
+EXT_DLL=.dll
+EXT_OBJ=.$(O)
+EXT_LIB=.$(A)
+EXT_ASM=.$(S)
+MANEXT=1
+SHARPBANGSCRIPTS=false
+PTHREAD_LINK=
+X11_INCLUDES=
+X11_LINK=
+DBM_INCLUDES=
+DBM_LINK=
+BYTECCRPATH=
+SUPPORTS_SHARED_LIBRARIES=true
+SHAREDCCCOMPOPTS=
+NATIVECCPROFOPTS=
+NATIVECCRPATH=
+ASFLAGS=
+ASPP=
+ASPPFLAGS=
+ASPPPROFFLAGS=
+PROFILING=noprof
+DYNLINKOPTS=
+DEBUGGER=
+CC_PROFILE=
+SYSTHREAD_SUPPORT=true
########## Configuration for the bytecode compiler
diff --git a/configure b/configure
index ef7cd46bc..dd68f6e79 100755
--- a/configure
+++ b/configure
@@ -986,7 +986,7 @@ elif sh ./hasgot $dllib -ldl dlopen; then
echo "dlopen() found in -ldl."
dllib="$dllib -ldl"
else
- shared_libraries_supported=no
+ shared_libraries_supported=false
fi
if $shared_libraries_supported; then
@@ -1087,7 +1087,6 @@ if test "$pthread_wanted" = "yes"; then
nativecccompopts="$nativecccompopts -pthread";;
esac
echo "Options for linking with POSIX threads: $pthread_link"
- echo "PTHREAD_LINK=$pthread_link" >> Makefile
if sh ./hasgot $pthread_link sigwait; then
echo "sigwait() found"
echo "#define HAS_SIGWAIT" >> s.h
@@ -1096,7 +1095,10 @@ if test "$pthread_wanted" = "yes"; then
echo "POSIX threads not found."
pthread_link=""
fi
+else
+ pthread_link=""
fi
+echo "PTHREAD_LINK=$pthread_link" >> Makefile
# Determine if the bytecode thread library is supported
@@ -1240,9 +1242,9 @@ else
else
x11_include="-I$x11_include"
fi
- echo "X11_INCLUDES=$x11_include" >> Makefile
- echo "X11_LINK=$x11_link" >> Makefile
fi
+echo "X11_INCLUDES=$x11_include" >> Makefile
+echo "X11_LINK=$x11_link" >> Makefile
# See if we can compile the dbm library
@@ -1284,13 +1286,13 @@ else
else
dbm_include="-I$dbm_include"
fi
- echo "DBM_INCLUDES=$dbm_include" >> Makefile
- echo "DBM_LINK=$dbm_link" >> Makefile
if test "$use_gdbm_ndbm" = "yes"; then
echo "#define DBM_USES_GDBM_NDBM" >> s.h
fi
otherlibraries="$otherlibraries dbm"
fi
+echo "DBM_INCLUDES=$dbm_include" >> Makefile
+echo "DBM_LINK=$dbm_link" >> Makefile
# Look for tcl/tk
@@ -1406,6 +1408,8 @@ if test $has_tk = true; then
otherlibraries="$otherlibraries labltk"
else
echo "Configuration failed, LablTk will not be built."
+ echo "TK_DEFS=" >> Makefile
+ echo "TK_LINK=" >> Makefile
fi
# Final twiddling of compiler options to work around known bugs
@@ -1429,8 +1433,22 @@ echo "BYTECCRPATH=$byteccrpath" >> Makefile
echo "EXE=$exe" >> Makefile
echo "SUPPORTS_SHARED_LIBRARIES=$shared_libraries_supported" >> Makefile
echo "SHAREDCCCOMPOPTS=$sharedcccompopts" >> Makefile
-echo "MKSHAREDLIB=$mksharedlib" >> Makefile
echo "MKSHAREDLIBRPATH=$mksharedlibrpath" >> Makefile
+cat >> Makefile <<EOF
+SYSLIB=-l\$(1)
+#ml let syslib x = \"-l\"^x;;
+
+MKEXE=\$(BYTECC) -o \$(1) \$(2)
+#ml let mkexe out files opts = Printf.sprintf "%s -o %s %s %s" bytecc out opts files;;
+
+### How to build a DLL
+MKDLL=$mksharedlib \$(1) \$(3)
+#ml let mkdll out _implib files opts = Printf.sprintf "%s %s %s %s" "$mksharedlib" out opts files;;
+
+### How to build a static library
+MKLIB=ar rc \$(1) \$(2); ranlib \$(1)
+#ml let mklib out files opts = Printf.sprintf "ar rc %s %s %s; ranlib %s" out opts files out;;
+EOF
echo "ARCH=$arch" >> Makefile
echo "MODEL=$model" >> Makefile
echo "SYSTEM=$system" >> Makefile
@@ -1449,8 +1467,18 @@ echo "DYNLINKOPTS=$dllib" >> Makefile
echo "OTHERLIBRARIES=$otherlibraries" >> Makefile
echo "DEBUGGER=$debugger" >> Makefile
echo "CC_PROFILE=$cc_profile" >> Makefile
-echo "SYSTHREAD_SUPPORT=$systhread_support" >>Makefile
-echo "PARTIALLD=$partialld" >>Makefile
+echo "SYSTHREAD_SUPPORT=$systhread_support" >> Makefile
+echo "PARTIALLD=$partialld" >> Makefile
+echo "DLLCCCOMPOPTS=" >> Makefile
+echo "O=o" >> Makefile
+echo "A=a" >> Makefile
+echo "EXT_OBJ=.o" >> Makefile
+echo "EXT_ASM=.s" >> Makefile
+echo "EXT_LIB=.a" >> Makefile
+echo "EXT_DLL=.so" >> Makefile
+echo "EXTRALIBS=" >> Makefile
+echo "CCOMPTYPE=cc" >> Makefile
+echo "TOOLCHAIN=cc" >> Makefile
rm -f tst hasgot.c
rm -f ../m.h ../s.h ../Makefile
diff --git a/otherlibs/bigarray/Makefile b/otherlibs/bigarray/Makefile
index 9102b5b97..7e07815e5 100644
--- a/otherlibs/bigarray/Makefile
+++ b/otherlibs/bigarray/Makefile
@@ -54,7 +54,7 @@ partialclean:
rm -f *.cm*
clean: partialclean
- rm -f libbigarray.* *.o bigarray.a *.so
+ rm -f *.o *.so *.a
.SUFFIXES: .ml .mli .cmo .cmi .cmx
diff --git a/stdlib/Makefile.nt b/stdlib/Makefile.nt
index f29a583de..16b20142e 100644
--- a/stdlib/Makefile.nt
+++ b/stdlib/Makefile.nt
@@ -55,7 +55,7 @@ stdlib.cmxa: $(OBJS:.cmo=.cmx)
$(CAMLOPT) -a -o stdlib.cmxa $(OBJS:.cmo=.cmx)
camlheader camlheader_ur: headernt.c ../config/Makefile
- $(call MKEXE,tmpheader.exe,$(BYTECCCOMPOPTS) $(BYTECCLINKOPTS) headernt.c $(EXTRALIBS))
+ $(call MKEXE,tmpheader.exe,-I../byterun $(BYTECCCOMPOPTS) $(BYTECCLINKOPTS) headernt.c $(EXTRALIBS))
rm -f camlheader.exe
mv tmpheader.exe camlheader
cp camlheader camlheader_ur
diff --git a/stdlib/headernt.c b/stdlib/headernt.c
index 9c723bcc9..c8d23ee25 100644
--- a/stdlib/headernt.c
+++ b/stdlib/headernt.c
@@ -17,8 +17,8 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
-#include "../byterun/mlvalues.h"
-#include "../byterun/exec.h"
+#include "mlvalues.h"
+#include "exec.h"
#ifndef __MINGW32__
#pragma comment(linker , "/entry:headerentry")
diff --git a/tools/Makefile b/tools/Makefile
index f7dec5b0f..efef1d572 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -88,8 +88,13 @@ clean::
# To help building mixed-mode libraries (Caml + C)
-ocamlmklib: ocamlmklib.cmo
- $(CAMLC) $(LINKFLAGS) -o ocamlmklib ocamlmklib.cmo
+ocamlmklib: myocamlbuild_config.cmo ocamlmklib.cmo
+ $(CAMLC) $(LINKFLAGS) -o ocamlmklib myocamlbuild_config.cmo ocamlmklib.cmo
+
+ocamlmklib.cmo: myocamlbuild_config.cmi
+myocamlbuild_config.ml: ../config/Makefile
+ ../build/mkmyocamlbuild_config.sh
+ cp ../myocamlbuild_config.ml .
install::
cp ocamlmklib $(BINDIR)/ocamlmklib
diff --git a/tools/ocamlmklib.mlp b/tools/ocamlmklib.mlp
index 5a613eefe..46eeb6e7c 100644
--- a/tools/ocamlmklib.mlp
+++ b/tools/ocamlmklib.mlp
@@ -13,18 +13,11 @@
(* $Id$ *)
open Printf
-
-let bindir = "%%BINDIR%%"
-and supports_shared_libraries = %%SUPPORTS_SHARED_LIBRARIES%%
-and mksharedlib = "%%MKSHAREDLIB%%"
-and bytecc_rpath = "%%BYTECCRPATH%%"
-and nativecc_rpath = "%%NATIVECCRPATH%%"
-and mksharedlib_rpath = "%%MKSHAREDLIBRPATH%%"
-and ranlib = "%%RANLIB%%"
+open Myocamlbuild_config
let bytecode_objs = ref [] (* .cmo,.cma,.ml,.mli files to pass to ocamlc *)
and native_objs = ref [] (* .cmx,.cmxa,.ml,.mli files to pass to ocamlopt *)
-and c_objs = ref [] (* .o, .a files to pass to mksharedlib and ar *)
+and c_objs = ref [] (* .o, .a, .obj, .lib files to pass to mksharedlib and ar *)
and caml_libs = ref [] (* -cclib to pass to ocamlc, ocamlopt *)
and caml_opts = ref [] (* -ccopt to pass to ocamlc, ocamlopt *)
and dynlink = ref supports_shared_libraries
@@ -37,6 +30,7 @@ and ocamlopt = ref (Filename.concat bindir "ocamlopt")
and output = ref "a" (* Output name for Caml part of library *)
and output_c = ref "" (* Output name for C part of library *)
and rpath = ref [] (* rpath options *)
+and implib = ref "" (* windows implib flag *)
and verbose = ref false
let starts_with s pref =
@@ -69,7 +63,7 @@ let parse_arguments argv =
else if ends_with s ".ml" || ends_with s ".mli" then
(bytecode_objs := s :: !bytecode_objs;
native_objs := s :: !native_objs)
- else if ends_with s ".o" || ends_with s ".a" then
+ else if List.exists (ends_with s) [".o"; ".a"; ".obj"; ".lib"] then
c_objs := s :: !c_objs
else if s = "-cclib" then
caml_libs := next_arg () :: "-cclib" :: !caml_libs
@@ -77,6 +71,8 @@ let parse_arguments argv =
caml_opts := next_arg () :: "-ccopt" :: !caml_opts
else if s = "-custom" then
dynlink := false
+ else if s = "-implib" then
+ implib := next_arg ()
else if s = "-I" then
caml_opts := next_arg () :: "-I" :: !caml_opts
else if s = "-failsafe" then
@@ -135,7 +131,7 @@ let parse_arguments argv =
if !output_c = "" then output_c := !output
let usage = "\
-Usage: ocamlmklib [options] <.cmo|.cma|.cmx|.cmxa|.ml|.mli|.o|.a files>
+Usage: ocamlmklib [options] <.cmo|.cma|.cmx|.cmxa|.ml|.mli|.o|.a|.obj|.lib files>
Options are:
-cclib <lib> C library passed to ocamlc -a or ocamlopt -a only
-ccopt <opt> C option passed to ocamlc -a or ocamlopt -a only
@@ -202,25 +198,20 @@ let build_libs () =
if !c_objs <> [] then begin
if !dynlink then begin
let retcode = command
- (sprintf "%s %s %s %s %s %s %s"
- mksharedlib
- (prepostfix "dll" !output_c ".so")
+ (mkdll (prepostfix "dll" !output_c ext_dll)
+ !implib
+ (sprintf "%s %s %s %s %s"
(String.concat " " !c_objs)
(String.concat " " !c_opts)
(String.concat " " !ld_opts)
- (make_rpath mksharedlib_rpath)
- (String.concat " " !c_libs)) in
+ (make_rpath mksharedlibrpath)
+ (String.concat " " !c_libs)) "") in
if retcode <> 0 then if !failsafe then dynlink := false else exit 2
end;
- safe_remove (prepostfix "lib" !output_c ".a");
- scommand
- (sprintf "ar rc %s %s"
- (prepostfix "lib" !output_c ".a")
- (String.concat " " !c_objs));
+ safe_remove (prepostfix "lib" !output_c ext_lib);
scommand
- (sprintf "%s %s"
- ranlib
- (prepostfix "lib" !output_c ".a"))
+ (mklib (prepostfix "lib" !output_c ext_lib)
+ (String.concat " " !c_objs) "");
end;
if !bytecode_objs <> [] then
scommand
@@ -230,10 +221,10 @@ let build_libs () =
!output
(String.concat " " !caml_opts)
(String.concat " " !bytecode_objs)
- !output_c
- !output_c
+ (Filename.basename !output_c)
+ (Filename.basename !output_c)
(String.concat " " (prefix_list "-ccopt " !c_opts))
- (make_rpath_ccopt bytecc_rpath)
+ (make_rpath_ccopt byteccrpath)
(String.concat " " (prefix_list "-cclib " !c_libs))
(String.concat " " !caml_libs));
if !native_objs <> [] then
@@ -243,9 +234,9 @@ let build_libs () =
!output
(String.concat " " !caml_opts)
(String.concat " " !native_objs)
- !output_c
+ (Filename.basename !output_c)
(String.concat " " (prefix_list "-ccopt " !c_opts))
- (make_rpath_ccopt nativecc_rpath)
+ (make_rpath_ccopt nativeccrpath)
(String.concat " " (prefix_list "-cclib " !c_libs))
(String.concat " " !caml_libs))