bsd.lib.mk revision 1.399       1  1.398  christos #	$NetBSD: bsd.lib.mk,v 1.399 2024/04/02 16:18:23 christos 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.207   thorpej .include <bsd.shlib.mk>
      6  1.219   thorpej .include <bsd.gcc.mk>
      7  1.380     kamil .include <bsd.sanitizer.mk>
      8  1.376     kamil 
      9  1.227     lukem # Pull in <bsd.sys.mk> here so we can override its .c.o rule
     10  1.227     lukem .include <bsd.sys.mk>
     11   1.97   mycroft 
     12  1.282     lukem LIBISMODULE?=	no
     13  1.281     lukem LIBISPRIVATE?=	no
     14  1.291       mrg LIBISCXX?=	no
     15  1.281     lukem 
     16  1.282     lukem .if ${LIBISMODULE} != "no"
     17  1.330  christos _LIB_PREFIX?=	# empty
     18  1.282     lukem MKDEBUGLIB:=	no
     19  1.399  christos MKPICINSTALL:=	no
     20  1.398  christos MKPROFILE:=	no
     21  1.282     lukem MKSTATICLIB:=	no
     22  1.388  christos _LINTINSTALL?=	no
     23  1.330  christos .else
     24  1.330  christos _LIB_PREFIX?=	lib
     25  1.282     lukem .endif
     26  1.282     lukem 
     27  1.281     lukem .if ${LIBISPRIVATE} != "no"
     28  1.280     lukem MKDEBUGLIB:=	no
     29  1.290      cube MKPICINSTALL:=	no
     30  1.290      cube . if defined(NOSTATICLIB) && ${MKPICLIB} != "no"
     31  1.290      cube MKSTATICLIB:=	no
     32  1.383  christos . elif ${LIBISPRIVATE} != "pic"
     33  1.280     lukem MKPIC:=		no
     34  1.290      cube . endif
     35  1.399  christos MKPROFILE:=	no
     36  1.388  christos _LINTINSTALL?=	no
     37  1.280     lukem .endif
     38  1.280     lukem 
     39  1.388  christos _LINTINSTALL?=	${MKLINT}
     40  1.388  christos 
     41  1.188        tv ##### Basic targets
     42  1.246     lukem .PHONY:		checkver libinstall
     43  1.143       erh realinstall:	checkver libinstall
     44  1.232       erh 
     45  1.232       erh ##### LIB specific flags.
     46  1.287  christos # XXX: This is needed for programs that link with .a libraries
     47  1.287  christos # Perhaps a more correct solution is to always generate _pic.a
     48  1.287  christos # files or always have a shared library.
     49  1.371  christos # Another fix is to provide rcrt0.o like OpenBSD does and
     50  1.371  christos # do relocations for static PIE.
     51  1.366  christos .if defined(MKPIE) && (${MKPIE} != "no") && !defined(NOPIE)
     52  1.366  christos CFLAGS+=        ${PIE_CFLAGS}
     53  1.366  christos AFLAGS+=        ${PIE_AFLAGS}
     54  1.366  christos .endif
     55    1.1       cgd 
     56  1.387       ryo PGFLAGS+=	-pg
     57  1.378  christos .if ${MKPIC} != "no"
     58  1.378  christos PGFLAGS+=	-fPIC
     59  1.378  christos .endif
     60  1.378  christos 
     61  1.256     lukem ##### Libraries that this may depend upon.
     62  1.256     lukem .if defined(LIBDPLIBS) && ${MKPIC} != "no"				# {
     63  1.256     lukem .for _lib _dir in ${LIBDPLIBS}
     64  1.256     lukem .if !defined(LIBDO.${_lib})
     65  1.303  christos LIBDO.${_lib}!=	cd "${_dir}" && ${PRINTOBJDIR}
     66  1.256     lukem .MAKEOVERRIDES+=LIBDO.${_lib}
     67  1.256     lukem .endif
     68  1.325     pooka .if ${LIBDO.${_lib}} == "_external"
     69  1.325     pooka LDADD+=		-l${_lib}
     70  1.325     pooka .else
     71  1.256     lukem LDADD+=		-L${LIBDO.${_lib}} -l${_lib}
     72  1.391  christos .if exists(${LIBDO.${_lib}}/lib${_lib}_pic.a)
     73  1.391  christos DPADD+=         ${LIBDO.${_lib}}/lib${_lib}_pic.a
     74  1.391  christos .elif exists(${LIBDO.${_lib}}/lib${_lib}.so)
     75  1.391  christos DPADD+=         ${LIBDO.${_lib}}/lib${_lib}.so
     76  1.392  riastrad .else
     77  1.391  christos DPADD+=         ${LIBDO.${_lib}}/lib${_lib}.a
     78  1.392  riastrad .endif
     79  1.325     pooka .endif
     80  1.256     lukem .endfor
     81  1.256     lukem .endif									# }
     82  1.256     lukem 
     83  1.188        tv ##### Build and install rules
     84  1.356       erh MKDEP_SUFFIXES?=	.o .po .pico .go .ln .d
     85  1.292     pooka 
     86  1.252     lukem .if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE})		# {
     87  1.154    simonb SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major
     88  1.154    simonb SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor
     89  1.171  christos SHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny
     90  1.143       erh 
     91  1.295        he DPADD+=	${SHLIB_VERSION_FILE}
     92  1.295        he 
     93  1.143       erh # Check for higher installed library versions.
     94  1.145       erh .if !defined(NOCHECKVER) && !defined(NOCHECKVER_${LIB}) && \
     95  1.201     lukem 	exists(${NETBSDSRCDIR}/lib/checkver)
     96  1.143       erh checkver:
     97  1.303  christos 	@(cd "${.CURDIR}" && \
     98  1.289       apb 	    HOST_SH=${HOST_SH:Q} AWK=${TOOL_AWK:Q} \
     99  1.239     lukem 	    ${HOST_SH} ${NETBSDSRCDIR}/lib/checkver -v ${SHLIB_VERSION_FILE} \
    100  1.327  christos 		    -d ${_DEST.OBJ} ${LIB})
    101  1.173  christos .endif
    102  1.252     lukem .endif									# }
    103  1.173  christos 
    104  1.173  christos .if !target(checkver)
    105  1.143       erh checkver:
    106  1.143       erh .endif
    107  1.173  christos 
    108  1.169   thorpej print-shlib-major:
    109  1.185        tv .if defined(SHLIB_MAJOR) && ${MKPIC} != "no"
    110  1.169   thorpej 	@echo ${SHLIB_MAJOR}
    111  1.173  christos .else
    112  1.173  christos 	@false
    113  1.173  christos .endif
    114  1.169   thorpej 
    115  1.169   thorpej print-shlib-minor:
    116  1.185        tv .if defined(SHLIB_MINOR) && ${MKPIC} != "no"
    117  1.169   thorpej 	@echo ${SHLIB_MINOR}
    118  1.173  christos .else
    119  1.173  christos 	@false
    120  1.173  christos .endif
    121  1.171  christos 
    122  1.171  christos print-shlib-teeny:
    123  1.185        tv .if defined(SHLIB_TEENY) && ${MKPIC} != "no"
    124  1.171  christos 	@echo ${SHLIB_TEENY}
    125  1.143       erh .else
    126  1.169   thorpej 	@false
    127  1.173  christos .endif
    128  1.169   thorpej 
    129  1.383  christos .if ${LIBISPRIVATE} == "no"
    130  1.252     lukem .if defined(SHLIB_MAJOR) && !empty(SHLIB_MAJOR)				# {
    131  1.173  christos .if defined(SHLIB_MINOR) && !empty(SHLIB_MINOR)
    132  1.173  christos .if defined(SHLIB_TEENY) && !empty(SHLIB_TEENY)
    133  1.173  christos SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}.${SHLIB_TEENY}
    134  1.173  christos .else
    135  1.173  christos SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}
    136  1.173  christos .endif
    137  1.173  christos .else
    138  1.173  christos SHLIB_FULLVERSION=${SHLIB_MAJOR}
    139  1.173  christos .endif
    140  1.252     lukem .endif									# }
    141  1.383  christos .endif
    142    1.1       cgd 
    143  1.101   mycroft # add additional suffixes not exported.
    144  1.101   mycroft # .po is used for profiling object files.
    145  1.304     njoly # .pico is used for PIC object files.
    146  1.304     njoly .SUFFIXES: .out .a .ln .pico .po .go .o .s .S .c .cc .cpp .cxx .C .m .F .f .r .y .l .cl .p .h
    147  1.118     lukem .SUFFIXES: .sh .m4 .m
    148   1.82     mikel 
    149   1.86  jonathan 
    150   1.86  jonathan # Set PICFLAGS to cc flags for producing position-independent code,
    151  1.338     joerg # if not already set.
    152   1.86  jonathan 
    153  1.164    simonb # Data-driven table using make variables to control how shared libraries
    154   1.86  jonathan # are built for different platforms and object formats.
    155  1.302       abs # SHLIB_MAJOR, SHLIB_MINOR, SHLIB_TEENY: Major, minor, and teeny version
    156  1.302       abs #			numbers of shared library
    157  1.164    simonb # SHLIB_SOVERSION:	version number to be compiled into a shared library
    158  1.385    andvar #			via -soname. Usually ${SHLIB_MAJOR} on ELF.
    159  1.173  christos #			NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR}
    160  1.173  christos #			[.${SHLIB_TEENY}]]
    161  1.164    simonb # SHLIB_SHFLAGS:	Flags to tell ${LD} to emit shared library.
    162  1.123  jonathan #			with ELF, also set shared-lib version for ld.so.
    163  1.123  jonathan # SHLIB_LDSTARTFILE:	support .o file, call C++ file-level constructors
    164  1.123  jonathan # SHLIB_LDENDFILE:	support .o file, call C++ file-level destructors
    165   1.86  jonathan 
    166  1.338     joerg PICFLAGS ?= -fPIC
    167  1.160    simonb 
    168  1.205      yamt .if ${MKPICLIB} != "no"
    169  1.377     kamil CSHLIBFLAGS+= ${PICFLAGS} ${SANITIZERFLAGS} ${LIBCSANITIZERFLAGS}
    170  1.205      yamt .endif
    171  1.205      yamt 
    172  1.205      yamt .if defined(CSHLIBFLAGS) && !empty(CSHLIBFLAGS)
    173  1.205      yamt MKSHLIBOBJS= yes
    174  1.205      yamt .else
    175  1.205      yamt MKSHLIBOBJS= no
    176  1.205      yamt .endif
    177  1.205      yamt 
    178  1.390       mrg # Avoid adding "-g" if we already have a "-g*" option.
    179  1.390       mrg .if (${MKDEBUG:Uno} != "no" && !defined(NODEBUG)) && \
    180  1.390       mrg     (!defined(CFLAGS) || empty(CFLAGS:M-g*)) && \
    181  1.390       mrg     (!defined(CXXFLAGS) || empty(CXXFLAGS:M-g*))
    182  1.335  riastrad # We only add -g to the shared library objects
    183  1.335  riastrad # because we don't currently split .a archives.
    184  1.335  riastrad CSHLIBFLAGS+=	-g
    185  1.383  christos .if ${LIBISPRIVATE} != "no"
    186  1.335  riastrad CFLAGS+=	-g
    187  1.335  riastrad .endif
    188  1.335  riastrad .endif
    189  1.335  riastrad 
    190  1.123  jonathan # Platform-independent linker flags for ELF shared libraries
    191  1.182       mrg SHLIB_SOVERSION=	${SHLIB_MAJOR}
    192  1.327  christos SHLIB_SHFLAGS=		-Wl,-soname,${_LIB}.so.${SHLIB_SOVERSION}
    193  1.375     kamil SHLIB_SHFLAGS+=		${SANITIZERFLAGS}
    194  1.354     pooka .if !defined(SHLIB_WARNTEXTREL) || ${SHLIB_WARNTEXTREL} != "no"
    195  1.272  christos SHLIB_SHFLAGS+=		-Wl,--warn-shared-textrel
    196  1.354     pooka .endif
    197  1.337     pooka .if !defined(SHLIB_MKMAP) || ${SHLIB_MKMAP} != "no"
    198  1.336      matt SHLIB_SHFLAGS+=		-Wl,-Map=${_LIB}.so.${SHLIB_SOVERSION}.map
    199  1.337     pooka .endif
    200  1.336      matt CLEANFILES+=		${_LIB}.so.${SHLIB_SOVERSION}.map
    201  1.322  christos SHLIB_LDSTARTFILE?=	${_GCC_CRTI} ${_GCC_CRTBEGINS}
    202  1.322  christos SHLIB_LDENDFILE?=	${_GCC_CRTENDS} ${_GCC_CRTN}
    203   1.86  jonathan 
    204   1.82     mikel CFLAGS+=	${COPTS}
    205  1.267       mrg OBJCFLAGS+=	${OBJCOPTS}
    206  1.257    simonb AFLAGS+=	${COPTS}
    207  1.179  dmcmahil FFLAGS+=	${FOPTS}
    208    1.1       cgd 
    209  1.305    darran .if defined(CTFCONVERT)
    210  1.305    darran .if defined(CFLAGS) && !empty(CFLAGS:M*-g*)
    211  1.305    darran CTFFLAGS+=	-g
    212  1.367       mrg .if defined(HAVE_GCC)
    213  1.348  christos #CFLAGS+=	-gdwarf-2
    214  1.347  christos .endif
    215  1.305    darran .endif
    216  1.305    darran .endif
    217  1.305    darran 
    218  1.333  christos LIBSTRIPAOBJS=	yes
    219  1.333  christos .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
    220  1.333  christos LIBSTRIPCOBJS=	yes
    221  1.333  christos .endif
    222  1.333  christos .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
    223  1.333  christos LIBSTRIPOBJCOBJS=	yes
    224  1.333  christos .endif
    225  1.333  christos .if !defined(FFLAGS) || empty(FFLAGS:M*-g*)
    226  1.333  christos LIBSTRIPFOBJS=	yes
    227  1.333  christos .endif
    228  1.392  riastrad .if !defined(CSHLIBFLAGS) || empty(CSHLIBFLAGS:M*-g*)
    229  1.333  christos LIBSTRIPSHLIBOBJS=	yes
    230  1.333  christos .endif
    231  1.333  christos 
    232    1.1       cgd .c.o:
    233  1.238     lukem 	${_MKTARGET_COMPILE}
    234  1.384  christos 	${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
    235  1.384  christos 	${CTFCONVERT_RUN}
    236  1.333  christos .if defined(LIBSTRIPCOBJS)
    237  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    238  1.153  christos .endif
    239    1.1       cgd 
    240    1.1       cgd .c.po:
    241  1.238     lukem 	${_MKTARGET_COMPILE}
    242  1.384  christos 	${COMPILE.c} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${PGFLAGS} ${.IMPSRC} ${OBJECT_TARGET}
    243  1.384  christos 	${CTFCONVERT_RUN}
    244  1.333  christos .if defined(LIBSTRIPCOBJS)
    245  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    246  1.153  christos .endif
    247   1.17   mycroft 
    248  1.266  christos .c.go:
    249  1.266  christos 	${_MKTARGET_COMPILE}
    250  1.266  christos 	${COMPILE.c} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET}
    251  1.266  christos 
    252  1.304     njoly .c.pico:
    253  1.238     lukem 	${_MKTARGET_COMPILE}
    254  1.263       dsl 	${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
    255  1.333  christos .if defined(LIBSTRIPSHLIBOBJS)
    256  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    257  1.153  christos .endif
    258   1.27        pk 
    259  1.223     lukem .cc.o .cpp.o .cxx.o .C.o:
    260  1.238     lukem 	${_MKTARGET_COMPILE}
    261  1.263       dsl 	${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
    262  1.333  christos .if defined(LIBSTRIPCOBJS)
    263  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    264  1.153  christos .endif
    265   1.17   mycroft 
    266  1.266  christos .cc.po .cpp.po .cxx.po .C.po:
    267  1.238     lukem 	${_MKTARGET_COMPILE}
    268  1.378  christos 	${COMPILE.cc} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${PGFLAGS} ${.IMPSRC} -o ${.TARGET}
    269  1.333  christos .if defined(LIBSTRIPCOBJS)
    270  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    271  1.153  christos .endif
    272   1.28       cgd 
    273  1.266  christos .cc.go .cpp.go .cxx.go .C.go:
    274  1.266  christos 	${_MKTARGET_COMPILE}
    275  1.266  christos 	${COMPILE.cc} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET}
    276  1.266  christos 
    277  1.304     njoly .cc.pico .cpp.pico .cxx.pico .C.pico:
    278  1.238     lukem 	${_MKTARGET_COMPILE}
    279  1.263       dsl 	${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
    280  1.333  christos .if defined(LIBSTRIPSHLIBOBJS)
    281  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    282  1.153  christos .endif
    283  1.118     lukem 
    284  1.179  dmcmahil .f.o:
    285  1.238     lukem 	${_MKTARGET_COMPILE}
    286  1.384  christos 	${COMPILE.f} ${.IMPSRC} ${OBJECT_TARGET}
    287  1.384  christos 	${CTFCONVERT_RUN}
    288  1.333  christos .if defined(LIBSTRIPFOBJS)
    289  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    290  1.179  dmcmahil .endif
    291  1.179  dmcmahil 
    292  1.179  dmcmahil .f.po:
    293  1.238     lukem 	${_MKTARGET_COMPILE}
    294  1.384  christos 	${COMPILE.f} ${PROFFLAGS} ${PGFLAGS} ${.IMPSRC} ${OBJECT_TARGET}
    295  1.384  christos 	${CTFCONVERT_RUN}
    296  1.333  christos .if defined(LIBSTRIPFOBJS)
    297  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    298  1.179  dmcmahil .endif
    299  1.179  dmcmahil 
    300  1.266  christos .f.go:
    301  1.266  christos 	${_MKTARGET_COMPILE}
    302  1.266  christos 	${COMPILE.f} ${DEBUGFLAGS} -g ${.IMPSRC} -o ${.TARGET}
    303  1.266  christos 
    304  1.304     njoly .f.pico:
    305  1.238     lukem 	${_MKTARGET_COMPILE}
    306  1.338     joerg 	${COMPILE.f} ${PICFLAGS} ${.IMPSRC} -o ${.TARGET}
    307  1.333  christos .if defined(LIBSTRIPFOBJS)
    308  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    309  1.179  dmcmahil .endif
    310  1.179  dmcmahil 
    311  1.179  dmcmahil .f.ln:
    312  1.238     lukem 	${_MKTARGET_COMPILE}
    313  1.217       wiz 	@echo Skipping lint for Fortran libraries.
    314  1.179  dmcmahil 
    315  1.118     lukem .m.o:
    316  1.238     lukem 	${_MKTARGET_COMPILE}
    317  1.384  christos 	${COMPILE.m} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
    318  1.384  christos 	${CTFCONVERT_RUN}
    319  1.333  christos .if defined(LIBSTRIPOBJCOBJS)
    320  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    321  1.153  christos .endif
    322  1.118     lukem 
    323  1.118     lukem .m.po:
    324  1.238     lukem 	${_MKTARGET_COMPILE}
    325  1.384  christos 	${COMPILE.m} ${PROFFLAGS} ${PGFLAGS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
    326  1.384  christos 	${CTFCONVERT_RUN}
    327  1.333  christos .if defined(LIBSTRIPOBJCOBJS)
    328  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    329  1.153  christos .endif
    330  1.118     lukem 
    331  1.266  christos .m.go:
    332  1.266  christos 	${_MKTARGET_COMPILE}
    333  1.267       mrg 	${COMPILE.m} ${DEBUGFLAGS} -g ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
    334  1.333  christos .if defined(LIBSTRIPOBJCOBJS)
    335  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    336  1.266  christos .endif
    337  1.266  christos 
    338  1.304     njoly .m.pico:
    339  1.238     lukem 	${_MKTARGET_COMPILE}
    340  1.267       mrg 	${COMPILE.m} ${CSHLIBFLAGS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
    341  1.333  christos .if defined(LIBSTRIPOBJCOBJS)
    342  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    343  1.153  christos .endif
    344    1.1       cgd 
    345  1.251     lukem .s.o:
    346  1.238     lukem 	${_MKTARGET_COMPILE}
    347  1.384  christos 	${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
    348  1.384  christos 	${CTFCONVERT_RUN}
    349  1.333  christos .if defined(LIBSTRIPAOBJS)
    350  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    351  1.333  christos .endif
    352    1.1       cgd 
    353  1.251     lukem .S.o:
    354  1.251     lukem 	${_MKTARGET_COMPILE}
    355  1.384  christos 	${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
    356  1.384  christos 	${CTFCONVERT_RUN}
    357  1.333  christos .if defined(LIBSTRIPAOBJS)
    358  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    359  1.333  christos .endif
    360  1.251     lukem 
    361  1.251     lukem .s.po:
    362  1.251     lukem 	${_MKTARGET_COMPILE}
    363  1.384  christos 	${COMPILE.s} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
    364  1.384  christos 	${CTFCONVERT_RUN}
    365  1.333  christos .if defined(LIBSTRIPAOBJS)
    366  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    367  1.333  christos .endif
    368  1.251     lukem 
    369  1.251     lukem .S.po:
    370  1.238     lukem 	${_MKTARGET_COMPILE}
    371  1.384  christos 	${COMPILE.S} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
    372  1.384  christos 	${CTFCONVERT_RUN}
    373  1.333  christos .if defined(LIBSTRIPAOBJS)
    374  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    375  1.333  christos .endif
    376    1.1       cgd 
    377  1.266  christos .s.go:
    378  1.266  christos 	${_MKTARGET_COMPILE}
    379  1.266  christos 	${COMPILE.s} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
    380  1.266  christos 
    381  1.266  christos .S.go:
    382  1.266  christos 	${_MKTARGET_COMPILE}
    383  1.266  christos 	${COMPILE.S} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
    384  1.266  christos 
    385  1.304     njoly .s.pico:
    386  1.251     lukem 	${_MKTARGET_COMPILE}
    387  1.338     joerg 	${COMPILE.s} ${PICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
    388  1.333  christos .if defined(LIBSTRIPAOBJS)
    389  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    390  1.333  christos .endif
    391  1.251     lukem 
    392  1.304     njoly .S.pico:
    393  1.238     lukem 	${_MKTARGET_COMPILE}
    394  1.338     joerg 	${COMPILE.S} ${PICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
    395  1.333  christos .if defined(LIBSTRIPAOBJS)
    396  1.320  christos 	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
    397  1.333  christos .endif
    398   1.27        pk 
    399  1.327  christos # Declare a few variables to make our life easier later.
    400  1.327  christos _LIB:=${_LIB_PREFIX}${LIB}
    401  1.327  christos _LIB.a:=${_LIB}.a
    402  1.327  christos _LIB_p.a:=${_LIB}_p.a
    403  1.327  christos _LIB_g.a:=${_LIB}_g.a
    404  1.327  christos _LIB_pic.a:=${_LIB}_pic.a
    405  1.327  christos _LIB.ln:=llib-l${LIB}.ln
    406  1.327  christos 
    407  1.327  christos .if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION)
    408  1.327  christos _LIB.so:=${_LIB}.so
    409  1.327  christos _LIB.so.major:=${_LIB}.so.${SHLIB_MAJOR}
    410  1.327  christos _LIB.so.full:=${_LIB}.so.${SHLIB_FULLVERSION}
    411  1.358       mrg _LIB.so.link:=${_LIB}.so.${SHLIB_FULLVERSION}.link
    412  1.364  christos .if ${MKDEBUG:Uno} != "no" && !defined(NODEBUG)
    413  1.327  christos _LIB.so.debug:=${_LIB.so.full}.debug
    414  1.327  christos .endif
    415  1.327  christos .endif
    416  1.327  christos 
    417  1.327  christos _DEST.LIB:=${DESTDIR}${LIBDIR}
    418  1.327  christos _DEST.OBJ:=${DESTDIR}${_LIBSODIR}
    419  1.327  christos _DEST.LINT:=${DESTDIR}${LINTLIBDIR}
    420  1.327  christos _DEST.DEBUG:=${DESTDIR}${DEBUGDIR}${LIBDIR}
    421  1.334  christos _DEST.ODEBUG:=${DESTDIR}${DEBUGDIR}${_LIBSODIR}
    422  1.327  christos 
    423  1.252     lukem .if defined(LIB)							# {
    424  1.234     lukem .if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
    425  1.234     lukem 	|| ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
    426  1.327  christos _LIBS=${_LIB.a}
    427  1.130        tv .else
    428  1.130        tv _LIBS=
    429  1.130        tv .endif
    430   1.58       cgd 
    431  1.167      matt OBJS+=${SRCS:N*.h:N*.sh:R:S/$/.o/g}
    432  1.158  christos 
    433  1.255   thorpej STOBJS+=${OBJS}
    434  1.255   thorpej 
    435  1.280     lukem LOBJS+=${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
    436  1.280     lukem 
    437  1.281     lukem .if ${LIBISPRIVATE} != "no"
    438  1.252     lukem # No installation is required
    439  1.252     lukem libinstall::
    440  1.306     lukem .endif
    441  1.252     lukem 
    442  1.268     lukem .if ${MKDEBUGLIB} != "no"
    443  1.327  christos _LIBS+=${_LIB_g.a}
    444  1.266  christos GOBJS+=${OBJS:.o=.go}
    445  1.266  christos DEBUGFLAGS?=-DDEBUG
    446  1.266  christos .endif
    447  1.266  christos 
    448  1.149     lukem .if ${MKPROFILE} != "no"
    449  1.327  christos _LIBS+=${_LIB_p.a}
    450  1.167      matt POBJS+=${OBJS:.o=.po}
    451  1.262  christos PROFFLAGS?=-DGPROF -DPROF
    452    1.1       cgd .endif
    453    1.1       cgd 
    454  1.252     lukem .if ${MKPIC} != "no"							# {
    455  1.160    simonb .if ${MKPICLIB} == "no"
    456  1.205      yamt .if ${MKSHLIBOBJS} != "no"
    457  1.205      yamt # make _pic.a, which isn't really pic,
    458  1.205      yamt # since it's needed for making shared lib.
    459  1.205      yamt # but don't install it.
    460  1.327  christos SOLIB=${_LIB_pic.a}
    461  1.304     njoly SOBJS+=${OBJS:.o=.pico}
    462  1.205      yamt .else
    463  1.327  christos SOLIB=${_LIB.a}
    464  1.205      yamt .endif
    465  1.160    simonb .else
    466  1.327  christos SOLIB=${_LIB_pic.a}
    467  1.160    simonb _LIBS+=${SOLIB}
    468  1.304     njoly SOBJS+=${OBJS:.o=.pico}
    469  1.160    simonb .endif
    470  1.171  christos .if defined(SHLIB_FULLVERSION)
    471  1.327  christos _LIBS+=${_LIB.so.full}
    472   1.27        pk .endif
    473  1.252     lukem .endif									# }
    474   1.27        pk 
    475  1.279     lukem .if ${MKLINT} != "no" && !empty(LOBJS)
    476  1.327  christos _LIBS+=${_LIB.ln}
    477  1.215  christos .endif
    478   1.27        pk 
    479  1.234     lukem ALLOBJS=
    480  1.234     lukem .if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
    481  1.234     lukem 	|| ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
    482  1.255   thorpej ALLOBJS+=${STOBJS}
    483  1.179  dmcmahil .endif
    484  1.234     lukem ALLOBJS+=${POBJS} ${SOBJS}
    485  1.279     lukem .if ${MKLINT} != "no" && !empty(LOBJS)
    486  1.179  dmcmahil ALLOBJS+=${LOBJS}
    487  1.216  christos .endif
    488  1.252     lukem .else	# !defined(LIB)							# } {
    489  1.216  christos LOBJS=
    490  1.216  christos SOBJS=
    491  1.252     lukem .endif	# !defined(LIB)							# }
    492  1.186        tv 
    493  1.254     lukem _YLSRCS=	${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
    494  1.253  christos 
    495  1.253  christos .NOPATH: ${ALLOBJS} ${_LIBS} ${_YLSRCS}
    496  1.158  christos 
    497  1.327  christos realall: ${SRCS} ${ALLOBJS:O} ${_LIBS} ${_LIB.so.debug}
    498    1.1       cgd 
    499  1.296     perry .if ${MKARZERO} == "yes"
    500  1.296     perry _ARFL=crsD
    501  1.297     perry _ARRANFL=sD
    502  1.296     perry _INSTRANLIB=
    503  1.296     perry .else
    504  1.296     perry _ARFL=crs
    505  1.297     perry _ARRANFL=s
    506  1.296     perry _INSTRANLIB=${empty(PRESERVE):?-a "${RANLIB} -t":}
    507  1.296     perry .endif
    508  1.296     perry 
    509  1.293     pooka # If you change this, please consider reflecting the change in
    510  1.293     pooka # the override in sys/rump/Makefile.rump.
    511  1.243       rtr .if !target(__archivebuild)
    512   1.90  christos __archivebuild: .USE
    513  1.238     lukem 	${_MKTARGET_BUILD}
    514  1.373  christos 	@rm -f ${.TARGET}
    515  1.389  christos 	${AR} ${_ARFL} ${.TARGET} $$(NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT})
    516  1.243       rtr .endif
    517   1.89  christos 
    518  1.243       rtr .if !target(__archiveinstall)
    519   1.89  christos __archiveinstall: .USE
    520  1.238     lukem 	${_MKTARGET_INSTALL}
    521  1.198     lukem 	${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
    522  1.296     perry 	    ${_INSTRANLIB} ${.ALLSRC} ${.TARGET}
    523  1.243       rtr .endif
    524   1.89  christos 
    525  1.197   mycroft __archivesymlinkpic: .USE
    526  1.238     lukem 	${_MKTARGET_INSTALL}
    527  1.264     jwise 	${INSTALL_SYMLINK} ${.ALLSRC} ${.TARGET}
    528  1.197   mycroft 
    529  1.373  christos .if !target(__buildstdlib)
    530  1.373  christos __buildstdlib: .USE
    531  1.373  christos 	@echo building standard ${.TARGET:T:S/.o//:S/lib//} library
    532  1.373  christos 	@rm -f ${.TARGET}
    533  1.389  christos 	@${LINK.c:S/-nostdinc//} -nostdlib ${LDFLAGS} -Wno-unused-command-line-argument -r -o ${.TARGET} $$(NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT})
    534  1.373  christos .endif
    535  1.373  christos 
    536  1.373  christos .if !target(__buildproflib)
    537  1.373  christos __buildproflib: .USE
    538  1.373  christos 	@echo building profiled ${.TARGET:T:S/.o//:S/lib//} library
    539  1.373  christos 	${_MKTARGET_BUILD}
    540  1.373  christos 	@rm -f ${.TARGET}
    541  1.389  christos 	@${LINK.c:S/-nostdinc//} -nostdlib ${LDFLAGS} -r -o ${.TARGET} $$(NM=${NM} ${LORDER} ${.ALLSRC:M*po} | ${TSORT})
    542  1.373  christos .endif
    543  1.373  christos 
    544  1.253  christos DPSRCS+=	${_YLSRCS}
    545  1.253  christos CLEANFILES+=	${_YLSRCS}
    546  1.230     lukem 
    547  1.362  uebayasi ${STOBJS} ${POBJS} ${GOBJS} ${SOBJS} ${LOBJS}: ${DPSRCS}
    548  1.103   mycroft 
    549  1.362  uebayasi ${_LIB.a}:: ${STOBJS} __archivebuild
    550    1.1       cgd 
    551  1.362  uebayasi ${_LIB_p.a}:: ${POBJS} __archivebuild
    552    1.1       cgd 
    553  1.362  uebayasi ${_LIB_pic.a}:: ${SOBJS} __archivebuild
    554   1.27        pk 
    555  1.362  uebayasi ${_LIB_g.a}:: ${GOBJS} __archivebuild
    556  1.266  christos 
    557  1.235     lukem 
    558  1.235     lukem _LIBLDOPTS=
    559  1.235     lukem .if ${SHLIBDIR} != "/usr/lib"
    560  1.324     joerg _LIBLDOPTS+=	-Wl,-rpath,${SHLIBDIR} \
    561  1.324     joerg 		-L=${SHLIBDIR}
    562  1.324     joerg .elif ${SHLIBINSTALLDIR} != "/usr/lib"
    563  1.324     joerg _LIBLDOPTS+=	-Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR} \
    564  1.324     joerg 		-L=${SHLIBINSTALLDIR}
    565  1.235     lukem .endif
    566  1.394     lukem .if ${MKSTRIPSYM} != "no"
    567  1.369     ozaki _LIBLDOPTS+=	-Wl,-x
    568  1.369     ozaki .else
    569  1.369     ozaki _LIBLDOPTS+=	-Wl,-X
    570  1.369     ozaki .endif
    571  1.235     lukem 
    572  1.277  christos # gcc -shared now adds -lc automatically. For libraries other than libc and
    573  1.277  christos # libgcc* we add as a dependency the installed shared libc. For libc and
    574  1.277  christos # libgcc* we avoid adding libc as a dependency by using -nostdlib. Note that
    575  1.277  christos # -Xl,-nostdlib is not enough because we want to tell the compiler-driver not
    576  1.277  christos # to add standard libraries, not the linker.
    577  1.276  christos .if !defined(LIB)
    578  1.312      matt .if !empty(LIBC_SO)
    579  1.274  christos DPLIBC ?= ${DESTDIR}${LIBC_SO}
    580  1.312      matt .endif
    581  1.276  christos .else
    582  1.278    simonb .if ${LIB} != "c" && ${LIB:Mgcc*} == ""
    583  1.312      matt .if !empty(LIBC_SO)
    584  1.276  christos DPLIBC ?= ${DESTDIR}${LIBC_SO}
    585  1.312      matt .endif
    586  1.277  christos .else
    587  1.278    simonb LDLIBC ?= -nodefaultlibs
    588  1.341     joerg .if ${HAVE_LIBGCC} == "yes" && ${LIB} == "c"
    589  1.318       mrg LDADD+= -lgcc
    590  1.278    simonb .endif
    591  1.276  christos .endif
    592  1.274  christos .endif
    593  1.274  christos 
    594  1.291       mrg .if ${LIBISCXX} != "no"
    595  1.291       mrg LIBCC:=	${CXX}
    596  1.339     joerg . if ${MKLIBCXX} == "yes"
    597  1.339     joerg LIBDPLIBS+=     c++	${.CURDIR}/../../../../../external/bsd/libc++/lib
    598  1.339     joerg . else
    599  1.346       mrg LIBDPLIBS+=     stdc++	${.CURDIR}/../../../../../external/gpl3/${EXTERNAL_GCC_SUBDIR}/lib/libstdc++-v3
    600  1.339     joerg . endif
    601  1.291       mrg .else
    602  1.291       mrg LIBCC:=	${CC}
    603  1.291       mrg .endif
    604  1.291       mrg 
    605  1.327  christos _LDADD.${_LIB}=	${LDADD} ${LDADD.${_LIB}}
    606  1.327  christos _LDFLAGS.${_LIB}=	${LDFLAGS} ${LDFLAGS.${_LIB}}
    607  1.300  uebayasi 
    608  1.358       mrg _MAINLIBDEPS=	${SOLIB} ${DPADD} ${DPLIBC} \
    609  1.358       mrg 		${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
    610  1.358       mrg 
    611  1.358       mrg .if defined(_LIB.so.debug)
    612  1.358       mrg ${_LIB.so.debug}: ${_LIB.so.link}
    613  1.358       mrg 	${_MKTARGET_CREATE}
    614  1.358       mrg 	(  ${OBJCOPY} --only-keep-debug \
    615  1.358       mrg 		${_LIB.so.link} ${_LIB.so.debug} \
    616  1.358       mrg 	) || (rm -f ${.TARGET}; false)
    617  1.358       mrg ${_LIB.so.full}: ${_LIB.so.link} ${_LIB.so.debug}
    618  1.358       mrg 	${_MKTARGET_CREATE}
    619  1.358       mrg 	(  ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \
    620  1.358       mrg 		--add-gnu-debuglink=${_LIB.so.debug} \
    621  1.370       chs 		${_LIB.so.link} ${_LIB.so.full}.tmp && \
    622  1.379  christos 		${MV} ${_LIB.so.full}.tmp ${_LIB.so.full} \
    623  1.358       mrg 	) || (rm -f ${.TARGET}; false)
    624  1.358       mrg ${_LIB.so.link}: ${_MAINLIBDEPS}
    625  1.358       mrg .else # aka no MKDEBUG
    626  1.358       mrg ${_LIB.so.full}: ${_MAINLIBDEPS}
    627  1.358       mrg .endif
    628  1.238     lukem 	${_MKTARGET_BUILD}
    629  1.327  christos 	rm -f ${.TARGET}
    630  1.369     ozaki 	${LIBCC} ${LDLIBC} -shared ${SHLIB_SHFLAGS} \
    631  1.370       chs 	    ${_LDFLAGS.${_LIB}} -o ${.TARGET}.tmp ${_LIBLDOPTS} \
    632  1.327  christos 	    -Wl,--whole-archive ${SOLIB} \
    633  1.328      matt 	    -Wl,--no-whole-archive ${_LDADD.${_LIB}}
    634  1.370       chs .if ${MKSTRIPIDENT} != "no"
    635  1.370       chs 	${OBJCOPY} -R .ident ${.TARGET}.tmp
    636  1.370       chs .endif
    637  1.379  christos 	${MV} ${.TARGET}.tmp ${.TARGET}
    638  1.196     lukem #  We don't use INSTALL_SYMLINK here because this is just
    639  1.196     lukem #  happening inside the build directory/objdir. XXX Why does
    640  1.196     lukem #  this spend so much effort on libraries that aren't live??? XXX
    641  1.358       mrg #  XXX Also creates dead symlinks until the .full rule runs
    642  1.358       mrg #  above and creates the main link
    643  1.284     lukem .if defined(SHLIB_FULLVERSION) && defined(SHLIB_MAJOR) && \
    644  1.284     lukem     "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
    645  1.327  christos 	${HOST_LN} -sf ${_LIB.so.full} ${_LIB.so.major}.tmp
    646  1.379  christos 	${MV} ${_LIB.so.major}.tmp ${_LIB.so.major}
    647  1.283     lukem .endif
    648  1.327  christos 	${HOST_LN} -sf ${_LIB.so.full} ${_LIB.so}.tmp
    649  1.379  christos 	${MV} ${_LIB.so}.tmp ${_LIB.so}
    650   1.35        pk 
    651  1.395  riastrad # If there's a file listing expected symbols, fail if the diff from it
    652  1.395  riastrad # to the actual symbols is nonempty, and show the diff in that case.
    653  1.395  riastrad .if exists(${.CURDIR}/${LIB}.${MACHINE_ARCH}.expsym)
    654  1.395  riastrad LIB_EXPSYM?=	${LIB}.${MACHINE_ARCH}.expsym
    655  1.395  riastrad .elif exists(${.CURDIR}/${LIB}.expsym)
    656  1.395  riastrad LIB_EXPSYM?=	${LIB}.expsym
    657  1.395  riastrad .endif
    658  1.395  riastrad 
    659  1.397  riastrad .if !empty(LIB_EXPSYM) && ${MKPIC} != "no"
    660  1.395  riastrad realall: ${_LIB.so.full}.diffsym
    661  1.395  riastrad ${_LIB.so.full}.diffsym: ${LIB_EXPSYM} ${_LIB.so.full}.actsym
    662  1.395  riastrad 	${_MKTARGET_CREATE}
    663  1.395  riastrad 	if diff -u ${.ALLSRC} >${.TARGET}.tmp; then \
    664  1.395  riastrad 		${MV} ${.TARGET}.tmp ${.TARGET}; \
    665  1.395  riastrad 	else \
    666  1.395  riastrad 		ret=$$?; \
    667  1.395  riastrad 		cat ${.TARGET}.tmp; \
    668  1.395  riastrad 		echo ${_LIB.so.full}: error: \
    669  1.395  riastrad 			actual symbols differ from expected symbols >&2; \
    670  1.395  riastrad 		exit $$ret; \
    671  1.395  riastrad 	fi
    672  1.395  riastrad ${_LIB.so.full}.actsym: ${_LIB.so.full}
    673  1.395  riastrad 	${_MKTARGET_CREATE}
    674  1.395  riastrad 	${NM} --dynamic --extern-only --defined-only --with-symbol-versions \
    675  1.396  riastrad 		${.ALLSRC} \
    676  1.395  riastrad 	| cut -d' ' -f3 | LANG=C sort -u >${.TARGET}.tmp
    677  1.395  riastrad 	${MV} ${.TARGET}.tmp ${.TARGET}
    678  1.395  riastrad CLEANFILES+=	${_LIB.so.full}.actsym
    679  1.395  riastrad CLEANFILES+=	${_LIB.so.full}.actsym.tmp
    680  1.395  riastrad CLEANFILES+=	${_LIB.so.full}.diffsym
    681  1.395  riastrad CLEANFILES+=	${_LIB.so.full}.diffsym.tmp
    682  1.395  riastrad update-symbols: .PHONY
    683  1.395  riastrad update-symbols: ${_LIB.so.full}.actsym
    684  1.396  riastrad 	cp ${.ALLSRC} ${.CURDIR}/${LIB_EXPSYM}
    685  1.395  riastrad .endif
    686  1.395  riastrad 
    687  1.252     lukem .if !empty(LOBJS)							# {
    688  1.103   mycroft LLIBS?=		-lc
    689  1.327  christos ${_LIB.ln}: ${LOBJS}
    690  1.238     lukem 	${_MKTARGET_COMPILE}
    691  1.327  christos 	rm -f ${.TARGET}
    692  1.206   thorpej .if defined(DESTDIR)
    693  1.228     lukem 	${LINT} -C${LIB} ${.ALLSRC} -L${DESTDIR}/usr/libdata ${LLIBS}
    694  1.206   thorpej .else
    695  1.228     lukem 	${LINT} -C${LIB} ${.ALLSRC} ${LLIBS}
    696  1.206   thorpej .endif
    697  1.252     lukem .endif									# }
    698    1.1       cgd 
    699  1.280     lukem lint: ${LOBJS}
    700  1.280     lukem .if defined(LOBJS) && !empty(LOBJS)
    701  1.280     lukem 	${LINT} ${LINTFLAGS} ${LOBJS}
    702  1.280     lukem .endif
    703  1.280     lukem 
    704  1.327  christos 
    705  1.317       apb # If the number of entries in CLEANFILES is too large, then the
    706  1.317       apb # commands in bsd.clean.mk encounter errors like "exec(/bin/sh)
    707  1.317       apb # failed (Argument list too long)".  Avoid that by splitting the
    708  1.317       apb # files to clean into several lists using different variable names.
    709  1.317       apb # __cleanuse is an internal target in bsd.clean.mk; the way we
    710  1.317       apb # use it here mimics the way it's used by the clean target in
    711  1.317       apb # bsd.clean.mk.
    712  1.317       apb #
    713  1.317       apb clean: libclean1 libclean2 libclean3 libclean4 libclean5
    714  1.317       apb libclean1: .PHONY .MADE __cleanuse LIBCLEANFILES1
    715  1.317       apb libclean2: .PHONY .MADE __cleanuse LIBCLEANFILES2
    716  1.317       apb libclean3: .PHONY .MADE __cleanuse LIBCLEANFILES3
    717  1.317       apb libclean4: .PHONY .MADE __cleanuse LIBCLEANFILES4
    718  1.317       apb libclean5: .PHONY .MADE __cleanuse LIBCLEANFILES5
    719  1.316       apb CLEANFILES+= a.out [Ee]rrs mklog core *.core
    720  1.327  christos LIBCLEANFILES1+= ${_LIB.a}   ${STOBJS} ${STOBJS:=.tmp}
    721  1.327  christos LIBCLEANFILES2+= ${_LIB_p.a} ${POBJS}  ${POBJS:=.tmp}
    722  1.327  christos LIBCLEANFILES3+= ${_LIB_g.a} ${GOBJS}  ${GOBJS:=.tmp}
    723  1.327  christos LIBCLEANFILES4+= ${_LIB_pic.a}
    724  1.327  christos .if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION)
    725  1.327  christos LIBCLEANFILES4+= ${_LIB.so}.* ${_LIB.so} ${_LIB.so.debug}
    726  1.327  christos .endif
    727  1.317       apb LIBCLEANFILES4+= ${SOBJS} ${SOBJS:=.tmp}
    728  1.327  christos LIBCLEANFILES5+= ${_LIB.ln} ${LOBJS}
    729  1.252     lukem 
    730  1.252     lukem .if !target(libinstall)							# {
    731  1.148     lukem # Make sure it gets defined, in case MKPIC==no && MKLINKLIB==no
    732  1.139        tv libinstall::
    733  1.139        tv 
    734  1.399  christos .if ${MKLINKLIB} != "no" && ${MKSTATICLIB} != "no"
    735  1.327  christos libinstall:: ${_DEST.LIB}/${_LIB.a}
    736  1.327  christos .PRECIOUS: ${_DEST.LIB}/${_LIB.a}
    737  1.197   mycroft 
    738  1.269       dbj .if ${MKUPDATE} == "no"
    739  1.327  christos .if !defined(BUILD) && !make(all) && !make(${_LIB.a})
    740  1.327  christos ${_DEST.LIB}/${_LIB.a}! .MADE
    741   1.89  christos .endif
    742  1.327  christos ${_DEST.LIB}/${_LIB.a}! ${_LIB.a} __archiveinstall
    743  1.197   mycroft .else
    744  1.327  christos .if !defined(BUILD) && !make(all) && !make(${_LIB.a})
    745  1.327  christos ${_DEST.LIB}/${_LIB.a}: .MADE
    746   1.89  christos .endif
    747  1.327  christos ${_DEST.LIB}/${_LIB.a}: ${_LIB.a} __archiveinstall
    748  1.130        tv .endif
    749  1.197   mycroft .endif
    750   1.89  christos 
    751  1.149     lukem .if ${MKPROFILE} != "no"
    752  1.327  christos libinstall:: ${_DEST.LIB}/${_LIB_p.a}
    753  1.327  christos .PRECIOUS: ${_DEST.LIB}/${_LIB_p.a}
    754  1.197   mycroft 
    755  1.269       dbj .if ${MKUPDATE} == "no"
    756  1.327  christos .if !defined(BUILD) && !make(all) && !make(${_LIB_p.a})
    757  1.327  christos ${_DEST.LIB}/${_LIB_p.a}! .MADE
    758   1.32        pk .endif
    759  1.327  christos ${_DEST.LIB}/${_LIB_p.a}! ${_LIB_p.a} __archiveinstall
    760  1.197   mycroft .else
    761  1.327  christos .if !defined(BUILD) && !make(all) && !make(${_LIB_p.a})
    762  1.327  christos ${_DEST.LIB}/${_LIB_p.a}: .MADE
    763   1.89  christos .endif
    764  1.327  christos ${_DEST.LIB}/${_LIB_p.a}: ${_LIB_p.a} __archiveinstall
    765   1.89  christos .endif
    766  1.197   mycroft .endif
    767   1.89  christos 
    768  1.268     lukem .if ${MKDEBUGLIB} != "no"
    769  1.327  christos libinstall:: ${_DEST.LIB}/${_LIB_g.a}
    770  1.327  christos .PRECIOUS: ${_DEST.LIB}/${_LIB_g.a}
    771  1.266  christos 
    772  1.269       dbj .if ${MKUPDATE} == "no"
    773  1.329       spz .if !defined(BUILD) && !make(all) && !make(${_LIB_g.a})
    774  1.327  christos ${_DEST.LIB}/${_LIB_g.a}! .MADE
    775  1.266  christos .endif
    776  1.327  christos ${_DEST.LIB}/${_LIB_g.a}! ${_LIB_g.a} __archiveinstall
    777  1.266  christos .else
    778  1.327  christos .if !defined(BUILD) && !make(all) && !make(${LIB_g.a})
    779  1.327  christos ${_DEST.LIB}/${_LIB_g.a}: .MADE
    780  1.266  christos .endif
    781  1.327  christos ${_DEST.LIB}/${_LIB_g.a}: ${_LIB_g.a} __archiveinstall
    782  1.266  christos .endif
    783  1.266  christos .endif
    784  1.266  christos 
    785  1.149     lukem .if ${MKPIC} != "no" && ${MKPICINSTALL} != "no"
    786  1.327  christos libinstall:: ${_DEST.LIB}/${_LIB_pic.a}
    787  1.327  christos .PRECIOUS: ${_DEST.LIB}/${_LIB_pic.a}
    788  1.197   mycroft 
    789  1.269       dbj .if ${MKUPDATE} == "no"
    790  1.327  christos .if !defined(BUILD) && !make(all) && !make(${_LIB_pic.a})
    791  1.327  christos ${_DEST.LIB}/${_LIB_pic.a}! .MADE
    792   1.89  christos .endif
    793  1.197   mycroft .if ${MKPICLIB} == "no"
    794  1.331  nakayama ${_DEST.LIB}/${_LIB_pic.a}! ${_LIB.a} __archivesymlinkpic
    795  1.197   mycroft .else
    796  1.327  christos ${_DEST.LIB}/${_LIB_pic.a}! ${_LIB_pic.a} __archiveinstall
    797  1.197   mycroft .endif
    798  1.197   mycroft .else
    799  1.327  christos .if !defined(BUILD) && !make(all) && !make(${_LIB_pic.a})
    800  1.327  christos ${_DEST.LIB}/${_LIB_pic.a}: .MADE
    801   1.33        pk .endif
    802  1.160    simonb .if ${MKPICLIB} == "no"
    803  1.331  nakayama ${_DEST.LIB}/${_LIB_pic.a}: ${_LIB.a} __archivesymlinkpic
    804  1.160    simonb .else
    805  1.327  christos ${_DEST.LIB}/${_LIB_pic.a}: ${_LIB_pic.a} __archiveinstall
    806  1.160    simonb .endif
    807   1.89  christos .endif
    808  1.197   mycroft .endif
    809   1.89  christos 
    810  1.171  christos .if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION)
    811  1.282     lukem 
    812  1.327  christos libinstall:: ${_DEST.OBJ}/${_LIB.so.full}
    813  1.327  christos .PRECIOUS: ${_DEST.OBJ}/${_LIB.so.full}
    814  1.197   mycroft 
    815  1.269       dbj .if ${MKUPDATE} == "no"
    816  1.327  christos .if !defined(BUILD) && !make(all) && !make(${_LIB.so.full})
    817  1.327  christos ${_DEST.OBJ}/${_LIB.so.full}! .MADE
    818   1.89  christos .endif
    819  1.327  christos ${_DEST.OBJ}/${_LIB.so.full}! ${_LIB.so.full}
    820  1.197   mycroft .else
    821  1.327  christos .if !defined(BUILD) && !make(all) && !make(${_LIB.so.full})
    822  1.327  christos ${_DEST.OBJ}/${_LIB.so.full}: .MADE
    823   1.89  christos .endif
    824  1.327  christos ${_DEST.OBJ}/${_LIB.so.full}: ${_LIB.so.full}
    825  1.197   mycroft .endif
    826  1.238     lukem 	${_MKTARGET_INSTALL}
    827  1.188        tv 	${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
    828  1.327  christos 	    ${.ALLSRC} ${.TARGET}
    829  1.195     lukem .if ${_LIBSODIR} != ${LIBDIR}
    830  1.327  christos 	${INSTALL_SYMLINK} -l r ${_DEST.OBJ}/${_LIB.so.full} \
    831  1.392  riastrad 	    ${_DEST.LIB}/${_LIB.so.full}
    832  1.195     lukem .endif
    833  1.284     lukem .if defined(SHLIB_FULLVERSION) && defined(SHLIB_MAJOR) && \
    834  1.284     lukem     "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
    835  1.327  christos 	${INSTALL_SYMLINK} ${_LIB.so.full} ${_DEST.OBJ}/${_LIB.so.major}
    836  1.195     lukem .if ${_LIBSODIR} != ${LIBDIR}
    837  1.327  christos 	${INSTALL_SYMLINK} -l r ${_DEST.OBJ}/${_LIB.so.full} \
    838  1.327  christos 	    ${_DEST.LIB}/${_LIB.so.major}
    839  1.195     lukem .endif
    840  1.284     lukem .endif
    841  1.399  christos .if ${MKLINKLIB} != "no"
    842  1.327  christos 	${INSTALL_SYMLINK}  ${_LIB.so.full} ${_DEST.OBJ}/${_LIB.so}
    843  1.195     lukem .if ${_LIBSODIR} != ${LIBDIR}
    844  1.327  christos 	${INSTALL_SYMLINK} -l r ${_DEST.OBJ}/${_LIB.so.full} \
    845  1.327  christos 	    ${_DEST.LIB}/${_LIB.so}
    846  1.195     lukem .endif
    847   1.83       cgd .endif
    848   1.12       cgd .endif
    849   1.89  christos 
    850  1.327  christos .if defined(_LIB.so.debug)
    851  1.327  christos libinstall:: ${_DEST.DEBUG}/${_LIB.so.debug}
    852  1.327  christos .PRECIOUS: ${_DEST.DEBUG}/${_LIB.so.debug}
    853  1.307     lukem 
    854  1.327  christos ${_DEST.DEBUG}/${_LIB.so.debug}: ${_LIB.so.debug}
    855  1.307     lukem 	${_MKTARGET_INSTALL}
    856  1.307     lukem 	${INSTALL_FILE} -o ${DEBUGOWN} -g ${DEBUGGRP} -m ${DEBUGMODE} \
    857  1.327  christos 	    ${.ALLSRC} ${.TARGET}
    858  1.334  christos .if ${_LIBSODIR} != ${LIBDIR}
    859  1.334  christos 	${INSTALL_SYMLINK} -l r ${_DEST.DEBUG}/${_LIB.so.debug} \
    860  1.392  riastrad 	    ${_DEST.ODEBUG}/${_LIB.so.debug}
    861  1.334  christos .endif
    862  1.307     lukem .endif
    863  1.307     lukem 
    864  1.388  christos .if ${_LINTINSTALL} != "no" && !empty(LOBJS)
    865  1.327  christos libinstall:: ${_DEST.LINT}/${_LIB.ln}
    866  1.327  christos .PRECIOUS: ${_DEST.LINT}/${_LIB.ln}
    867  1.197   mycroft 
    868  1.269       dbj .if ${MKUPDATE} == "no"
    869  1.327  christos .if !defined(BUILD) && !make(all) && !make(${_LIB.ln})
    870  1.327  christos ${_DEST.LINT}/${_LIB.ln}! .MADE
    871   1.89  christos .endif
    872  1.327  christos ${_DEST.LINT}/${_LIB.ln}! ${_LIB.ln}
    873  1.197   mycroft .else
    874  1.327  christos .if !defined(BUILD) && !make(all) && !make(${_LIB.ln})
    875  1.327  christos ${_DEST.LINT}/${_LIB.ln}: .MADE
    876   1.89  christos .endif
    877  1.327  christos ${_DEST.LINT}/${_LIB.ln}: ${_LIB.ln}
    878  1.197   mycroft .endif
    879  1.238     lukem 	${_MKTARGET_INSTALL}
    880  1.188        tv 	${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
    881  1.327  christos 		${.ALLSRC} ${_DEST.LINT}
    882   1.58       cgd .endif
    883  1.252     lukem .endif	# !target(libinstall)						# }
    884    1.1       cgd 
    885  1.188        tv ##### Pull in related .mk logic
    886  1.298       apb LINKSOWN?= ${LIBOWN}
    887  1.298       apb LINKSGRP?= ${LIBGRP}
    888  1.298       apb LINKSMODE?= ${LIBMODE}
    889    1.1       cgd .include <bsd.man.mk>
    890   1.57       jtc .include <bsd.nls.mk>
    891   1.91  christos .include <bsd.files.mk>
    892   1.89  christos .include <bsd.inc.mk>
    893  1.109       cjs .include <bsd.links.mk>
    894   1.24   mycroft .include <bsd.dep.mk>
    895  1.315     joerg .include <bsd.clang-analyze.mk>
    896  1.316       apb .include <bsd.clean.mk>
    897  1.117   mycroft 
    898  1.188        tv ${TARGETS}:	# ensure existence
    899