Back to home page

Enduro/X

 
 

    


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