|
|||
How to do the library closure with Lucent C++ 4.x?If you use Lucent's C++ 4.x (aka EDG's) and nmake to build libraries, you need
to do the closure (template instantiation) for the libraries. For C++ 4.0You need nmake 3.1 or above, and the rules:
------------------
EDG_PRELINK_OPTION =
.ARTOUCHO : .MAKE .VIRTUAL .FORCE .REPEAT .AFTER
.UNBIND : $(**:T=F:T=G:A!=.ARCHIVE)
.REBIND : $(**:T=F:T=G:A!=.ARCHIVE)
.ARCHIVE.o : .CLEAR .USE .ARCHIVE (AR) (ARFLAGS) (LDFLAGS) .ARTOUCHO .ARPREVIOUS .ARUPDATE .ARCLEAN
$(^:?$$(CP) $$(^) $$(<)$$("\n")??)$(.ARPREVIOUS.$(<:B:S):@?$(IGNORE) $$(AR) d $$(<) $$(.ARPREVIOUS.$$(<:B:S))$$("\n")??)
if [ "$(>:A!=.ARCHIVE)" ]
then if [ -f $(<) ]
then silent ignore $(AR) d $(<) $(>:A!=.ARCHIVE)
edg_prelink $(EDG_PRELINK_OPTION) $(LDFLAGS) -L/lib -L/usr/lib $(>:A!=.ARCHIVE) -- $(*:A=.ARCHIVE) $(<)
else
edg_prelink $(EDG_PRELINK_OPTION) $(LDFLAGS) -L/lib -L/usr/lib $(>:A!=.ARCHIVE) -- $(*:A=.ARCHIVE)
fi
fi
$(>:A!=.ARCHIVE:K=$(AR) $(ARFLAGS) $(<))
-------------------
Note, to use this rule, you have to set EDG_PRELINK_OPTION as follows:
-fSVR4 for NCR
-fHPUX for HP
-fSGI for SGI
-fsolaris for solaris
You may find the option for your machine not listed above from the CC script. Search for EDG_PRELINK_DEFAULT_OPTIONS. The default of edg_prelink is for SunOS 4.x (i.e. there is no -f option needed). For C++ 4.1You have to use nmake 3.1.1, and the rules:
----------------
.ARCHIVE.LIST. : .FUNCTION
local I
.UNBIND : . $(***:T=F:T=G:A!=.ARCHIVE)
.UNION : .CLEAR
for I $(***:T=F:T=G:A!=.ARCHIVE)
.REBIND : $(I)
.UNION : $(I)
end
return $(~.UNION)
.DO.ARCHIVE : .AFTER .VIRTUAL .FORCE .REPEAT .ARCLEAN
$(.ARCHIVE.LIST.:K=$(AR) $(ARFLAGS) $(<<))
.ARCHIVE.o : .CLEAR .USE .ARCHIVE (AR) (ARFLAGS) (LDFLAGS) .ARPREVIOUS .ARUPDATE .DO.ARCHIVE
$(^:?$$(CP) $$(^) $$(<)$$("\n")??)$(.ARPREVIOUS.$(<:B:S):@?$(IGNORE) $$(AR) d $$(<) $$(.ARPREVIOUS.$$(<:B:S))$$("\n")??)
if [ "$(>:A!=.ARCHIVE)" ]
then if [ -f $(<) ]
then silent ignore $(AR) d $(<) $(>:A!=.ARCHIVE)
$(CC) --prelink_objects --prelink_copy_if_nonlocal $(LDFLAGS) -L/lib -L/usr/lib $(>:A!=.ARCHIVE) -- $(*:A=.ARCHIVE) $(<)
else
$(CC) --prelink_objects --prelink_copy_if_nonlocal $(LDFLAGS) -L/lib -L/usr/lib $(>:A!=.ARCHIVE) -- $(*:A=.ARCHIVE)
fi
fi
-------------------
Please also note, make sure if you build several libraries which will be always linked together, the build order is important. You have to build with the order of that earlier built libraries are the dependencies of later built libraries. e.g.: liba.a :: a.c libb.a :: b.c -la libc.a :: c.c -lb -la target :: main.c -lc -lb -la The libraries are not necessary to be built within a same makefile, but the build order is important here. In this way, templates won't be multiply instantiated. To know more information about C++ library closure, visit the C++ Library Closure page. Last Update: Wednesday,20-Dec-06 13:21:56 CST
|
|||