From d335486454fecb6e8e2b672e5e7cbd9d6b0d56b9 Mon Sep 17 00:00:00 2001 From: Pavel Charvat Date: Tue, 3 Jun 2014 00:20:58 +0200 Subject: [PATCH] Build: Improved paths in local builds. * CONFIG_LOCAL by default uses absolute paths, so you can execute run/bin/* from anywhere or directly use resulting *.pc by external commands. * Define CONFIG_RELATIVE_PATHS for old relative paths. * Removed SONAME_PREFIX, replaced with -rpath. --- ucw/doc/configure.txt | 24 ++++++++++++++---------- ucw/doc/install.txt | 2 +- ucw/perl/UCW/Configure/C.pm | 31 ++++++++++++------------------- ucw/perl/UCW/Configure/Paths.pm | 16 ++++++++++++---- 4 files changed, 39 insertions(+), 34 deletions(-) diff --git a/ucw/doc/configure.txt b/ucw/doc/configure.txt index 35784a25..6bd328bc 100644 --- a/ucw/doc/configure.txt +++ b/ucw/doc/configure.txt @@ -1,10 +1,10 @@ -How to Configure Sherlock libraries -=================================== +How to Configure libucw libraries +================================= What can be configured ---------------------- -There are two different levels of configuring/customizing program -based on sherlock libraries: +There are two different levels of configuring program +based on the libucw libraries: - runtime configuration in configuration files (see <>) @@ -56,19 +56,23 @@ set the `PREFIX` option: [[local_build]] You can create a local compilation, which does not need to be -installed. All paths are set relative to a `run` directory and -programs expect to have current working directory set to it. However, -you can move the `run` directory around your filesystem as you like. -To compile it that way, turn on the `CONFIG_LOCAL` option (and do not -set `PREFIX`): +installed. To compile it that way, turn on the `CONFIG_LOCAL` option +(and do not set `PREFIX`): ./configure CONFIG_LOCAL +Alternatively you can add the `CONFIG_RELATIVE_PATHS` option. +All paths are then set relative to a `run` directory and +programs expect to have current working directory set to it. However, +you can move the `run` directory around your filesystem as you like: + + ./configure CONFIG_LOCAL CONFIG_RELATIVE_PATHS + Examples -------- - `./configure -CONFIG_SHARED` will build the libraries statically. - `./configure -CONFIG_IMAGES` avoids building the image library. - `./configure CONFIG_UCW_ONLY -CONFIG_UCW_UTILS` compiles only the libucw library without its util programs. - - `./configure CONFIG_XML PREFIX=$HOME/sherlock` includes a xml + - `./configure CONFIG_XML PREFIX=$HOME/libucw` includes a xml library and installs into your home directory. diff --git a/ucw/doc/install.txt b/ucw/doc/install.txt index aef870c5..d3bce644 100644 --- a/ucw/doc/install.txt +++ b/ucw/doc/install.txt @@ -13,7 +13,7 @@ To build and run, you need: - Libjpeg, libpng and libungif to support all image formats (jpeg, png and gif). These libraries can be replaced by libgif (gif) and GraphicsMagick >= 1.1 (jpeg, png, gif and possible more formats). - See sherlock/default.cfg for related configuration switches. + See default.cfg for related configuration switches. Compiling --------- diff --git a/ucw/perl/UCW/Configure/C.pm b/ucw/perl/UCW/Configure/C.pm index 8af97830..e22ac0ed 100644 --- a/ucw/perl/UCW/Configure/C.pm +++ b/ucw/perl/UCW/Configure/C.pm @@ -119,28 +119,21 @@ Set("LIBS" => ""); # Extra flags for compiling and linking shared libraries Set("CSHARED" => '-fPIC'); -Set("SO_LINK_PATH" => ''); -if (IsSet("CONFIG_LOCAL")) { - Set("SONAME_PREFIX" => "lib/"); - Append("LOPT" => "-Wl,--rpath-link -Wl,run"); -} else { - Set("SONAME_PREFIX" => ""); - Append("LOPT" => "-Wl,--rpath-link -Wl,run/lib"); - if (IsSet("CONFIG_SHARED") && !(Get("INSTALL_LIB_DIR") eq "/usr/lib")) { - Set("SO_LINK_PATH" => "-Wl,--rpath " . Get("INSTALL_LIB_DIR")); - AtWrite { - # FIXME: This is a hack. GCC would otherwise fail to link binaries. - my $libdir = Get("INSTALL_LIB_DIR"); - if (!(-d $libdir)) { - `install -d -m 755 $libdir`; Fail("Cannot create $libdir") if $?; - } - }; - } +Append("LOPT" => "-Wl,--rpath-link -Wl,run/lib"); +if (!(Get("INSTALL_LIB_DIR") eq "/usr/lib")) { + Set("SO_LINK_PATH" => "-Wl,--rpath " . Get("INSTALL_LIB_DIR")); + AtWrite { + # FIXME: This is a hack. GCC would otherwise fail to link binaries. + my $libdir = Get("INSTALL_LIB_DIR"); + if (IsSet("CONFIG_SHARED") && !(-d $libdir)) { + `install -d -m 755 $libdir`; Fail("Cannot create $libdir") if $?; + } + }; } if (IsSet("CONFIG_DARWIN")) { - Set("LSHARED" => '-dynamiclib -install_name $(SONAME_PREFIX)$(@F)$(SONAME_SUFFIX) -undefined dynamic_lookup'); + Set("LSHARED" => '-dynamiclib -install_name $(@F)$(SONAME_SUFFIX) -undefined dynamic_lookup'); } else { - Set("LSHARED" => '-shared -Wl,-soname,$(SONAME_PREFIX)$(@F)$(SONAME_SUFFIX)'); + Set("LSHARED" => '-shared -Wl,-soname,$(@F)$(SONAME_SUFFIX)'); } # Extra switches depending on GCC version: diff --git a/ucw/perl/UCW/Configure/Paths.pm b/ucw/perl/UCW/Configure/Paths.pm index f28ccb12..d03c90d6 100644 --- a/ucw/perl/UCW/Configure/Paths.pm +++ b/ucw/perl/UCW/Configure/Paths.pm @@ -11,10 +11,18 @@ use warnings; Log "Determining installation prefix ... "; if (IsSet("CONFIG_LOCAL")) { - Log("local build\n"); - Set("INSTALL_PREFIX", ""); - Set("INSTALL_USR_PREFIX", ""); - Set("INSTALL_VAR_PREFIX", ""); + if (IsSet("CONFIG_RELATIVE_PATHS")) { + Log("local build with relative paths\n"); + Set("INSTALL_PREFIX", ""); + } + else { + Log("local build with absolute paths\n"); + my $cwd = `pwd`; Fail("Cannot get current working directory") if $?; + chomp $cwd; + Set("INSTALL_PREFIX", "$cwd/run/"); + } + Set("INSTALL_USR_PREFIX", Get("INSTALL_PREFIX")); + Set("INSTALL_VAR_PREFIX", Get("INSTALL_PREFIX")); } else { Set("PREFIX", "/usr/local") unless IsSet("PREFIX"); my $ipx = Get("PREFIX"); -- 2.39.2