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