Skip to content
Snippets Groups Projects
packageBinaries.pl 54.2 KiB
Newer Older
Ted Leung's avatar
Ted Leung committed
#!/usr/local/bin/perl5
#
# The Apache Software License, Version 1.1
#
# Copyright (c) 1999-2004 The Apache Software Foundation.  All rights
# reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in
#    the documentation and/or other materials provided with the
#    distribution.
#
# 3. The end-user documentation included with the redistribution,
#    if any, must include the following acknowledgment:
#       "This product includes software developed by the
#        Apache Software Foundation (http://www.apache.org/)."
#    Alternately, this acknowledgment may appear in the software itself,
#    if and wherever such third-party acknowledgments normally appear.
#
# 4. The names "Xerces" and "Apache Software Foundation" must
#    not be used to endorse or promote products derived from this
#    software without prior written permission. For written
#    permission, please contact apache\@apache.org.
#
# 5. Products derived from this software may not be called "Apache",
#    nor may "Apache" appear in their name, without prior written
#    permission of the Apache Software Foundation.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
# ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# ====================================================================
#
# This software consists of voluntary contributions made by many
# individuals on behalf of the Apache Software Foundation, and was
# originally based on software copyright (c) 1999, International
# Business Machines, Inc., http://www.ibm.com .  For more information
# on the Apache Software Foundation, please see
# <http://www.apache.org/>.
#
Ted Leung's avatar
Ted Leung committed

push(@INC, "/home/xml4c/bin", "/home/xml4c/bin/perl/perl-RUN/opt/perl5/lib", "/Development2/cupert/bin/perl/perl-RUN/opt/perl5/lib", "/Development/cupert/usr/local/perl/perl-RUN/opt/perl5/lib");
Ted Leung's avatar
Ted Leung committed

require "getopt.pl";
Ted Leung's avatar
Ted Leung committed

$|=1;   # Force a flush after every print

my $XERCESCROOT = $opt_s;
my $targetdir              = $opt_o;
my $ICUROOT           = $ENV{'ICUROOT'};
my $ICUIsPresent      = (($opt_t =~ m/icu/i || $opt_m =~ m/icu/i) && length($ICUROOT) > 0);
my $ICUResourceDir = "$XERCESCROOT/src/xercesc/util/MsgLoaders/ICU/resources";
    
Ted Leung's avatar
Ted Leung committed
# Check for the environment variables and exit if error
Rahul Jain's avatar
Rahul Jain committed
if (!length($XERCESCROOT) || !length($targetdir) || (length($opt_h) > 0) ) {
    print ("Usage is: packageBinaries <options>\n");
Rahul Jain's avatar
Rahul Jain committed
    print ("  where options are:\n");
    print ("    -s <source_directory>\n");
    print ("    -o <target_directory>\n");
    print ("    -c <C compiler name> (e.g. gcc, cc, xlc_r, VC6, VC7, ecl or icl)\n");
    print ("    -x <C++ compiler name> (e.g. g++, CC, aCC, c++, xlC_r, cl, ecl, ecc, icl, VC6 or VC7)\n");
Rahul Jain's avatar
Rahul Jain committed
    print ("    -m <message loader> can be 'inmem' \(default\), 'icu' or 'iconv'\n");
    print ("    -n <net accessor> can be 'fileonly' or 'socket' \(default\)\n");
    print ("    -t <transcoder> can be 'icu' or 'native' \(default\)\n");
    print ("    -r <thread option> can be 'pthread' \(default\)or 'dce' (only used on HP-11)\n");
    print ("    -b <bitsToBuild> (accepts '64', '32')\n");
    print ("    -j suppress building of ICU (speeds up builds when debugging)\n");
Rahul Jain's avatar
Rahul Jain committed
    print ("    -h to get help on these commands\n\n");
    print ("Example: Under unix's\n");
PeiYong Zhang's avatar
PeiYong Zhang committed
    print ("    perl packageBinaries.pl -s \$HOME/xerces-c-src2_5_0");
    print (" -o \$HOME/xerces-c2_5_0-linux -c gcc -x g++ -m inmem -n fileonly -t native\n\n");
Rahul Jain's avatar
Rahul Jain committed
    print ("Example: Under Windows\n");
PeiYong Zhang's avatar
PeiYong Zhang committed
    print ("    perl packageBinaries.pl -s \\xerces-c-src2_5_0");
    print (" -o\\xerces-c2_5_0-win32 [-n fileonly] [-t icu]\n\n");
    print ("Note:\n");
    print ("    Under Windows, by default the XercesLib project files is\n");
    print ("    configured to use Win32 resource file based message loader,\n");
    print ("    WinSocket based net accessor and native Win32 based transcoder.\n");
    print ("    The two options mentioned in the example above are the only\n");
    print ("    options relevant under Windows on the command line for this script.\n");
Ted Leung's avatar
Ted Leung committed
}

