1 # Copyright (c) 2005 Vladimir Prus.
2 # Copyright 2006 Rene Rivera.
4 # Use, modification and distribution is subject to the Boost Software
5 # License Version 1.0. (See accompanying file LICENSE_1_0.txt or
6 # http://www.boost.org/LICENSE_1_0.txt)
8 # Provides mechanism for installing whole packages into a specific directory
9 # structure. This is opposed to the 'install' rule, that installs a number of
10 # targets to a single directory, and does not care about directory structure at
15 # package.install boost : <properties>
21 # This will install binaries, libraries and headers to the 'proper' location,
22 # given by command line options --prefix, --exec-prefix, --bindir, --libdir and
25 # The rule is just a convenient wrapper, avoiding the need to define several
28 # The only install-related feature is <install-source-root>. It will apply to
29 # headers only and if present, paths of headers relatively to source root will
30 # be retained after installing. If it is not specified, then "." is assumed, so
31 # relative paths in headers are always preserved.
33 import "class" : new ;
42 feature.feature install-default-prefix : : free incidental ;
44 rule install ( name package-name ? : requirements * : binaries * : libraries * : headers * )
46 package-name ?= $(name) ;
47 if [ MATCH --prefix=(.*) : [ modules.peek : ARGV ] ]
49 # If --prefix is explicitly specified on the command line,
50 # then we need wipe away any settings of libdir/includir that
51 # is specified via options in config files.
54 option.set includedir : ;
57 # If <install-source-root> is not specified, all headers are installed to
58 # prefix/include, no matter what their relative path is. Sometimes that is
60 local install-source-root = [ property.select <install-source-root> :
62 install-source-root = $(install-source-root:G=) ;
63 requirements = [ property.change $(requirements) : <install-source-root> ] ;
65 local install-header-subdir = [ property.select <install-header-subdir> :
67 install-header-subdir = /$(install-header-subdir:G=) ;
68 install-header-subdir ?= "" ;
69 requirements = [ property.change $(requirements) : <install-header-subdir> ]
72 # First, figure out all locations. Use the default if no prefix option
74 local prefix = [ get-prefix $(name) : $(requirements) ] ;
76 # Architecture dependent files.
77 local exec-locate = [ option.get exec-prefix : $(prefix) ] ;
80 local bin-locate = [ option.get bindir : $(prefix)/bin ] ;
82 # Object code libraries.
83 local lib-locate = [ option.get libdir : $(prefix)/lib ] ;
85 # Source header files.
86 local include-locate = [ option.get includedir : $(prefix)/include ] ;
88 stage.install $(name)-bin : $(binaries) : $(requirements)
89 <location>$(bin-locate) ;
90 alias $(name)-lib : $(name)-lib-shared $(name)-lib-static ;
92 # Since the install location of shared libraries differs on universe
93 # and cygwin, use target alternatives to make different targets.
94 # We should have used indirection conditioanl requirements, but it's
95 # awkward to pass bin-locate and lib-locate from there to another rule.
96 alias $(name)-lib-shared : $(name)-lib-shared-universe ;
97 alias $(name)-lib-shared : $(name)-lib-shared-cygwin : <target-os>cygwin ;
99 # For shared libraries, we install both explicitly specified one and the
100 # shared libraries that the installed executables depend on.
101 stage.install $(name)-lib-shared-universe : $(binaries) $(libraries) : $(requirements)
102 <location>$(lib-locate) <install-dependencies>on <install-type>SHARED_LIB ;
103 stage.install $(name)-lib-shared-cygwin : $(binaries) $(libraries) : $(requirements)
104 <location>$(bin-locate) <install-dependencies>on <install-type>SHARED_LIB ;
106 # For static libraries, we do not care about executable dependencies, since
107 # static libraries are already incorporated into them.
108 stage.install $(name)-lib-static : $(libraries) : $(requirements)
109 <location>$(lib-locate) <install-dependencies>on <install-type>STATIC_LIB ;
110 stage.install $(name)-headers : $(headers) : $(requirements)
111 <location>$(include-locate)$(install-header-subdir)
112 <install-source-root>$(install-source-root) ;
113 alias $(name) : $(name)-bin $(name)-lib $(name)-headers ;
115 local c = [ project.current ] ;
116 local project-module = [ $(c).project-module ] ;
117 module $(project-module)
119 explicit $(1)-bin $(1)-lib $(1)-headers $(1) $(1)-lib-shared $(1)-lib-static
120 $(1)-lib-shared-universe $(1)-lib-shared-cygwin ;
124 rule install-data ( target-name : package-name : data * : requirements * )
126 package-name ?= target-name ;
127 if [ MATCH --prefix=(.*) : [ modules.peek : ARGV ] ]
129 # If --prefix is explicitly specified on the command line,
130 # then we need wipe away any settings of datarootdir
131 option.set datarootdir : ;
134 local prefix = [ get-prefix $(package-name) : $(requirements) ] ;
135 local datadir = [ option.get datarootdir : $(prefix)/share ] ;
137 stage.install $(target-name)
139 : $(requirements) <location>$(datadir)/$(package-name)
142 local c = [ project.current ] ;
143 local project-module = [ $(c).project-module ] ;
144 module $(project-module)
150 local rule get-prefix ( package-name : requirements * )
152 local prefix = [ option.get prefix : [ property.select
153 <install-default-prefix> : $(requirements) ] ] ;
154 prefix = $(prefix:G=) ;
155 requirements = [ property.change $(requirements) : <install-default-prefix>
157 # Or some likely defaults if neither is given.
160 if [ modules.peek : NT ] { prefix = C:\\$(package-name) ; }
161 else if [ modules.peek : UNIX ] { prefix = /usr/local ; }