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