使用 bjam 构建 crypto++

最近打算使用 crypto++ 5.6.0 , 由于我的机器上装了不同版本的 vc, 为了构建方便,写了 bjam 的构建脚本,可以方便的用不同的编译器编译库和DLL,十分方便。

jamroot 文件

view plain copy to clipboard print ?
  1. import os ;  
  2. import pch ; 
  3. import path ;  
  4. import common ;  
  5. default-build = 
  6.         debug release 
  7.         <threading>multi 
  8.         <runtime-link>static <runtime-link>shared 
  9.         ; 
  10.     if [ os.name ] = NT 
  11.     { 
  12.         default-build += <runtime-link>static <runtime-link>shared ; 
  13.     } 
  14. # 这里的 <tag> 配合下面的 tag rule 可以定义输出的文件名,这里使用仿 boost 规则的库文件名,不过删除了版本信息 
  15. project name 
  16.     : requirements  <tag>@$(__name__).tag 
  17.     : build-dir bin 
  18.     : default-build $(default-build) 
  19.     ;  
  20. # 按仿 boost 规则生成 lib 文件名 
  21. rule tag ( name : type ? : property-set ) 
  22.     if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB 
  23.     { 
  24.   return [ common.format-name 
  25.    <base> <toolset> <threading> <runtime>  
  26.    : $(name) : $(type) : $(property-set) ] ; 
  27.     } 

import os ; import pch ; import path ; import common ; default-build = debug release <threading>multi <runtime-link>static <runtime-link>shared ; if [ os.name ] = NT { default-build += <runtime-link>static <runtime-link>shared ; } # 这里的 <tag> 配合下面的 tag rule 可以定义输出的文件名,这里使用仿 boost 规则的库文件名,不过删除了版本信息 project name : requirements <tag>@$(__name__).tag : build-dir bin : default-build $(default-build) ; # 按仿 boost 规则生成 lib 文件名 rule tag ( name : type ? : property-set ) { if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB { return [ common.format-name <base> <toolset> <threading> <runtime> : $(name) : $(type) : $(property-set) ] ; } }

在放 jamroot 的目录下创建 cryptopp 目录,并且放入 jamfile 文件

view plain copy to clipboard print ?
  1. project cryptopp 
  2.     : requirements  
  3.         <threading>multi 
  4.         <include>$(prjroot) 
  5.         <search>$(prjroot) 
  6.         <variant>release:<define>NDEBUG  
  7.         <define>USE_PRECOMPILED_HEADERS <define>WIN32 
  8.     : default-build release debug <link>shared <link>static <runtime-link>shared <runtime-link>static 
  9. path-constant  prjroot : ../../cryptopp ; 
  10. #        [ SHELL ( if not exist adhoc.cpp copy $(prjroot)/adhoc.cpp.proto $(prjroot)/adhoc.cpp ) ] ; 
  11. local files = 3way.cpp adler32.cpp algebra.cpp algparam.cpp arc4.cpp asn.cpp authenc.cpp  
  12.     base32.cpp base64.cpp basecode.cpp bfinit.cpp blowfish.cpp blumshub.cpp camellia.cpp  
  13.     cast.cpp casts.cpp cbcmac.cpp ccm.cpp channels.cpp cmac.cpp cpu.cpp crc.cpp cryptlib.cpp  
  14.     default.cpp des.cpp dessp.cpp dh.cpp dh2.cpp dsa.cpp eax.cpp ec2n.cpp  
  15.     ecp.cpp elgamal.cpp emsa2.cpp  esign.cpp files.cpp filters.cpp fips140.cpp 
  16.     fipstest.cpp gcm.cpp gf256.cpp gf2_32.cpp gf2n.cpp gfpcrypt.cpp gost.cpp gzip.cpp  
  17.     hex.cpp hmac.cpp hrtimer.cpp ida.cpp idea.cpp integer.cpp luc.cpp mars.cpp  
  18.     marss.cpp md2.cpp md4.cpp md5.cpp misc.cpp modes.cpp mqueue.cpp mqv.cpp nbtheory.cpp  
  19.     network.cpp oaep.cpp osrng.cpp panama.cpp pkcspad.cpp polynomi.cpp pssr.cpp  
  20.     pubkey.cpp queue.cpp rabin.cpp randpool.cpp rc2.cpp rc5.cpp rc6.cpp rdtables.cpp rijndael.cpp  
  21.     ripemd.cpp rng.cpp rsa.cpp rw.cpp safer.cpp salsa.cpp seal.cpp seed.cpp serpent.cpp sha.cpp  
  22.     shacal2.cpp shark.cpp sharkbox.cpp simple.cpp skipjack.cpp socketft.cpp sosemanuk.cpp square.cpp  
  23.     squaretb.cpp strciphr.cpp tea.cpp tftables.cpp tiger.cpp tigertab.cpp trdlocal.cpp ttmac.cpp  
  24.     twofish.cpp vmac.cpp wait.cpp wake.cpp whrlpool.cpp winpipes.cpp xtr.cpp xtrcrypt.cpp zdeflate.cpp  
  25.     zinflate.cpp zlib.cpp ; 
  26. # 系统库列表 
  27. local .system_lib = kernel32 user32 winspool Ws2_32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid odbc32 odbccp32 ; 
  28. lib $(.system_lib) ; 
  29. lib cryptopp  
  30.     [ obj dll_obj : $(prjroot)/dll.cpp ]  
  31.     [ obj iterhash_obj : $(prjroot)/iterhash.cpp ]  
  32.     [ cpp-pch cryptopp_pch : $(prjroot)/pch.h : <include>$(prjroot) ] 
  33.     $(prjroot)/$(files) $(.system_lib)  
  34. :  
  35.     <link>shared:<define>CRYPTOPP_EXPORTS 
  36.     <link>shared:<define>CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2=1  
  37. :    
  38.      
  39.     ; 
  40. install stage 
  41.     :   cryptopp 
  42.     :   <location>../../stage/lib 
  43.     ; 

