]> mj.ucw.cz Git - leo.git/blob - perl/UCW/Configure/Paths.pm
Switched to UCW configure and build system
[leo.git] / perl / UCW / Configure / Paths.pm
1 # UCW Library configuration system: installation paths
2 # (c) 2005--2009 Martin Mares <mj@ucw.cz>
3 # (c) 2006 Robert Spalek <robert@ucw.cz>
4 # (c) 2008 Michal Vaner <vorner@ucw.cz>
5
6 package UCW::Configure::Paths;
7 use UCW::Configure;
8
9 use strict;
10 use warnings;
11
12 Log "Determining installation prefix ... ";
13 if (IsSet("CONFIG_LOCAL")) {
14         if (IsSet("CONFIG_RELATIVE_PATHS")) {
15                 Log("local build with relative paths\n");
16                 Set("INSTALL_PREFIX", "");
17         }
18         else {
19                 Log("local build with absolute paths\n");
20                 my $cwd = `pwd`; Fail("Cannot get current working directory") if $?;
21                 chomp $cwd;
22                 Set("INSTALL_PREFIX", "$cwd/run/");
23         }
24         Set("INSTALL_USR_PREFIX", Get("INSTALL_PREFIX"));
25         Set("INSTALL_VAR_PREFIX", Get("INSTALL_PREFIX"));
26 } else {
27         Set("PREFIX", "/usr/local") unless IsSet("PREFIX");
28         my $ipx = Get("PREFIX");
29         $ipx =~ s{/$}{};
30         Set("INSTALL_PREFIX", "$ipx/");
31         my $upx = ($ipx eq "" ? "/usr/" : "$ipx/");
32         Set("INSTALL_USR_PREFIX", $upx);
33         $upx =~ s{^/usr\b}{/var};
34         Set("INSTALL_VAR_PREFIX", $upx);
35         Log(Get("PREFIX") . "\n");
36 }
37
38 Set('CONFIG_DIR', 'etc') unless IsSet('CONFIG_DIR');
39 Set('INSTALL_CONFIG_DIR', Get('INSTALL_PREFIX') . Get('CONFIG_DIR'));
40 Set('INSTALL_BIN_DIR', Get('INSTALL_USR_PREFIX') . 'bin');
41 Set('INSTALL_SBIN_DIR', Get('INSTALL_USR_PREFIX') . 'sbin');
42 Set('INSTALL_LIB_DIR', Get('INSTALL_USR_PREFIX') . 'lib');
43 Set('INSTALL_INCLUDE_DIR', Get('INSTALL_USR_PREFIX') . 'include');
44 Set('INSTALL_PKGCONFIG_DIR', Get('INSTALL_USR_PREFIX') . 'lib/pkgconfig');
45 Set('INSTALL_SHARE_DIR', Get('INSTALL_USR_PREFIX') . 'share');
46 Set('INSTALL_MAN_DIR', Get('INSTALL_USR_PREFIX') . 'share/man');
47 Set('INSTALL_LOG_DIR', Get('INSTALL_VAR_PREFIX') . 'log');
48 Set('INSTALL_STATE_DIR', Get('INSTALL_VAR_PREFIX') . 'lib');
49 Set('INSTALL_RUN_DIR', Get('INSTALL_VAR_PREFIX') . 'run');
50 Set('INSTALL_DOC_DIR', Get('INSTALL_USR_PREFIX') . 'share/doc');
51 Set('INSTALL_PERL_DIR', Get('INSTALL_LIB_DIR') . '/perl5');
52
53 # Remember PKG_CONFIG_PATH used for building, so that it will be propagated to
54 # pkg-config's run locally in the makefiles.
55 Set("PKG_CONFIG_PATH", $ENV{"PKG_CONFIG_PATH"}) if defined $ENV{"PKG_CONFIG_PATH"};
56
57 # We succeeded
58 1;