root/middleware-offline/trunk/_src/eidmw/build.pl @ 5

Revision 5, 3.7 KB (checked in by vsilva, 9 years ago)

Initial comit

Line 
1#!/usr/bin/perl -w
2
3use strict;
4
5## run only on Mac
6##   since I'm not sure if $^O contains a specific word on mac,
7##   I check that this is not linux instead
8&bailOutExit("This script is supposed to be used only on Mac") if($^O =~ m/linux/);
9
10my $workdir = $ENV{"PWD"};
11
12print STDERR "We are working in $workdir\n";
13$workdir =~ s/(.*eidmw).*/$1/;
14
15&bailOutExit("I could not find a working copy of eidmw!") unless ($workdir =~ /eidmw/);
16
17chdir "$workdir" or die "Could not chdir to $workdir: $!\n" unless ($workdir eq $ENV{"PWD"});
18
19print STDERR "We are working in $workdir\n";
20
21my @libPath = ("$workdir/lib/");
22
23##
24## check if the cryptlib library is built and build it if not
25##
26print STDERR "Check cryptlib ... ";
27my $libname = "libcl.so"; 
28my $dirname = "$workdir/../ThirdParty/cryptlib331";
29unless ( -e "$dirname/$libname" || -l "$dirname/$libname" || 1){
30  print STDERR "cryptlib library not found, building .. \n";
31  ## if the lib is there but not the link, we just set the link and do not build anything
32  unless ( -e "libcl.so.3.3.0" ) {
33    chdir "$dirname"  or die "Could not chdir to $dirname: $!\n";
34    ## - unzip
35    if (-e "cl331.zip") {
36      system("unzip -a cl331.zip") 
37    } else {
38      &bailOutExit("cl331.zip not found in $dirname");
39    }
40
41    ## - edit random/unix.c
42    ##   substitute the inclusion of linux/timex.h with the inclusion of sys/timex.h
43    $^I = "";
44    @ARGV=("random/unix.c");
45    while (<>) {
46      s#<linux/timex.h>#<sys/timex.h>#;
47      print;
48    }
49
50    ## - compile
51    system("make shared > make.log");
52    &bailOutExit("build of $libname failed") unless( -e "libcl.so.3.3.0");
53  }
54  symlink "libcl.so.3.3.0",$libname;
55
56  ## - get back to the working directory
57  chdir "$workdir";
58}
59push @libPath,$dirname;
60print STDERR " ....  OK\n";
61
62## check if the unittest library is built and build it if not
63print STDERR "Check UnitTest++ ... ";
64$libname = "libUnitTest++.a";
65$dirname = "$workdir/../ThirdParty/unittest-cpp-1.3/UnitTest++/";
66unless ( -e "$dirname/$libname" ){
67  chdir "$dirname"  or die "Could not chdir to $dirname: $!\n";
68
69  ## - compile
70  system("./build.pl");
71  &bailOutExit("build of $libname failed") unless( -e "$libname");
72
73  ## - get back to the working directory
74  chdir "$workdir";
75## - compile
76## - get back to the working directory
77}
78
79## set some useful environment variables
80## -- attention: the settings will not survive the script
81push @libPath,$dirname;
82print STDERR " ....  OK\n";
83
84## set useful paths
85
86## protect the special characters (e.g. UnitTest++)
87my $testLibPath = join(":",@libPath);
88$testLibPath =~ s/\+/\\+/g;
89
90my $ldEnvVariable = "LD_LIBRARY_PATH";
91$ldEnvVariable =~ s/^L/DYL/  unless ($^O =~ /linux/);
92
93$ENV{"$ldEnvVariable"} .= join(":",@libPath)
94  unless ( defined $ENV{"$ldEnvVariable"} &&
95           $ENV{"$ldEnvVariable"} =~ /$testLibPath/ );
96print STDERR "$ldEnvVariable set to: $ENV{$ldEnvVariable}\n";
97
98
99##proceed to build
100my @projectToBuild = ("common","applayer","eidlib","dialogs/dialogsQT","cardlayer","cardlayerEmulation");
101my @exeToBuild = ("commonTest","cardlayerTool");
102
103foreach(my $p = 0; $p<@projectToBuild;++$p){
104  chdir "$workdir/$projectToBuild[$p]" or die "Could not chdir to $workdir/$projectToBuild[$p]: \n";
105  system("qmake ; make clean &> make-clean.log; make &> make.log;");
106  chdir "$workdir";
107  print STDERR "  .... OK \n";
108}
109
110foreach(my $p = 0; $p<@exeToBuild;++$p){
111  chdir "$workdir/$exeToBuild[$p]" or die "Could not chdir to $workdir/$exeToBuild[$p]: \n";
112  die if system("qmake; make clean &> make-clean.log; make &> make.log;");     
113  chdir "$workdir";
114  print STDERR "  .... OK \n";
115}
116
117
118exit;
119
120sub bailOutExit(){
121  bailOut($_[0]);
122  chdir "$workdir";
123  print STDERR "Abort\n";
124  exit;
125}
126
127sub bailOut(){
128  print STDERR "$0 Error: $_[0]\n";
129}
130
131
Note: See TracBrowser for help on using the browser.