1 # /SharedLibrary library : sources : def : import ;
3 # Compiles _sources_ and generates a shared _library_ (i.e. DLL on Windows,
4 # or shared object on Unix). Calls @SharedObjects and @SharedLibraryFromObjects
6 # If @SharedLibrary is invoked with no suffix on _library_, then
7 # $(SUFLIBSHR) suffix is used
9 # _def_ is the name of the corresponding definition file used to generate
10 # the library on Windows and OS/2 (ignored otherwise). If undefined, it
11 # will default to _library_ with the .def suffix
13 # _import_ is the name of the corresponding import library for Windows
14 # and OS/2 platforms (ignored otherwise). If undefined, it will default
15 # to _library_ with the .dll.lib suffix.
18 #Echo "SharedLibrary: $(<)" ; #dbg
19 #Echo "SharedLibrary: $(>:S=$(SUFOBJSHR))" ; #dbg
20 #Echo "SharedLibrary: $(3)" ; #dbg
21 #Echo "SharedLibrary: $(4)" ; #dbg
22 SharedLibraryFromObjects $(<) : $(>:S=$(SUFOBJSHR)) : $(3) : $(4) ;
26 # /SharedLibraryFromObjects library : objects : def : import ;
28 # Equivalent of @LibraryFromObjects for shared libraries.
30 # Called by @SharedLibrary. Most people shouldn't call this rule
33 rule SharedLibraryFromObjects {
36 # Add grist to file names
37 _s = [ FGristFiles $(>) ] ;
38 _l = $(<:S=$(SUFLIBSHR)) ;
40 #Echo "Library is $(_l)" ;
41 # library depends on its member objects
48 # Set LOCATE for the library and its contents. The bound
49 # value shows up as $(NEEDLIBS) on the Link actions.
50 # For compatibility, we only do this if the library doesn't
51 # already have a path.
53 #!!MakeLocate $(_l) : $(LOCATE_TARGET) ;
54 MakeLocate $(_l) : $(LOCATE_LIBSO) ;
57 #Echo "SharedLibraryFromObjects: _s = $(_s)" ; #dbg
58 #Echo "SharedLibraryFromObjects: _l = $(_l)" ; #dbg
60 # we never scan shared libraries for member objects
61 Depends $(_l) : $(_s) ;
65 # I don't know if VMS supports shared libraries, so I prefer
66 # to disable the following right now
68 #if $(CRELIB) { CreLib $(_l) : $(_s[1]) ; }
70 # creating the library is so much fun on Unix :-)
72 #!LIBTOOL!# if $(K8_USE_LIBTOOL) {
73 #!LIBTOOL!# local libtool = [ LibToolFind ] ; # find the right libtool
74 #!LIBTOOL!# AR on $(_l) = "$(libtool) --mode=link $(AR:J= )" ;
76 LINKFLAGS on $(_l) += "-shared" ;
77 C++LINKFLAGS on $(_l) += "-shared" ;
78 LinkUnixLibrary $(_l) : $(_s) ; # in Jambase.link.lib.c
81 local _implib = $(4) ;
84 _implib ?= $(_l:S=$(SUFLIBSHR)$(SUFLIB)) ;
85 _def ?= $(_l:S=.def) ;
87 Clean clean : $(_implib) ;
88 Depends lib : $(_implib) $(_def) ;
90 Depends $(_implib) : $(_def) $(_l) ;
91 Depends $(_l) : $(_def) ;
93 DEFFILENAME on $(_l) = $(_def) ;
94 IMPLIBNAME on $(_l) = $(_implib) ;
96 #!!MakeLocate $(_implib) : $(LOCATE_TARGET) ;
97 #!!MakeLocate $(_implib:S=.exp) : $(LOCATE_TARGET) ;
98 MakeLocate $(_implib) : $(LOCATE_LIBSO) ;
99 MakeLocate $(_implib:S=.exp) : $(LOCATE_LIBSO) ;
101 if $(JAM_TOOLSET) in VISUALC BORLANDC LCC WATCOM DIGITALMARS {
102 SharedLink-$(JAM_TOOLSET) $(_l) : $(_s) : $(_implib) : $(_def) ;
104 DllLink $(_l) : $(_s) ;
106 Echo "Sorry, I don't know how to make a shared library on your system" ;
107 Exit "Please *DON'T* contact the K8Jam maintainer for help" ;
112 # Since building shared libraries is so different depending on the
113 # compiler being used, I've broken this task into compiler-specific
116 rule SharedLink-LCC {
117 Echo "Sorry, but generating DLLs with LCC is not supported. That's" ;
118 Echo "because the 'lcclnk' tool that comes with this compiler is" ;
119 Echo "unreliable and doesn't work as expected." ;
122 # the 'lcclnk' tool is absolutely broken:
123 # - its -o flag doesn't work when there is a LIBRARY statement
126 # - it uses the LIBRARY name in the .def file to determine
127 # the name of the dll and its import library, and always
128 # places them in the current directory !!
130 # - if there is no LIBRARY statement, the -o flag is only
131 # used to determine where the DLL is placed, the import
132 # library will always be placed in the current directory !!
135 # clean the .exp file too, don't know how to get rid of it
136 Clean clean : $(4:S=.exp) ;
140 actions updated together piecemeal LinkUnixLibrary bind NEEDLIBS {
141 $(LINK) $(LINKFLAGS.all) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS.all) $(LINKLIBS)