project cryptopp : requirements <threading>multi <include>$(prjroot) <search>$(prjroot) <variant>release:<define>NDEBUG <define>USE_PRECOMPILED_HEADERS <define>WIN32 : default-build release debug <link>shared <link>static <runtime-link>shared <runtime-link>static ; path-constant prjroot : ../../cryptopp ; # [ SHELL ( if not exist adhoc.cpp copy $(prjroot)/adhoc.cpp.proto $(prjroot)/adhoc.cpp ) ] ; local files = 3way.cpp adler32.cpp algebra.cpp algparam.cpp arc4.cpp asn.cpp authenc.cpp base32.cpp base64.cpp basecode.cpp bfinit.cpp blowfish.cpp blumshub.cpp camellia.cpp cast.cpp casts.cpp cbcmac.cpp ccm.cpp channels.cpp cmac.cpp cpu.cpp crc.cpp cryptlib.cpp default.cpp des.cpp dessp.cpp dh.cpp dh2.cpp dsa.cpp eax.cpp ec2n.cpp ecp.cpp elgamal.cpp emsa2.cpp esign.cpp files.cpp filters.cpp fips140.cpp fipstest.cpp gcm.cpp gf256.cpp gf2_32.cpp gf2n.cpp gfpcrypt.cpp gost.cpp gzip.cpp hex.cpp hmac.cpp hrtimer.cpp ida.cpp idea.cpp integer.cpp luc.cpp mars.cpp marss.cpp md2.cpp md4.cpp md5.cpp misc.cpp modes.cpp mqueue.cpp mqv.cpp nbtheory.cpp network.cpp oaep.cpp osrng.cpp panama.cpp pkcspad.cpp polynomi.cpp pssr.cpp pubkey.cpp queue.cpp rabin.cpp randpool.cpp rc2.cpp rc5.cpp rc6.cpp rdtables.cpp rijndael.cpp ripemd.cpp rng.cpp rsa.cpp rw.cpp safer.cpp salsa.cpp seal.cpp seed.cpp serpent.cpp sha.cpp shacal2.cpp shark.cpp sharkbox.cpp simple.cpp skipjack.cpp socketft.cpp sosemanuk.cpp square.cpp squaretb.cpp strciphr.cpp tea.cpp tftables.cpp tiger.cpp tigertab.cpp trdlocal.cpp ttmac.cpp twofish.cpp vmac.cpp wait.cpp wake.cpp whrlpool.cpp winpipes.cpp xtr.cpp xtrcrypt.cpp zdeflate.cpp zinflate.cpp zlib.cpp ; # 系统库列表 local .system_lib = kernel32 user32 winspool Ws2_32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid odbc32 odbccp32 ; lib $(.system_lib) ; lib cryptopp : [ obj dll_obj : $(prjroot)/dll.cpp ] [ obj iterhash_obj : $(prjroot)/iterhash.cpp ] [ cpp-pch cryptopp_pch : $(prjroot)/pch.h : <include>$(prjroot) ] $(prjroot)/$(files) $(.system_lib) : <link>shared:<define>CRYPTOPP_EXPORTS <link>shared:<define>CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2=1 : ; install stage : cryptopp : <location>../../stage/lib ;

这个脚本会自动创建不同版本的库和动态链接库,并且安装到 stage/lib 目录,使用 boost 的库命名方式。

view plain copy to clipboard print ?
  1. cryptopp-vc100-mt-gd.dll 
  2. cryptopp-vc100-mt-gd.pdb 
  3. cryptopp-vc100-mt-s.dll 
  4. cryptopp-vc100-mt-sgd.dll 
  5. cryptopp-vc100-mt-sgd.pdb 
  6. cryptopp-vc100-mt.dll 
  7. libcryptopp-vc100-mt-gd.lib 
  8. libcryptopp-vc100-mt-s.lib 
  9. libcryptopp-vc100-mt-sgd.lib 
  10. libcryptopp-vc100-mt.lib 

cryptopp-vc100-mt-gd.dll cryptopp-vc100-mt-gd.pdb cryptopp-vc100-mt-s.dll cryptopp-vc100-mt-sgd.dll cryptopp-vc100-mt-sgd.pdb cryptopp-vc100-mt.dll libcryptopp-vc100-mt-gd.lib libcryptopp-vc100-mt-s.lib libcryptopp-vc100-mt-sgd.lib libcryptopp-vc100-mt.lib

可以参考我的 博文: http://blog.csdn.net/jadedrip/archive/2007/10/11/1820368.aspx

另外,如果使用 vs 2010 来编译需要修改 pubkey.h 的 243 行为

view plain copy to clipboard print ?
  1. return HashIdentifier((const unsigned char*)NULL, 0); 

return HashIdentifier((const unsigned char*)NULL, 0);

还要把 zdeflate.cpp 389 行左右改成如下:

view plain copy to clipboard print ?
  1. #if defined(_MSC_VER) && _MSC_VER >= 1600 
  2.         std::mismatch 
  3. #else 
  4. # if defined(_STDEXT_BEGIN) && !(defined(_MSC_VER) && _MSC_VER < 1400) && !defined(_STLPORT_VERSION) 
  5.                 stdext::unchecked_mismatch 
  6. # else 
  7.     std::mismatch 
  8. # endif 
  9. #endif 

 

你可能感兴趣的:(shell,脚本,search,dll,import,include)