# vim: set ts=2 sw=2 tw=99 noet ft=python: 
import os

compiler = SM.DefaultExtCompiler('extensions/regex')
compiler['CXXINCLUDES'].append(os.path.join(SM.mmsPath, 'core', 'sourcehook'))

extension = AMBuild.AddJob('regex.ext')
binary = Cpp.LibraryBuilder('regex.ext', AMBuild, extension, compiler)

if AMBuild.target['platform'] == 'linux':
	path = os.path.join(AMBuild.sourceFolder, 'extensions', 'regex', 'lib_linux', 'libpcre.a')
elif AMBuild.target['platform'] == 'windows':
	path = os.path.join(AMBuild.sourceFolder, 'extensions', 'regex', 'lib_win', 'pcre.lib')
elif AMBuild.target['platform'] == 'darwin':
	path = os.path.join(AMBuild.sourceFolder, 'extensions', 'regex', 'lib_darwin', 'libpcre.a')

binary.RelinkIfNewer(path)
binary['POSTLINKFLAGS'].append(path)

binary.AddSourceFiles('extensions/regex', [
	'extension.cpp',
	'CRegEx.cpp',
	'sdk/smsdk_ext.cpp',
	])
SM.AutoVersion('extensions/regex', binary)
binary.SendToJob()