1# Copyright (C) 2013, 2018 Olga Yakovleva <yakovleva.o.v@gmail.com> 2 3# This program is free software: you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation, either version 3 of the License, or 6# (at your option) any later version. 7 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12 13# You should have received a copy of the GNU General Public License 14# along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16import sys 17from SCons.Script import * 18 19def IsLibraryShared(env): 20 if sys.platform=="win32": 21 return (env["liblevel"]>1) 22 else: 23 return (env["enable_shared"] and (env["liblevel"]>0)) 24 25def BuildLibrary(env,target,sources): 26 if env.IsLibraryShared(): 27 if sys.platform=="win32": 28 return env.SharedLibrary(target,sources,MS_LINKER_SUBSYSTEM="WINDOWS") 29 else: 30 return env.SharedLibrary(target,sources,SHLIBVERSION=env["libversion"]) 31 elif env["liblevel"]==0: 32 if env.get("enable_shared",False): 33 return env.SharedObject(sources) 34 else: 35 return env.StaticObject(sources) 36 else: 37 return env.StaticLibrary(target,sources) 38 39def exists(env): 40 return True 41 42def generate(env): 43 env.AddMethod(BuildLibrary) 44 env.AddMethod(IsLibraryShared) 45