Skip to content

Commit

Permalink
Debut du portage Windows NT/95
Browse files Browse the repository at this point in the history
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@636 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information
xavierleroy committed Feb 15, 1996
1 parent 9843ff4 commit 84ffb16
Show file tree
Hide file tree
Showing 18 changed files with 173 additions and 168 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ utils/config.ml: utils/config.mlp config/Makefile
-e 's|%%ARCH%%|$(ARCH)|' \
-e 's|%%MODEL%%|$(MODEL)|' \
-e 's|%%SYSTEM%%|$(SYSTEM)|' \
-e 's|%%EXT_OBJ%%|.o|' \
-e 's|%%EXT_ASM%%|.s|' \
-e 's|%%EXT_LIB%%|.a|' \
utils/config.mlp > utils/config.ml
@chmod -w utils/config.ml

Expand Down
7 changes: 4 additions & 3 deletions asmcomp/asmgen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
(* From lambda to assembly code *)

open Format
open Config
open Clflags
open Misc
open Cmm
Expand Down Expand Up @@ -80,8 +81,8 @@ let compile_phrase p =
let compile_implementation prefixname lam =
let asmfile =
if !keep_asm_file
then prefixname ^ ".s"
else Filename.temp_file "camlasm" ".s" in
then prefixname ^ ext_asm
else Filename.temp_file "camlasm" ext_asm in
let oc = open_out asmfile in
begin try
Emitaux.output_channel := oc;
Expand All @@ -94,7 +95,7 @@ let compile_implementation prefixname lam =
if !keep_asm_file then () else remove_file asmfile;
raise x
end;
if Proc.assemble_file asmfile (prefixname ^ ".o") <> 0
if Proc.assemble_file asmfile (prefixname ^ ext_obj) <> 0
then raise(Error(Assembler_error asmfile));
if !keep_asm_file then () else remove_file asmfile

Expand Down
13 changes: 7 additions & 6 deletions asmcomp/asmlibrarian.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ open Compilenv

type error =
File_not_found of string
| Archiver_error
| Archiver_error of string

exception Error of error

Expand All @@ -35,18 +35,18 @@ let read_info name =
The linker, which is the only one that reads .cmxa files, does not
need the approximation. *)
info.ui_approx <- Clambda.Value_unknown;
(Filename.chop_suffix filename ".cmx" ^ ".o", (info, crc))
(Filename.chop_suffix filename ".cmx" ^ ext_obj, (info, crc))

let create_archive file_list lib_name =
let archive_name = Filename.chop_suffix lib_name ".cmxa" ^ ".a" in
let archive_name = Filename.chop_suffix lib_name ".cmxa" ^ ext_lib in
let outchan = open_out_bin lib_name in
try
output_string outchan cmxa_magic_number;
let (objfile_list, descr_list) =
List.split (List.map read_info file_list) in
output_value outchan descr_list;
if Proc.create_archive archive_name objfile_list <> 0
then raise(Error(Archiver_error));
then raise(Error(Archiver_error archive_name));
close_out outchan
with x ->
close_out outchan;
Expand All @@ -59,6 +59,7 @@ open Format
let report_error = function
File_not_found name ->
print_string "Cannot find file "; print_string name
| Archiver_error ->
print_string "Error while writing the .a file"
| Archiver_error name ->
print_string "Error while creating the library ";
print_string name

2 changes: 1 addition & 1 deletion asmcomp/asmlibrarian.mli
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ val create_archive: string list -> string -> unit

type error =
File_not_found of string
| Archiver_error
| Archiver_error of string

exception Error of error

Expand Down
55 changes: 35 additions & 20 deletions asmcomp/asmlink.ml
Original file line number Diff line number Diff line change
Expand Up @@ -164,25 +164,40 @@ let make_startup_file filename info_list =
close_out oc

let call_linker file_list startup_file =
let libname = "libasmrun" ^ ext_lib in
let runtime_lib =
try
find_in_path !load_path "libasmrun.a"
find_in_path !load_path libname
with Not_found ->
raise(Error(File_not_found "libasmrun.a")) in
if Sys.command
(Printf.sprintf
"%s -I%s -o %s %s %s %s -L%s %s %s %s"
Config.native_c_compiler
Config.standard_library
!Clflags.exec_name
(String.concat " " (List.rev !Clflags.ccopts))
(String.concat " " (List.rev file_list))
startup_file
Config.standard_library
(String.concat " " (List.rev !Clflags.ccobjs))
runtime_lib
Config.c_libraries) <> 0
then raise(Error Linking_error)
raise(Error(File_not_found libname)) in
let cmd =
match Config.system with
"win32" ->
Printf.sprintf
"%s -Fe %s -I%s %s %s %s %s %s %s"
Config.native_c_compiler
!Clflags.exec_name
Config.standard_library
(String.concat " " (List.rev !Clflags.ccopts))
(String.concat " " (List.rev file_list))
startup_file
(String.concat " " (List.rev !Clflags.ccobjs))
runtime_lib
Config.c_libraries
| _ ->
Printf.sprintf
"%s -o %s -I%s %s %s %s -L%s %s %s %s"
Config.native_c_compiler
!Clflags.exec_name
Config.standard_library
(String.concat " " (List.rev !Clflags.ccopts))
(String.concat " " (List.rev file_list))
startup_file
Config.standard_library
(String.concat " " (List.rev !Clflags.ccobjs))
runtime_lib
Config.c_libraries in
if Sys.command cmd <> 0 then raise(Error Linking_error)

