summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Doligez <damien.doligez-inria.fr>2005-01-21 18:15:55 +0000
committerDamien Doligez <damien.doligez-inria.fr>2005-01-21 18:15:55 +0000
commit461779527fdea726bb397416264ae77cd7da458b (patch)
treee8aefdc94e05a529cf464e3c4e895bc0791c1423
parent1889817c2d76840b22af600a26c7250fd4a95419 (diff)
ajout support ocamlopt -pack pour Mac OS X
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6750 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--asmcomp/asmpackager.ml3
-rwxr-xr-xconfigure55
-rw-r--r--tools/Makefile5
-rwxr-xr-xtools/ocaml-objcopy-macosx53
4 files changed, 93 insertions, 23 deletions
diff --git a/asmcomp/asmpackager.ml b/asmcomp/asmpackager.ml
index 10ac15c5f..235fdd11f 100644
--- a/asmcomp/asmpackager.ml
+++ b/asmcomp/asmpackager.ml
@@ -85,7 +85,8 @@ let extract_symbols units symbolfile =
try
let i = 3 + (try search_substring " T " l 0 with Not_found ->
try search_substring " D " l 0 with Not_found ->
- search_substring " R " l 0) in
+ try search_substring " R " l 0 with Not_found ->
+ search_substring " S " l 0) in
let j = try search_substring "__" l i
with Not_found -> String.length l in
let k = if l.[i] = '_' then i + 1 else i in
diff --git a/configure b/configure
index 0adcea5a5..271b199f9 100755
--- a/configure
+++ b/configure
@@ -663,31 +663,41 @@ esac
# Where are GNU binutils?
binutils_objcopy=''
+binutils_install_objcopy=':'
binutils_nm=''
-if test "$arch" != "none"; then
- binutils_path="${binutils_dir}:${PATH}:/usr/libexec/binutils"
- old_IFS="$IFS"
- IFS=':'
- for d in ${binutils_path}; do
- if test -z "$d"; then continue; fi
- if test -f "$d/objcopy" && test -f "$d/nm"; then
- echo "objcopy and nm found in $d"
- if test `$d/objcopy --help | grep -s -c 'redefine-sym'` -eq 0; then
- echo "$d/objcopy does not support option --redefine-sym, discarded"
- continue;
- fi
- if test `$d/nm --version | grep -s -c 'GNU nm'` -eq 0; then
- echo "$d/nm is not from GNU binutils, discarded"
- continue;
- fi
- binutils_objcopy="$d/objcopy"
- binutils_nm="$d/nm"
- break
+case "$host" in
+ powerpc-*-darwin*)
+ binutils_objcopy='$(LIBDIR)/ocaml-objcopy'
+ binutils_install_objcopy=cp
+ binutils_nm=/usr/bin/nm
+ ;;
+ *)
+ if test "$arch" != "none"; then
+ binutils_path="${binutils_dir}:${PATH}:/usr/libexec/binutils"
+ old_IFS="$IFS"
+ IFS=':'
+ for d in ${binutils_path}; do
+ if test -z "$d"; then continue; fi
+ if test -f "$d/objcopy" && test -f "$d/nm"; then
+ echo "objcopy and nm found in $d"
+ if test `$d/objcopy --help | grep -s -c 'redefine-sym'` -eq 0; then
+ echo "$d/objcopy does not support option --redefine-sym, discarded"
+ continue;
+ fi
+ if test `$d/nm --version | grep -s -c 'GNU nm'` -eq 0; then
+ echo "$d/nm is not from GNU binutils, discarded"
+ continue;
+ fi
+ binutils_objcopy="$d/objcopy"
+ binutils_nm="$d/nm"
+ break
+ fi
+ done
+ IFS="$old_IFS"
fi
- done
- IFS="$old_IFS"
-fi
+ ;;
+esac
# Where is ranlib?
@@ -1444,6 +1454,7 @@ echo "ASPPFLAGS=$asppflags" >> Makefile
echo "ASPPPROFFLAGS=$asppprofflags" >> Makefile
echo "PROFILING=$profiling" >> Makefile
echo "BINUTILS_OBJCOPY=$binutils_objcopy" >> Makefile
+echo "BINUTILS_INSTALL_OBJCOPY=$binutils_install_objcopy" >> Makefile
echo "BINUTILS_NM=$binutils_nm" >> Makefile
echo "DYNLINKOPTS=$dllib" >> Makefile
echo "OTHERLIBRARIES=$otherlibraries" >> Makefile
diff --git a/tools/Makefile b/tools/Makefile
index 9bc1646ef..810558870 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -112,6 +112,11 @@ beforedepend:: ocamlmklib.ml
clean::
rm -f ocamlmklib.ml
+# ocamlopt -pack support for Mac OS X: objcopy emulator
+
+install::
+ $(BINUTILS_INSTALL_OBJCOPY) ocaml-objcopy-macosx $(BINUTILS_OBJCOPY)
+
# Converter olabl/ocaml 2.99 to ocaml 3
OCAML299TO3= lexer299.cmo ocaml299to3.cmo
diff --git a/tools/ocaml-objcopy-macosx b/tools/ocaml-objcopy-macosx
new file mode 100755
index 000000000..31070f54b
--- /dev/null
+++ b/tools/ocaml-objcopy-macosx
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+#########################################################################
+# #
+# Objective Caml #
+# #
+# Damien Doligez, projet Cristal, INRIA Rocquencourt #
+# #
+# Copyright 2005 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+# $Id$
+
+
+TEMP=/tmp/ocaml-objcopy-$$.o
+UNDEF=/tmp/ocaml-objcopy-$$.sym
+
+usage () {
+ echo "usage: objcopy {--redefine-sym <old>=<new>} file.o" >&2
+ exit 2
+}
+
+: > "$UNDEF"
+
+while : ; do
+ case $# in
+ 0) break;;
+ *) case $1 in
+ --redefine-sym)
+ case $2 in
+ *=*) ALIAS="$ALIAS -i${2#*=}:${2%%=*}"
+ echo ${2%%=*} >>"$UNDEF"
+ ;;
+ *) usage;;
+ esac
+ shift 2
+ ;;
+ -*) usage;;
+ *) case $FILE in
+ "") FILE=$1; shift;;
+ *) usage;;
+ esac;;
+ esac;;
+ esac
+done
+
+ld -o "$TEMP" -r $ALIAS "$FILE"
+ld -o "$FILE" -r -unexported_symbols_list "$UNDEF" "$TEMP"
+
+rm -f "$TEMP" "$UNDEF"