From b5dc9949d05d1aa1548020eaa908b8010fd45f9d Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Tue, 1 Mar 2016 15:58:10 -0700 Subject: [PATCH] Fix building bzip2 from source as a shared library. bzip2 doesn't use a macro to control symbol export. Instead it provides a .def file, which we need to pass to the linker. --- src/tools/bzip2.jam | 50 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/src/tools/bzip2.jam b/src/tools/bzip2.jam index a994a70ef..0a525905c 100644 --- a/src/tools/bzip2.jam +++ b/src/tools/bzip2.jam @@ -20,6 +20,9 @@ import path ; import modules ; import errors ; import indirect ; +import make ; +import os ; +import print ; import property ; import property-set ; @@ -167,6 +170,7 @@ rule init ( tag = [ indirect.make $(tag) : [ $(caller).project-module ] ] ; } sources = [ path.glob $(source-path) : $(sources) ] ; + def-file = [ path.glob $(source-path) : libbz2.def ] ; if $(.debug) { ECHO "notice: [bzip2] Building bzip from source as $(build-name)" ; @@ -184,7 +188,15 @@ rule init ( } } local target ; - if $(sources) { + if $(sources) + { + if ! $(.def-file-target) + { + .def-file-target = [ targets.create-metatarget make-target-class + : $(.project) : libbz2.def : $(def-file) + : @bzip2.make-bz2-def-file ] + ; + } target = [ targets.create-typed-target LIB : $(.project) : $(build-name).$(library-id) : $(sources) @@ -193,7 +205,7 @@ rule init ( $(source-path) msvc:_CRT_SECURE_NO_DEPRECATE msvc:_SCL_SECURE_NO_DEPRECATE - shared:BZIP2_DLL + shared:libbz2.def : : $(source-path) ] ; } @@ -224,3 +236,37 @@ rule init ( } .configured.$(condition) = true ; } + +if [ os.name ] = NT +{ + local rule read-file ( file ) + { + return [ SPLIT_BY_CHARACTERS [ SHELL "type \"$(file:G=)\" 2>nul" ] : "\n" ] ; + } +} +else if [ os.name ] = VMS +{ + local rule read-file ( file ) + { + return [ SPLIT_BY_CHARACTERS [ SHELL "PIPE TYPE $(file:W) 2>NL:" ] : "\n" ] ; + } +} +else +{ + local rule read-file ( file ) + { + return [ SPLIT_BY_CHARACTERS [ SHELL "cat \"$(file:G=)\" 2>/dev/null" ] : "\n" ] ; + } +} + +rule make-bz2-def-file ( target : source : properties * ) +{ + print.output $(target) ; + for local line in [ read-file $(source) ] + { + if ! [ MATCH "(LIBRARY[ \t]+LIBBZ2)" : $(line) ] + { + print.text $(line) : yes ; + } + } +}