if (($opt_t =~ m/icu/i || $opt_m =~ m/icu/i) && (length($ICUROOT) == 0)) {
    print "You have specified an ICU build but you have not defined your ICU install directory.\n";
    print "To build with ICU, you must set an environment variable called ICUROOT\n";
    print "Cannot proceed any further.\n";
    exit(-1);
Ted Leung's avatar
Ted Leung committed
}
Ted Leung's avatar
Ted Leung committed
# Check if the source directory exists or not
Rahul Jain's avatar
Rahul Jain committed
if (!(-e $XERCESCROOT)) {
    print ("The directory $XERCESCROOT does not exist. Cannot proceed any further.\n");
    exit(-1);
Ted Leung's avatar
Ted Leung committed
}

# Check if the target directory exists, exit if it does
if (-e $targetdir) {
    print ("Error: The target directory \'$targetdir\' already exists.\n");
    print ("       You must start with a clean directory to package your product.\n");
    exit(1);
Ted Leung's avatar
Ted Leung committed
}

Tinny Ng's avatar
Tinny Ng committed
# Find out the platform from 'uname -s'
open(PLATFORM, "uname -s|");
$platform = <PLATFORM>;
chomp($platform);
close (PLATFORM);
Ted Leung's avatar
Ted Leung committed

#Fix the backslashes on the Windows platform
$XERCESCROOT =~ s/\\/\//g;
$ICUROOT =~ s/\\/\//g;
$targetdir =~ s/\\/\//g;

print "Packaging binaries for \`" . $platform . "\` in " . $targetdir . " ...\n";   # "
Ted Leung's avatar
Ted Leung committed

#Construct the name of the zip file by extracting the last directory name
$zipfiles =~ s/.*(\/|\\)([\w-\.]*)$/$2/g;
$zipfiles = $zipfiles . "/*";
Ted Leung's avatar
Ted Leung committed

#   WINDOWS builds happen here, as long as they
#     aren't using gcc...
#
#  Tasks:
#
#    Preparation
#          Initialize Vars
#          Make the target directory and its main subdirectories
#          'FileOnly' NetAccessor
#
#   Build
#          ICU and/or Resource bundle library for ICUMsgLoader
#          Xerces-C libraries, samples and tests
#
#   Population
#          include
#          ICU and/or ICUMsgLoader
#          Xerces-C libraries, samples and tests
#          Documentation
if ($platform =~ m/Windows/  || ($platform =~ m/CYGWIN/ && !($opt_c =~ m/gcc/))) {
#
# Preparation Begin
#
#    Preparation::Initialize Vars
#
    my $PlatformName = 'Win32'; 
    my $DevStudioVer = "6.0";
    my $VCBuildDir     = "VC6";
    my $Transcoder     = 0;
    my $MsgLoader     = 0;

    my $ReleaseBuildDir  = undef;
    my $DebugBuildDir    = undef;
    my $ProjectDir          = undef;
                        
    if ($opt_b eq "64") {
        $PlatformName = 'Win64';
    }
      
    if ($opt_x eq "" || $opt_x =~ m/VC6/ )
        $DevStudioVer = "6.0";
        $VCBuildDir     = "VC6"; 
        $ProjectDir      = "$XERCESCROOT/Projects/Win32/$VCBuildDir/xerces-all";
        $DevStudioVer = "7.0";
        $VCBuildDir     = "VC7"; 
        $ProjectDir      = "$XERCESCROOT/Projects/Win32/$VCBuildDir/xerces-all";
Tinny Ng's avatar
Tinny Ng committed
    }
    elsif ($opt_x =~ m/ecl/ || $opt_x =~ m/icl/ )
    {
        $DevStudioVer = "6.1";
Loading
Loading full blame...