Skip to content

Commit

Permalink
Accept CXXFLAGS and LDFLAGS from environment (GH #1237)
Browse files Browse the repository at this point in the history
Also remove a duplicated block (rebase error)
  • Loading branch information
randombit committed Dec 2, 2017
1 parent 70e88d6 commit 3415a93
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 30 deletions.
41 changes: 16 additions & 25 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ def process_command_line(args): # pylint: disable=too-many-locals
help='set compiler ABI flags',
default='')

target_group.add_option('--cxxflags', metavar='FLAG',
help='set compiler flags', default=None)

target_group.add_option('--ldflags', metavar='FLAG',
help='set linker flags', default=None)

target_group.add_option('--ar-command', dest='ar_command', metavar='AR', default=None,
help='set path to static archive creator')

Expand Down Expand Up @@ -622,6 +628,10 @@ def parse_multiple_enable(modules):
options.ar_command = os.getenv('AR')
if options.compiler_binary is None:
options.compiler_binary = os.getenv('CXX')
if options.cxxflags is None:
options.cxxflags = os.getenv('CXXFLAGS')
if options.ldflags is None:
options.ldflags = os.getenv('LDFLAGS')

return options

Expand Down Expand Up @@ -2088,7 +2098,8 @@ def configure_command_line():
'linker': cc.linker_name or '$(CXX)',

'cc_lang_flags': cc.cc_lang_flags(),
'cc_compile_flags': cc.cc_compile_flags(options),
'cc_compile_flags': options.cxxflags or cc.cc_compile_flags(options),
'ldflags': options.ldflags or '',
'cc_warning_flags': cc.cc_warning_flags(options),
'output_to_exe': cc.output_to_exe,

Expand Down Expand Up @@ -2138,6 +2149,8 @@ def configure_command_line():
variables['test_exe'] = os.path.join(variables['out_dir'],
'botan-test' + variables['program_suffix'])

variables['post_link_cmd'] = osinfo.so_post_link_command.format(**variables) if options.build_shared_lib else ''

if options.os == 'windows':
# For historical reasons? the library does not have the major number on Windows
# This should probably be fixed in a future major release.
Expand All @@ -2148,7 +2161,6 @@ def configure_command_line():
variables['libname'] = 'botan-%d' % (Version.major())
variables['lib_basename'] = 'lib' + variables['libname']
variables['cli_exe'] = os.path.join(variables['out_dir'], 'botan' + variables['program_suffix'])

variables['botan_pkgconfig'] = os.path.join(build_config.build_dir, PKG_CONFIG_FILENAME)

variables['static_lib_name'] = variables['lib_basename'] + '.' + variables['static_suffix']
Expand All @@ -2169,29 +2181,6 @@ def configure_command_line():
else:
variables['lib_link_cmd'] = ''

if options.os == 'darwin' and options.build_shared_lib:
# In order that these executables work from the build directory,
# we need to change the install names
variables['post_link_cmd'] = osinfo.so_post_link_command.format(**variables)
else:
variables['post_link_cmd'] = ''

variables.update(MakefileListsGenerator(build_config, options, modules, cc, arch, osinfo).generate())

if options.os == 'windows':
# For historical reasons? the library does not have the major number on Windows
# This should probably be fixed in a future major release.
variables['libname'] = 'botan'
variables['lib_basename'] = variables['libname']
variables['cli_exe'] = os.path.join(variables['out_dir'], 'botan-cli' + variables['program_suffix'])
else:
variables['libname'] = 'botan-%d' % (Version.major())
variables['lib_basename'] = 'lib' + variables['libname']
variables['cli_exe'] = os.path.join(variables['out_dir'], 'botan' + variables['program_suffix'])
variables['botan_pkgconfig'] = os.path.join(build_config.build_dir, PKG_CONFIG_FILENAME)

variables['static_lib_name'] = variables['lib_basename'] + '.' + variables['static_suffix']

if options.os == 'llvm' or options.compiler == 'msvc':
# llvm-link and msvc require just naming the file directly
variables['link_to_botan'] = os.path.join(variables['out_dir'], variables['static_lib_name'])
Expand All @@ -2208,6 +2197,8 @@ def configure_command_line():

variables['library_targets'] = ' '.join([os.path.join(variables['out_dir'], variables[t]) for t in lib_targets])

variables.update(MakefileListsGenerator(build_config, options, modules, cc, arch, osinfo).generate())

return variables

class ModulesChooser(object):
Expand Down
11 changes: 6 additions & 5 deletions src/build-data/makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LANG_FLAGS = %{cc_lang_flags}
CXXFLAGS = %{cc_compile_flags}
WARN_FLAGS = %{cc_warning_flags}
SO_OBJ_FLAGS = %{shared_flags}
LDFLAGS = %{ldflags}

LIB_LINK_CMD = %{lib_link_cmd}
EXE_LINK_CMD = %{exe_link_cmd}
Expand All @@ -27,7 +28,7 @@ INSTALLED_LIB_DIR = %{prefix}/%{libdir}
POST_LINK_CMD = %{post_link_cmd}

# The primary target
all: libs cli tests
all: libs cli tests docs

# Executable targets
CLI = %{cli_exe}
Expand All @@ -40,18 +41,18 @@ libs: $(LIBRARIES)

# Misc targets

docs:
%{build_doc_commands}

clean:
$(PYTHON_EXE) $(SCRIPTS_DIR)/cleanup.py --build-dir="%{build_dir}"

distclean:
$(PYTHON_EXE) $(SCRIPTS_DIR)/cleanup.py --build-dir="%{build_dir}" --distclean

install: $(CLI) docs
install: libs cli docs
$(PYTHON_EXE) $(SCRIPTS_DIR)/install.py --prefix=%{prefix} --build-dir="%{build_dir}" --bindir=%{bindir} --libdir=%{libdir} --docdir=%{docdir} --includedir=%{includedir}

docs:
%{build_doc_commands}

# Object Files
LIBOBJS = %{lib_objs}

Expand Down
2 changes: 2 additions & 0 deletions src/build-data/os/darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ soname_pattern_base "libbotan-{version_major}.dylib"
soname_pattern_abi "libbotan-{version_major}.{abi_rev}.dylib"
soname_pattern_patch "libbotan-{version_major}.{abi_rev}.{version_minor}.{version_patch}.dylib"

# In order that these executables work from the build directory,
# we need to change the install names
so_post_link_command "install_name_tool -change '$(INSTALLED_LIB_DIR)/{soname_abi}' '@executable_path/{soname_abi}' $@"

doc_dir doc
Expand Down

0 comments on commit 3415a93

Please sign in to comment.