aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-12-11 16:25:06 -0500
committerJack Lloyd <[email protected]>2017-12-11 20:10:54 -0500
commit6c7b3fc30ede3f78cc91868e496ff9b4476423a6 (patch)
treed11a0df1cd5fbe7a950ae3572c4d1c049b364e5f
parent48502ed20525e631f5a565877747d0fa1debbfcc (diff)
Clean up macro generation
-rwxr-xr-xconfigure.py24
-rw-r--r--src/build-data/buildh.in30
-rwxr-xr-xsrc/scripts/install.py2
3 files changed, 32 insertions, 24 deletions
diff --git a/configure.py b/configure.py
index bfd1a0102..f9092108a 100755
--- a/configure.py
+++ b/configure.py
@@ -1029,8 +1029,6 @@ class ArchInfo(InfoObject):
if self.family is not None:
macros.append('TARGET_CPU_IS_%s_FAMILY' % (self.family.upper()))
- macros.append('TARGET_CPU_NATIVE_WORD_SIZE %d' % (self.wordsize))
-
if self.wordsize == 64:
macros.append('TARGET_CPU_HAS_NATIVE_64BIT')
@@ -1729,9 +1727,6 @@ def create_template_vars(source_paths, build_config, options, modules, cc, arch,
Create the template variables needed to process the makefile, build.h, etc
"""
- def make_cpp_macros(macros):
- return '\n'.join(['#define BOTAN_' + macro for macro in macros])
-
def external_link_cmd():
return (' ' + cc.add_lib_dir_option + options.with_external_libdir) if options.with_external_libdir else ''
@@ -1910,22 +1905,19 @@ def create_template_vars(source_paths, build_config, options, modules, cc, arch,
'libs_used': [lib.replace('.lib', '') for lib in link_to('libs')],
'include_paths': build_config.format_include_paths(cc, options.with_external_includedir),
- 'module_defines': make_cpp_macros(sorted(flatten([m.defines() for m in modules]))),
-
- 'target_os_defines': make_cpp_macros(osinfo.defines(options)),
+ 'module_defines': sorted(flatten([m.defines() for m in modules])),
- 'target_compiler_defines': make_cpp_macros(cc.defines()),
-
- 'target_cpu_defines': make_cpp_macros(arch.defines(cc, options)),
+ 'os_defines': osinfo.defines(options),
+ 'cc_defines': cc.defines(),
+ 'cpu_defines': arch.defines(cc, options),
+ 'house_ecc_curve_defines': house_ecc_curve_macros(options.house_curve),
'botan_include_dir': build_config.botan_include_dir,
- 'unsafe_fuzzer_mode_define': '#define BOTAN_UNSAFE_FUZZER_MODE' if options.unsafe_fuzzer_mode else '',
- 'fuzzer_type': '#define BOTAN_FUZZER_IS_%s' % (options.build_fuzzers.upper()) if options.build_fuzzers else '',
-
- 'mod_list': '\n'.join(sorted([m.basename for m in modules])),
+ 'fuzzer_mode': options.unsafe_fuzzer_mode,
+ 'fuzzer_type': options.build_fuzzers.upper() if options.build_fuzzers else '',
- 'house_ecc_curve_defines': make_cpp_macros(house_ecc_curve_macros(options.house_curve))
+ 'mod_list': sorted([m.basename for m in modules])
}
if options.os != 'windows':
diff --git a/src/build-data/buildh.in b/src/build-data/buildh.in
index 822a73c44..aeae12cec 100644
--- a/src/build-data/buildh.in
+++ b/src/build-data/buildh.in
@@ -24,8 +24,13 @@
/* How many bits per limb in a BigInt */
#define BOTAN_MP_WORD_BITS %{mp_bits}
-%{unsafe_fuzzer_mode_define}
-%{fuzzer_type}
+
+%{if fuzzer_mode}
+#define BOTAN_UNSAFE_FUZZER_MODE
+%{endif}
+%{if fuzzer_type}
+#define BOTAN_FUZZER_IS_%{fuzzer_type}
+%{endif}
#define BOTAN_INSTALL_PREFIX R"(%{prefix})"
#define BOTAN_INSTALL_HEADER_DIR "%{includedir}/botan-%{version_major}"
@@ -38,22 +43,33 @@
#endif
/* Target identification and feature test macros */
-%{target_os_defines}
+%{for os_defines}
+#define BOTAN_%{i}
+%{endfor}
-%{target_cpu_defines}
+%{for cc_defines}
+#define BOTAN_%{i}
+%{endfor}
-%{target_compiler_defines}
+%{for cpu_defines}
+#define BOTAN_%{i}
+%{endfor}
/*
* Module availability definitions
*/
-%{module_defines}
+%{for module_defines}
+#define BOTAN_%{i}
+%{endfor}
/*
* Local/misc configuration options (if any) follow
*/
%{local_config}
-%{house_ecc_curve_defines}
+
+%{for house_ecc_curve_defines}
+%{i}
+%{endfor}
/*
* Things you can edit (but probably shouldn't)
diff --git a/src/scripts/install.py b/src/scripts/install.py
index c6e4ec2cd..d30493ebe 100755
--- a/src/scripts/install.py
+++ b/src/scripts/install.py
@@ -229,7 +229,7 @@ def main(args):
copy_file(cfg['botan_pkgconfig'],
prepend_destdir(os.path.join(pkgconfig_dir, os.path.basename(cfg['botan_pkgconfig']))))
- if 'ffi' in cfg['mod_list'].split('\n'):
+ if 'ffi' in cfg['mod_list']:
for ver in cfg['python_version'].split(','):
py_lib_path = os.path.join(lib_dir, 'python%s' % (ver), 'site-packages')
logging.debug('Installing python module to %s' % (py_lib_path))