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