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, version 3 of the License ONLY.
5 # This program is distributed in the hope that it will be useful,
6 # but WITHOUT ANY WARRANTY; without even the implied warranty of
7 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 # GNU General Public License for more details.
10 # You should have received a copy of the GNU General Public License
11 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # /Library library : sources ;
15 # Compiles _sources_ and archives them into _library_. The intermediate
16 # objects are deleted. Calles @Object and @LibraryFromObjects
18 # If @Library is invoked with no suffix on _library_, the $(SUFLIB)
22 local _xl = [ LibraryFromObjects $(<) : $(>:S=$(SUFOBJ)) : $(>) ] ;
23 Objects $(_xl) : : $(1) ;
27 # /LibraryFromObjects library : objects : origsrc ;
29 # Archives _objects_ into _library_. The _objects_ are then deleted
31 # If _library_ has no suffix, the $(SUFLIB) suffix is used
33 # Called by @Library rule. Most people should never call this rule
36 rule LibraryFromObjects {
37 local objlist tgt have_attrs ;
39 # check if we have attributes
40 have_attrs = [ --main-preprocess-attrs-- $(>) ] ;
41 objlist = $(have_attrs[2-]) ;
42 have_attrs = $(have_attrs[1]) ;
44 tgt = $(<:S=$(SUFLIB)) ;
46 # library depends on its member objects
48 Depends obj : $(objlist) ;
50 Depends lib : $(tgt) ;
53 # Set LOCATE for the library and its contents. The bound
54 # value shows up as $(NEEDLIBS) on the Link actions.
55 # For compatibility, we only do this if the library doesn't
56 # already have a path.
58 MakeLocate $(tgt) "$(tgt)($(objlist:BS))" : $(LOCATE_LIB) ;
62 # If we can't scan the library to timestamp its contents,
63 # we have to just make the library depend directly on the
64 # on-disk object files.
65 Depends $(tgt) : $(objlist) ;
67 # If we can scan the library, we make the library depend
68 # on its members and each member depend on the on-disk
70 Depends $(tgt) : "$(tgt)($(objlist:BS))" ;
71 for local objname in $(objlist) {
72 Depends "$(tgt)($(objname:BS))" : $(objname) ;
76 Clean clean : $(tgt) ;
78 #if $(CRELIB) { CreLib $(tgt) : $(objlist[1]) ; }
80 Archive $(tgt) : $(objlist) ;
82 if $(RANLIB) { Ranlib $(tgt) ; }
84 # If we can't scan the library, we have to leave the .o's around.
85 if ! ( $(NOARSCAN) || $(NOARUPDATE) ) { RmTemps $(tgt) : $(objlist) ; }
87 if $(have_attrs) { return [ --main-postprocess-attrs-- $(3) ] ; }