diff options
author | Nicolas Pouillard <np@nicolaspouillard.fr> | 2010-05-11 13:34:20 +0000 |
---|---|---|
committer | Nicolas Pouillard <np@nicolaspouillard.fr> | 2010-05-11 13:34:20 +0000 |
commit | 0d72001f2ad6c686799b3391f71ef47f92aa9549 (patch) | |
tree | b6352608bc4b8e8217d0120cbd53d402701a7120 | |
parent | e9c19d4e100a3bfbc5e953b4cc1523c33b30f135 (diff) |
Merge branch 'ocaml-git/buildsys' (early part) into trunk
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10386 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | myocamlbuild.ml | 166 | ||||
-rw-r--r-- | otherlibs/bigarray/dllbigarray.dlib | 1 | ||||
-rw-r--r-- | otherlibs/num/dllnums.dlib | 1 | ||||
-rw-r--r-- | otherlibs/str/dllstr.dlib | 1 | ||||
-rw-r--r-- | otherlibs/systhreads/dllthreads.dlib | 1 | ||||
-rw-r--r-- | otherlibs/systhreads/libthreads.clib | 2 | ||||
-rw-r--r-- | otherlibs/systhreads/libthreadswin32.clib | 1 | ||||
-rw-r--r-- | otherlibs/win32graph/dllgraphics.dlib | 1 | ||||
-rw-r--r-- | otherlibs/win32unix/dllunix.dlib | 17 |
9 files changed, 45 insertions, 146 deletions
diff --git a/myocamlbuild.ml b/myocamlbuild.ml index 033f3b7f9..5e3a75e0f 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -45,30 +45,21 @@ let syscamllib x = if ccomptype = "msvc" then A(Printf.sprintf "lib%s.lib" x) else A("-l"^x) -let mkobj obj file opts = - let obj = obj-.-C.o in +let ccoutput cc obj file = if ccomptype = "msvc" then - Seq[Cmd(S[Sh C.bytecc; Sh C.bytecccompopts; opts; A"-c"; Px file]); + Seq[Cmd(S[cc; A"-c"; Px file]); mv (Pathname.basename (Pathname.update_extension C.o file)) obj] else - Cmd(S[Sh C.bytecc; Sh C.bytecccompopts; opts; A"-c"; P file; A"-o"; Px obj]) + Cmd(S[cc; A"-c"; P file; A"-o"; Px obj]) -let mkdynobj obj file opts = - let d_obj = obj-.-"d"-.-C.o in - if ccomptype = "msvc" then - Seq[Cmd(S[Sh C.bytecc; opts; Sh C.dllcccompopts; A"-c"; Px file]); - mv (Pathname.basename (Pathname.update_extension C.o file)) d_obj] - else - Cmd(S[Sh C.bytecc; opts; Sh C.dllcccompopts; A"-c"; P file; A"-o"; Px d_obj]) +let mkobj obj file opts = + let tags = tags_of_pathname file++"c"++"compile"++ccomptype in + let bytecc_with_opts = S[Sh C.bytecc; Sh C.bytecccompopts; opts; T tags] in + ccoutput bytecc_with_opts obj file let mknatobj obj file opts = - let obj = obj-.-C.o in - if ccomptype = "msvc" then - Seq[Cmd(S[Sh C.nativecc; opts; A"-c"; Px file]); - mv (Pathname.basename (Pathname.update_extension C.o file)) obj] - else - Cmd(S[Sh C.nativecc; A"-O"; opts; - Sh C.nativecccompopts; A"-c"; P file; A"-o"; Px obj]) + let nativecc_with_opts = S[Sh C.nativecc; opts; Sh C.nativecccompopts] in + ccoutput nativecc_with_opts obj file let add_exe a = if not windows || Pathname.check_extension a "exe" then a @@ -126,6 +117,11 @@ let dynlink_dir = if_mixed_dir "otherlibs/dynlink";; let str_dir = if_mixed_dir "otherlibs/str";; let toplevel_dir = if_mixed_dir "toplevel";; +let systhreads_file f = "otherlibs/systhreads"/f +let systhreads_obj f = "otherlibs/systhreads"/f-.-C.o +let systhreads_lib f = "otherlibs/systhreads"/f-.-C.a +let systhreads_dll f = "otherlibs/systhreads"/f-.-C.so + let ocamlc_solver = let native_deps = ["ocamlc.opt"; "stdlib/stdlib.cmxa"; "stdlib/std_exit.cmx"; "stdlib/std_exit"-.-C.o] in @@ -311,13 +307,6 @@ copy_rule "The thread specific unix library (mllib)" ~insert:`bottom "otherl (* Temporary rule, waiting for a full usage of ocamlbuild *) copy_rule "Temporary rule, waiting for a full usage of ocamlbuild" "%.mlbuild" "%.ml";; -if windows then - copy_rule "thread_win32.ml -> thread.ml" - "otherlibs/systhreads/thread_win32.ml" "otherlibs/systhreads/thread.ml" -else - copy_rule "thread_posix.ml -> thread.ml" - "otherlibs/systhreads/thread_posix.ml" "otherlibs/systhreads/thread.ml";; - copy_rule "graph/graphics.ml -> win32graph/graphics.ml" "otherlibs/graph/graphics.ml" "otherlibs/win32graph/graphics.ml";; copy_rule "graph/graphics.mli -> win32graph/graphics.mli" "otherlibs/graph/graphics.mli" "otherlibs/win32graph/graphics.mli";; @@ -407,17 +396,7 @@ rule "C files" ~dep:"%.c" ~insert:(`before "ocaml C stubs: c -> o") begin fun env _ -> - let c = env "%.c" in - mkobj (env "%") c (T(tags_of_pathname c++"c"++"compile"++ccomptype)) - end;; - -rule "C files for windows dynamic libraries" - ~prod:("%.d"-.-C.o) - ~dep:"%.c" - ~insert:(`before "C files") - begin fun env _ -> - let c = env "%.c" in - mkdynobj (env "%") c (T(tags_of_pathname c++"c"++"compile"++"dll"++ccomptype)) + mkobj (env ("%"-.-C.o)) (env "%.c") N end;; (* ../ is because .h files are not dependencies so they are not imported in build dir *) @@ -481,89 +460,54 @@ flag ["c"; "compile"; "otherlibs_labltk"] (S[A"-Ibyterun"; Sh C.tk_defs; Sh C.sh (* Sys threads *) -rule "posix native systhreads" - ~prod:"otherlibs/systhreads/posix_n.o" - ~dep:"otherlibs/systhreads/posix.c" - ~insert:`top - begin fun _ _ -> - Cmd(S[Sh C.nativecc; A"-O"; A"-I../asmrun"; A"-I../byterun"; - Sh C.nativecccompopts; Sh C.sharedcccompopts; - A"-DNATIVE_CODE"; A("-DTARGET_"^C.arch); A("-DSYS_"^C.system); A"-c"; - A"otherlibs/systhreads/posix.c"; A"-o"; Px"otherlibs/systhreads/posix_n.o"]) - end;; - -rule "posix bytecode systhreads" - ~prod:"otherlibs/systhreads/posix_b.o" - ~dep:"otherlibs/systhreads/posix.c" - ~insert:`top - begin fun _ _ -> - Cmd(S[Sh C.bytecc; A"-O"; A"-I../byterun"; - Sh C.bytecccompopts; Sh C.sharedcccompopts; - A"-c"; A"otherlibs/systhreads/posix.c"; A"-o"; Px"otherlibs/systhreads/posix_b.o"]) - end;; - -rule "windows native systhreads" - ~prod:("otherlibs/systhreads/win32_n"-.-C.o) - ~dep:"otherlibs/systhreads/win32.c" - ~insert:`top - begin fun _ _ -> - mknatobj "otherlibs/systhreads/win32_n" - "otherlibs/systhreads/win32.c" - (S[A"-I../asmrun"; A"-I../byterun"; A"-DNATIVE_CODE"]) - end;; +let systhreads_stubs_headers = + List.map systhreads_file + [if windows then "st_win32.h" else "st_posix.h"; "threads.h"] +;; -rule "windows bytecode static systhreads" - ~prod:("otherlibs/systhreads/win32_b"-.-C.o) - ~dep:"otherlibs/systhreads/win32.c" +rule "native systhreads" + ~prod:(systhreads_obj "st_stubs_n") + ~deps:(systhreads_file "st_stubs.c" :: systhreads_stubs_headers) ~insert:`top begin fun _ _ -> - mkobj "otherlibs/systhreads/win32_b" "otherlibs/systhreads/win32.c" - ((*A"-O"; why ? *) A"-I../byterun") + mknatobj (systhreads_obj "st_stubs_n") + (systhreads_file "st_stubs.c") + (S[A"-I../asmrun"; A"-I../byterun"; A"-Iotherlibs/systhreads"; + if windows then N else Sh C.sharedcccompopts; + A"-DNATIVE_CODE"; A("-DTARGET_"^C.arch); A("-DSYS_"^C.system)]) end;; -rule "windows bytecode dynamic systhreads" - ~prod:("otherlibs/systhreads/win32_b.d"-.-C.o) - ~dep:"otherlibs/systhreads/win32.c" +rule "bytecode systhreads" + ~prod:(systhreads_obj "st_stubs_b") + ~deps:(systhreads_file "st_stubs.c" :: systhreads_stubs_headers) ~insert:`top begin fun _ _ -> - mkdynobj "otherlibs/systhreads/win32_b" "otherlibs/systhreads/win32.c" - ((*A"-O"; why ? *) A"-I../byterun") + mkobj (systhreads_obj "st_stubs_b") (systhreads_file "st_stubs.c") + (S[A"-I../byterun"; A"-Iotherlibs/systhreads"; Sh C.sharedcccompopts]) end;; -if windows then begin - rule "windows libthreadsnat.a" - ~prod:("otherlibs/systhreads/libthreadsnat"-.-C.a) - ~dep:("otherlibs/systhreads/win32_n"-.-C.o) - ~insert:`top - begin fun _ _ -> - mklib ("otherlibs/systhreads/libthreadsnat"-.-C.a) (P("otherlibs/systhreads/win32_n"-.-C.o)) N - end -end else begin -(* Dynamic linking with -lpthread is risky on many platforms, so - do not create a shared object for libthreadsnat. *) rule "libthreadsnat.a" - ~prod:"otherlibs/systhreads/libthreadsnat.a" - ~dep:"otherlibs/systhreads/posix_n.o" + ~prod:(systhreads_lib "libthreadsnat") + ~dep:(systhreads_obj "st_stubs_n") ~insert:`top begin fun _ _ -> - mklib "otherlibs/systhreads/libthreadsnat.a" (A"otherlibs/systhreads/posix_n.o") N + if windows then + mklib (systhreads_lib "libthreadsnat") (P(systhreads_obj "st_stubs_n")) N + else + (* Dynamic linking with -lpthread is risky on many platforms, so + do not create a shared object for libthreadsnat. *) + Cmd(S[ar; A"rc"; Px(systhreads_lib "libthreadsnat"); + P(systhreads_obj "st_stubs_n")]) end; (* See remark above: force static linking of libthreadsnat.a *) -flag ["ocaml"; "link"; "library"; "otherlibs_systhreads"; "native"] begin - S[A"-cclib"; syscamllib "threadsnat"; (* A"-cclib"; syscamllib "unix"; seems to be useless and can be dangerous during bootstrap *) Sh C.pthread_link] -end; -end;; - if windows then -copy_rule "systhreads/libthreads.clib is diffrent on windows" - ~insert:`top - ("otherlibs/systhreads/libthreadswin32"-.-C.a) - ("otherlibs/systhreads/libthreads"-.-C.a);; + flag ["ocaml"; "link"; "library"; "otherlibs_systhreads"; "native"] begin + S[A"-cclib"; syscamllib "threadsnat"; (* A"-cclib"; syscamllib "unix"; seems to be useless and can be dangerous during bootstrap *) Sh C.pthread_link] + end;; flag ["ocaml"; "ocamlmklib"; "otherlibs_systhreads"] (S[(* A"-cclib"; syscamllib "unix";; seems to be useless and can be dangerous during bootstrap *) Sh C.pthread_link]);; - flag ["c"; "compile"; "otherlibs"] begin S[A"-I"; P"../byterun"; A"-I"; P(".."/unix_dir); @@ -638,28 +582,6 @@ rule "camlheader" A"cp"; A"stdlib/camlheader"; A"stdlib/camlheader_ur"]) end;; -rule "ocaml C stubs on windows: dlib & d.o* -> dll" - ~prod:"%.dll" - ~deps:["%.dlib"(*; "byterun/libcamlrun"-.-C.a*)] - ~insert:`top - begin fun env build -> - let dlib = env "%.dlib" in - let dll = env "%.dll" in - let objs = string_list_of_file dlib in - let include_dirs = Pathname.include_dirs_of (Pathname.dirname dll) in - let resluts = build begin - List.map begin fun d_o -> - List.map (fun dir -> dir / (Pathname.update_extension C.o d_o)) include_dirs - end objs - end in - let objs = List.map begin function - | Outcome.Good d_o -> d_o - | Outcome.Bad exn -> raise exn - end resluts in - mkdll dll (S[atomize objs; P("byterun/libcamlrun"-.-C.a)]) - (T(tags_of_pathname dll++"dll"++"link"++"c")) - end;; - copy_rule "win32unix use some unix files" "otherlibs/unix/%" "otherlibs/win32unix/%";; (* Temporary rule *) diff --git a/otherlibs/bigarray/dllbigarray.dlib b/otherlibs/bigarray/dllbigarray.dlib deleted file mode 100644 index 5ab811729..000000000 --- a/otherlibs/bigarray/dllbigarray.dlib +++ /dev/null @@ -1 +0,0 @@ -bigarray_stubs.d.o mmap_win32.d.o diff --git a/otherlibs/num/dllnums.dlib b/otherlibs/num/dllnums.dlib deleted file mode 100644 index e54aa8e24..000000000 --- a/otherlibs/num/dllnums.dlib +++ /dev/null @@ -1 +0,0 @@ -bng.d.o nat_stubs.d.o diff --git a/otherlibs/str/dllstr.dlib b/otherlibs/str/dllstr.dlib deleted file mode 100644 index 0c346262f..000000000 --- a/otherlibs/str/dllstr.dlib +++ /dev/null @@ -1 +0,0 @@ -strstubs.d.o diff --git a/otherlibs/systhreads/dllthreads.dlib b/otherlibs/systhreads/dllthreads.dlib deleted file mode 100644 index 40686f641..000000000 --- a/otherlibs/systhreads/dllthreads.dlib +++ /dev/null @@ -1 +0,0 @@ -win32_b.d.o diff --git a/otherlibs/systhreads/libthreads.clib b/otherlibs/systhreads/libthreads.clib index 111ec5ae2..a0582d41f 100644 --- a/otherlibs/systhreads/libthreads.clib +++ b/otherlibs/systhreads/libthreads.clib @@ -1 +1 @@ -posix_b.o +st_stubs_b.o diff --git a/otherlibs/systhreads/libthreadswin32.clib b/otherlibs/systhreads/libthreadswin32.clib deleted file mode 100644 index 51b11a2da..000000000 --- a/otherlibs/systhreads/libthreadswin32.clib +++ /dev/null @@ -1 +0,0 @@ -win32_b.o diff --git a/otherlibs/win32graph/dllgraphics.dlib b/otherlibs/win32graph/dllgraphics.dlib deleted file mode 100644 index ab0ba91b4..000000000 --- a/otherlibs/win32graph/dllgraphics.dlib +++ /dev/null @@ -1 +0,0 @@ -open.d.o draw.d.o events.d.o dib.d.o diff --git a/otherlibs/win32unix/dllunix.dlib b/otherlibs/win32unix/dllunix.dlib deleted file mode 100644 index e3ebf34e9..000000000 --- a/otherlibs/win32unix/dllunix.dlib +++ /dev/null @@ -1,17 +0,0 @@ -# Files in this directory -accept.d.o bind.d.o channels.d.o close.d.o -close_on.d.o connect.d.o createprocess.d.o dup.d.o dup2.d.o errmsg.d.o -getpeername.d.o getpid.d.o getsockname.d.o gettimeofday.d.o -link.d.o listen.d.o lockf.d.o lseek.d.o nonblock.d.o -mkdir.d.o open.d.o pipe.d.o read.d.o rename.d.o -select.d.o sendrecv.d.o -shutdown.d.o sleep.d.o socket.d.o sockopt.d.o startup.d.o stat.d.o -system.d.o unixsupport.d.o windir.d.o winwait.d.o write.d.o -winlist.d.o winworker.d.o windbug.d.o - -# Files from the ../unix directory -access.d.o addrofstr.d.o chdir.d.o chmod.d.o cst2constr.d.o -cstringv.d.o envir.d.o execv.d.o execve.d.o execvp.d.o -exit.d.o getcwd.d.o gethost.d.o gethostname.d.o getproto.d.o -getserv.d.o gmtime.d.o putenv.d.o rmdir.d.o -socketaddr.d.o strofaddr.d.o time.d.o unlink.d.o utimes.d.o |