The SCons wiki has moved to https://github.com/SCons/scons/wiki/PlatformIndependedInstallationTool
Platform independent installation
Multiplatform project may have some files which should be installed to different directories on different platforms or some files which should not be installed at all on some platforms. This Tool provides set of pseudo builders to install files using default installation directory structure of the target operation system and set correct permissions on POSIX systems. It creates alias target 'install' to install all targets at once.
How to get the tool
Tool is available in the following git repository: http://repo.or.cz/r/vestnik_site_scons.git in the file smartinstall.py
To get the latest version run:
git clone http://repo.or.cz/r/vestnik_site_scons.git
You can put this file into the site_scons/site_tools directory.
- Set the name of your program or library to the env['package'] variable in your environment. This key should exist in the environment before tool initialization since it's used to calculate default installation paths.
- Initialize the tool with the Tool() method in the Environment object.
- You may want to change some of installation paths using the following available environment variables:
- env['prefix'] installation path prefix. Default value: '/usr/locla' on Linux or 'C:\Program Files\$package' on Windows
- env['prefix_bin'] your program installation path. On windows it's used to install *.dll files. Default value: '$prefix/bin'
- env['prefix_lib'] libraries installation path. Default: '$prefix/lib'
- env['prefix_pc'] pkg-config *pc files installation path. Default: '$prefix/lib/pkgconfig'
- env['prefix_inc'] header files installation path. Default: '$prefix/include/$package' on Linux or '$prefix\include' on Windows
- env['prefix_data'] application data installation path. Default: '$prefix/share/$package' on Linux or '$prefix\data' on Windows
- env['install_dev'] Install or not development files. Should be True or False Default: False
- Now you can use the following pseudo builders:
- InstallProgram() installs files to '$prefix_bin' directory and sets 0755 permissions on Linux
- InstallLibrary() installs files to '$prefix_lib' except .dll files on Windows which are installed to '$prefix_bin'. Sets 0755 permissions to .so files and 0644 permissions to other files on Linux. If '$install_dev' is False this builder will install only shared libraries (.so on Linux or *.dll on Windows) other files will be ignored. TODO: add installing .so files with version suffixes and correct symlink creation (libMy.so -> libMy.so.1 -> libMy.so.1.2 -> libMy.so.1.2.3) on Linux.
- InstallPkgConfig() installs files to the '$prefix_pc' dir. Sets 0644 permissions on Linux. Doesn't install anything if '$install_dev' is False.
- InstallHeader() installs files to '$prefix_inc' dir. Sets 0644 permissions on Linux. Doesn't install anything if '$install_dev' is False.
- InstallData() installs files to '$prefix_data' dir. Sets 0644 permissions on Linux.
- All builders checks that 'install' target is specified and return None if not. Alias target 'install' created to install all files passed to those builders.
scons installto install your package and
scons install -cto uninstall it.
env = Environment() env['package'] = 'foo' env.Tool('smartinstall') lib = env.SharedLibrary('bar',[... lib sources here ...]) prog = env.Program('foo',[... lib sources here ...], LIBS='bar') env.InstallProgram(prog) env.InstallLibrary(lib)
will create the following installation:
bar.lib created by SharedLibrary builder will be ignored since '$install_dev' is set to False by default. If you explicitly set it to True
env = Environment() env['package'] = 'foo' env['install_dev'] = True env.Tool('smartinstall') lib = env.SharedLibrary('bar',[... lib sources here ...]) prog = env.Program('foo',[... lib sources here ...], LIBS='bar') env.InstallProgram(prog) env.InstallLibrary(lib)
the following files will be installed: