1# Copyright (C) Christopher Currie 2003. Permission to copy, use, 2# modify, sell and distribute this software is granted provided this 3# copyright notice appears in all copies. This software is provided 4# "as is" without express or implied warranty, and with no claim as to 5# its suitability for any purpose. 6 7# Please see http://article.gmane.org/gmane.comp.lib.boost.build/3389/ 8# for explanation why it's a separate toolset. 9 10import common, gcc, builtin 11from b2.build import feature, toolset, type, action, generators 12from b2.util.utility import * 13 14toolset.register ('darwin') 15 16toolset.inherit_generators ('darwin', [], 'gcc') 17toolset.inherit_flags ('darwin', 'gcc') 18toolset.inherit_rules ('darwin', 'gcc') 19 20def init (version = None, command = None, options = None): 21 options = to_seq (options) 22 23 condition = common.check_init_parameters ('darwin', None, ('version', version)) 24 25 command = common.get_invocation_command ('darwin', 'g++', command) 26 27 common.handle_options ('darwin', condition, command, options) 28 29 gcc.init_link_flags ('darwin', 'darwin', condition) 30 31# Darwin has a different shared library suffix 32type.set_generated_target_suffix ('SHARED_LIB', ['<toolset>darwin'], 'dylib') 33 34# we need to be able to tell the type of .dylib files 35type.register_suffixes ('dylib', 'SHARED_LIB') 36 37feature.feature ('framework', [], ['free']) 38 39toolset.flags ('darwin.compile', 'OPTIONS', '<link>shared', ['-dynamic']) 40toolset.flags ('darwin.compile', 'OPTIONS', None, ['-Wno-long-double', '-no-cpp-precomp']) 41toolset.flags ('darwin.compile.c++', 'OPTIONS', None, ['-fcoalesce-templates']) 42 43toolset.flags ('darwin.link', 'FRAMEWORK', '<framework>') 44 45# This is flag is useful for debugging the link step 46# uncomment to see what libtool is doing under the hood 47# toolset.flags ('darwin.link.dll', 'OPTIONS', None, '[-Wl,-v']) 48 49action.register ('darwin.compile.cpp', None, ['$(CONFIG_COMMAND) $(ST_OPTIONS) -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) -framework$(_)$(FRAMEWORK) $(OPTIONS)']) 50 51# TODO: how to set 'bind LIBRARIES'? 52action.register ('darwin.link.dll', None, ['$(CONFIG_COMMAND) -dynamiclib -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) -framework$(_)$(FRAMEWORK) $(OPTIONS)']) 53 54def darwin_archive (manager, targets, sources, properties): 55 pass 56 57action.register ('darwin.archive', darwin_archive, ['ar -c -r -s $(ARFLAGS) "$(<:T)" "$(>:T)"']) 58