bsd.lib.mk revision 1.190       1  1.190        tv #	$NetBSD: bsd.lib.mk,v 1.190 2001/11/14 21:49:53 tv Exp $
      2   1.92     mikel #	@(#)bsd.lib.mk	8.3 (Berkeley) 4/22/94
      3    1.1       cgd 
      4  1.188        tv .include <bsd.init.mk>
      5   1.97   mycroft 
      6  1.188        tv ##### Basic targets
      7  1.143       erh .PHONY:		checkver cleanlib libinstall
      8  1.143       erh realinstall:	checkver libinstall
      9  1.183        tv clean:		cleanlib
     10    1.1       cgd 
     11  1.188        tv ##### Build and install rules
     12  1.190        tv CPPFLAGS+=	${DESTDIR:D-nostdinc -isystem ${DESTDIR}/usr/include}
     13  1.190        tv 
     14  1.184        tv .if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE})
     15  1.154    simonb SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major
     16  1.154    simonb SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor
     17  1.171  christos SHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny
     18  1.143       erh 
     19  1.143       erh # Check for higher installed library versions.
     20  1.145       erh .if !defined(NOCHECKVER) && !defined(NOCHECKVER_${LIB}) && \
     21  1.145       erh 	exists(${BSDSRCDIR}/lib/checkver)
     22  1.143       erh checkver:
     23  1.144       erh 	@(cd ${.CURDIR} && \
     24  1.176  gmcgarry 		sh ${BSDSRCDIR}/lib/checkver -v ${SHLIB_VERSION_FILE} \
     25  1.154    simonb 		    -d ${DESTDIR}${LIBDIR} ${LIB})
     26  1.173  christos .endif
     27  1.173  christos .endif
     28  1.173  christos 
     29  1.173  christos .if !target(checkver)
     30  1.143       erh checkver:
     31  1.143       erh .endif
     32  1.173  christos 
     33  1.169   thorpej print-shlib-major:
     34  1.185        tv .if defined(SHLIB_MAJOR) && ${MKPIC} != "no"
     35  1.169   thorpej 	@echo ${SHLIB_MAJOR}
     36  1.173  christos .else
     37  1.173  christos 	@false
     38  1.173  christos .endif
     39  1.169   thorpej 
     40  1.169   thorpej print-shlib-minor:
     41  1.185        tv .if defined(SHLIB_MINOR) && ${MKPIC} != "no"
     42  1.169   thorpej 	@echo ${SHLIB_MINOR}
     43  1.173  christos .else
     44  1.173  christos 	@false
     45  1.173  christos .endif
     46  1.171  christos 
     47  1.171  christos print-shlib-teeny:
     48  1.185        tv .if defined(SHLIB_TEENY) && ${MKPIC} != "no"
     49  1.171  christos 	@echo ${SHLIB_TEENY}
     50  1.143       erh .else
     51  1.169   thorpej 	@false
     52  1.173  christos .endif
     53  1.169   thorpej 
     54  1.173  christos .if defined(SHLIB_MAJOR) && !empty(SHLIB_MAJOR)
     55  1.173  christos .if defined(SHLIB_MINOR) && !empty(SHLIB_MINOR)
     56  1.173  christos .if defined(SHLIB_TEENY) && !empty(SHLIB_TEENY)
     57  1.173  christos SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}.${SHLIB_TEENY}
     58  1.173  christos .else
     59  1.173  christos SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}
     60  1.173  christos .endif
     61  1.173  christos .else
     62  1.173  christos SHLIB_FULLVERSION=${SHLIB_MAJOR}
     63  1.173  christos .endif
     64   1.35        pk .endif
     65    1.1       cgd 
     66  1.101   mycroft # add additional suffixes not exported.
     67  1.101   mycroft # .po is used for profiling object files.
     68  1.101   mycroft # .so is used for PIC object files.
     69  1.118     lukem .SUFFIXES: .out .a .ln .so .po .o .s .S .c .cc .C .m .F .f .r .y .l .cl .p .h
     70  1.118     lukem .SUFFIXES: .sh .m4 .m
     71   1.82     mikel 
     72   1.86  jonathan 
     73   1.86  jonathan # Set PICFLAGS to cc flags for producing position-independent code,
     74   1.86  jonathan # if not already set.  Includes -DPIC, if required.
     75   1.86  jonathan 
     76  1.164    simonb # Data-driven table using make variables to control how shared libraries
     77   1.86  jonathan # are built for different platforms and object formats.
     78  1.125  jonathan # OBJECT_FMT:		currently either "ELF" or "a.out", from <bsd.own.mk>
     79  1.164    simonb # SHLIB_SOVERSION:	version number to be compiled into a shared library
     80  1.164    simonb #			via -soname. Usualy ${SHLIB_MAJOR} on ELF.
     81  1.173  christos #			NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR}
     82  1.173  christos #			[.${SHLIB_TEENY}]]
     83  1.164    simonb # SHLIB_SHFLAGS:	Flags to tell ${LD} to emit shared library.
     84  1.123  jonathan #			with ELF, also set shared-lib version for ld.so.
     85  1.123  jonathan # SHLIB_LDSTARTFILE:	support .o file, call C++ file-level constructors
     86  1.123  jonathan # SHLIB_LDENDFILE:	support .o file, call C++ file-level destructors
     87  1.179  dmcmahil # FPICFLAGS:		flags for ${FC} to compile .[fF] files to .so objects.
     88  1.164    simonb # CPPICFLAGS:		flags for ${CPP} to preprocess .[sS] files for ${AS}
     89  1.164    simonb # CPICFLAGS:		flags for ${CC} to compile .[cC] files to .so objects.
     90  1.164    simonb # CAPICFLAGS		flags for {$CC} to compiling .[Ss] files
     91  1.107  jonathan #		 	(usually just ${CPPPICFLAGS} ${CPICFLAGS})
     92  1.164    simonb # APICFLAGS:		flags for ${AS} to assemble .[sS] to .so objects.
     93   1.86  jonathan 
     94  1.148     lukem .if ${MACHINE_ARCH} == "alpha"
     95  1.123  jonathan 		# Alpha-specific shared library flags
     96  1.179  dmcmahil FPICFLAGS ?= -fPIC
     97  1.165  dmcmahil CPICFLAGS ?= -fPIC -DPIC
     98  1.107  jonathan CPPPICFLAGS?= -DPIC 
     99  1.107  jonathan CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
    100  1.107  jonathan APICFLAGS ?=
    101  1.151  drochner .elif ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb"
    102  1.123  jonathan 		# mips-specific shared library flags
    103   1.86  jonathan 
    104  1.160    simonb # On mips, all libs are compiled with ABIcalls, not just sharedlibs.
    105  1.160    simonb MKPICLIB= no
    106  1.160    simonb 
    107  1.160    simonb # so turn shlib PIC flags on for ${AS}.
    108  1.160    simonb AINC+=-DABICALLS
    109   1.86  jonathan AFLAGS+= -fPIC
    110   1.86  jonathan AS+=	-KPIC
    111  1.172      matt 
    112  1.172      matt .elif ${MACHINE_ARCH} == "vax" && ${OBJECT_FMT} == "ELF"
    113  1.172      matt # On the VAX, all object are PIC by default, not just sharedlibs.
    114  1.172      matt MKPICLIB= no
    115  1.150  christos 
    116  1.175       mrg .elif (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") && \
    117  1.175       mrg        ${OBJECT_FMT} == "ELF"
    118  1.150  christos 
    119  1.179  dmcmahil FPICFLAGS ?= -fPIC
    120  1.165  dmcmahil CPICFLAGS ?= -fPIC -DPIC
    121  1.150  christos CPPPICFLAGS?= -DPIC 
    122  1.150  christos CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
    123  1.150  christos APICFLAGS ?= -KPIC
    124   1.86  jonathan 
    125   1.86  jonathan .else
    126   1.86  jonathan 
    127  1.187   nathanw # Platform-independent flags for NetBSD a.out shared libraries
    128  1.171  christos SHLIB_SOVERSION=${SHLIB_FULLVERSION}
    129  1.125  jonathan SHLIB_SHFLAGS=
    130  1.179  dmcmahil FPICFLAGS ?= -fPIC
    131  1.165  dmcmahil CPICFLAGS?= -fPIC -DPIC
    132  1.107  jonathan CPPPICFLAGS?= -DPIC 
    133  1.107  jonathan CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
    134  1.107  jonathan APICFLAGS?= -k
    135   1.86  jonathan 
    136   1.86  jonathan .endif
    137   1.86  jonathan 
    138  1.160    simonb MKPICLIB?= yes
    139  1.160    simonb 
    140  1.123  jonathan # Platform-independent linker flags for ELF shared libraries
    141  1.148     lukem .if ${OBJECT_FMT} == "ELF"
    142  1.182       mrg SHLIB_SOVERSION=	${SHLIB_MAJOR}
    143  1.182       mrg SHLIB_SHFLAGS=		-soname lib${LIB}.so.${SHLIB_SOVERSION}
    144  1.182       mrg SHLIB_LDSTARTFILE?=	${DESTDIR}/usr/lib/crtbeginS.o
    145  1.182       mrg SHLIB_LDENDFILE?=	${DESTDIR}/usr/lib/crtendS.o
    146  1.123  jonathan .endif
    147   1.86  jonathan 
    148   1.82     mikel CFLAGS+=	${COPTS}
    149  1.179  dmcmahil FFLAGS+=	${FOPTS}
    150    1.1       cgd 
    151    1.1       cgd .c.o:
    152  1.153  christos .if defined(COPTS) && !empty(COPTS:M*-g*)
    153  1.153  christos 	${COMPILE.c} ${.IMPSRC}
    154  1.153  christos .else
    155   1.80  christos 	@echo ${COMPILE.c:Q} ${.IMPSRC}
    156  1.122       cgd 	@${COMPILE.c} ${.IMPSRC} -o ${.TARGET}.o
    157   1.62  christos 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
    158   1.62  christos 	@rm -f ${.TARGET}.o
    159  1.153  christos .endif
    160    1.1       cgd 
    161    1.1       cgd .c.po:
    162  1.153  christos .if defined(COPTS) && !empty(COPTS:M*-g*)
    163  1.153  christos 	${COMPILE.c} -pg ${.IMPSRC} -o ${.TARGET}
    164  1.153  christos .else
    165   1.80  christos 	@echo ${COMPILE.c:Q} -pg ${.IMPSRC} -o ${.TARGET}
    166   1.68       cgd 	@${COMPILE.c} -pg ${.IMPSRC} -o ${.TARGET}.o
    167   1.62  christos 	@${LD} -X -r ${.TARGET}.o -o ${.TARGET}
    168   1.62  christos 	@rm -f ${.TARGET}.o
    169  1.153  christos .endif
    170   1.17   mycroft 
    171   1.27        pk .c.so:
    172  1.153  christos .if defined(COPTS) && !empty(COPTS:M*-g*)
    173  1.153  christos 	${COMPILE.c} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
    174  1.153  christos .else
    175   1.86  jonathan 	@echo ${COMPILE.c:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
    176   1.86  jonathan 	@${COMPILE.c} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
    177   1.62  christos 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
    178   1.62  christos 	@rm -f ${.TARGET}.o
    179  1.153  christos .endif
    180   1.27        pk 
    181   1.58       cgd .c.ln:
    182  1.121   thorpej 	${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
    183   1.58       cgd 
    184   1.18   mycroft .cc.o .C.o:
    185  1.153  christos .if defined(COPTS) && !empty(COPTS:M*-g*)
    186  1.153  christos 	${COMPILE.cc} ${.IMPSRC}
    187  1.153  christos .else
    188   1.80  christos 	@echo ${COMPILE.cc:Q} ${.IMPSRC}
    189   1.62  christos 	@${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}.o
    190   1.63       jtc 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
    191   1.62  christos 	@rm -f ${.TARGET}.o
    192  1.153  christos .endif
    193   1.17   mycroft 
    194   1.18   mycroft .cc.po .C.po:
    195  1.153  christos .if defined(COPTS) && !empty(COPTS:M*-g*)
    196  1.153  christos 	${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}
    197  1.153  christos .else
    198   1.80  christos 	@echo ${COMPILE.cc:Q} -pg ${.IMPSRC} -o ${.TARGET}
    199   1.68       cgd 	@${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}.o
    200   1.62  christos 	@${LD} -X -r ${.TARGET}.o -o ${.TARGET}
    201   1.62  christos 	@rm -f ${.TARGET}.o
    202  1.153  christos .endif
    203   1.28       cgd 
    204   1.28       cgd .cc.so .C.so:
    205  1.153  christos .if defined(COPTS) && !empty(COPTS:M*-g*)
    206  1.153  christos 	${COMPILE.cc} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
    207  1.153  christos .else
    208   1.86  jonathan 	@echo ${COMPILE.cc:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
    209   1.86  jonathan 	@${COMPILE.cc} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
    210   1.62  christos 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
    211   1.62  christos 	@rm -f ${.TARGET}.o
    212  1.153  christos .endif
    213  1.118     lukem 
    214  1.179  dmcmahil .f.o:
    215  1.179  dmcmahil .if defined(FOPTS) && !empty(FOPTS:M*-g*)
    216  1.179  dmcmahil 	${COMPILE.f} ${.IMPSRC}
    217  1.179  dmcmahil .else
    218  1.179  dmcmahil 	@echo ${COMPILE.f:Q} ${.IMPSRC}
    219  1.179  dmcmahil 	@${COMPILE.f} ${.IMPSRC} -o ${.TARGET}.o
    220  1.179  dmcmahil 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
    221  1.179  dmcmahil 	@rm -f ${.TARGET}.o
    222  1.179  dmcmahil .endif
    223  1.179  dmcmahil 
    224  1.179  dmcmahil .f.po:
    225  1.179  dmcmahil .if defined(FOPTS) && !empty(FOPTS:M*-g*)
    226  1.179  dmcmahil 	${COMPILE.f} -pg ${.IMPSRC} -o ${.TARGET}
    227  1.179  dmcmahil .else
    228  1.179  dmcmahil 	@echo ${COMPILE.f:Q} -pg ${.IMPSRC} -o ${.TARGET}
    229  1.179  dmcmahil 	@${COMPILE.f} -pg ${.IMPSRC} -o ${.TARGET}.o
    230  1.179  dmcmahil 	@${LD} -X -r ${.TARGET}.o -o ${.TARGET}
    231  1.179  dmcmahil 	@rm -f ${.TARGET}.o
    232  1.179  dmcmahil .endif
    233  1.179  dmcmahil 
    234  1.179  dmcmahil .f.so:
    235  1.179  dmcmahil .if defined(FOPTS) && !empty(FOPTS:M*-g*)
    236  1.179  dmcmahil 	${COMPILE.f} ${FPICFLAGS} ${.IMPSRC} -o ${.TARGET}
    237  1.179  dmcmahil .else
    238  1.179  dmcmahil 	@echo ${COMPILE.f:Q} ${FPICFLAGS} ${.IMPSRC} -o ${.TARGET}
    239  1.179  dmcmahil 	@${COMPILE.f} ${FPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
    240  1.179  dmcmahil 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
    241  1.179  dmcmahil 	@rm -f ${.TARGET}.o
    242  1.179  dmcmahil .endif
    243  1.179  dmcmahil 
    244  1.179  dmcmahil .f.ln:
    245  1.179  dmcmahil 	${ECHO} Skipping lint for Fortran libraries.
    246  1.179  dmcmahil 
    247  1.118     lukem .m.o:
    248  1.153  christos .if defined(OBJCFLAGS) && !empty(OBJCFLAGS:M*-g*)
    249  1.153  christos 	${COMPILE.m} ${.IMPSRC}
    250  1.153  christos .else
    251  1.118     lukem 	@echo ${COMPILE.m:Q} ${.IMPSRC}
    252  1.122       cgd 	@${COMPILE.m} ${.IMPSRC} -o ${.TARGET}.o
    253  1.118     lukem 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
    254  1.118     lukem 	@rm -f ${.TARGET}.o
    255  1.153  christos .endif
    256  1.118     lukem 
    257  1.118     lukem .m.po:
    258  1.153  christos .if defined(OBJCFLAGS) && !empty(OBJCFLAGS:M*-g*)
    259  1.153  christos 	${COMPILE.m} -pg ${.IMPSRC} -o ${.TARGET}
    260  1.153  christos .else
    261  1.118     lukem 	@echo ${COMPILE.m:Q} -pg ${.IMPSRC} -o ${.TARGET}
    262  1.118     lukem 	@${COMPILE.m} -pg ${.IMPSRC} -o ${.TARGET}.o
    263  1.118     lukem 	@${LD} -X -r ${.TARGET}.o -o ${.TARGET}
    264  1.118     lukem 	@rm -f ${.TARGET}.o
    265  1.153  christos .endif
    266  1.118     lukem 
    267  1.118     lukem .m.so:
    268  1.153  christos .if defined(OBJCFLAGS) && !empty(OBJCFLAGS:M*-g*)
    269  1.153  christos 	${COMPILE.m} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
    270  1.153  christos .else
    271  1.118     lukem 	@echo ${COMPILE.m:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
    272  1.118     lukem 	@${COMPILE.m} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
    273  1.118     lukem 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
    274  1.118     lukem 	@rm -f ${.TARGET}.o
    275  1.153  christos .endif
    276    1.1       cgd 
    277   1.40       cgd .S.o .s.o:
    278   1.80  christos 	@echo ${COMPILE.S:Q} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
    279   1.69       jtc 	@${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
    280   1.62  christos 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
    281   1.62  christos 	@rm -f ${.TARGET}.o
    282    1.1       cgd 
    283   1.40       cgd .S.po .s.po:
    284   1.80  christos 	@echo ${COMPILE.S:Q} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
    285   1.75       jtc 	@${COMPILE.S} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
    286   1.62  christos 	@${LD} -X -r ${.TARGET}.o -o ${.TARGET}
    287   1.62  christos 	@rm -f ${.TARGET}.o
    288    1.1       cgd 
    289   1.40       cgd .S.so .s.so:
    290  1.107  jonathan 	@echo ${COMPILE.S:Q} ${CAPICFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
    291  1.107  jonathan 	@${COMPILE.S} ${CAPICFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
    292   1.62  christos 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
    293   1.62  christos 	@rm -f ${.TARGET}.o
    294   1.27        pk 
    295  1.148     lukem .if ${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
    296  1.148     lukem 	|| ${MKLINKLIB} != "no"
    297  1.130        tv _LIBS=lib${LIB}.a
    298  1.130        tv .else
    299  1.130        tv _LIBS=
    300  1.130        tv .endif
    301   1.58       cgd 
    302  1.167      matt OBJS+=${SRCS:N*.h:N*.sh:R:S/$/.o/g}
    303  1.158  christos 
    304  1.149     lukem .if ${MKPROFILE} != "no"
    305  1.130        tv _LIBS+=lib${LIB}_p.a
    306  1.167      matt POBJS+=${OBJS:.o=.po}
    307    1.1       cgd .endif
    308    1.1       cgd 
    309  1.148     lukem .if ${MKPIC} != "no"
    310  1.160    simonb .if ${MKPICLIB} == "no"
    311  1.160    simonb SOLIB=lib${LIB}.a
    312  1.160    simonb .else
    313  1.160    simonb SOLIB=lib${LIB}_pic.a
    314  1.160    simonb _LIBS+=${SOLIB}
    315  1.167      matt SOBJS+=${OBJS:.o=.so}
    316  1.160    simonb .endif
    317  1.171  christos .if defined(SHLIB_FULLVERSION)
    318  1.171  christos _LIBS+=lib${LIB}.so.${SHLIB_FULLVERSION}
    319   1.27        pk .endif
    320   1.35        pk .endif
    321   1.27        pk 
    322  1.179  dmcmahil LOBJS+=${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
    323  1.179  dmcmahil .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS)
    324   1.58       cgd _LIBS+=llib-l${LIB}.ln
    325   1.27        pk .endif
    326   1.27        pk 
    327  1.167      matt .if ${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
    328  1.167      matt 	|| ${MKLINKLIB} != "no"
    329  1.179  dmcmahil ALLOBJS=${OBJS} ${POBJS} ${SOBJS}
    330  1.167      matt .else
    331  1.179  dmcmahil ALLOBJS=${POBJS} ${SOBJS} 
    332  1.179  dmcmahil .endif
    333  1.179  dmcmahil .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS)
    334  1.179  dmcmahil ALLOBJS+=${LOBJS}
    335  1.167      matt .endif
    336  1.186        tv 
    337  1.186        tv .NOPATH: ${ALLOBJS} ${_LIBS} ${SRCS:M*.[ly]:C/..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
    338  1.158  christos 
    339  1.162   mycroft realall: ${SRCS} ${ALLOBJS:O} ${_LIBS}
    340    1.1       cgd 
    341   1.90  christos __archivebuild: .USE
    342   1.89  christos 	@rm -f ${.TARGET}
    343  1.138        tv 	@${AR} cq ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
    344   1.89  christos 	${RANLIB} ${.TARGET}
    345   1.89  christos 
    346   1.89  christos __archiveinstall: .USE
    347  1.188        tv 	${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m 600 ${.ALLSRC} ${.TARGET}
    348   1.89  christos 	${RANLIB} -t ${.TARGET}
    349   1.89  christos 	chmod ${LIBMODE} ${.TARGET}
    350   1.89  christos 
    351  1.186        tv DPSRCS+=	${SRCS:M*.[ly]:C/..$/.c/}
    352  1.186        tv CLEANFILES+=	${DPSRCS} ${YHEADER:D${SRCS:M*.y:.y=.h}}
    353  1.103   mycroft 
    354   1.89  christos lib${LIB}.a:: ${OBJS} __archivebuild
    355    1.1       cgd 	@echo building standard ${LIB} library
    356    1.1       cgd 
    357   1.89  christos lib${LIB}_p.a:: ${POBJS} __archivebuild
    358    1.1       cgd 	@echo building profiled ${LIB} library
    359    1.1       cgd 
    360   1.89  christos lib${LIB}_pic.a:: ${SOBJS} __archivebuild
    361   1.27        pk 	@echo building shared object ${LIB} library
    362   1.27        pk 
    363  1.171  christos lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOLIB} ${DPADD} \
    364   1.88       cgd     ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
    365  1.171  christos 	@echo building shared ${LIB} library \(version ${SHLIB_FULLVERSION}\)
    366  1.171  christos 	@rm -f lib${LIB}.so.${SHLIB_FULLVERSION}
    367  1.152      fair .if defined(DESTDIR)
    368  1.155  wrstuden 	$(LD) -nostdlib -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
    369  1.152      fair 	    ${SHLIB_LDSTARTFILE} \
    370  1.160    simonb 	    --whole-archive ${SOLIB} \
    371  1.170       erh 	    --no-whole-archive ${LDADD} \
    372  1.155  wrstuden 	    -L${DESTDIR}${LIBDIR} -R${LIBDIR} \
    373  1.152      fair 	    ${SHLIB_LDENDFILE}
    374  1.152      fair .else
    375  1.126  jonathan 	$(LD) -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
    376  1.123  jonathan 	    ${SHLIB_LDSTARTFILE} \
    377  1.160    simonb 	    --whole-archive ${SOLIB} --no-whole-archive ${LDADD} \
    378  1.115       cjs 	    ${SHLIB_LDENDFILE}
    379  1.152      fair .endif
    380  1.148     lukem .if ${OBJECT_FMT} == "ELF"
    381  1.177   mycroft 	ln -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.${SHLIB_MAJOR}.tmp
    382  1.177   mycroft 	mv -f lib${LIB}.so.${SHLIB_MAJOR}.tmp lib${LIB}.so.${SHLIB_MAJOR}
    383  1.177   mycroft 	ln -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.tmp
    384  1.177   mycroft 	mv -f lib${LIB}.so.tmp lib${LIB}.so
    385  1.133        tv .endif
    386   1.35        pk 
    387  1.179  dmcmahil .if !empty(LOBJS)
    388  1.103   mycroft LLIBS?=		-lc
    389   1.58       cgd llib-l${LIB}.ln: ${LOBJS}
    390   1.58       cgd 	@echo building llib-l${LIB}.ln
    391   1.58       cgd 	@rm -f llib-l${LIB}.ln
    392  1.141  wrstuden 	@${LINT} -C${LIB} ${.ALLSRC} ${LLIBS}
    393  1.179  dmcmahil .endif
    394    1.1       cgd 
    395   1.81       cgd cleanlib:
    396   1.48   mycroft 	rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
    397   1.59       cgd 	rm -f lib${LIB}.a ${OBJS}
    398   1.59       cgd 	rm -f lib${LIB}_p.a ${POBJS}
    399  1.133        tv 	rm -f lib${LIB}_pic.a lib${LIB}.so.* lib${LIB}.so ${SOBJS}
    400   1.59       cgd 	rm -f llib-l${LIB}.ln ${LOBJS}
    401    1.1       cgd 
    402   1.26   mycroft .if defined(SRCS)
    403   1.64  christos afterdepend: .depend
    404    1.1       cgd 	@(TMP=/tmp/_depend$$$$; \
    405   1.79       cgd 	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.ln:/' \
    406   1.58       cgd 	      < .depend > $$TMP; \
    407    1.1       cgd 	    mv $$TMP .depend)
    408   1.26   mycroft .endif
    409    1.1       cgd 
    410   1.97   mycroft .if !target(libinstall)
    411  1.148     lukem # Make sure it gets defined, in case MKPIC==no && MKLINKLIB==no
    412  1.139        tv libinstall::
    413  1.139        tv 
    414  1.148     lukem .if ${MKLINKLIB} != "no"
    415   1.89  christos libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.a
    416  1.168   mycroft .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.a
    417   1.89  christos .if !defined(UPDATE)
    418   1.89  christos .PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}.a
    419   1.89  christos .endif
    420  1.168   mycroft 
    421  1.157     fredb .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a)
    422   1.89  christos ${DESTDIR}${LIBDIR}/lib${LIB}.a: .MADE
    423   1.89  christos .endif
    424   1.89  christos ${DESTDIR}${LIBDIR}/lib${LIB}.a: lib${LIB}.a __archiveinstall
    425  1.130        tv .endif
    426   1.89  christos 
    427  1.149     lukem .if ${MKPROFILE} != "no"
    428   1.89  christos libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
    429  1.168   mycroft .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
    430   1.89  christos .if !defined(UPDATE)
    431   1.89  christos .PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
    432   1.32        pk .endif
    433  1.168   mycroft 
    434  1.157     fredb .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a)
    435   1.89  christos ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: .MADE
    436   1.89  christos .endif
    437   1.89  christos ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: lib${LIB}_p.a __archiveinstall
    438   1.89  christos .endif
    439   1.89  christos 
    440  1.149     lukem .if ${MKPIC} != "no" && ${MKPICINSTALL} != "no"
    441  1.168   mycroft libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
    442  1.160    simonb .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
    443   1.89  christos .if !defined(UPDATE)
    444   1.89  christos .PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
    445   1.89  christos .endif
    446  1.168   mycroft 
    447  1.157     fredb .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a)
    448   1.89  christos ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: .MADE
    449   1.33        pk .endif
    450  1.160    simonb .if ${MKPICLIB} == "no"
    451  1.160    simonb ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a:
    452  1.160    simonb 	rm -f ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
    453  1.160    simonb 	ln -s lib${LIB}.a ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
    454  1.160    simonb .else
    455   1.89  christos ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}_pic.a __archiveinstall
    456  1.160    simonb .endif
    457   1.89  christos .endif
    458   1.89  christos 
    459  1.171  christos .if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION)
    460  1.171  christos libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
    461  1.171  christos .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
    462   1.89  christos .if !defined(UPDATE)
    463  1.171  christos .PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
    464   1.89  christos .endif
    465  1.168   mycroft 
    466  1.171  christos .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION})
    467  1.171  christos ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: .MADE
    468   1.89  christos .endif
    469  1.171  christos ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: lib${LIB}.so.${SHLIB_FULLVERSION}
    470  1.188        tv 	${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
    471  1.188        tv 		${.ALLSRC} ${.TARGET}
    472  1.148     lukem .if ${OBJECT_FMT} == "a.out" && !defined(DESTDIR)
    473  1.146   thorpej 	/sbin/ldconfig -m ${LIBDIR}
    474  1.146   thorpej .endif
    475  1.148     lukem .if ${OBJECT_FMT} == "ELF"
    476  1.178   mycroft 	ln -sf lib${LIB}.so.${SHLIB_FULLVERSION}\
    477  1.177   mycroft 	    ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.tmp
    478  1.178   mycroft 	mv -f ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.tmp\
    479   1.83       cgd 	    ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
    480  1.148     lukem .if ${MKLINKLIB} != "no"
    481  1.178   mycroft 	ln -sf lib${LIB}.so.${SHLIB_FULLVERSION}\
    482  1.177   mycroft 	    ${DESTDIR}${LIBDIR}/lib${LIB}.so.tmp
    483  1.178   mycroft 	mv -f ${DESTDIR}${LIBDIR}/lib${LIB}.so.tmp\
    484   1.83       cgd 	    ${DESTDIR}${LIBDIR}/lib${LIB}.so
    485   1.83       cgd .endif
    486   1.12       cgd .endif
    487  1.139        tv .endif
    488   1.89  christos 
    489  1.179  dmcmahil .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS)
    490   1.89  christos libinstall:: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
    491  1.168   mycroft .PRECIOUS: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
    492   1.89  christos .if !defined(UPDATE)
    493   1.89  christos .PHONY: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
    494   1.89  christos .endif
    495  1.168   mycroft 
    496  1.157     fredb .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln)
    497   1.89  christos ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: .MADE
    498   1.89  christos .endif
    499   1.95   mycroft ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: llib-l${LIB}.ln
    500  1.188        tv 	${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
    501  1.188        tv 		${.ALLSRC} ${DESTDIR}${LINTLIBDIR}
    502   1.58       cgd .endif
    503    1.1       cgd .endif
    504    1.1       cgd 
    505  1.188        tv ##### Pull in related .mk logic
    506    1.1       cgd .include <bsd.man.mk>
    507   1.57       jtc .include <bsd.nls.mk>
    508   1.91  christos .include <bsd.files.mk>
    509   1.89  christos .include <bsd.inc.mk>
    510  1.109       cjs .include <bsd.links.mk>
    511   1.24   mycroft .include <bsd.dep.mk>
    512   1.66  christos .include <bsd.sys.mk>
    513  1.117   mycroft 
    514  1.188        tv ${TARGETS}:	# ensure existence
    515