cosmetix in Jambase: use single-quoted string where appropriate
[k8jam.git] / defaults / main / Jambase.main.libso
blob1db5b11c1363aab849a5e655952180a00f7be5f6
1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
14 # /SharedLibrary  library : sources : def : import ;
16 # Compiles _sources_ and generates a shared _library_ (i.e. DLL on Windows,
17 # or shared object on Unix). Calls @SharedObjects and @SharedLibraryFromObjects
19 # If @SharedLibrary is invoked with no suffix on _library_, then
20 # $(SUFLIBSHR) suffix is used
22 # _def_ is the name of the corresponding definition file used to generate
23 # the library on Windows and OS/2 (ignored otherwise). If undefined, it
24 # will default to _library_ with the .def suffix
26 # _import_ is the name of the corresponding import library for Windows
27 # and OS/2 platforms (ignored otherwise). If undefined, it will default
28 # to _library_ with the .dll.lib suffix.
30 rule SharedLibrary {
31   local _xl = [ SharedLibraryFromObjects $(<) : $(>:S=$(SUFOBJSHR)) : $(3) : $(4) : $(>) ] ;
32   SharedObjects $(_xl) ;
36 # /SharedLibraryFromObjects  library : objects : def : import : origlist ;
38 # Equivalent of @LibraryFromObjects for shared libraries.
40 # Called by @SharedLibrary. Most people shouldn't call this rule
41 # directly
43 rule SharedLibraryFromObjects {
44   local objlist tgt have_attrs ;
46   # check if we have attributes
47   have_attrs = [ --main-preprocess-attrs-- $(>) ] ;
48   objlist = $(have_attrs[2-]) ;
49   have_attrs = $(have_attrs[1]) ;
51   tgt = $(<:S=$(SUFLIBSHR)) ;
53   #Echo "Library is $(tgt)"    ;
54   # library depends on its member objects
55   if $(KEEPOBJS) {
56     Depends obj : $(objlist) ;
57   } else {
58     Depends lib : $(tgt) ;
59   }
61   # Set LOCATE for the library and its contents.  The bound
62   # value shows up as $(NEEDLIBS) on the Link actions.
63   # For compatibility, we only do this if the library doesn't
64   # already have a path.
65   if ! $(tgt:D) {
66     #!!MakeLocate $(tgt) : $(LOCATE_TARGET) ;
67     MakeLocate $(tgt) : $(LOCATE_LIBSO) ;
68   }
70   #Echo "SharedLibraryFromObjects: objlist = $(objlist)" ; #dbg
71   #Echo "SharedLibraryFromObjects: tgt = $(tgt)" ; #dbg
73   # we never scan shared libraries for member objects
74   Depends $(tgt) : $(objlist) ;
76   Clean clean : $(tgt) ;
78   # I don't know if VMS supports shared libraries, so I prefer
79   # to disable the following right now
80   #
81   #if $(CRELIB) { CreLib $(tgt) : $(objlist[1]) ; }
83   # creating the library is so much fun on Unix :-)
84   if $(UNIX) {
85     LINKFLAGS on $(tgt) += '-shared' ;
86     C++LINKFLAGS on $(tgt) += '-shared' ;
87     LinkUnixLibrary $(tgt) : $(objlist) ;  # in Jambase.link.lib.c
88   } else if $(NT) {
89     local _implib = $(4) ;
90     local _def    = $(3) ;
92     _implib ?= $(tgt:S=$(SUFLIBSHR)$(SUFLIB)) ;
93     _def    ?= $(tgt:S=.def) ;
95     Clean    clean : $(_implib) ;
96     Depends  lib   : $(_implib) $(_def) ;
98     Depends $(_implib) : $(_def) $(tgt) ;
99     Depends $(tgt)      : $(_def) ;
101     DEFFILENAME on $(tgt) = $(_def) ;
102     IMPLIBNAME  on $(tgt) = $(_implib) ;
104     #!!MakeLocate $(_implib)        : $(LOCATE_TARGET) ;
105     #!!MakeLocate $(_implib:S=.exp) : $(LOCATE_TARGET) ;
106     MakeLocate $(_implib)        : $(LOCATE_LIBSO) ;
107     MakeLocate $(_implib:S=.exp) : $(LOCATE_LIBSO) ;
109     if $(JAM_TOOLSET) in VISUALC BORLANDC LCC WATCOM DIGITALMARS {
110       SharedLink-$(JAM_TOOLSET) $(tgt) : $(objlist) : $(_implib) : $(_def) ;
111     }
112     DllLink $(tgt) : $(objlist) ;
113   } else {
114     Echo "Sorry, I don't know how to make a shared library on your system" ;
115     Exit "Please *DON'T* contact the K8Jam maintainer for help" ;
116   }
118   if $(have_attrs) { return [ --main-postprocess-attrs-- $(5) ] ; }
119   return $(5) ;
123 # Since building shared libraries is so different depending on the
124 # compiler being used, I've broken this task into compiler-specific
125 # ones
127 rule SharedLink-LCC {
128   Echo "Sorry, but generating DLLs with LCC is not supported. That's" ;
129   Echo "because the 'lcclnk' tool that comes with this compiler is" ;
130   Echo "unreliable and doesn't work as expected." ;
131   Exit ;
133   # the 'lcclnk' tool is absolutely broken:
134   #   - its -o flag doesn't work when there is a LIBRARY statement
135   #     in the .def file.
136   #
137   #   - it uses the LIBRARY name in the .def file to determine
138   #     the name of the dll and its import library, and always
139   #     places them in the current directory !!
140   #
141   #   - if there is no LIBRARY statement, the -o flag is only
142   #     used to determine where the DLL is placed, the import
143   #     library will always be placed in the current directory !!
144   #
146   # clean the .exp file too, don't know how to get rid of it
147   Clean clean : $(4:S=.exp) ;