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",
53 # Make best guess as to where this program was run from (note, it is
54 # always possible to override the location of $0 by the calling
55 # program, so we can't really tell for sure that this is where we
62 $exec_path = abs_path($0);
64 $exec_path = dirname($exec_path);
66 my $root_path = getcwd();
67 if($exec_path =~ m!dali-env/opt/bin!)
69 $root_path = $exec_path;
70 while($root_path !~ m!dali-env$!)
72 $root_path = dirname($root_path);
75 elsif($root_path =~ m!dali-env!)
77 while($root_path !~ m!dali-env$!)
79 $root_path = dirname($root_path);
85 $root_path .= "/dali-env";
88 my $src_path = "$root_path/src-packages";
89 my $sbs_path = "$root_path/target";
90 my $install_path = "$root_path/opt";
97 GetOptions("create" => \$opt_create,
98 "setenv" => \$opt_setenv,
100 "man" => \$opt_man) or pod2usage(2);
102 pod2usage(1) if $opt_help;
103 pod2usage(-exitstatus => 0, -verbose => 2) if $opt_man;
106 ################################################################################
110 mkpath("$install_path/bin");
111 mkpath("$install_path/lib/pkgconfig");
112 mkpath("$install_path/include");
113 mkpath("$install_path/share/aclocal");
117 copy($0, "$install_path/bin/dali_env");
118 chmod(0755, "$install_path/bin/dali_env");
121 ################################################################################
125 my $cwd = substr(getcwd(), 0, length($root_path));
126 #print "cwd = $cwd\nroot = $root_path\n";
127 return $cwd eq $root_path;
130 ################################################################################
135 # To use the desktop libraries, please add the following lines to your .bashrc or
136 # create a setenv script from them, e.g. by running this command as follows
137 # \$ dali_env -s > setenv
139 # You can then source this script by using
142 # Use DESKTOP_PREFIX when running configure in dali/build/slp:
143 # \$ CXXFLAGS="-g -O0" ./configure --prefix=\$DESKTOP_PREFIX
145 export DESKTOP_PREFIX=$install_path
146 export PATH=$install_path/bin:\$PATH
147 export LD_LIBRARY_PATH=$install_path/lib:\$LD_LIBRARY_PATH
148 export INCLUDEDIR=$install_path/include
149 export PKG_CONFIG_PATH=$install_path/lib/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
154 ################################################################################
156 sub check_system_package
159 foreach $package (@_)
161 my @x=split(/\s+/, `dpkg -l $package|grep $package`);
164 print "Attempting to install $package\n";
165 system("sudo apt-get -y install $package");
170 sub check_system_packages
172 print "Checking for required system packages (may require sudo password)\n";
174 check_system_package(@system_packages);
175 my $gnome_v =`dpkg -l gnome-common| tail -1| sed "s/ \\+/ /g" | cut -d' ' -f 3`;
176 my @am = split(/\./, `automake --version | head -1 | cut -f4 -d' '`);
177 if($gnome_v =~ /$2.24/ && $am[1]>10)
179 die "Gnome common and automake are not compatible - automake is too new\n";
181 my @gpp_v = (`g++ --version | head -1` =~ /(\d+)\.(\d+)\.(\d+)/);
183 if(! (($gpp_v[0] > 4)
185 ($gpp_v[0] == 4 && $gpp_v[1] > 4)
187 ($gpp_v[0] == 4 && $gpp_v[1] == 4 && $gpp_v[2] >= 5)))
189 die "You need g++ 4.5.1 or greater to build dali\n";
193 ################################################################################
200 my $link = "/usr/lib/$arch-linux-gnu/libturbojpeg.so";
204 print "Creating libjpegturbo symbolic link\n";
205 system("sudo ln -s $link.0 $link");
209 ################################################################################
211 ################################################################################
216 my $new_root = getcwd() . "/dali-env";
218 if($exec_path =~ m!dali-env/opt/bin!)
220 die "Already in a dali-env directory\n";
221 # Could query if user wants to re-create?
225 die "A dali-env directory already exists here\n";
228 check_system_packages();
239 die "$root_path does not exist\n";
243 die "$root_path is not an existing environment\n";
256 dali_env - Create the DALi environment for Ubuntu
260 dali_env [-c] [-s] [-h|-m]
268 Create a DALi environment directory in the current directory.
272 Display environment variables to setup.
280 Display the manual page
288 Gets the required dependencies for DALi and them to a local directory. Can also create a setenv script to point to the installation.