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