let object_file_name name =
let file_name =
Expand All @@ -191,9 +206,9 @@ let object_file_name name =
with Not_found ->
fatal_error "Asmlink.object_file_name: not found" in
if Filename.check_suffix file_name ".cmx" then
Filename.chop_suffix file_name ".cmx" ^ ".o"
Filename.chop_suffix file_name ".cmx" ^ ext_obj
else if Filename.check_suffix file_name ".cmxa" then
Filename.chop_suffix file_name ".cmxa" ^ ".a"
Filename.chop_suffix file_name ".cmxa" ^ ext_lib
else
fatal_error "Asmlink.object_file_name: bad ext"

Expand All @@ -205,9 +220,9 @@ let link objfiles =
Array.iter remove_required Runtimedef.builtin_exceptions;
if not (StringSet.is_empty !missing_globals) then
raise(Error(Missing_implementations(StringSet.elements !missing_globals)));
let startup = Filename.temp_file "camlstartup" ".s" in
let startup = Filename.temp_file "camlstartup" ext_asm in
make_startup_file startup units_tolink;
let startup_obj = Filename.temp_file "camlstartup" ".o" in
let startup_obj = Filename.temp_file "camlstartup" ext_obj in
if Proc.assemble_file startup startup_obj <> 0 then
raise(Error(Assembler_error startup));
try
Expand Down
44 changes: 31 additions & 13 deletions bytecomp/bytelink.ml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ let link_bytecode objfiles exec_name copy_header =
(* The table of global data *)
let pos2 = pos_out outchan in
output_value outchan (Symtable.initial_global_table());
(* The List.map of global identifiers *)
(* The map of global identifiers *)
let pos3 = pos_out outchan in
Symtable.output_global_map outchan;
(* The trailer *)
Expand All @@ -216,6 +216,35 @@ let link_bytecode objfiles exec_name copy_header =
remove_file exec_name;
raise x

(* Build a custom runtime *)

let build_custom_runtime prim_name exec_name =
match Config.system with
"win32" ->
Sys.command
(Printf.sprintf
"%s -Fe %s -I%s %s %s %s %s\\libcamlrun.lib %s"
Config.bytecomp_c_compiler
exec_name
Config.standard_library
(String.concat " " (List.rev !Clflags.ccopts))
prim_name
(String.concat " " (List.rev !Clflags.ccobjs))
Config.standard_library
Config.c_libraries)
| _ ->
Sys.command
(Printf.sprintf
"%s -o %s -I%s %s %s -L%s %s -lcamlrun %s"
Config.bytecomp_c_compiler
exec_name
Config.standard_library
(String.concat " " (List.rev !Clflags.ccopts))
prim_name
Config.standard_library
(String.concat " " (List.rev !Clflags.ccobjs))
Config.c_libraries)

(* Main entry point (build a custom runtime if needed) *)

let link objfiles =
Expand All @@ -227,18 +256,7 @@ let link objfiles =
try
link_bytecode objfiles bytecode_name false;
Symtable.output_primitives prim_name;
if Sys.command
(Printf.sprintf
"%s -I%s -o %s %s %s -L%s %s -lcamlrun %s"
Config.bytecomp_c_compiler
Config.standard_library
!Clflags.exec_name
(String.concat " " (List.rev !Clflags.ccopts))
prim_name
Config.standard_library
(String.concat " " (List.rev !Clflags.ccobjs))
Config.c_libraries)
<> 0
if build_custom_runtime prim_name !Clflags.exec_name <> 0
then raise(Error Custom_runtime);
let oc =
open_out_gen [Open_wronly; Open_append; Open_binary] 0
Expand Down
11 changes: 6 additions & 5 deletions byterun/str.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,18 @@ value is_printable(chr) /* ML */
value chr;
{
int c;
static int iso_charset = -1;
unsigned char * printable_chars;

#ifdef _WIN32
printable_chars = printable_chars_iso;
#else
static int iso_charset = -1;
if (iso_charset == -1) {
char * lc_ctype = (char *) getenv("LC_CTYPE");
if (lc_ctype != 0 && strcmp(lc_ctype, "iso_8859_1") == 0)
iso_charset = 1;
else
iso_charset = 0;
iso_charset = (lc_ctype != 0 && strcmp(lc_ctype, "iso_8859_1") == 0);
}
printable_chars = iso_charset ? printable_chars_iso : printable_chars_ascii;
#endif
c = Int_val(chr);
return Val_bool(printable_chars[c >> 3] & (1 << (c & 7)));
}
3 changes: 2 additions & 1 deletion config/.cvsignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
m.h
s.h
Makefile.h
Makefile

