SCons is a software construction tool (build tool, or make tool) implemented in Python, that uses Python scripts as “configuration files” for software builds. Based on the design that won the Software Carpentry build tool competition, SCons solves a number of problems associated with other build tools, especially including the classic and ubiquitous Make itself.
In its evolution, SCons will be more general than a make replacement, it will be a Gnu Build System replacement. The Gnu Build System (GBS) is also known as the set of Autotools (autoconf, automake, autoheader, etc…).
Quote From http://www.scons.org/wiki/TheBigPicture
So scons is just a makefile replacement? Which claims to be simple and feature rich? Let me construct a simple but sufficient scons configuration file (SConstruct), and show you how you can compile your c++ projects. Then you make the judgement whether to go for it or not.
#filename: SConstruct
env = Environment(
CXX = 'g++34',
CCFLAGS = ['-g','-O3','-Wall','-DPOSIX_C_SOURCE=199506L','-D_REENTRANT','-DLINT_ARGS','-DLINUXOS'],
LIBS = ['pthread', 'c','nsl','rt' ,'lbestd'],
LIBPATH = ['lib'],
CPPPATH = ['.','lib/inc'],
LINKFLAGS = ['-mt']
)
env.Program(
'bin/msgQ',
['Main.cc', 'MainState.cc','MainFunc.cc',
'MyLog.cc','MyQueue.cc','MyTcp.cc',
'TcpSvr.cc']
)
To compile the source codes, simply do this:
scons
To clear the objects and binaries, simply do this:
scons -c
Let me briefly explain the items in the SConstruct file.
By default, scons does define a simple compilation environment for you, if you write helloworld.cc, you just need to write a line in SConstruct.
Program('helloworld.cc')
But the case above, I overwrite some environment variable’s value for my needs to build a complex application.
CXX is the variable defines you c++ compiler. My case, I change it to g++34.
You can check the default value by just insert a python print statement in your SConstruct file.
env = Environment()
print "CXX = ", env['CXX']
CCFLAGS defines compilation flags.
LIBS defines library to link.
LIBPATH defines additional library paths besides the system default.
CPPPATH defines include file paths.
LINKFLAGS defines compiler linker flags
After constructed the environment, just compile your binary by calling Program function.
scons have more features compiles java codes too and importantly it is cross platform. To know more? Check out the scons man pages ans well as user manual.