aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure.py43
-rw-r--r--src/build-data/botan-config.in17
-rw-r--r--src/build-data/makefile/dso.in6
-rw-r--r--src/build-data/makefile/gmake.in35
-rw-r--r--src/build-data/makefile/header.in8
-rw-r--r--src/build-data/makefile/nmake.in10
-rwxr-xr-xsrc/scripts/install.py171
7 files changed, 210 insertions, 80 deletions
diff --git a/configure.py b/configure.py
index 9d5b4304b..cc51d2a22 100755
--- a/configure.py
+++ b/configure.py
@@ -175,9 +175,6 @@ class BuildConfigurationInformation(object):
yield cmd_for('manual')
- if options.build_relnotes:
- yield cmd_for('relnotes')
-
if options.with_doxygen:
yield 'doxygen %s/botan.doxy' % (self.build_dir)
@@ -191,9 +188,6 @@ class BuildConfigurationInformation(object):
yield self.internal_include_dir
yield os.path.join(self.doc_output_dir, 'manual')
- if options.build_relnotes:
- yield os.path.join(self.doc_output_dir, 'relnotes')
-
if options.with_doxygen:
yield os.path.join(self.doc_output_dir, 'doxygen')
@@ -333,9 +327,6 @@ def process_command_line(args):
default=None,
help='Use Sphinx to generate HTML manual')
- build_group.add_option('--build-relnotes', action='store_true', default=False,
- help='Use Sphinx to produce HTML release notes')
-
build_group.add_option('--without-sphinx', action='store_false',
dest='with_sphinx', help=optparse.SUPPRESS_HELP)
@@ -420,6 +411,8 @@ def process_command_line(args):
help='set the install directory')
install_group.add_option('--docdir', metavar='DIR',
help='set the documentation install directory')
+ install_group.add_option('--bindir', metavar='DIR',
+ help='set the binary install directory')
install_group.add_option('--libdir', metavar='DIR',
help='set the library install directory')
install_group.add_option('--includedir', metavar='DIR',
@@ -433,7 +426,6 @@ def process_command_line(args):
# These exist only for autoconf compatability (requested by zw for mtn)
compat_with_autoconf_options = [
- 'bindir',
'datadir',
'datarootdir',
'dvidir',
@@ -944,6 +936,7 @@ class OsInfo(object):
'ar_needs_ranlib': False,
'install_root': '/usr/local',
'header_dir': 'include',
+ 'bin_dir': 'bin',
'lib_dir': 'lib',
'doc_dir': 'share/doc',
'build_shared': 'yes',
@@ -1223,12 +1216,16 @@ def create_template_vars(build_config, options, modules, cc, arch, osinfo):
'prefix': options.prefix or osinfo.install_root,
'destdir': options.destdir or options.prefix or osinfo.install_root,
+ 'bindir': options.bindir or osinfo.bin_dir,
'libdir': options.libdir or osinfo.lib_dir,
'includedir': options.includedir or osinfo.header_dir,
'docdir': options.docdir or osinfo.doc_dir,
+ 'out_dir': options.with_build_dir or os.path.curdir,
'build_dir': build_config.build_dir,
+ 'with_shared_lib': options.build_shared_lib,
+
'appobj_dir': build_config.appobj_dir,
'libobj_dir': build_config.libobj_dir,
'testobj_dir': build_config.testobj_dir,
@@ -1261,6 +1258,8 @@ def create_template_vars(build_config, options, modules, cc, arch, osinfo):
'shared_flags': cc.gen_shared_flags(options),
'visibility_attribute': cc.gen_visibility_attribute(options),
+ 'libname': 'botan-%d.%d' % (build_config.version_major, build_config.version_minor),
+
'so_link': cc.so_link_command_for(osinfo.basename),
'link_to': ' '.join([cc.add_lib_option + lib for lib in link_to()]),
@@ -1316,25 +1315,24 @@ def create_template_vars(build_config, options, modules, cc, arch, osinfo):
'install_cmd_exec': osinfo.install_cmd_exec,
'install_cmd_data': osinfo.install_cmd_data,
- 'app_prefix': prefix_with_build_dir(''),
- 'lib_prefix': prefix_with_build_dir(''),
+ 'lib_prefix': 'lib' if options.os != 'windows' else '',
'static_suffix': osinfo.static_suffix,
'so_suffix': osinfo.so_suffix,
- 'botan_config': prefix_with_build_dir(
- os.path.join(build_config.build_dir,
- build_config.config_shell_script())),
-
- 'botan_pkgconfig': prefix_with_build_dir(
- os.path.join(build_config.build_dir,
- build_config.pkg_config_file())),
-
'mod_list': '\n'.join(sorted([m.basename for m in modules])),
- 'python_version': options.python_version
+ 'python_version': options.python_version,
+ 'with_sphinx': options.with_sphinx
}
+ if options.os != 'windows':
+ vars['botan_config'] = prefix_with_build_dir(os.path.join(build_config.build_dir,
+ build_config.config_shell_script()))
+ vars['botan_pkgconfig'] = prefix_with_build_dir(os.path.join(build_config.build_dir,
+ build_config.pkg_config_file()))
+
+
vars["header_in"] = process_template('src/build-data/makefile/header.in', vars)
vars["commands_in"] = process_template('src/build-data/makefile/commands.in', vars)
@@ -1649,6 +1647,9 @@ def setup_build(build_config, options, template_vars):
link_headers(build_config.build_internal_headers, 'internal',
build_config.internal_include_dir)
+ with open(os.path.join(build_config.build_dir, 'build_config.py'), 'w') as f:
+ f.write(str(template_vars))
+
"""
Generate the amalgamation
"""
diff --git a/src/build-data/botan-config.in b/src/build-data/botan-config.in
index f855cbc50..e8d8bc2c1 100644
--- a/src/build-data/botan-config.in
+++ b/src/build-data/botan-config.in
@@ -1,16 +1,9 @@
#!/bin/sh
-# For normal builds:
-guess_prefix=`dirname \`dirname $0\``
+prefix=%{prefix}
includedir=%{includedir}/botan-%{version_major}.%{version_minor}
libdir=%{libdir}
-# For workspace builds:
-#guess_prefix=`dirname $0`
-#includedir=build/include
-#libdir=
-
-install_prefix=%{prefix}
prefix=
usage()
@@ -23,12 +16,6 @@ if test $# -eq 0; then
usage
fi
-if test `echo $guess_prefix | cut -c 1` = "/"; then
- prefix=$guess_prefix
-else
- prefix=$install_prefix
-fi
-
while test $# -gt 0; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
@@ -49,7 +36,7 @@ while test $# -gt 0; do
echo -I$prefix/$includedir
;;
--libs)
- if [ $prefix != "/usr" -a $prefix != "/usr/local" ]
+ if [ $prefix != "/usr" ]
then
echo -L$prefix/$libdir -lbotan-%{version_major}.%{version_minor} %{link_to}
else
diff --git a/src/build-data/makefile/dso.in b/src/build-data/makefile/dso.in
index 7e9829fff..0c791515f 100644
--- a/src/build-data/makefile/dso.in
+++ b/src/build-data/makefile/dso.in
@@ -1,6 +1,6 @@
-SONAME = $(LIBNAME)-$(BRANCH).%{so_suffix}.%{so_abi_rev}
-SHARED_LIB = $(SONAME).%{version_patch}
-SYMLINK = $(LIBNAME)-$(BRANCH).%{so_suffix}
+SHARED_LIB = $(LIBNAME).%{so_suffix}.%{so_abi_rev}.%{version_patch}
+SONAME = $(LIBNAME).%{so_suffix}.%{so_abi_rev}
+SYMLINK = $(LIBNAME).%{so_suffix}
$(SHARED_LIB): $(LIBOBJS)
$(LIB_LINK_CMD) $(LDFLAGS) $(LIBOBJS) $(LIB_LINKS_TO) -o $(SHARED_LIB)
diff --git a/src/build-data/makefile/gmake.in b/src/build-data/makefile/gmake.in
index e9320ce02..6b2703cb7 100644
--- a/src/build-data/makefile/gmake.in
+++ b/src/build-data/makefile/gmake.in
@@ -3,12 +3,9 @@
%{commands_in}
# Library targets
-LIBRARIES = $(STATIC_LIB)
-
-LIBNAME = %{lib_prefix}libbotan
-STATIC_LIB = $(LIBNAME)-$(BRANCH).a
+STATIC_LIB = %{out_dir}/$(LIBNAME).%{static_suffix}
-LIBPATH = botan-$(BRANCH)
+LIBRARIES = $(STATIC_LIB)
# File Lists
INCLUDE_DIR = %{botan_include_dir}
@@ -30,10 +27,10 @@ TESTOBJS = %{test_objs}
%{dso_in}
$(APP): $(LIBRARIES) $(APPOBJS)
- $(CXX) $(LDFLAGS) $(APPOBJS) -L. -l$(LIBPATH) $(APP_LINKS_TO) -o $(APP)
+ $(CXX) $(LDFLAGS) $(APPOBJS) -L%{out_dir} -l%{libname} $(APP_LINKS_TO) -o $(APP)
$(TEST): $(LIBRARIES) $(TESTOBJS)
- $(CXX) $(LDFLAGS) $(TESTOBJS) -L. -l$(LIBPATH) $(TEST_LINKS_TO) -o $(TEST)
+ $(CXX) $(LDFLAGS) $(TESTOBJS) -L%{out_dir} -l%{libname} $(TEST_LINKS_TO) -o $(TEST)
$(STATIC_LIB): $(LIBOBJS)
$(RM) $(STATIC_LIB)
@@ -64,29 +61,7 @@ docs:
%{build_doc_commands}
install: $(LIBRARIES) docs
- $(MKDIR_INSTALL) $(DOCDIR)
- $(COPY_R) %{doc_output_dir}/* $(DOCDIR)
-
- $(MKDIR_INSTALL) $(HEADERDIR)
- for i in $(INCLUDE_DIR)/*.h; do \
- $(INSTALL_CMD_DATA) $$i $(HEADERDIR); \
- done
-
- $(MKDIR_INSTALL) $(LIBDIR)
- $(INSTALL_CMD_DATA) $(STATIC_LIB) $(LIBDIR)
-
-ifneq ($(SHARED_LIB),)
- $(INSTALL_CMD_EXEC) $(SHARED_LIB) $(LIBDIR)
- $(CD) $(LIBDIR); $(LN) $(SHARED_LIB) $(SYMLINK)
- $(CD) $(LIBDIR); $(LN) $(SHARED_LIB) $(SONAME)
-endif
-
- $(MKDIR_INSTALL) $(BINDIR)
- $(INSTALL_CMD_EXEC) $(CONFIG_SCRIPT) $(BINDIR)
- $(INSTALL_CMD_EXEC) $(APP) $(BINDIR)
-
- $(MKDIR_INSTALL) $(PKGCONF_DIR)
- $(INSTALL_CMD_DATA) $(PKGCONFIG) $(PKGCONF_DIR)
+ $(SCRIPTS_DIR)/install.py --destdir=%{destdir} --bindir=%{bindir} --libdir=%{libdir} --docdir=%{docdir} --includedir=%{includedir}
website:
rm -rf $(WEBSITE_SRC_DIR) $(WEBSITE_DIR)
diff --git a/src/build-data/makefile/header.in b/src/build-data/makefile/header.in
index c481f65f3..86d4c65c5 100644
--- a/src/build-data/makefile/header.in
+++ b/src/build-data/makefile/header.in
@@ -16,10 +16,14 @@ LIB_FLAGS = $(SO_OBJ_FLAGS) $(LANG_FLAGS) $(LIB_OPT) $(WARN_FLAGS)
APP_FLAGS = $(LANG_FLAGS) $(APP_OPT) $(WARN_FLAGS)
TEST_FLAGS = $(LANG_FLAGS) $(APP_OPT) $(WARN_FLAGS)
+SCRIPTS_DIR = src/scripts
+
# Version Numbers
VERSION = %{version}
BRANCH = %{version_major}.%{version_minor}
+LIBNAME = %{lib_prefix}botan-%{version_major}.%{version_minor}
+
# Installation Settings
DESTDIR = %{destdir}
BINDIR = $(DESTDIR)/bin
@@ -32,7 +36,7 @@ CONFIG_SCRIPT = %{botan_config}
PKGCONFIG = %{botan_pkgconfig}
# Executable targets
-APP = %{app_prefix}botan%{program_suffix}
-TEST = %{app_prefix}botan-test%{program_suffix}
+APP = %{out_dir}/botan%{program_suffix}
+TEST = %{out_dir}/botan-test%{program_suffix}
all: $(APP) $(TEST)
diff --git a/src/build-data/makefile/nmake.in b/src/build-data/makefile/nmake.in
index f45690d06..95d8c0422 100644
--- a/src/build-data/makefile/nmake.in
+++ b/src/build-data/makefile/nmake.in
@@ -73,12 +73,4 @@ distclean: clean
$(RM) Makefile $(LIBNAME).* $(APP).*
install: $(LIBRARIES) docs
- -$(MKDIR) $(DESTDIR)\include\botan
- $(INSTALL_CMD) botan.* $(DESTDIR)
- $(INSTALL_CMD) build\include\botan\*.h $(DESTDIR)\include\botan
-
- -$(MKDIR) $(DESTDIR)\bin
- $(INSTALL_CMD) $(APP) $(DESTDIR)\bin
-
- -$(MKDIR) $(DESTDIR)\lib
- $(INSTALL_CMD) $(LIBRARIES) $(DESTDIR)\lib
+ $(SCRIPTS_DIR)/install.py --destdir=%{destdir} --bindir=%{bindir} --libdir=%{libdir} --docdir=%{docdir} --includedir=%{includedir}
diff --git a/src/scripts/install.py b/src/scripts/install.py
new file mode 100755
index 000000000..f3daa9f44
--- /dev/null
+++ b/src/scripts/install.py
@@ -0,0 +1,171 @@
+#!/usr/bin/python
+
+import errno
+import logging
+import optparse
+import os
+import shutil
+import string
+import sys
+
+def parse_command_line(args):
+
+ parser = optparse.OptionParser()
+
+ parser.add_option('--verbose', action='store_true', default=False,
+ help='Show debug messages')
+ parser.add_option('--quiet', action='store_true', default=False,
+ help='Show only warnings and errors')
+
+ build_group = optparse.OptionGroup(parser, 'Source options')
+ build_group.add_option('--build-dir', metavar='DIR', default='build',
+ help='Location of build output (default \'%default\')')
+ parser.add_option_group(build_group)
+
+ install_group = optparse.OptionGroup(parser, 'Installation options')
+ install_group.add_option('--destdir', default='/tmp/local',
+ help='Set output directory (default %default)')
+ install_group.add_option('--bindir', default='bin', metavar='DIR',
+ help='Set binary subdir (default %default)')
+ install_group.add_option('--libdir', default='lib', metavar='DIR',
+ help='Set library subdir (default %default)')
+ install_group.add_option('--includedir', default='include', metavar='DIR',
+ help='Set include subdir (default %default)')
+ install_group.add_option('--docdir', default='share/doc', metavar='DIR',
+ help='Set documentation subdir (default %default)')
+ install_group.add_option('--pkgconfigdir', default='pkgconfig', metavar='DIR',
+ help='Set pkgconfig subdir (default %default)')
+
+ install_group.add_option('--include-dir-suffix', metavar='SUFFIX', default='',
+ help='Set optional suffix on include dir')
+ install_group.add_option('--doc-dir-suffix', metavar='SUFFIX', default='',
+ help='Set optional suffix on doc dir')
+
+ install_group.add_option('--umask', metavar='MASK', default='022',
+ help='Umask to set (default %default)')
+ parser.add_option_group(install_group)
+
+ (options, args) = parser.parse_args(args)
+
+ def log_level():
+ if options.verbose:
+ return logging.DEBUG
+ if options.quiet:
+ return logging.WARNING
+ return logging.INFO
+
+ logging.getLogger().setLevel(log_level())
+
+ return (options, args)
+
+def makedirs(dirname, exist_ok = True):
+ try:
+ logging.debug('Creating directory %s' % (dirname))
+ os.makedirs(dirname)
+ except OSError as e:
+ if e.errno != errno.EEXIST or not exist_ok:
+ raise e
+
+def main(args = None):
+ if args is None:
+ args = sys.argv
+
+ logging.basicConfig(stream = sys.stdout,
+ format = '%(levelname) 7s: %(message)s')
+
+ (options, args) = parse_command_line(args)
+
+ exe_mode = 0777
+
+ if 'umask' in os.__dict__:
+ umask = int(options.umask, 8)
+ logging.debug('Setting umask to %s' % oct(umask))
+ os.umask(int(options.umask, 8))
+ exe_mode &= (umask ^ 0777)
+
+ def copy_executable(src, dest):
+ shutil.copyfile(src, dest)
+ logging.debug('Copied %s to %s' % (src, dest))
+ os.chmod(dest, exe_mode)
+
+ build_vars = eval(open(os.path.join(options.build_dir, 'build_config.py')).read())
+
+ def process_template(template_str):
+ class PercentSignTemplate(string.Template):
+ delimiter = '%'
+
+ try:
+ template = PercentSignTemplate(template_str)
+ return template.substitute(build_vars)
+ except KeyError as e:
+ raise Exception('Unbound var %s in template' % (e))
+ except Exception as e:
+ raise Exception('Exception %s in template' % (e))
+
+ bin_dir = os.path.join(options.destdir, options.bindir)
+ lib_dir = os.path.join(options.destdir, options.libdir)
+ doc_dir = os.path.join(options.destdir, options.docdir)
+ include_dir = os.path.join(options.destdir, options.includedir)
+ botan_doc_dir = os.path.join(doc_dir, 'botan' + options.doc_dir_suffix)
+ botan_include_dir = os.path.join(include_dir, 'botan' + options.include_dir_suffix)
+
+ out_dir = process_template('%{out_dir}')
+ app_exe = process_template('botan%{program_suffix}')
+
+ makedirs(options.destdir)
+ makedirs(lib_dir)
+ makedirs(bin_dir)
+ makedirs(doc_dir)
+ makedirs(include_dir)
+ makedirs(botan_include_dir) # False
+
+ build_include_dir = os.path.join(options.build_dir, 'include', 'botan')
+
+ for include in os.listdir(build_include_dir):
+ if include == 'internal':
+ continue
+ shutil.copyfile(os.path.join(build_include_dir, include),
+ os.path.join(botan_include_dir, include))
+
+ static_lib = process_template('%{lib_prefix}%{libname}.%{static_suffix}')
+ shutil.copyfile(static_lib, os.path.join(lib_dir, os.path.basename(static_lib)))
+
+ if bool(build_vars['with_shared_lib']):
+ shared_lib = process_template('%{lib_prefix}%{libname}.%{so_suffix}.%{so_abi_rev}.%{version_patch}')
+ soname = process_template('%{lib_prefix}%{libname}.%{so_suffix}.%{so_abi_rev}')
+ baselib = process_template('%{lib_prefix}%{libname}.%{so_suffix}')
+
+ copy_executable(shared_lib, os.path.join(lib_dir, os.path.basename(shared_lib)))
+
+ prev_cwd = os.getcwd()
+ try:
+ os.chdir(lib_dir)
+ os.symlink(shared_lib, soname)
+ os.symlink(soname, baselib)
+ finally:
+ os.chdir(prev_cwd)
+
+ copy_executable(os.path.join(out_dir, app_exe), os.path.join(bin_dir, app_exe))
+
+ if 'botan_config' in build_vars:
+ copy_executable(build_vars['botan_config'],
+ os.path.join(bin_dir, os.path.basename(build_vars['botan_config'])))
+
+ if 'botan_pkgconfig' in build_vars:
+ pkgconfig_dir = os.path.join(options.destdir, options.pkgconfigdir)
+ makedirs(pkgconfig_dir)
+ shutil.copyfile(build_vars['botan_pkgconfig'],
+ os.path.join(pkgconfig_dir, os.path.basename(build_vars['botan_pkgconfig'])))
+
+ shutil.copytree(build_vars['doc_output_dir'], botan_doc_dir)
+
+ logging.info('Botan %s installation complete', build_vars['version'])
+
+if __name__ == '__main__':
+ try:
+ sys.exit(main())
+ except Exception as e:
+ logging.error('Failure: %s' % (e))
+ import traceback
+ logging.debug(traceback.format_exc())
+ sys.exit(1)