Back to home page

Enduro/X

 
 

    


0001 #!/usr/bin/perl
0002 ##
0003 ## @brief @(#) Builds Enduro/X server process
0004 ##
0005 ## @file buildserver
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 server.
0040 #
0041 sub buildmain {
0042 
0043     my %options=();
0044 
0045     $options{l} = "";
0046 
0047     # Bug #254 29/11/2017
0048     getopts("o:f:s:a:l:", \%options);
0049 
0050     my $CFLAGS = $ENV{'CFLAGS'};
0051 
0052     # Support #104, mvitolin 23/03/2017 - give chance to change compiler
0053     my $CC = "cc";
0054     if ($ENV{'CC'})
0055     {
0056         $CC=$ENV{'CC'};
0057     }
0058 
0059     my $CFLAGS="";
0060     if ($ENV{'CFLAGS'})
0061     {
0062         $CFLAGS=$ENV{'CFLAGS'};
0063     }
0064 
0065     my $NDRX_INCL="";
0066     if (defined $ENV{'NDRX_HOME'})
0067     {
0068         $NDRX_INCL="-I$ENV{'NDRX_HOME'}/include";
0069     }
0070 
0071     my $NDRX_LIBPATH="";
0072     if (defined $ENV{'NDRX_HOME'})
0073     {
0074         if (-d "$ENV{'NDRX_HOME'}/lib64")
0075         {
0076             $NDRX_LIBPATH="-L$ENV{'NDRX_HOME'}/lib64";
0077         }
0078         else
0079         {
0080             $NDRX_LIBPATH="-L$ENV{'NDRX_HOME'}/lib";
0081         }
0082     }
0083 
0084     # Print out the options we have
0085     #print "-o $options{o}\n" if defined $options{o};
0086     #print "-f $options{f}\n" if defined $options{f};
0087     #print "-l $options{l}\n" if defined $options{l};
0088 
0089     # Set RT LIB
0090     my $dyn_libs = "-lrt -ldl -lpthread";
0091     my $wd = getcwd;
0092 
0093     print "OS Version: $^O wd: $wd\n";
0094 
0095     if ($^O eq "freebsd" )
0096     {
0097         $dyn_libs = "-lrt -lpthread";
0098     }
0099     elsif ($^O eq "darwin")
0100     {
0101         $dyn_libs = "-ldl -lpthread";
0102     }
0103 
0104     my $command="$CC $CFLAGS -o $options{o} $options{l} $options{f} -latmisrv -latmi -lubf -lnstd $dyn_libs -lm -lc -lpthread $options{a} $NDRX_INCL $NDRX_LIBPATH";
0105 
0106     # print the build output
0107     print "$command\n";
0108     my $output=`$command`;
0109     my $ret = $?;
0110 
0111     print STDERR $output;
0112 
0113     #
0114     # Termiante process accordingly
0115     #
0116     if ($ret != 0)
0117     {
0118         exit -1;
0119     }
0120     else
0121     {
0122         exit 0;
0123     }
0124     
0125 }
0126 
0127 # Run the main
0128 buildmain();
0129 
0130