summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2006-09-23 08:51:31 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2006-09-23 08:51:31 +0000
commit8d3d91b9a3eef4368b6d12989db65283078071ad (patch)
treec6c7161b4c91509100694a355705d611fbaebaac
parente577031fa6ef39b66dc70d974aa4496fb7d7dd48 (diff)
Attempt to support Visual C++ 2005. Remain to be tested.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7636 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--asmcomp/asmlink.ml24
-rw-r--r--bytecomp/bytelink.ml11
-rw-r--r--config/Makefile.mingw6
-rw-r--r--config/Makefile.msvc14
-rw-r--r--config/Makefile.msvc6416
-rw-r--r--stdlib/Makefile.nt2
-rw-r--r--utils/ccomp.ml13
-rw-r--r--utils/ccomp.mli1
-rw-r--r--yacc/Makefile.nt2
9 files changed, 58 insertions, 31 deletions
diff --git a/asmcomp/asmlink.ml b/asmcomp/asmlink.ml
index 891ac927f..f0b297c9a 100644
--- a/asmcomp/asmlink.ml
+++ b/asmcomp/asmlink.ml
@@ -229,9 +229,9 @@ let call_linker file_list startup_file output_name =
raise(Error(File_not_found libname)) in
let c_lib =
if !Clflags.nopervasives then "" else Config.native_c_libraries in
- let cmd =
- match Config.ccomp_type with
- "cc" ->
+ match Config.ccomp_type with
+ | "cc" ->
+ let cmd =
if not !Clflags.output_c_object then
Printf.sprintf "%s %s -o %s %s %s %s %s %s %s %s %s"
!Clflags.c_linker
@@ -253,8 +253,10 @@ let call_linker file_list startup_file output_name =
(Filename.quote output_name)
(Filename.quote startup_file)
(Ccomp.quote_files (List.rev file_list))
- | "msvc" ->
- if not !Clflags.output_c_object then
+ in if Ccomp.command cmd <> 0 then raise(Error Linking_error)
+ | "msvc" ->
+ if not !Clflags.output_c_object then begin
+ let cmd =
Printf.sprintf "%s /Fe%s %s %s %s %s %s %s %s"
!Clflags.c_linker
(Filename.quote output_name)
@@ -265,15 +267,19 @@ let call_linker file_list startup_file output_name =
(List.rev_map Ccomp.expand_libname !Clflags.ccobjs))
(Filename.quote runtime_lib)
c_lib
- (Ccomp.make_link_options !Clflags.ccopts)
- else
+ (Ccomp.make_link_options !Clflags.ccopts) in
+ if Ccomp.command cmd <> 0 then raise(Error Linking_error);
+ if Ccomp.merge_manifest output_name <> 0 then raise(Error Linking_error)
+ end else begin
+ let cmd =
Printf.sprintf "%s /out:%s %s %s"
Config.native_partial_linker
(Filename.quote output_name)
(Filename.quote startup_file)
(Ccomp.quote_files (List.rev file_list))
- | _ -> assert false
- in if Ccomp.command cmd <> 0 then raise(Error Linking_error)
+ in if Ccomp.command cmd <> 0 then raise(Error Linking_error)
+ end
+ | _ -> assert false
let object_file_name name =
let file_name =
diff --git a/bytecomp/bytelink.ml b/bytecomp/bytelink.ml
index 135ae2bc2..7d72038a7 100644
--- a/bytecomp/bytelink.ml
+++ b/bytecomp/bytelink.ml
@@ -428,13 +428,6 @@ void caml_startup(char ** argv)
(* Build a custom runtime *)
-let rec extract suffix l =
- match l with
- | [] -> []
- | h::t when Filename.check_suffix h suffix -> h :: (extract suffix t)
- | h::t -> extract suffix t
-;;
-
let build_custom_runtime prim_name exec_name =
match Config.ccomp_type with
"cc" ->
@@ -469,7 +462,9 @@ let build_custom_runtime prim_name exec_name =
file is created in the current working directory. *)
remove_file
(Filename.chop_suffix (Filename.basename prim_name) ".c" ^ ".obj");
- retcode
+ if retcode <> 0
+ then retcode
+ else Ccomp.merge_manifest exec_name
| _ -> assert false
let append_bytecode_and_cleanup bytecode_name exec_name prim_name =
diff --git a/config/Makefile.mingw b/config/Makefile.mingw
index 8861b104a..784db9d65 100644
--- a/config/Makefile.mingw
+++ b/config/Makefile.mingw
@@ -63,6 +63,9 @@ NATIVECCLIBS=
### How to invoke the C preprocessor
CPP=$(BYTECC) -E
+### How to build an EXE
+MKEXE=$(BYTECC) -o $(1) $(2)
+
### How to build a DLL
MKDLL=$(BYTECC) -shared -o $(1) -Wl,--out-implib,$(2) $(3)
@@ -72,9 +75,6 @@ MKLIB=rm -f $(1); ar rcs $(1) $(2)
### Canonicalize the name of a system library
SYSLIB=-l$(1)
-### Specify the name of the generated executable when calling the C compiler
-OUTPUTEXE=-o $(1)
-
### The ranlib command
RANLIBCMD=ranlib
diff --git a/config/Makefile.msvc b/config/Makefile.msvc
index fa1787f32..017e98275 100644
--- a/config/Makefile.msvc
+++ b/config/Makefile.msvc
@@ -63,8 +63,17 @@ NATIVECCLIBS=advapi32.lib
### How to invoke the C preprocessor
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
+
+### How to build an EXE
+MKEXE=$(BYTECC) /Fe$(1) $(2) && ($(MERGEMANIFEST))
+
### How to build a DLL
-MKDLL=link /nologo /dll /out:$(1) /implib:$(2) $(3)
+MKDLL=link /nologo /dll /out:$(1) /implib:$(2) $(3) && ($(MERGEMANIFEST))
### How to build a static library
MKLIB=link /lib /nologo /out:$(1) $(2)
@@ -72,9 +81,6 @@ MKLIB=link /lib /nologo /out:$(1) $(2)
### Canonicalize the name of a system library
SYSLIB=$(1).lib
-### Specify the name of the generated executable when calling the C compiler
-OUTPUTEXE=/Fe$(1)
-
### The ranlib command
RANLIBCMD=
diff --git a/config/Makefile.msvc64 b/config/Makefile.msvc64
index 2ea28441a..90420f87b 100644
--- a/config/Makefile.msvc64
+++ b/config/Makefile.msvc64
@@ -46,7 +46,7 @@ EXE=.exe
########## Configuration for the bytecode compiler
### Which C compiler to use for the bytecode interpreter.
-BYTECC=cl /nologo
+BYTECC=cl /nologo -D_CRT_SECURE_NO_DEPRECATE
### Additional compile-time options for $(BYTECC). (For static linking.)
BYTECCCOMPOPTS=/Ox /MT
@@ -68,8 +68,17 @@ NATIVECCLIBS=advapi32.lib $(EXTRALIBS)
### How to invoke the C preprocessor
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
+
+### How to build an EXE
+MKEXE=$(BYTECC) /Fe$(1) $(2) && ($(MERGEMANIFEST))
+
### How to build a DLL
-MKDLL=link /nologo /dll /machine:AMD64 /out:$(1) /implib:$(2) $(3) $(EXTRALIBS)
+MKDLL=link /nologo /dll /machine:AMD64 /out:$(1) /implib:$(2) $(3) $(EXTRALIBS) && ($(MERGEMANIFEST))
### How to build a static library
MKLIB=link /lib /nologo /machine:AMD64 /out:$(1) $(2)
@@ -77,9 +86,6 @@ MKLIB=link /lib /nologo /machine:AMD64 /out:$(1) $(2)
### Canonicalize the name of a system library
SYSLIB=$(1).lib
-### Specify the name of the generated executable when calling the C compiler
-OUTPUTEXE=/Fe$(1)
-
### The ranlib command
RANLIBCMD=
diff --git a/stdlib/Makefile.nt b/stdlib/Makefile.nt
index cc2fbb4f2..3d9e6c443 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
- $(BYTECC) $(BYTECCCOMPOPTS) $(BYTECCLINKOPTS) $(call OUTPUTEXE,tmpheader.exe) headernt.c $(EXTRALIBS)
+ $(call MKEXE,tmpheader.exe,$(BYTECCCOMPOPTS) $(BYTECCLINKOPTS) headernt.c $(EXTRALIBS))
rm -f camlheader.exe
mv tmpheader.exe camlheader
cp camlheader camlheader_ur
diff --git a/utils/ccomp.ml b/utils/ccomp.ml
index 1d35dced7..fe8c0034a 100644
--- a/utils/ccomp.ml
+++ b/utils/ccomp.ml
@@ -97,3 +97,16 @@ let make_link_options optlist =
otheropts rem
else split linkopts (opt :: otheropts) rem
in split [] [] optlist
+
+(* Handling of Visual C++ 2005 manifest files *)
+
+let merge_manifest exefile =
+ let manfile = exefile ^ ".manifest" in
+ if not (Sys.file_exists manfile) then 0 else begin
+ let retcode =
+ command (Printf.sprintf "mt -nologo -outputresource:%s -manifest:%s"
+ (Filename.quote exefile)
+ (Filename.quote manfile)) in
+ Misc.remove_file manfile;
+ retcode
+ end
diff --git a/utils/ccomp.mli b/utils/ccomp.mli
index d5d49c772..22bc2e8d6 100644
--- a/utils/ccomp.mli
+++ b/utils/ccomp.mli
@@ -21,3 +21,4 @@ val create_archive: string -> string list -> int
val expand_libname: string -> string
val quote_files: string list -> string
val make_link_options: string list -> string
+val merge_manifest: string -> int
diff --git a/yacc/Makefile.nt b/yacc/Makefile.nt
index 4bd8e27b7..503237aac 100644
--- a/yacc/Makefile.nt
+++ b/yacc/Makefile.nt
@@ -23,7 +23,7 @@ OBJS= closure.$(O) error.$(O) lalr.$(O) lr0.$(O) main.$(O) \
all: ocamlyacc.exe
ocamlyacc.exe: $(OBJS)
- $(BYTECC) $(BYTECCLINKOPTS) $(call OUTPUTEXE,ocamlyacc.exe) $(OBJS) $(EXTRALIBS)
+ $(call MKEXE,ocamlyacc,exe,$(BYTECCLINKOPTS) $(OBJS) $(EXTRALIBS))
version.h : ../stdlib/sys.ml
sed -n -e 's/;;//' \