Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 900b192a8c73b3486687a74ea9dd4fa9e7f6ce50 Mon Sep 17 00:00:00 2001
- From: Serge Ziryukin <ftrvxmtrx@gmail.com>
- Date: Wed, 22 Dec 2010 13:03:28 +0200
- Subject: [PATCH] cross toolchain patch
- ---
- Makefile | 36 +++++-
- asmcomp/asmlink.ml | 4 +-
- asmcomp/asmpackager.ml | 2 +-
- asmrun/Makefile | 16 +-
- bytecomp/bytelink.ml | 4 +-
- byterun/Makefile.common | 5 +-
- config/Makefile-templ | 25 +++-
- config/auto-aux/trycompile | 6 +-
- configure | 321 ++++++++++++++++++++++-------------------
- otherlibs/Makefile.shared | 13 +-
- otherlibs/dynlink/Makefile | 2 +-
- otherlibs/labltk/lib/Makefile | 2 +-
- otherlibs/systhreads/Makefile | 10 +-
- otherlibs/threads/Makefile | 2 +-
- stdlib/Makefile | 5 +-
- tools/Makefile.shared | 1 +
- tools/ocamlmklib.mlp | 8 +-
- utils/ccomp.ml | 22 ++-
- utils/ccomp.mli | 2 +-
- utils/clflags.ml | 7 +-
- utils/clflags.mli | 1 +
- utils/config.mli | 8 +
- utils/config.mlp | 4 +
- 23 files changed, 311 insertions(+), 195 deletions(-)
- diff --git a/Makefile b/Makefile
- index e83e881..87cf45d 100644
- --- a/Makefile
- +++ b/Makefile
- @@ -261,6 +261,22 @@ opt:
- $(MAKE) otherlibrariesopt
- $(MAKE) ocamlbuildlib.native
- +# Compile the cross-compiler
- +cross:
- + cd boot && cp $(BINDIR)/ocamlrun .
- + cd byterun && cp $(BINDIR)/ocamlrun .
- + cd stdlib; $(MAKE) COMPILER=../boot/ocamlc all
- + cd stdlib; cp $(LIBFILES) ../boot
- + cd yacc; $(MAKE) all
- + cp yacc/ocamlyacc$(EXE) boot/ocamlyacc$(EXE)
- + $(MAKE) ocamlc
- + $(MAKE) ocamltools
- + $(MAKE) library
- + $(MAKE) runtimeopt
- + $(MAKE) ocamlopt
- + $(MAKE) libraryopt
- + $(MAKE) otherlibrariesopt
- +
- # Native-code versions of the tools
- opt.opt: checkstack runtime core ocaml opt-core ocamlc.opt otherlibraries \
- ocamlbuild.byte camlp4out $(DEBUGGER) ocamldoc ocamlopt.opt \
- @@ -274,7 +290,7 @@ base.opt: checkstack runtime core ocaml opt-core ocamlc.opt otherlibraries \
- # Installation
- install:
- if test -d $(BINDIR); then : ; else $(MKDIR) $(BINDIR); fi
- - if test -d $(LIBDIR); then : ; else $(MKDIR) $(LIBDIR); fi
- + if test -d $(LIBDIR)/host; then : ; else $(MKDIR) -p $(LIBDIR)/host; fi
- if test -d $(STUBLIBDIR); then : ; else $(MKDIR) $(STUBLIBDIR); fi
- if test -d $(MANDIR)/man$(MANEXT); then : ; \
- else $(MKDIR) $(MANDIR)/man$(MANEXT); fi
- @@ -306,6 +322,18 @@ install:
- BINDIR=$(BINDIR) LIBDIR=$(LIBDIR) PREFIX=$(PREFIX) \
- ./build/partial-install.sh
- +# Installation of the cross-compiler
- +installcross:
- + if test -d $(BINDIR); then : ; else $(MKDIR) $(BINDIR); fi
- + if test -d $(LIBDIR); then : ; else $(MKDIR) $(LIBDIR); fi
- + if test -d $(STUBLIBDIR); then : ; else $(MKDIR) $(STUBLIBDIR); fi
- + cd asmrun; $(MAKE) install
- + cp byterun/ocamlrun $(BINDIR)/ocamlrun$(EXE)
- + cp ocamlopt $(BINDIR)/ocamlopt$(EXE)
- + cd stdlib; $(MAKE) installopt
- + for i in $(OTHERLIBRARIES); \
- + do (cd otherlibs/$$i; $(MAKE) installopt) || exit $$?; done
- +
- # Installation of the native-code compiler
- installopt:
- cd asmrun; $(MAKE) install
- @@ -382,6 +410,7 @@ utils/config.ml: utils/config.mlp config/Makefile
- -e 's|%%BYTECCLIBS%%|$(BYTECCLIBS)|' \
- -e 's|%%NATIVECCLIBS%%|$(NATIVECCLIBS)|' \
- -e 's|%%RANLIBCMD%%|$(RANLIBCMD)|' \
- + -e 's|%%TARGETRANLIBCMD%%|$(TARGETRANLIBCMD)|' \
- -e 's|%%CC_PROFILE%%|$(CC_PROFILE)|' \
- -e 's|%%ARCH%%|$(ARCH)|' \
- -e 's|%%MODEL%%|$(MODEL)|' \
- @@ -395,6 +424,9 @@ utils/config.ml: utils/config.mlp config/Makefile
- -e 's|%%MKDLL%%|$(MKDLL)|' \
- -e 's|%%MKEXE%%|$(MKEXE)|' \
- -e 's|%%MKMAINDLL%%|$(MKMAINDLL)|' \
- + -e 's|%%TARGETMKDLL%%|$(TARGETMKDLL)|' \
- + -e 's|%%TARGETMKEXE%%|$(TARGETMKEXE)|' \
- + -e 's|%%TARGETMKMAINDLL%%|$(TARGETMKMAINDLL)|' \
- utils/config.mlp > utils/config.ml
- @chmod -w utils/config.ml
- @@ -654,7 +686,7 @@ alldepend::
- otherlibraries: ocamltools
- for i in $(OTHERLIBRARIES); do \
- - (cd otherlibs/$$i; $(MAKE) RUNTIME=$(RUNTIME) all) || exit $$?; \
- + (cd otherlibs/$$i; $(MAKE) NATIVECC="$(BYTECC)" HOST=-host RUNTIME=$(RUNTIME) all) || exit $$?; \
- done
- otherlibrariesopt:
- diff --git a/asmcomp/asmlink.ml b/asmcomp/asmlink.ml
- index 8b8cbc0..909c244 100644
- --- a/asmcomp/asmlink.ml
- +++ b/asmcomp/asmlink.ml
- @@ -251,7 +251,7 @@ let make_shared_startup_file ppf units filename =
- let call_linker_shared file_list output_name =
- - if not (Ccomp.call_linker Ccomp.Dll output_name file_list "")
- + if not (Ccomp.call_linker true Ccomp.Dll output_name file_list "")
- then raise(Error Linking_error)
- let link_shared ppf objfiles output_name =
- @@ -294,7 +294,7 @@ let call_linker file_list startup_file output_name =
- else if !Clflags.output_c_object then Ccomp.Partial
- else Ccomp.Exe
- in
- - if not (Ccomp.call_linker mode output_name files c_lib)
- + if not (Ccomp.call_linker true mode output_name files c_lib)
- then raise(Error Linking_error)
- (* Main entry point *)
- diff --git a/asmcomp/asmpackager.ml b/asmcomp/asmpackager.ml
- index fadfa49..62454e3 100644
- --- a/asmcomp/asmpackager.ml
- +++ b/asmcomp/asmpackager.ml
- @@ -104,7 +104,7 @@ let make_package_object ppf members targetobj targetname coercion =
- (fun m -> chop_extension_if_any m.pm_file ^ Config.ext_obj)
- (List.filter (fun m -> m.pm_kind <> PM_intf) members) in
- let ok =
- - Ccomp.call_linker Ccomp.Partial targetobj (objtemp :: objfiles) ""
- + Ccomp.call_linker true Ccomp.Partial targetobj (objtemp :: objfiles) ""
- in
- remove_file objtemp;
- if not ok then raise(Error Linking_error)
- diff --git a/asmrun/Makefile b/asmrun/Makefile
- index 3e37ab1..c9b1588 100644
- --- a/asmrun/Makefile
- +++ b/asmrun/Makefile
- @@ -38,13 +38,13 @@ all: libasmrun.a all-$(PROFILING)
- libasmrun.a: $(OBJS)
- rm -f libasmrun.a
- - ar rc libasmrun.a $(OBJS)
- - $(RANLIB) libasmrun.a
- + $(TARGETAR) rc libasmrun.a $(OBJS)
- + $(TARGETRANLIB) libasmrun.a
- libasmrund.a: $(DOBJS)
- rm -f libasmrund.a
- - ar rc libasmrund.a $(DOBJS)
- - $(RANLIB) libasmrund.a
- + $(TARGETAR) rc libasmrund.a $(DOBJS)
- + $(TARGETRANLIB) libasmrund.a
- all-noprof:
- @@ -52,21 +52,21 @@ all-prof: libasmrunp.a
- libasmrunp.a: $(POBJS)
- rm -f libasmrunp.a
- - ar rc libasmrunp.a $(POBJS)
- - $(RANLIB) libasmrunp.a
- + $(TARGETAR) rc libasmrunp.a $(POBJS)
- + $(TARGETRANLIB) libasmrunp.a
- install: install-default install-$(PROFILING)
- install-default:
- cp libasmrun.a $(LIBDIR)/libasmrun.a
- - cd $(LIBDIR); $(RANLIB) libasmrun.a
- + cd $(LIBDIR); $(TARGETRANLIB) libasmrun.a
- install-noprof:
- rm -f $(LIBDIR)/libasmrunp.a; ln -s libasmrun.a $(LIBDIR)/libasmrunp.a
- install-prof:
- cp libasmrunp.a $(LIBDIR)/libasmrunp.a
- - cd $(LIBDIR); $(RANLIB) libasmrunp.a
- + cd $(LIBDIR); $(TARGETRANLIB) libasmrunp.a
- power.o: power-$(SYSTEM).o
- cp power-$(SYSTEM).o power.o
- diff --git a/bytecomp/bytelink.ml b/bytecomp/bytelink.ml
- index ede7bb9..edf7a4d 100644
- --- a/bytecomp/bytelink.ml
- +++ b/bytecomp/bytelink.ml
- @@ -466,7 +466,7 @@ void caml_startup(char ** argv)\n\
- (* Build a custom runtime *)
- let build_custom_runtime prim_name exec_name =
- - Ccomp.call_linker Ccomp.Exe exec_name
- + Ccomp.call_linker false Ccomp.Exe exec_name
- ([prim_name] @ List.rev !Clflags.ccobjs @ ["-lcamlrun"])
- (Clflags.std_include_flag "-I" ^ " " ^ Config.bytecomp_c_libraries)
- @@ -546,7 +546,7 @@ let link objfiles output_name =
- if not (Filename.check_suffix output_name Config.ext_obj) then begin
- temps := obj_file :: !temps;
- if not (
- - Ccomp.call_linker Ccomp.MainDll output_name
- + Ccomp.call_linker false Ccomp.MainDll output_name
- ([obj_file] @ List.rev !Clflags.ccobjs @ ["-lcamlrun"])
- Config.bytecomp_c_libraries
- ) then raise (Error Custom_runtime);
- diff --git a/byterun/Makefile.common b/byterun/Makefile.common
- index cc75cce..2d4c72f 100755
- --- a/byterun/Makefile.common
- +++ b/byterun/Makefile.common
- @@ -43,11 +43,12 @@ all:: ocamlrun$(EXE) ld.conf libcamlrun.$(A)
- ld.conf: ../config/Makefile
- echo "$(STUBLIBDIR)" > ld.conf
- echo "$(LIBDIR)" >> ld.conf
- + echo "$(LIBDIR)/host" >> ld.conf
- install::
- cp ocamlrun$(EXE) $(BINDIR)/ocamlrun$(EXE)
- - cp libcamlrun.$(A) $(LIBDIR)/libcamlrun.$(A)
- - cd $(LIBDIR); $(RANLIB) libcamlrun.$(A)
- + cp libcamlrun.$(A) $(LIBDIR)/host/libcamlrun.$(A)
- + cd $(LIBDIR)/host; $(RANLIB) libcamlrun.$(A)
- if test -d $(LIBDIR)/caml; then : ; else mkdir $(LIBDIR)/caml; fi
- for i in $(PUBLIC_INCLUDES); do \
- sed -f ../tools/cleanup-header $$i > $(LIBDIR)/caml/$$i; \
- diff --git a/config/Makefile-templ b/config/Makefile-templ
- index dd65452..2ebe7d3 100644
- --- a/config/Makefile-templ
- +++ b/config/Makefile-templ
- @@ -82,7 +82,7 @@ SHARPBANGSCRIPTS=true
- #ml let syslib x = "-l"^x;;
- #ml let mklib out files opts = Printf.sprintf "ar rc %s %s %s; ranlib %s" out opts files out;;
- -### How to invoke ranlib
- +### How to invoke ranlib (for a 'local' library)
- RANLIB=ranlib
- RANLIBCMD=ranlib
- @@ -90,6 +90,17 @@ RANLIBCMD=ranlib
- #RANLIB=ar rs
- #RANLIBCMD=
- +### How to invoke ranlib (for a 'target' library)
- +# BSD-style:
- +#TARGETRANLIB=ranlib
- +#TARGETRANLIBCMD=ranlib
- +# If ranlib is not needed:
- +#TARGETRANLIB=ar rs
- +#TARGETRANLIBCMD=
- +
- +### How to invoke ar (for a 'target' library)
- +#TARGETAR=
- +
- ### Shared library support
- # Extension for shared libraries: so if supported, a if not supported
- #SO=so
- @@ -287,3 +298,15 @@ BNG_ASM_LEVEL=1
- #TK_LINK="-ltk8.0 -ltcl8.0"
- # For Tcl/Tk 8.0 on FreeBSD:
- #TK_LINK="-L/usr/local/lib -ltk8.0 -ltcl8.0"
- +
- +### Compilers for producing executables ('local' and 'target' ones)
- +#MKEXE=
- +#TARGETMKEXE=
- +
- +### Compilers for producing dlls ('local' and 'target' ones)
- +#MKDLL=
- +#TARGETMKDLL=
- +
- +### Compilers for producing dlls ('local' and 'target' ones)
- +#MKMAINDLL=
- +#TARGETMKMAINDLL=
- diff --git a/config/auto-aux/trycompile b/config/auto-aux/trycompile
- index 797a1c3..1ec8876 100755
- --- a/config/auto-aux/trycompile
- +++ b/config/auto-aux/trycompile
- @@ -1,7 +1,7 @@
- #!/bin/sh
- if test "$verbose" = yes; then
- -echo "trycompile: $cc -o tst $* $cclibs" >&2
- -$cc -o tst $* $cclibs || exit 100
- +echo "trycompile: $trycc -o tst $* $cclibs" >&2
- +$trycc -o tst $* $cclibs || exit 100
- else
- -$cc -o tst $* $cclibs 2> /dev/null || exit 100
- +$trycc -o tst $* $cclibs 2> /dev/null || exit 100
- fi
- diff --git a/configure b/configure
- index 56a209c..99c3c7e 100755
- --- a/configure
- +++ b/configure
- @@ -25,10 +25,12 @@ host_type=unknown
- ccoption=''
- asoption=''
- asppoption=''
- +crosscompile=''
- cclibs=''
- curseslibs=''
- mathlib='-lm'
- dllib=''
- +disablex11=no
- x11_include_dir=''
- x11_lib_dir=''
- tk_wanted=yes
- @@ -73,18 +75,22 @@ while : ; do
- shift;;
- -host*|--host*)
- host_type=$2; shift;;
- - -cc*)
- + -bytecc*)
- ccoption="$2"; shift;;
- -as)
- asoption="$2"; shift;;
- -aspp)
- asppoption="$2"; shift;;
- + -cross-compile)
- + crosscompile="$2"; shift;;
- -lib*)
- cclibs="$2 $cclibs"; shift;;
- -no-curses)
- withcurses=no;;
- -no-shared-libs)
- withsharedlibs=no;;
- + -no-x11)
- + disablex11=yes;;
- -x11include*|--x11include*)
- x11_include_dir=$2; shift;;
- -x11lib*|--x11lib*)
- @@ -187,14 +193,20 @@ echo "Configuring for a $host ..."
- if test -z "$ccoption"; then
- if sh ./searchpath gcc; then
- echo "gcc found"
- - cc=gcc
- + cc="gcc"
- else
- - cc=cc
- + cc="cc"
- fi
- else
- cc="$ccoption"
- fi
- +if test -z "$crosscompile"; then
- + trycc="$cc"
- +else
- + trycc="${crosscompile}gcc"
- +fi
- +
- # Check for buggy versions of GCC
- buggycc="no"
- @@ -332,7 +344,7 @@ esac
- # Configure compiler to use in further tests
- cc="$bytecc -O $bytecclinkopts"
- -export cc cclibs verbose
- +export trycc cc cclibs verbose
- # Check C compiler
- @@ -707,14 +719,18 @@ if $arch64; then
- esac
- fi
- -if test -z "$ccoption"; then
- - case "$arch,$system,$cc" in
- - alpha,digital,gcc*) nativecc=cc;;
- - mips,*,gcc*) nativecc=cc;;
- - *) nativecc="$bytecc";;
- - esac
- +if test -z "$crosscompile"; then
- + if test -z "$ccoption"; then
- + case "$arch,$system,$cc" in
- + alpha,digital,gcc*) nativecc=cc;;
- + mips,*,gcc*) nativecc=cc;;
- + *) nativecc="$bytecc";;
- + esac
- + else
- + nativecc="$ccoption"
- + fi
- else
- - nativecc="$ccoption"
- + nativecc="gcc"
- fi
- nativecccompopts=''
- @@ -1249,143 +1265,149 @@ fi
- x11_include="not found"
- x11_link="not found"
- -for dir in \
- - $x11_include_dir \
- - \
- - /usr/X11R7/include \
- - /usr/include/X11R7 \
- - /usr/local/X11R7/include \
- - /usr/local/include/X11R7 \
- - /opt/X11R7/include \
- - \
- - /usr/X11R6/include \
- - /usr/include/X11R6 \
- - /usr/local/X11R6/include \
- - /usr/local/include/X11R6 \
- - /opt/X11R6/include \
- - \
- - /usr/X11/include \
- - /usr/include/X11 \
- - /usr/local/X11/include \
- - /usr/local/include/X11 \
- - /opt/X11/include \
- - \
- - /usr/X11R5/include \
- - /usr/include/X11R5 \
- - /usr/local/X11R5/include \
- - /usr/local/include/X11R5 \
- - /usr/local/x11r5/include \
- - /opt/X11R5/include \
- - \
- - /usr/X11R4/include \
- - /usr/include/X11R4 \
- - /usr/local/X11R4/include \
- - /usr/local/include/X11R4 \
- - \
- - /usr/X386/include \
- - /usr/x386/include \
- - /usr/XFree86/include/X11 \
- - \
- - /usr/include \
- - /usr/local/include \
- - /usr/unsupported/include \
- - /usr/athena/include \
- - /usr/lpp/Xamples/include \
- - \
- - /usr/openwin/include \
- - /usr/openwin/share/include \
- - ; \
- -do
- - if test -f $dir/X11/X.h; then
- - x11_include=$dir
- - break
- - fi
- -done
- -
- -if test "$x11_include" = "not found"; then
- - x11_try_lib_dir=''
- -else
- - x11_try_lib_dir=`echo $x11_include | sed -e 's|include|lib|'`
- -fi
- -
- -for dir in \
- - $x11_lib_dir \
- - $x11_try_lib_dir \
- - \
- - /usr/X11R6/lib64 \
- - /usr/X11R6/lib \
- - /usr/lib/X11R6 \
- - /usr/local/X11R6/lib \
- - /usr/local/lib/X11R6 \
- - /opt/X11R6/lib \
- - \
- - /usr/X11/lib \
- - /usr/lib/X11 \
- - /usr/local/X11/lib \
- - /usr/local/lib/X11 \
- - /opt/X11/lib \
- - \
- - /usr/X11R5/lib \
- - /usr/lib/X11R5 \
- - /usr/local/X11R5/lib \
- - /usr/local/lib/X11R5 \
- - /usr/local/x11r5/lib \
- - /opt/X11R5/lib \
- - \
- - /usr/X11R4/lib \
- - /usr/lib/X11R4 \
- - /usr/local/X11R4/lib \
- - /usr/local/lib/X11R4 \
- - \
- - /usr/X386/lib \
- - /usr/x386/lib \
- - /usr/XFree86/lib/X11 \
- - \
- - /usr/lib64 \
- - /usr/lib \
- - /usr/local/lib \
- - /usr/unsupported/lib \
- - /usr/athena/lib \
- - /usr/lpp/Xamples/lib \
- - /lib/usr/lib/X11 \
- - \
- - /usr/openwin/lib \
- - /usr/openwin/share/lib \
- - ; \
- -do
- - if test -f $dir/libX11.a || \
- - test -f $dir/libX11.so || \
- - test -f $dir/libX11.dll.a || \
- - test -f $dir/libX11.dylib || \
- - test -f $dir/libX11.sa; then
- - if test $dir = /usr/lib; then
- - x11_link="-lX11"
- +if test "$disablex11" = "no"; then
- + for dir in \
- + $x11_include_dir \
- + \
- + /usr/X11R7/include \
- + /usr/include/X11R7 \
- + /usr/local/X11R7/include \
- + /usr/local/include/X11R7 \
- + /opt/X11R7/include \
- + \
- + /usr/X11R6/include \
- + /usr/include/X11R6 \
- + /usr/local/X11R6/include \
- + /usr/local/include/X11R6 \
- + /opt/X11R6/include \
- + \
- + /usr/X11/include \
- + /usr/include/X11 \
- + /usr/local/X11/include \
- + /usr/local/include/X11 \
- + /opt/X11/include \
- + \
- + /usr/X11R5/include \
- + /usr/include/X11R5 \
- + /usr/local/X11R5/include \
- + /usr/local/include/X11R5 \
- + /usr/local/x11r5/include \
- + /opt/X11R5/include \
- + \
- + /usr/X11R4/include \
- + /usr/include/X11R4 \
- + /usr/local/X11R4/include \
- + /usr/local/include/X11R4 \
- + \
- + /usr/X386/include \
- + /usr/x386/include \
- + /usr/XFree86/include/X11 \
- + \
- + /usr/include \
- + /usr/local/include \
- + /usr/unsupported/include \
- + /usr/athena/include \
- + /usr/lpp/Xamples/include \
- + \
- + /usr/openwin/include \
- + /usr/openwin/share/include \
- + ; \
- + do
- + if test -f $dir/X11/X.h; then
- + x11_include=$dir
- + break
- + fi
- + done
- +
- + if test "$x11_include" = "not found"; then
- + x11_try_lib_dir=''
- else
- - x11_libs="-L$dir"
- - case "$host" in
- - *-*-*bsd*) x11_link="-R$dir -L$dir -lX11";;
- - *) x11_link="-L$dir -lX11";;
- - esac
- + x11_try_lib_dir=`echo $x11_include | sed -e 's|include|lib|'`
- fi
- - break
- - fi
- -done
- -
- -if test "$x11_include" = "not found" || test "$x11_link" = "not found"
- -then
- - echo "X11 not found, the \"graph\" library will not be supported."
- - x11_include=""
- + for dir in \
- + $x11_lib_dir \
- + $x11_try_lib_dir \
- + \
- + /usr/X11R6/lib64 \
- + /usr/X11R6/lib \
- + /usr/lib/X11R6 \
- + /usr/local/X11R6/lib \
- + /usr/local/lib/X11R6 \
- + /opt/X11R6/lib \
- + \
- + /usr/X11/lib \
- + /usr/lib/X11 \
- + /usr/local/X11/lib \
- + /usr/local/lib/X11 \
- + /opt/X11/lib \
- + \
- + /usr/X11R5/lib \
- + /usr/lib/X11R5 \
- + /usr/local/X11R5/lib \
- + /usr/local/lib/X11R5 \
- + /usr/local/x11r5/lib \
- + /opt/X11R5/lib \
- + \
- + /usr/X11R4/lib \
- + /usr/lib/X11R4 \
- + /usr/local/X11R4/lib \
- + /usr/local/lib/X11R4 \
- + \
- + /usr/X386/lib \
- + /usr/x386/lib \
- + /usr/XFree86/lib/X11 \
- + \
- + /usr/lib64 \
- + /usr/lib \
- + /usr/local/lib \
- + /usr/unsupported/lib \
- + /usr/athena/lib \
- + /usr/lpp/Xamples/lib \
- + /lib/usr/lib/X11 \
- + \
- + /usr/openwin/lib \
- + /usr/openwin/share/lib \
- + ; \
- + do
- + if test -f $dir/libX11.a || \
- + test -f $dir/libX11.so || \
- + test -f $dir/libX11.dll.a || \
- + test -f $dir/libX11.dylib || \
- + test -f $dir/libX11.sa; then
- + if test $dir = /usr/lib; then
- + x11_link="-lX11"
- + else
- + x11_libs="-L$dir"
- + case "$host" in
- + *-*-*bsd*) x11_link="-R$dir -L$dir -lX11";;
- + *) x11_link="-L$dir -lX11";;
- + esac
- + fi
- + break
- + fi
- + done
- +
- +
- + if test "$x11_include" = "not found" || test "$x11_link" = "not found"
- + then
- + echo "X11 not found, the \"graph\" library will not be supported."
- + x11_include=""
- + else
- + echo "Location of X11 include files: $x11_include/X11"
- + echo "Options for linking with X11: $x11_link"
- + otherlibraries="$otherlibraries graph"
- + if test "$x11_include" = "/usr/include"; then
- + x11_include=""
- + else
- + x11_include="-I$x11_include"
- + fi
- + fi
- else
- - echo "Location of X11 include files: $x11_include/X11"
- - echo "Options for linking with X11: $x11_link"
- - otherlibraries="$otherlibraries graph"
- - if test "$x11_include" = "/usr/include"; then
- x11_include=""
- - else
- - x11_include="-I$x11_include"
- - fi
- + x11_link=""
- fi
- +
- echo "X11_INCLUDES=$x11_include" >> Makefile
- echo "X11_LINK=$x11_link" >> Makefile
- @@ -1603,25 +1625,29 @@ echo "SUPPORTS_SHARED_LIBRARIES=$shared_libraries_supported" >> Makefile
- echo "SHAREDCCCOMPOPTS=$sharedcccompopts" >> Makefile
- echo "MKSHAREDLIBRPATH=$mksharedlibrpath" >> Makefile
- echo "NATDYNLINKOPTS=$natdynlinkopts" >> Makefile
- +echo "TARGETAR=${crosscompile}ar" >> Makefile
- +echo "TARGETRANLIB=${crosscompile}ranlib" >> Makefile
- cat >> Makefile <<EOF
- SYSLIB=-l\$(1)
- #ml let syslib x = "-l"^x;;
- ### How to build a static library
- +TARGETMKLIB=\$(TARGETAR) rc \$(1) \$(2); \$(TARGETRANLIB) \$(1)
- +#ml let targetmklib out files opts = Printf.sprintf "${crosscompile}ar rc %s %s %s; ${crosscompile}ranlib %s" out opts files out;;
- 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
- -echo "NATIVECC=$nativecc" >> Makefile
- +echo "NATIVECC=${crosscompile}$nativecc" >> Makefile
- echo "NATIVECCCOMPOPTS=$nativecccompopts" >> Makefile
- echo "NATIVECCPROFOPTS=$nativeccprofopts" >> Makefile
- echo "NATIVECCLINKOPTS=$nativecclinkopts" >> Makefile
- echo "NATIVECCRPATH=$nativeccrpath" >> Makefile
- echo "NATIVECCLIBS=$cclibs $dllib" >> Makefile
- -echo "ASM=$as" >> Makefile
- -echo "ASPP=$aspp" >> Makefile
- +echo "ASM=${crosscompile}$as" >> Makefile
- +echo "ASPP=${crosscompile}$aspp" >> Makefile
- echo "ASPPPROFFLAGS=$asppprofflags" >> Makefile
- echo "PROFILING=$profiling" >> Makefile
- echo "DYNLINKOPTS=$dllib" >> Makefile
- @@ -1629,7 +1655,7 @@ 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 "PARTIALLD=${crosscompile}$partialld" >> Makefile
- echo "PACKLD=\$(PARTIALLD) \$(NATIVECCLINKOPTS) -o " \
- | sed -e 's/ $/\\ /' >> Makefile
- echo "DLLCCCOMPOPTS=$dllccompopts" >> Makefile
- @@ -1647,8 +1673,11 @@ echo "TOOLCHAIN=cc" >> Makefile
- echo "NATDYNLINK=$natdynlink" >> Makefile
- echo "CMXS=$cmxs" >> Makefile
- echo "MKEXE=$mkexe" >> Makefile
- +echo "TARGETMKEXE=${crosscompile}gcc" >> Makefile
- echo "MKDLL=$mksharedlib" >> Makefile
- +echo "TARGETMKDLL=${crosscompile}gcc -shared" >> Makefile
- echo "MKMAINDLL=$mkmaindll" >> Makefile
- +echo "TARGETMKMAINDLL=${crosscompile}gcc -shared" >> Makefile
- rm -f tst hasgot.c
- rm -f ../m.h ../s.h ../Makefile
- diff --git a/otherlibs/Makefile.shared b/otherlibs/Makefile.shared
- index 7e6780b..eed147b 100644
- --- a/otherlibs/Makefile.shared
- +++ b/otherlibs/Makefile.shared
- @@ -22,7 +22,7 @@ include $(ROOTDIR)/config/Makefile
- CC=$(BYTECC)
- CAMLRUN=$(ROOTDIR)/boot/ocamlrun
- COMPFLAGS=-warn-error A -g $(EXTRACAMLFLAGS)
- -MKLIB=$(CAMLRUN) $(ROOTDIR)/tools/ocamlmklib
- +MKLIB=$(CAMLRUN) $(ROOTDIR)/tools/ocamlmklib $(HOST)
- # Variables to be defined by individual libraries:
- #LIBNAME=
- @@ -59,14 +59,15 @@ lib$(CLIBNAME).$(A): $(COBJS)
- install::
- if test -f dll$(CLIBNAME)$(EXT_DLL); then \
- cp dll$(CLIBNAME)$(EXT_DLL) $(STUBLIBDIR)/; fi
- - cp lib$(CLIBNAME).$(A) $(LIBDIR)/
- - cd $(LIBDIR); $(RANLIB) lib$(CLIBNAME).$(A)
- + cp lib$(CLIBNAME).$(A) $(LIBDIR)/host/
- + cd $(LIBDIR)/host; $(RANLIB) lib$(CLIBNAME).$(A)
- cp $(LIBNAME).cma $(CMIFILES) $(CMIFILES:.cmi=.mli) $(LIBDIR)/
- if test -n "$(HEADERS)"; then cp $(HEADERS) $(LIBDIR)/caml/; fi
- installopt:
- - cp $(CAMLOBJS_NAT) $(LIBNAME).cmxa $(LIBNAME).$(A) $(LIBDIR)/
- - cd $(LIBDIR); $(RANLIB) $(LIBNAME).a
- + cp $(CAMLOBJS_NAT) $(LIBNAME).cmxa $(LIBNAME).$(A) $(CMIFILES) \
- + $(CMIFILES:.cmi=.mli) lib$(CLIBNAME).$(A) $(LIBDIR)/
- + cd $(LIBDIR); $(TARGETRANLIB) $(LIBNAME).a; $(TARGETRANLIB) lib$(CLIBNAME).$(A)
- if test -f $(LIBNAME).cmxs; then cp $(LIBNAME).cmxs $(LIBDIR)/; fi
- partialclean:
- @@ -87,4 +88,4 @@ clean:: partialclean
- $(CAMLOPT) -c $(COMPFLAGS) $<
- .c.$(O):
- - $(BYTECC) $(BYTECCCOMPOPTS) $(CFLAGS) -c $<
- + $(NATIVECC) $(BYTECCCOMPOPTS) $(CFLAGS) -c $<
- diff --git a/otherlibs/dynlink/Makefile b/otherlibs/dynlink/Makefile
- index 3da485f..71c9b8b 100644
- --- a/otherlibs/dynlink/Makefile
- +++ b/otherlibs/dynlink/Makefile
- @@ -72,7 +72,7 @@ install:
- installopt:
- if $(NATDYNLINK); then \
- cp $(NATOBJS) dynlink.cmxa dynlink.$(A) $(LIBDIR) && \
- - cd $(LIBDIR) && $(RANLIB) dynlink.$(A); \
- + cd $(LIBDIR) && $(TARGETRANLIB) dynlink.$(A); \
- fi
- partialclean:
- diff --git a/otherlibs/labltk/lib/Makefile b/otherlibs/labltk/lib/Makefile
- index b82bcdd..9cff7b5 100644
- --- a/otherlibs/labltk/lib/Makefile
- +++ b/otherlibs/labltk/lib/Makefile
- @@ -78,6 +78,6 @@ install:
- installopt:
- @if test -d $(INSTALLDIR); then : ; else mkdir $(INSTALLDIR); fi
- cp $(LIBNAME).cmxa $(LIBNAME).$(A) $(INSTALLDIR)
- - cd $(INSTALLDIR); $(RANLIB) $(LIBNAME).$(A)
- + cd $(INSTALLDIR); $(TARGETRANLIB) $(LIBNAME).$(A)
- chmod 644 $(INSTALLDIR)/$(LIBNAME).cmxa
- chmod 644 $(INSTALLDIR)/$(LIBNAME).$(A)
- diff --git a/otherlibs/systhreads/Makefile b/otherlibs/systhreads/Makefile
- index f5c80c0..075ce7a 100644
- --- a/otherlibs/systhreads/Makefile
- +++ b/otherlibs/systhreads/Makefile
- @@ -17,7 +17,7 @@ include ../../config/Makefile
- CAMLC=../../ocamlcomp.sh -I ../unix
- CAMLOPT=../../ocamlcompopt.sh -I ../unix
- -MKLIB=../../boot/ocamlrun ../../tools/ocamlmklib
- +MKLIB=../../boot/ocamlrun ../../tools/ocamlmklib $(HOST)
- COMPFLAGS=-warn-error A -g
- BYTECODE_C_OBJS=st_stubs_b.o
- @@ -71,8 +71,8 @@ clean: partialclean
- install:
- if test -f dllthreads.so; then cp dllthreads.so $(STUBLIBDIR)/dllthreads.so; fi
- - cp libthreads.a $(LIBDIR)/libthreads.a
- - cd $(LIBDIR); $(RANLIB) libthreads.a
- + cp libthreads.a $(LIBDIR)/host/libthreads.a
- + cd $(LIBDIR)/host; $(RANLIB) libthreads.a
- if test -d $(LIBDIR)/threads; then :; else mkdir $(LIBDIR)/threads; fi
- cp $(THREAD_OBJS:.cmo=.cmi) threads.cma $(LIBDIR)/threads
- rm -f $(LIBDIR)/threads/stdlib.cma
- @@ -81,9 +81,9 @@ install:
- installopt:
- cp libthreadsnat.a $(LIBDIR)/libthreadsnat.a
- - cd $(LIBDIR); $(RANLIB) libthreadsnat.a
- + cd $(LIBDIR); $(TARGETRANLIB) libthreadsnat.a
- cp $(THREAD_OBJS:.cmo=.cmx) threads.cmxa threads.a $(LIBDIR)/threads
- - cd $(LIBDIR)/threads; $(RANLIB) threads.a
- + cd $(LIBDIR)/threads; $(TARGETRANLIB) threads.a
- .SUFFIXES: .ml .mli .cmo .cmi .cmx
- diff --git a/otherlibs/threads/Makefile b/otherlibs/threads/Makefile
- index 0e6ef86..da89aaa 100644
- --- a/otherlibs/threads/Makefile
- +++ b/otherlibs/threads/Makefile
- @@ -18,7 +18,7 @@ include ../../config/Makefile
- CC=$(BYTECC)
- CFLAGS=-I../../byterun -O $(BYTECCCOMPOPTS) $(SHAREDCCCOMPOPTS) -g
- CAMLC=../../ocamlcomp.sh -I ../unix
- -MKLIB=../../boot/ocamlrun ../../tools/ocamlmklib
- +MKLIB=../../boot/ocamlrun ../../tools/ocamlmklib $(HOST)
- COMPFLAGS=-warn-error A
- C_OBJS=scheduler.o
- diff --git a/stdlib/Makefile b/stdlib/Makefile
- index 874dcf6..734028f 100644
- --- a/stdlib/Makefile
- +++ b/stdlib/Makefile
- @@ -23,10 +23,11 @@ allopt-prof: stdlib.p.cmxa std_exit.p.cmx
- rm -f std_exit.p.cmi
- installopt: installopt-default installopt-$(PROFILING)
- + cp *.cmi *.mli *.ml $(LIBDIR)
- installopt-default:
- cp stdlib.cmxa stdlib.a std_exit.o *.cmx $(LIBDIR)
- - cd $(LIBDIR); $(RANLIB) stdlib.a
- + cd $(LIBDIR); $(TARGETRANLIB) stdlib.a
- installopt-noprof:
- rm -f $(LIBDIR)/stdlib.p.cmxa; ln -s stdlib.cmxa $(LIBDIR)/stdlib.p.cmxa
- @@ -37,7 +38,7 @@ installopt-noprof:
- installopt-prof:
- cp stdlib.p.cmxa stdlib.p.a std_exit.p.cmx std_exit.p.o $(LIBDIR)
- - cd $(LIBDIR); $(RANLIB) stdlib.p.a
- + cd $(LIBDIR); $(TARGETRANLIB) stdlib.p.a
- stdlib.p.cmxa: $(OBJS:.cmo=.p.cmx)
- $(CAMLOPT) -a -o stdlib.p.cmxa $(OBJS:.cmo=.p.cmx)
- diff --git a/tools/Makefile.shared b/tools/Makefile.shared
- index 12bf76f..8d4c32d 100644
- --- a/tools/Makefile.shared
- +++ b/tools/Makefile.shared
- @@ -112,6 +112,7 @@ ocamlmklib.ml: ocamlmklib.mlp ../config/Makefile
- -e "s|%%NATIVECCRPATH%%|$(NATIVECCRPATH)|" \
- -e "s|%%MKSHAREDLIBRPATH%%|$(MKSHAREDLIBRPATH)|" \
- -e "s|%%RANLIB%%|$(RANLIB)|" \
- + -e "s|%%TARGETRANLIB%%|$(TARGETRANLIB)|" \
- ocamlmklib.mlp >> ocamlmklib.ml
- beforedepend:: ocamlmklib.ml
- diff --git a/tools/ocamlmklib.mlp b/tools/ocamlmklib.mlp
- index 737749c..7cb7217 100644
- --- a/tools/ocamlmklib.mlp
- +++ b/tools/ocamlmklib.mlp
- @@ -36,6 +36,7 @@ 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 verbose = ref false
- +and host = ref false
- let starts_with s pref =
- String.length s >= String.length pref &&
- @@ -119,6 +120,8 @@ let parse_arguments argv =
- rpath := chop_prefix s "-Wl,-R" :: !rpath
- else if s = "-v" || s = "-verbose" then
- verbose := true
- + else if s = "-host" then
- + host := true
- else if s = "-version" then
- print_version ()
- else if s = "-vnum" then
- @@ -223,7 +226,7 @@ let build_libs () =
- if !dynlink then begin
- let retcode = command
- (Printf.sprintf "%s -o %s %s %s %s %s %s"
- - mkdll
- + (if !host then mkdll else targetmkdll)
- (prepostfix "dll" !output_c ext_dll)
- (String.concat " " !c_objs)
- (String.concat " " !c_opts)
- @@ -236,7 +239,8 @@ let build_libs () =
- end;
- safe_remove (prepostfix "lib" !output_c ext_lib);
- scommand
- - (mklib (prepostfix "lib" !output_c ext_lib)
- + ((if !host then mklib else targetmklib)
- + (prepostfix "lib" !output_c ext_lib)
- (String.concat " " !c_objs) "");
- end;
- if !bytecode_objs <> [] then
- diff --git a/utils/ccomp.ml b/utils/ccomp.ml
- index 94a2921..2e27343 100644
- --- a/utils/ccomp.ml
- +++ b/utils/ccomp.ml
- @@ -53,7 +53,7 @@ let quote_optfile = function
- let compile_file name =
- command
- (Printf.sprintf
- - "%s -c %s %s %s %s"
- + "%s -c %s %s %s %s %s"
- (match !Clflags.c_compiler with
- | Some cc -> cc
- | None ->
- @@ -63,6 +63,9 @@ let compile_file name =
- (String.concat " " (List.rev !Clflags.ccopts))
- (quote_prefixed "-I" (List.rev !Clflags.include_dirs))
- (Clflags.std_include_flag "-I")
- + (if !Clflags.native_code
- + then Clflags.std_include_flag "-I"
- + else Clflags.std_host_include_flag "-I")
- (Filename.quote name))
- let create_archive archive file_list =
- @@ -98,7 +101,7 @@ type link_mode =
- | MainDll
- | Partial
- -let call_linker mode output_name files extra =
- +let call_linker target mode output_name files extra =
- let files = quote_files files in
- let cmd =
- if mode = Partial then
- @@ -109,12 +112,15 @@ let call_linker mode output_name files extra =
- extra
- else
- Printf.sprintf "%s -o %s %s %s %s %s %s %s"
- - (match !Clflags.c_compiler, mode with
- - | Some cc, _ -> cc
- - | None, Exe -> Config.mkexe
- - | None, Dll -> Config.mkdll
- - | None, MainDll -> Config.mkmaindll
- - | None, Partial -> assert false
- + (match !Clflags.c_compiler, mode, target with
- + | Some cc, _, _ -> cc
- + | None, Exe, false -> Config.mkexe
- + | None, Dll, false -> Config.mkdll
- + | None, MainDll, false -> Config.mkmaindll
- + | None, Exe, true -> Config.target_mkexe
- + | None, Dll, true -> Config.target_mkdll
- + | None, MainDll, true -> Config.target_mkmaindll
- + | None, Partial, _ -> assert false
- )
- (Filename.quote output_name)
- (if !Clflags.gprofile then Config.cc_profile else "")
- diff --git a/utils/ccomp.mli b/utils/ccomp.mli
- index 72ae713..d467d82 100644
- --- a/utils/ccomp.mli
- +++ b/utils/ccomp.mli
- @@ -29,4 +29,4 @@ type link_mode =
- | MainDll
- | Partial
- -val call_linker: link_mode -> string -> string list -> string -> bool
- +val call_linker: bool -> link_mode -> string -> string list -> string -> bool
- diff --git a/utils/clflags.ml b/utils/clflags.ml
- index 1074d36..c806728 100644
- --- a/utils/clflags.ml
- +++ b/utils/clflags.ml
- @@ -86,8 +86,13 @@ let std_include_flag prefix =
- else (prefix ^ (Filename.quote Config.standard_library))
- ;;
- +let std_host_include_flag prefix =
- + if !no_std_include then ""
- + else (prefix ^ (Filename.quote Config.standard_library) ^ "/host")
- +;;
- +
- let std_include_dir () =
- - if !no_std_include then [] else [Config.standard_library]
- + if !no_std_include then [] else [Config.standard_library; Config.standard_library ^ "/host"]
- ;;
- let shared = ref false (* -shared *)
- diff --git a/utils/clflags.mli b/utils/clflags.mli
- index d5357ef..658873b 100644
- --- a/utils/clflags.mli
- +++ b/utils/clflags.mli
- @@ -73,6 +73,7 @@ val native_code : bool ref
- val inline_threshold : int ref
- val dont_write_files : bool ref
- val std_include_flag : string -> string
- +val std_host_include_flag : string -> string
- val std_include_dir : unit -> string list
- val shared : bool ref
- val dlcode : bool ref
- diff --git a/utils/config.mli b/utils/config.mli
- index da39808..3ffadf5 100644
- --- a/utils/config.mli
- +++ b/utils/config.mli
- @@ -47,6 +47,14 @@ val mkmaindll: string
- (* The linker command line to build main programs as dlls. *)
- val ranlib: string
- (* Command to randomize a library, or "" if not needed *)
- +val target_mkdll: string
- + (* The linker command line to build dynamic libraries (for 'target' platform). *)
- +val target_mkexe: string
- + (* The linker command line to build executables (for 'target' platform). *)
- +val target_mkmaindll: string
- + (* The linker command line to build main programs as dlls (for 'target' platform). *)
- +val target_ranlib: string
- + (* Command to randomize a library, or "" if not needed (for 'target' platform) *)
- val cc_profile : string
- (* The command line option to the C compiler to enable profiling. *)
- diff --git a/utils/config.mlp b/utils/config.mlp
- index 4cabf90..b2f1f6a 100644
- --- a/utils/config.mlp
- +++ b/utils/config.mlp
- @@ -44,10 +44,14 @@ let native_c_compiler = "%%NATIVECC%%"
- let native_c_libraries = "%%NATIVECCLIBS%%"
- let native_pack_linker = "%%PACKLD%%"
- let ranlib = "%%RANLIBCMD%%"
- +let target_ranlib = "%%TARGETRANLIBCMD%%"
- let cc_profile = "%%CC_PROFILE%%"
- let mkdll = "%%MKDLL%%"
- let mkexe = "%%MKEXE%%"
- let mkmaindll = "%%MKMAINDLL%%"
- +let target_mkdll = "%%TARGETMKDLL%%"
- +let target_mkexe = "%%TARGETMKEXE%%"
- +let target_mkmaindll = "%%TARGETMKMAINDLL%%"
- let exec_magic_number = "Caml1999X008"
- and cmi_magic_number = "Caml1999I012"
- --
- 1.7.3.4
Add Comment
Please, Sign In to add comment