3 # Copyright (c) 2014 Samsung Electronics Co., Ltd.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
22 use File::Copy::Recursive qw(dircopy);
27 ################################################################################
29 ################################################################################
30 # Add any required system packages to this list - if they are not present, then
31 # this script will attempt to install them for you.
32 my @system_packages = (
39 "libboost-thread-dev",
52 # Make best guess as to where this program was run from (note, it is
53 # always possible to override the location of $0 by the calling
54 # program, so we can't really tell for sure that this is where we
61 $exec_path = abs_path($0);
63 $exec_path = dirname($exec_path);
65 my $root_path = getcwd();
66 if($exec_path =~ m!dali-env/opt/bin!)
68 $root_path = $exec_path;
69 while($root_path !~ m!dali-env$!)
71 $root_path = dirname($root_path);
74 elsif($root_path =~ m!dali-env!)
76 while($root_path !~ m!dali-env$!)
78 $root_path = dirname($root_path);
84 $root_path .= "/dali-env";
87 my $src_path = "$root_path/src-packages";
88 my $sbs_path = "$root_path/target";
89 my $install_path = "$root_path/opt";
96 GetOptions("create" => \$opt_create,
97 "setenv" => \$opt_setenv,
99 "man" => \$opt_man) or pod2usage(2);
101 pod2usage(1) if $opt_help;
102 pod2usage(-exitstatus => 0, -verbose => 2) if $opt_man;
105 ################################################################################
109 mkpath("$install_path/bin");
110 mkpath("$install_path/lib/pkgconfig");
111 mkpath("$install_path/include");
112 mkpath("$install_path/share/aclocal");
116 copy($0, "$install_path/bin/dali_env");
117 chmod(0755, "$install_path/bin/dali_env");
120 ################################################################################
124 my $cwd = substr(getcwd(), 0, length($root_path));
125 #print "cwd = $cwd\nroot = $root_path\n";
126 return $cwd eq $root_path;
129 ################################################################################
134 # To use the desktop libraries, please add the following lines to your .bashrc or
135 # create a setenv script from them, e.g. by running this command as follows
136 # \$ dali_env -s > setenv
138 # You can then source this script by using
141 # Use DESKTOP_PREFIX when running configure in dali/build/slp:
142 # \$ CXXFLAGS="-g -O0" ./configure --prefix=\$DESKTOP_PREFIX
144 export DESKTOP_PREFIX=$install_path
145 export PATH=$install_path/bin:\$PATH
146 export LD_LIBRARY_PATH=$install_path/lib:\$LD_LIBRARY_PATH
147 export INCLUDEDIR=$install_path/include
148 export PKG_CONFIG_PATH=$install_path/lib/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
153 ################################################################################
155 sub check_system_package
158 foreach $package (@_)
160 my @x=split(/\s+/, `dpkg -l $package|grep $package`);
163 print "Attempting to install $package\n";
164 system("sudo apt-get -y install $package");
169 sub check_system_packages
171 print "Checking for required system packages (may require sudo password)\n";
173 check_system_package(@system_packages);
174 my $gnome_v =`dpkg -l gnome-common| tail -1| sed "s/ \\+/ /g" | cut -d' ' -f 3`;
175 my @am = split(/\./, `automake --version | head -1 | cut -f4 -d' '`);
176 if($gnome_v =~ /$2.24/ && $am[1]>10)
178 die "Gnome common and automake are not compatible - automake is too new\n";
180 my @gpp_v = (`g++ --version | head -1` =~ /(\d+)\.(\d+)\.(\d+)/);
182 if(! (($gpp_v[0] > 4)
184 ($gpp_v[0] == 4 && $gpp_v[1] > 4)
186 ($gpp_v[0] == 4 && $gpp_v[1] == 4 && $gpp_v[2] >= 5)))
188 die "You need g++ 4.5.1 or greater to build dali\n";
192 ################################################################################
199 my $link = "/usr/lib/$arch-linux-gnu/libturbojpeg.so";
203 print "Creating libjpegturbo symbolic link\n";
204 system("sudo ln -s $link.0 $link");
208 ################################################################################
210 ################################################################################
215 my $new_root = getcwd() . "/dali-env";
217 if($exec_path =~ m!dali-env/opt/bin!)
219 die "Already in a dali-env directory\n";
220 # Could query if user wants to re-create?
224 die "A dali-env directory already exists here\n";
227 check_system_packages();
238 die "$root_path does not exist\n";
242 die "$root_path is not an existing environment\n";
255 dali_env - Create the DALi environment for Ubuntu
259 dali_env [-c] [-s] [-h|-m]
267 Create a DALi environment directory in the current directory.
271 Display environment variables to setup.
279 Display the manual page
287 Gets the required dependencies for DALi and them to a local directory. Can also create a setenv script to point to the installation.