kjam build tool
WARNINGThis web site is designed for Firefox, Internet Explorer 6+, Safari, and Opera 9+. We apologize if this site does not render correctly on your browser.
KJam main page KJam performance information KJam is the world's fastest build tool. \n Using KJam achieves the fastest compile time. \n KJam is an efficient build tool. It runs on Windows and Linux. \n KJam is a distributed build tool.\n It can be called a distributed build system or distributed build software.\n KJam is a variant of Jam or Jam/MR, just like BoostJam or Boost.Build, or FTJam.\n It builds in parallel like distcc. It is compatible with DJGPP and ccache.\n KJam results in the shortest incremental build times.\n

These files define all the update actions themselves. Each file is platform specific. All tools, their compiler options and how they are called are defined here. In this case we have two files, one for Windows, and another for Linux.

Here is a Windows version of the actions:


# definitions -------------------------------------------- # Specify the version of the c compiler we are using. This determines things # like the default compiler directories, and some special compilation options # CC_VER = MSVC6 ; # CC_VER = MSVC7 ; # CC_VER = MSVC8 ; if ( !$(CC_VER) ) { # CC_VER not set manually, so lets try to figure out what compilers are installed and what we should be using # does MSVC8 exist? if ( $(MSDEVDIR) ) CC_VER = MSVC6 ; if ( $(VS71COMNTOOLS) ) CC_VER = MSVC7 ; if ( $(VCToolkitInstallDir) ) CC_VER = MSVC7TK ; if ( $(VS80COMNTOOLS) ) CC_VER = MSVC8 ; } if ( $(CC_VER) == MSVC8 ) { MSVCDIR ?= "$(VCINSTALLDIR:N=\"\\\"0=\"/\"J=\" \")/vc" ; MSVCDIR ?= "$(VS80COMNTOOLS:N=\"\\\"0=\"/\"J=\" \")../../vc" ; MSVC_VER_DEBUG_OPTS = /RTCsu ; } if ( $(CC_VER) == MSVC7 ) { MSVCDIR ?= "$(VCINSTALLDIR:N=\"\\\"0=\"/\"J=\" \")/vc" ; MSVCDIR ?= "$(VS71COMNTOOLS:N=\"\\\"0=\"/\"J=\" \")../../vc" ; } if ( $(CC_VER) == MSVC7TK ) { MSVCDIR ?= "$(VCToolkitInstallDir:N=\"\\\"0=\"/\"J=\" \"N=\"/$\"0=\"\")" ; if ( $(CURFLAV) != release ) print "Warning: Microsoft Visual C++ Toolkit 2003 does not come with debug versions their c run-time libraries. Programs may fail to link unless compiled in release mode." ; } if ( $(CC_VER) == MSVC6 ) { MSVCDIR ?= "$(MSDEVDIR:N=\"\\\"0=\"/\"J=\" \")../../vc" ; } # if the platform sdk is installed lets search it for headers and libs MSPLAT_SDK_DIR ?= "C:/Program Files/Microsoft Platform SDK" ; # The tools we are going to use ---------------------------- CC ?= cl.exe /nologo ; LINKER ?= link.exe /nologo ; LIBEXE ?= link.exe /lib /nologo ; LEX ?= flex.exe ; YACC ?= bison.exe ; FSMC ?= fsmc.exe ; DEFAULT_LIB_DIRS ?= $(MSVCDIR)/lib $(MSPLAT_SDK_DIR)/lib ; DEFAULT_INCLUDE_DIRS ?= $(MSVCDIR)/include $(MSPLAT_SDK_DIR)/include ; OBJ_SUFFIX = .obj ; EXE_SUFFIX = .exe ; LIB_SUFFIX = .lib ; LIB_PREFIX = "" ; DLL_SUFFIX = .dll .lib ; # By default we use the built-in jam shell. Defining one of the following will cause # jam to use the given shell # JAMSHELL ?= "bash -c %" ; # JAMSHELL ?= "cmd.exe %" ; # macros to control output --------------------------------- if ( $(SHELL) ) { # using a unix type shell - which probably supports ansi codes SILENCE = " | rgxrpl -g (warning)\|(error) -1 \[1;31mwarning\[0m -2 \[1;31merror\[0m -x (\\.\\./)+ -d 0" ; } else { # using the primitive dos shell - which does not support ansi codes SILENCE = " | rgxrpl -g (warning)\|(error) -x (\\.\\./)+ -d 0" ; } # the flags ----------------------------- # to debug parsers: # YACC_FLAGS = --report=all ; # when compiling for use with purify, uncomment this line # PURIFY_LINKOPTS = "/INCREMENTAL:NO /FIXED:NO" ; rule ActionInitDirs { LIB_DIRS += $(DEFAULT_LIB_DIRS) ; INCLUDE_DIRS = $(INCLUDE_DIRS)/win32 $(INCLUDE_DIRS) $(DEFAULT_INCLUDE_DIRS) ; COMMON_DEFINES = WIN32 $(CCDEFINES) ; COMMON_CCOPTS += /W3 /c /GR- /EHs-c- "/I \"../../../../$(INCLUDE_DIRS:X=\"[[:alpha:]]:.*\")\"" "/I \"$(INCLUDE_DIRS:I=\"[[:alpha:]]:.*\")\"" ; if ( $(CURFLAV) ) CURFLAV = $(CURFLAV:L) ; else CURFLAV = debug ; if ( $(CURFLAV) == extra_debug ) { BUILD_CODE = x ; COMMON_DEFINES += _DEBUG DEBUG EXTRA_DEBUG ; CCOPTS = $(COMMON_CCOPTS) $(MSVC_VER_DEBUG_OPTS) /Z7 /MTd /Od /D$(COMMON_DEFINES) $(CCOPTS) ; LINKOPTS = /debug $(PURIFY_LINKOPTS) "/LIBPATH:\"$(LIB_DIRS)\"" /NODEFAULTLIB:libc $(LINKOPTS) ; } else if ( $(CURFLAV) == debug ) { BUILD_CODE = d ; COMMON_DEFINES += _DEBUG DEBUG ; CCOPTS = $(COMMON_CCOPTS) $(MSVC_VER_DEBUG_OPTS) /Z7 /MTd /Od /D$(COMMON_DEFINES) $(CCOPTS) ; LINKOPTS = /debug $(PURIFY_LINKOPTS) "/LIBPATH:\"$(LIB_DIRS)\"" /NODEFAULTLIB:libc $(LINKOPTS) ; } else if ( $(CURFLAV) == optimized ) { BUILD_CODE = o ; COMMON_DEFINES += _NDEBUG NDEBUG ; CCOPTS = $(COMMON_CCOPTS) /Z7 /MT /Ox /Oy- /D$(COMMON_DEFINES) $(CCOPTS) ; LINKOPTS = /debug $(PURIFY_LINKOPTS) "/LIBPATH:\"$(LIB_DIRS)\"" /NODEFAULTLIB:libc $(LINKOPTS) ; } else if ( $(CURFLAV) == release ) { BUILD_CODE = r ; COMMON_DEFINES += _NDEBUG NDEBUG RELEASE ; CCOPTS = $(COMMON_CCOPTS) /MT /Ox /D$(COMMON_DEFINES) $(CCOPTS) ; LINKOPTS = $(PURIFY_LINKOPTS) "/LIBPATH:\"$(LIB_DIRS)\"" /NODEFAULTLIB:libc $(LINKOPTS) ; } else { exit "CURFLAV must be set to one of extra_debug, debug, optimized, or release." ; } } # rules ----------------------------------------------------- rule ExpandSources SOURCES { DIRS = $(SOURCES:A) ; SEARCH += $(DIRS) ; SOURCES -= $(DIRS) ; return $(SOURCES) @($(DIRS)/*:MH) @($(DIRS)/win32/*:MH) ; } rule GetLinkObjs LIBS { return <static>$(LIBS:I="\.o$"S=.obj) <static>$(LIBS:I="\.obj$") ; } rule GetLinkLibs LIBS : DLLS { return $(LIBS:I="\.a$"S=.lib) $(LIBS:I="\.lib$") $(LIBS:I="\.dll$"S=.lib) $(LIBS:I="lib([^\.]*)\.so$"1).lib $(DLLS:I="\.dll$"S=.lib) $(DLLS:I="lib([^\.]*)\.so$"1).lib ; } rule GetLinkDlls LIBS { return $(LIBS:I="\.dll$") $(LIBS:I="lib([^\.]*)\.so$"1).dll ; } rule GetCopyDlls DLLS { return $(DLLS:I="\.dll$") $(DLLS:I="lib([^\.]*)\.so$"1).dll ; } rule CompileSharedObjectList_C TARGETS : SOURCES { CompileSharedObjectList_CXX $(TARGETS) : $(SOURCES) ; } rule CompileStaticObjectList_C TARGETS : SOURCES { CompileStaticObjectList_CXX $(TARGETS) : $(SOURCES) ; } rule CompileSharedObject_C TARGET : SOURCE { CompileSharedObject_CXX $(TARGETS) : $(SOURCES) ; } rule CompileStaticObject_C TARGET : SOURCE { CompileStaticObject_CXX $(TARGETS) : $(SOURCES) ; } # actions --------------------------------------------------- action updated piecemeal 5 quietly CompileSharedObjectList_CXX TARGETS : SOURCES {% echo Compiling Shared [$(BUILD_CODE)] $(SOURCES:H) cd $(BIN_DIR)shared $(CC) $(CCOPTS:X="^-D"N="\""0="\"") /D$(CCOPTS:N="^-D(.*)$"1N="\""0="\"") /D$(DLL_DEFINES) /c ../../../../$(SOURCES) $(SILENCE) %} action updated piecemeal 5 quietly CompileStaticObjectList_CXX TARGETS : SOURCES {% echo Compiling Static [$(BUILD_CODE)] $(SOURCES:H) cd $(BIN_DIR)static $(CC) $(CCOPTS:X="^-D"N="\""0="\"") /D$(CCOPTS:N="^-D(.*)$"1N="\""0="\"") /c ../../../../$(SOURCES) $(SILENCE) %} action quietly CompileSharedObject_CXX TARGET : SOURCE {% echo Compiling Shared [$(BUILD_CODE)] $(SOURCE:H) cd $(BIN_DIR)shared $(CC) $(CCOPTS:X="^-D"N="\""0="\"") /D$(CCOPTS:N="^-D(.*)$"1N="\""0="\"") /D$(DLL_DEFINES) /c ../../../../$(SOURCE) /Fo$(TARGET:H) $(SILENCE) %} action quietly CompileStaticObject_CXX TARGET : SOURCE {% echo Compiling Static [$(BUILD_CODE)] $(SOURCE:H) cd $(BIN_DIR)static $(CC) $(CCOPTS:X="^-D"N="\""0="\"") /D$(CCOPTS:N="^-D(.*)$"1N="\""0="\"") /c ../../../../$(SOURCE) /Fo$(TARGET:H) $(SILENCE) %} action quietly LinkStaticLibrary TARGET : SOURCES : LIBRARIES {% echo Linking Lib $(TARGET:H) : $(SOURCES:H) $(LIBRARIES:H) $(LIBEXE) $(SOURCES) $(LIBRARIES) /out:$(TARGET:S=.lib) $(SILENCE) %} action quietly LinkSharedLibrary TARGET : SOURCES : LIBRARIES {% echo Linking Dll $(TARGET:H) : $(SOURCES:H) $(LIBRARIES:H) # sometimes the .lib file is old, but if the file does not change, then relinking # will not update the timestamp, causing the build system to get into a state where it thinks # that it must *always* relink the .dll. To force the .lib's timestamp to get updated we # delete it if the .dll needs to be remade. We use -f so that we don't get an error message # even if the file does not already exists. ( such as after a clean ) rm -f $(TARGET[0]:S=.lib) $(LINKER) $(LINKOPTS) $(SOURCES) $(LIBRARIES) /DLL /out:$(TARGET[0]:S=.dll) $(SILENCE) %} action quietly LinkExecutable TARGET : SOURCES : LIBRARIES {% echo Linking Exe $(TARGET:H) : $(SOURCES:H) $(LIBRARIES:H) $(LINKER) $(LINKOPTS) $(SOURCES) $(LIBRARIES) /out:$(TARGET:S=.exe) $(SILENCE) %}



