tools/build/v2/tools/gcc.jam
# Copyright (c) 2001 David Abrahams. # Copyright (c) 2002-2003 Rene Rivera. # Copyright (c) 2002-2003 Vladimir Prus. # # Use, modification and distribution is subject to the Boost Software # License Version 1.0. (See accompanying file LICENSE_1_0.txt or # http://www.boost.org/LICENSE_1_0.txt) import toolset : flags ; import property ; import generators ; import os ; import type ; import feature ; feature.extend toolset : gcc ; feature.subfeature toolset gcc : version : : optional propagated link-incompatible ; # Make the "o" suffix used for gcc toolset on all # platforms type.set-generated-target-suffix OBJ : <toolset>gcc : o ; type.set-generated-target-suffix STATIC_LIB : <toolset>gcc : a ; # Initializes the gcc toolset # Each argument has the form: # version binary-name [path] # And specifies the name / path that should be used to invoke # the specified gcc version. The default version will be always called # with 'g++'. rule init ( a1 * : a2 * : a3 * ) { if $(a1) { local version = $(a1[1]) ; local name = $(a1[2]) ; local path = $(a1[3]) ; feature.extend-subfeature toolset gcc : version : $(version) ; flags gcc NAME <toolset>gcc-$(version) : $(name) ; # TODO: set path accordingly. } } if [ os.name ] = NT { # This causes single-line command invocation to not go through # .bat files, thus avoiding command-line length limitations JAMSHELL = % ; } # Declare generators generators.register-linker gcc.link : LIB OBJ : EXE : <toolset>gcc ; generators.register-composing gcc.archive : OBJ : STATIC_LIB : <toolset>gcc ; generators.register-linker gcc.link.dll : LIB OBJ : SHARED_LIB : <toolset>gcc ; generators.register-c-compiler gcc.compile.c++ : CPP : OBJ : <toolset>gcc ; generators.register-c-compiler gcc.compile.c : C : OBJ : <toolset>gcc ; # Declare flags and action for compilation flags gcc.compile OPTIONS <optimization>off : -O0 ; flags gcc.compile OPTIONS <optimization>speed : -O3 ; flags gcc.compile OPTIONS <optimization>space : -Os ; flags gcc.compile OPTIONS <inlining>off : -fno-inline ; flags gcc.compile OPTIONS <inlining>on : -Wno-inline ; flags gcc.compile OPTIONS <inlining>full : -finline-functions -Wno-inline ; flags gcc.compile OPTIONS <debug-symbols>on : -g ; flags gcc.compile OPTIONS <profiling>on : -pg ; flags gcc.compile OPTIONS <cflags> ; flags gcc.compile.c++ OPTIONS <cxxflags> ; flags gcc.compile DEFINES <define> ; flags gcc.compile INCLUDES <include> ; actions compile.c++ { $(NAME:E=g++) -x c++ -Wall -ftemplate-depth-100 $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" } actions compile.c { $(NAME:E=gcc) -x c -Wall $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" } # Declare flags and action for linking flags gcc.link OPTIONS <debug-symbols>on : -g ; # Strip the binary when no debugging is needed. flags gcc.link OPTIONS <debug-symbols>off : -s ; flags gcc.link OPTIONS <profiling>on : -pg ; flags gcc.link OPTIONS <linkflags> ; flags gcc.link LINKPATH <library-path> ; flags gcc.link FINDLIBS-ST <find-static-library> ; flags gcc.link FINDLIBS-SA <find-shared-library> ; flags gcc.link LIBRARIES <library-file> ; flags gcc.link LINK-RUNTIME <link-runtime>static : static ; flags gcc.link LINK-RUNTIME <link-runtime>shared : dynamic ; flags gcc.link RPATH <dll-path> ; rule link ( targets * : sources * : properties * ) { SPACE on $(targets) = " " ; } actions link bind LIBRARIES { $(NAME:E=g++) $(OPTIONS) -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -Wl,-Bdynamic -l$(FINDLIBS-SA) -Wl,-Bstatic -l$(FINDLIBS-ST) "$(LIBRARIES)" -Wl,-Bdynamic -l$(FINDLIBS-SA) -Wl,-Bstatic -l$(FINDLIBS-ST) -Wl,-B$(LINK-RUNTIME) } # Declare action for creating static libraries actions piecemeal archive { ar ur "$(<)" "$(>)" } rule link.dll ( targets * : sources * : properties * ) { SPACE on $(targets) = " " ; } # Differ from 'link' above only by -shared. actions link.dll bind LIBRARIES { $(NAME:E=g++) $(OPTIONS) -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -o "$(<)" -Wl,-h$(SPACE)-Wl,$(<[1]:D=) -shared "$(>)" "$(LIBRARIES)" -Wl,-Bdynamic -l$(FINDLIBS-SA) -Wl,-Bstatic -l$(FINDLIBS-ST) "$(LIBRARIES)" -Wl,-Bdynamic -l$(FINDLIBS-SA) -Wl,-Bstatic -l$(FINDLIBS-ST) -Wl,-B$(LINK-RUNTIME) } # Set up threading support. It's somewhat contrived, so perform it at the end, # to avoid cluttering other code. if [ os.on-windows ] { flags gcc OPTIONS <threading>multi : -mthreads ; } else if [ modules.peek : UNIX ] { switch [ modules.peek : JAMUNAME ] { case SunOS* : { flags gcc OPTIONS <threading>multi : -pthreads ; flags gcc FINDLIBS <threading>multi : rt ; } case BeOS : { # BeOS has no threading options, don't set anything here. } case *BSD : { flags gcc OPTIONS <threading>multi : -pthread ; # there is no -lrt on BSD } case IRIX : { # gcc on IRIX does not support multi-threading, don't set anything here. } case HP_UX : { # gcc on HP-UX does not support multi-threading, don't set anything here } case * : { flags gcc OPTIONS <threading>multi : -pthread ; flags gcc FINDLIBS <threading>multi : rt ; } } }