merge the formfield patch from ooo-build
[ooovba.git] / solenv / bin / macosx-create-bundle
blobf4cbeacc20f1de652192bed277972b28d8264530
1 #!/bin/sh
2 #*************************************************************************
4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 #
6 # Copyright 2008 by Sun Microsystems, Inc.
8 # OpenOffice.org - a multi-platform office productivity suite
10 # $RCSfile: macosx-create-bundle,v $
12 # $Revision: 1.5 $
14 # This file is part of OpenOffice.org.
16 # OpenOffice.org is free software: you can redistribute it and/or modify
17 # it under the terms of the GNU Lesser General Public License version 3
18 # only, as published by the Free Software Foundation.
20 # OpenOffice.org is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU Lesser General Public License version 3 for more details
24 # (a copy is included in the LICENSE file that accompanied this code).
26 # You should have received a copy of the GNU Lesser General Public License
27 # version 3 along with OpenOffice.org. If not, see
28 # <http://www.openoffice.org/license.html>
29 # for a copy of the LGPLv3 License.
31 #*************************************************************************
33 # Documentation
34 # -------------
36 # The purpose of this script to take Mac OS X executables and shared libraries
37 # and package them into the required Mac OS X bundle format.
39 # This script has the following usage:
40 # macosx-create-bundle file1 [file2] ... [fileN]
42 # Note that file1 through fileN can in either of the following formats:
43 # - A file name
44 # - A file name and a directory to look for missing files. To use this option,
45 # use the following format:
46 # filename=directory
48 # The file argument is the file that you want to package into a Mac OS X
49 # bundle. Currently, this script will only package executables and shared
50 # libraries.
52 # The output for each executable will be a bundle named <file>.app and
53 # the output for each shared library will be a symlink from libfoo.jnilib
54 # back to libfoo.dylib.
55 # These output directories will be in the same directory as the executable or
56 # shared library.
58 # Code
59 # ----
61 # Parse command line arguments
62 if [ $# = 0 ]; then
63 printf "macosx-create-bundle: error: incorrect number of arguments\n" >&2
64 printf "Usage: macosx-create-bundle file1 [file2] ... [fileN]\n" >&2
65 exit 1
68 while [ $# != 0 ]; do
69 inputfile=`echo "$1" | awk -F= '{print $1}'`
70 sourcedir=`echo "$1" | awk -F= '{print $2}'`
72 shift
74 inputfilename=`basename "$inputfile"`
75 outputdir=`dirname "$inputfile"`
77 solverlibdir="$SOLARVERSION/$INPATH/lib"
78 locallibdir="../../../../lib"
80 solverbindir="$SOLARVERSION/$INPATH/bin"
81 localbindir="../../.."
83 # Determine file type
84 filetype=`file -L "$inputfile"`
86 # Create bundle based on file type
87 if printf "$filetype" | grep -q 'Mach-O executable'; then
89 # Do nothing as this step is obsolete
92 elif printf "$filetype" | grep -q 'Mach-O dynamically linked shared library'; then
93 # Screen out lib\w+static libraries as they are not used directly
94 if ! printf "$inputfilename" | grep -q -x -E 'lib\w+static.*\.dylib'; then
95 # Create jnilib link
96 inputjnilibname="`basename $inputfilename .dylib`.jnilib"
97 if [ ! -L "$outputdir/$inputjnilibname" ]; then
98 rm -Rf "$outputdir/$inputjnilibname"
100 # Link jnilib
101 ln -sf "$inputfilename" "$outputdir/$inputjnilibname"
103 printf "macosx-create-bundle: $outputdir/$inputjnilibname successfully created\n"
105 else
106 printf "macosx-create-bundle: error: file is not an executable or shared library.\n" >&2
107 exit 1
109 done