Here is a Linux version of the actions:


# definitions --------------------------------------------

# The tools we are going to use ----------------------------
CC ?= gcc ;
CXX ?= g++ ;
LIBEXE ?= ar ;
LEX ?= flex ;
YACC ?= bison ;
FSMC ?= fsmc ;

OBJ_SUFFIX = .o ;
EXE_SUFFIX = "";
LIB_SUFFIX = .a ;
LIB_PREFIX = lib ;
DLL_SUFFIX = .so ;
   
PLATFORM = $(PLATFORM)-$(JAMUNAME[0]:L) ;

# macros to control output ---------------------------------
SILENCE = " | rgxrpl -g (warning)\|(error) -1 \[1;31mwarning\[0m -2 \[1;31merror\[0m -x (\\.\\./)+ -d 0" ;

# the flags -----------------------------

# to debug parsers:
# YACC_FLAGS = --report=all ;

SAVE_TEMPS ?= false ;
if ( $(SAVE_TEMPS:L) != false )
  SAVE_TEMPS_FLAGS = -save-temps --verbose-asm ;
  
rule ActionInitDirs
{
   INCLUDE_DIRS = $(INCLUDE_DIRS)/linux $(INCLUDE_DIRS) ;
   
   if ( $(CURFLAV) )   CURFLAV = $(CURFLAV:L) ;
   else                CURFLAV = debug ;
   
   COMMON_DEFINES = LINUX $(CCDEFINES) ;
   COMMON_CCOPTS  = -c -W -Wall -Wno-unused --short-enums $(SAVE_TEMPS_FLAGS) -I$(INCLUDE_DIRS) ;
   COMMON_CXXOPTS = $(COMMON_CCOPTS) -fno-rtti -ffor-scope -fno-enforce-eh-specs ;
   
   if ( $(CURFLAV) == extra_debug )
   {
      BUILD_CODE = x ;
      COMMON_DEFINES += _DEBUG DEBUG EXTRA_DEBUG ;
      FINAL_CCOPTS  = -g     $(COMMON_CCOPTS)  -D$(COMMON_DEFINES) ;
      FINAL_CXXOPTS = -g     $(COMMON_CXXOPTS) -D$(COMMON_DEFINES) ;
   
   } else if ( $(CURFLAV) == debug ) { 
   
      BUILD_CODE = d ;
      COMMON_DEFINES += _DEBUG DEBUG ;
      FINAL_CCOPTS  = -g     $(COMMON_CCOPTS)  -D$(COMMON_DEFINES) ;
      FINAL_CXXOPTS = -g     $(COMMON_CXXOPTS) -D$(COMMON_DEFINES) ;
   
   } else if ( $(CURFLAV) == optimized ) {
   
      BUILD_CODE = o ;
      COMMON_DEFINES += _NDEBUG NDEBUG ;
      FINAL_CCOPTS  = -g -Os $(COMMON_CCOPTS)  -D$(COMMON_DEFINES) ;
      FINAL_CXXOPTS = -g -Os $(COMMON_CXXOPTS) -D$(COMMON_DEFINES) ;
   
   } else if ( $(CURFLAV) == release ) {
   
      BUILD_CODE = r ;
      COMMON_DEFINES += _NDEBUG NDEBUG RELEASE ;
      FINAL_CCOPTS  =    -Os $(COMMON_CCOPTS)  -D$(COMMON_DEFINES) --omit-frame-pointer ;
      FINAL_CXXOPTS =    -Os $(COMMON_CXXOPTS) -D$(COMMON_DEFINES) --omit-frame-pointer ;
   
   } else {
   
     exit "CURFLAV must be set to one of extra_debug, debug, optimized, or release." ;
   }
}

