Back to home page

Enduro/X

 
 

    


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