16 changes: 8 additions & 8 deletions config/Makefile-templ
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ SHARPBANGSCRIPTS=true
# On most platforms:
#CCLIBS=-lcurses -ltermcap -lm

### How to invoke the C preprocessor
# On most machines:
#CPP=/lib/cpp -P
# Under Solaris:
#CPP=/usr/ccs/lib/cpp -P
# Under FreeBSD:
#CPP=cpp -P

### How to invoke ranlib
# BSD-style:
#RANLIB=ranlib
Expand Down Expand Up @@ -153,14 +161,6 @@ SHARPBANGSCRIPTS=true

############# Configuration for the contributed libraries

### How to invoke the C preprocessor
# On most machines:
#CPP=/lib/cpp -P
# Under Solaris:
#CPP=/usr/ccs/lib/cpp -P
# Under FreeBSD:
#CPP=cpp -P

### Name of the target architecture for the "num" library
# Known targets:
# 68K vax ns mips alpha pyramid i960
Expand Down
46 changes: 24 additions & 22 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ fi
echo "Checking the sizes of integers and pointers..."
set `sh runtest sizes.c`
case "$1,$2,$3" in
4,4,4) echo "OK, this is a regular 32 bit architecture.";;
4,4,4) echo "OK, this is a regular 32 bit architecture."
echo "#undef SIXTYFOUR" >> m.h;;
4,8,8) echo "Wow! A 64 bit architecture!"
echo "#define SIXTYFOUR" >> m.h;;
8,*,*) echo "Wow! A 64 bit architecture!"
Expand Down Expand Up @@ -136,7 +137,8 @@ esac

sh runtest dblalign.c
case $? in
0) echo "Doubles can be word-aligned.";;
0) echo "Doubles can be word-aligned."
echo "#undef ALIGN_DOUBLE" >> m.h;;
1) echo "Doubles must be doubleword-aligned."
echo "#define ALIGN_DOUBLE" >> m.h;;
*) echo "Something went wrong during alignment determination for doubles."
Expand Down Expand Up @@ -246,6 +248,26 @@ else
echo " assembler flags........... $asflags"
fi

# Checking how to invoke cpp

if sh ./searchpath cpp; then
cpp="cpp -P"
elif test -f /lib/cpp; then
cpp="/lib/cpp -P"
elif test -f /usr/ccs/lib/cpp; then
cpp="/usr/ccs/lib/cpp -P"
else
cpp="not found"
fi

echo "CPP=$cpp" >> Makefile

echo "How to invoke the C preprocessor: $cpp"

if test "$cpp" = "not found"; then
echo "(Please edit the generated config/Makefile to set CPP correctly)"
fi

# Where is ranlib?

if sh ./searchpath ranlib; then
Expand Down Expand Up @@ -450,26 +472,6 @@ if sh hasgot gettimeofday; then
echo "#define HAS_GETTIMEOFDAY" >> s.h
fi

# Checking how to invoke cpp

if sh ./searchpath cpp; then
cpp="cpp -P"
elif test -f /lib/cpp; then
cpp="/lib/cpp -P"
elif test -f /usr/ccs/lib/cpp; then
cpp="/usr/ccs/lib/cpp -P"
else
cpp="not found"
fi

echo "CPP=$cpp" >> Makefile

echo "How to invoke the C preprocessor: $cpp"

if test "$cpp" = "not found"; then
echo "(Please edit the generated config/Makefile to set CPP correctly)"
fi

# Determine the target architecture for the "num" library

case "$host" in
Expand Down
7 changes: 4 additions & 3 deletions driver/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

(* $Id$ *)

open Config
open Clflags

let process_file name =
Expand All @@ -24,12 +25,12 @@ let process_file name =
else if Filename.check_suffix name ".cmo"
or Filename.check_suffix name ".cma" then
objfiles := name :: !objfiles
else if Filename.check_suffix name ".o"
or Filename.check_suffix name ".a" then
else if Filename.check_suffix name ext_obj
or Filename.check_suffix name ext_lib then
ccobjs := name :: !ccobjs
else if Filename.check_suffix name ".c" then begin
Compile.c_file name;
ccobjs := (Filename.chop_suffix (Filename.basename name) ".c" ^ ".o")
ccobjs := (Filename.chop_suffix (Filename.basename name) ".c" ^ ext_obj)
:: !ccobjs
end
else
Expand Down
Loading

0 comments on commit 84ffb16

Please sign in to comment.