# rules -----------------------------------------------------

rule ExpandSources SOURCES
{
   DIRS = $(SOURCES:A) ;
   SEARCH += $(DIRS) ;
   SOURCES -= $(DIRS) ;
   return $(SOURCES) @($(DIRS)/*:MH) @($(DIRS)/win32/*:MH) ;
}

rule GetLinkObjs LIBS
{
   return <static>$(LIBS:I="\.obj$"S=.o) <static>$(LIBS:I="\.o$") ;
}

rule GetLinkLibs LIBS : DLLS
{
   return lib$(LIBS:I="\.lib$"S=.a)  $(LIBS:I="\.a$") lib$(LIBS:I="\.dll$"S=.so) $(LIBS:I="\.so$") 
                                                      lib$(DLLS:I="\.dll$"S=.so) $(DLLS:I="\.so$") ; 
}

rule GetLinkDlls LIBS
{
   return ;
}

rule GetCopyDlls DLLS
{
   return <static>lib$(DLLS:I="\.dll$"S=.so) <static>$(DLLS:I="\.so$") ; 
}

rule LinkExecutable TARGET : SOURCES : LIBRARIES
{
   LinkExecutableAction $(TARGET) : $(SOURCES) : $(LIBRARIES) ;
   if ( $(CURFLAV) == release ) StripExecutable $(TARGET) ;
}

# actions ---------------------------------------------------

action updated piecemeal 1 quietly CompileStaticObjectList_C TARGET : SOURCE
{%
   echo Compiling Static [$(BUILD_CODE)] $(SOURCE:H)
   $(CC) $(FINAL_CCOPTS:X="^/D"N="\\\\\""0="\"") -D$(FINAL_CCOPTS:N="^/D(.*)$"1N="\\\\\""0="\"") -D$(CCOPTS:N="^/D(.*)$"1N="\\\\\""0="\"") $(SOURCE) -o $(TARGET) $(SILENCE)
%}

action quietly CompileStaticObject_C TARGET : SOURCE
{%
   echo Compiling Static [$(BUILD_CODE)] $(SOURCE:H)
   $(CC) $(FINAL_CCOPTS:X="^/D"N="\\\\\""0="\"") -D$(FINAL_CCOPTS:N="^/D(.*)$"1N="\\\\\""0="\"") -D$(CCOPTS:N="^/D(.*)$"1N="\\\\\""0="\"") $(SOURCE) -o $(TARGET) $(SILENCE)
%}

action updated piecemeal 1 quietly CompileStaticObjectList_CXX TARGET : SOURCE
{%
   echo Compiling Static [$(BUILD_CODE)] $(SOURCE:H)
   $(CXX) $(FINAL_CXXOPTS:X="^/D"N="\\\\\""0="\"") -D$(FINAL_CXXOPTS:N="^/D(.*)$"1N="\\\\\""0="\"") -D$(CCOPTS:N="^/D(.*)$"1N="\\\\\""0="\"") $(SOURCE) -o $(TARGET) $(SILENCE)
%}

action quietly CompileStaticObject_CXX TARGET : SOURCE
{%
   echo Compiling Static [$(BUILD_CODE)] $(SOURCE:H)
   $(CXX) $(FINAL_CXXOPTS:X="^/D"N="\\\\\""0="\"") -D$(FINAL_CXXOPTS:N="^/D(.*)$"1N="\\\\\""0="\"") -D$(CCOPTS:N="^/D(.*)$"1N="\\\\\""0="\"") $(SOURCE) -o $(TARGET) $(SILENCE)
%}

action quietly LinkStaticLibrary TARGET : SOURCES : LIBRARIES
{%
   echo Linking              $(TARGET:H) : $(SOURCES:H) $(LIBRARIES:H)
   $(LIBEXE) -rs $(TARGET) $(SOURCES) $(LIBRARIES) 2>&1 > nul
%}

action quietly LinkSharedLibrary TARGET : SOURCES : LIBRARIES
{%
   echo Linking              $(TARGET:H) : $(SOURCES:H) $(LIBRARIES:H)
   $(CXX) -L$(LIB_DIRS) -shared -Wl,-soname,$(TARGET:H)  -o $(TARGET) $(SOURCES) -l$(LIBRARIES:HN="lib([^\.]*)\.(a|so)"1) -lpthread $(SILENCE)
%}

action quietly LinkExecutableAction TARGET : SOURCES : LIBRARIES
{%
   echo Linking              $(TARGET:H) : $(SOURCES:H) $(LIBRARIES:H)
   $(CXX) $(LINKOPTS) -L$(LIB_DIRS) $(SOURCES) -l$(LIBRARIES:HN="lib([^\.]*)\.(a|so)"1) -lpthread -o $(TARGET) $(SILENCE)
%}

action quietly StripExecutable TARGET
{%
   echo Stripping            $(TARGET:H)
   strip $(TARGET)
%}