Back to home page

Enduro/X

 
 

    


0001 #!/usr/bin/perl
0002 ##
0003 ## @brief @(#) Builds Enduro/X client process
0004 ##
0005 ## @file buildclient
0006 ##
0007 ## -----------------------------------------------------------------------------
0008 ## Enduro/X Middleware Platform for Distributed Transaction Processing
0009 ## Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0010 ## Copyright (C) 2017-2018, Mavimax, Ltd. All Rights Reserved.
0011 ## This software is released under one of the following licenses:
0012 ## GPL or Mavimax's license for commercial use.
0013 ## -----------------------------------------------------------------------------
0014 ## GPL license:
0015 ## 
0016 ## This program is free software; you can redistribute it and/or modify it under
0017 ## the terms of the GNU General Public License as published by the Free Software
0018 ## Foundation; either version 3 of the License, or (at your option) any later
0019 ## version.
0020 ##
0021 ## This program is distributed in the hope that it will be useful, but WITHOUT ANY
0022 ## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0023 ## PARTICULAR PURPOSE. See the GNU General Public License for more details.
0024 ##
0025 ## You should have received a copy of the GNU General Public License along with
0026 ## this program; if not, write to the Free Software Foundation, Inc., 59 Temple
0027 ## Place, Suite 330, Boston, MA 02111-1307 USA
0028 ##
0029 ## -----------------------------------------------------------------------------
0030 ## A commercial use license is available from Mavimax, Ltd
0031 ## contact@mavimax.com
0032 ## -----------------------------------------------------------------------------
0033 ##
0034 
0035 use Getopt::Std;
0036 use Cwd;
0037 
0038 #
0039 # Compile the client.
0040 #
0041 sub buildmain {
0042 
0043     my %options=();
0044     $options{l} = "";
0045     getopts("o:f:a:l:", \%options);
0046 
0047     # Support #104, mvitolin 23/03/2017 - give chance to change compiler
0048     my $CC = "cc";
0049     if ($ENV{'CC'})
0050     {
0051         $CC=$ENV{'CC'};
0052     }
0053 
0054     my $CFLAGS="";
0055     if (defined $ENV{'CFLAGS'})
0056     {
0057         $CFLAGS=$ENV{'CFLAGS'};
0058     }
0059 
0060     my $NDRX_INCL="";
0061     if (defined $ENV{'NDRX_HOME'})
0062     {
0063             $NDRX_INCL="-I$ENV{'NDRX_HOME'}/include";
0064     }
0065 
0066     my $NDRX_LIBPATH="";
0067     if (defined $ENV{'NDRX_HOME'})
0068     {
0069         if (-d "$ENV{'NDRX_HOME'}/lib64")
0070         {
0071             $NDRX_LIBPATH="-L$ENV{'NDRX_HOME'}/lib64";
0072         }
0073         else
0074         {
0075             $NDRX_LIBPATH="-L$ENV{'NDRX_HOME'}/lib";
0076         }
0077     }
0078 
0079     # Print out the options we have
0080     #print "-o $options{o}\n" if defined $options{o};
0081     #print "-f $options{f}\n" if defined $options{f};
0082     #print "-l $options{l}\n" if defined $options{l};
0083 
0084     # Set RT LIB
0085     my $dyn_libs = "-lrt -ldl -lpthread";
0086     my $wd = getcwd;
0087 
0088     print "OS Version: $^O wd: $wd\n";
0089 
0090     if ($^O eq "freebsd" )
0091     {
0092         $dyn_libs = "-lrt -lpthread";
0093     }
0094     elsif ($^O eq "darwin")
0095     {
0096         $dyn_libs = "-ldl -lpthread";
0097     }
0098 
0099     my $command="$CC $CFLAGS -o $options{o} $options{l} $options{f} -latmiclt -latmi -lubf -lnstd $dyn_libs -lm -lc -lpthread $options{a} $NDRX_INCL $NDRX_LIBPATH";
0100     # print the build output
0101     print "$command\n";
0102     my $output=`$command`;
0103     my $ret = $?;
0104 
0105     print STDERR $output;
0106 
0107     #
0108     # Terminate process accordingly
0109     #
0110     if ($ret != 0)
0111     {
0112         exit -1;
0113     }
0114     else
0115     {
0116         exit 0;
0117     }    
0118 }
0119 
0120 # Run the main
0121 buildmain();
0122