bsd.lib.mk revision 1.255       1  1.255   thorpej #	$NetBSD: bsd.lib.mk,v 1.255 2004/07/29 03:14:04 thorpej 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.227     lukem # Pull in <bsd.sys.mk> here so we can override its .c.o rule
      8  1.227     lukem .include <bsd.sys.mk>
      9   1.97   mycroft 
     10  1.188        tv ##### Basic targets
     11  1.246     lukem .PHONY:		checkver libinstall
     12  1.143       erh realinstall:	checkver libinstall
     13  1.183        tv clean:		cleanlib
     14  1.232       erh 
     15  1.232       erh ##### LIB specific flags.
     16  1.232       erh COPTS+=    ${COPTS.lib${LIB}}
     17  1.232       erh CPPFLAGS+=  ${CPPFLAGS.lib${LIB}}
     18  1.232       erh CXXFLAGS+=  ${CXXFLAGS.lib${LIB}}
     19  1.232       erh LDADD+=     ${LDADD.lib${LIB}}
     20  1.233       erh LDFLAGS+=   ${LDFLAGS.lib${LIB}}
     21  1.233       erh LDSTATIC+=  ${LDSTATIC.lib${LIB}}
     22    1.1       cgd 
     23  1.188        tv ##### Build and install rules
     24  1.240       dsl MKDEP_SUFFIXES?=	.o .po .so .ln
     25  1.192   thorpej CPPFLAGS+=	${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
     26  1.225       mrg CXXFLAGS+=	${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} ${DESTDIR}/usr/include/g++}
     27  1.190        tv 
     28  1.252     lukem .if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE})		# {
     29  1.154    simonb SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major
     30  1.154    simonb SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor
     31  1.171  christos SHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny
     32  1.143       erh 
     33  1.143       erh # Check for higher installed library versions.
     34  1.145       erh .if !defined(NOCHECKVER) && !defined(NOCHECKVER_${LIB}) && \
     35  1.201     lukem 	exists(${NETBSDSRCDIR}/lib/checkver)
     36  1.143       erh checkver:
     37  1.144       erh 	@(cd ${.CURDIR} && \
     38  1.239     lukem 	    ${HOST_SH} ${NETBSDSRCDIR}/lib/checkver -v ${SHLIB_VERSION_FILE} \
     39  1.195     lukem 		    -d ${DESTDIR}${_LIBSODIR} ${LIB})
     40  1.173  christos .endif
     41  1.252     lukem .endif									# }
     42  1.173  christos 
     43  1.173  christos .if !target(checkver)
     44  1.143       erh checkver:
     45  1.143       erh .endif
     46  1.173  christos 
     47  1.169   thorpej print-shlib-major:
     48  1.185        tv .if defined(SHLIB_MAJOR) && ${MKPIC} != "no"
     49  1.169   thorpej 	@echo ${SHLIB_MAJOR}
     50  1.173  christos .else
     51  1.173  christos 	@false
     52  1.173  christos .endif
     53  1.169   thorpej 
     54  1.169   thorpej print-shlib-minor:
     55  1.185        tv .if defined(SHLIB_MINOR) && ${MKPIC} != "no"
     56  1.169   thorpej 	@echo ${SHLIB_MINOR}
     57  1.173  christos .else
     58  1.173  christos 	@false
     59  1.173  christos .endif
     60  1.171  christos 
     61  1.171  christos print-shlib-teeny:
     62  1.185        tv .if defined(SHLIB_TEENY) && ${MKPIC} != "no"
     63  1.171  christos 	@echo ${SHLIB_TEENY}
     64  1.143       erh .else
     65  1.169   thorpej 	@false
     66  1.173  christos .endif
     67  1.169   thorpej 
     68  1.252     lukem .if defined(SHLIB_MAJOR) && !empty(SHLIB_MAJOR)				# {
     69  1.173  christos .if defined(SHLIB_MINOR) && !empty(SHLIB_MINOR)
     70  1.173  christos .if defined(SHLIB_TEENY) && !empty(SHLIB_TEENY)
     71  1.173  christos SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}.${SHLIB_TEENY}
     72  1.173  christos .else
     73  1.173  christos SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}
     74  1.173  christos .endif
     75  1.173  christos .else
     76  1.173  christos SHLIB_FULLVERSION=${SHLIB_MAJOR}
     77  1.173  christos .endif
     78  1.252     lukem .endif									# }
     79    1.1       cgd 
     80  1.101   mycroft # add additional suffixes not exported.
     81  1.101   mycroft # .po is used for profiling object files.
     82  1.101   mycroft # .so is used for PIC object files.
     83  1.223     lukem .SUFFIXES: .out .a .ln .so .po .o .s .S .c .cc .cpp .cxx .C .m .F .f .r .y .l .cl .p .h
     84  1.118     lukem .SUFFIXES: .sh .m4 .m
     85   1.82     mikel 
     86   1.86  jonathan 
     87   1.86  jonathan # Set PICFLAGS to cc flags for producing position-independent code,
     88   1.86  jonathan # if not already set.  Includes -DPIC, if required.
     89   1.86  jonathan 
     90  1.164    simonb # Data-driven table using make variables to control how shared libraries
     91   1.86  jonathan # are built for different platforms and object formats.
     92  1.125  jonathan # OBJECT_FMT:		currently either "ELF" or "a.out", from <bsd.own.mk>
     93  1.164    simonb # SHLIB_SOVERSION:	version number to be compiled into a shared library
     94  1.164    simonb #			via -soname. Usualy ${SHLIB_MAJOR} on ELF.
     95  1.173  christos #			NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR}
     96  1.173  christos #			[.${SHLIB_TEENY}]]
     97  1.164    simonb # SHLIB_SHFLAGS:	Flags to tell ${LD} to emit shared library.
     98  1.123  jonathan #			with ELF, also set shared-lib version for ld.so.
     99  1.123  jonathan # SHLIB_LDSTARTFILE:	support .o file, call C++ file-level constructors
    100  1.123  jonathan # SHLIB_LDENDFILE:	support .o file, call C++ file-level destructors
    101  1.179  dmcmahil # FPICFLAGS:		flags for ${FC} to compile .[fF] files to .so objects.
    102  1.164    simonb # CPPICFLAGS:		flags for ${CPP} to preprocess .[sS] files for ${AS}
    103  1.205      yamt # CPICFLAGS:		flags for ${CC} to compile .[cC] files to pic objects.
    104  1.205      yamt # CSHLIBFLAGS:		flags for ${CC} to compile .[cC] files to .so objects.
    105  1.205      yamt #			(usually includes ${CPICFLAGS})
    106  1.205      yamt # CAPICFLAGS:		flags for ${CC} to compiling .[Ss] files
    107  1.107  jonathan #		 	(usually just ${CPPPICFLAGS} ${CPICFLAGS})
    108  1.164    simonb # APICFLAGS:		flags for ${AS} to assemble .[sS] to .so objects.
    109   1.86  jonathan 
    110  1.252     lukem .if ${MACHINE_ARCH} == "alpha"						# {
    111  1.209   thorpej 
    112  1.179  dmcmahil FPICFLAGS ?= -fPIC
    113  1.165  dmcmahil CPICFLAGS ?= -fPIC -DPIC
    114  1.222     lukem CPPPICFLAGS?= -DPIC
    115  1.107  jonathan CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
    116  1.107  jonathan APICFLAGS ?=
    117  1.209   thorpej 
    118  1.175       mrg .elif (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") && \
    119  1.252     lukem        ${OBJECT_FMT} == "ELF"						# } {
    120  1.209   thorpej 
    121  1.222     lukem # If you use -fPIC you need to define BIGPIC to turn on 32-bit
    122  1.202       eeh # relocations in asm code
    123  1.179  dmcmahil FPICFLAGS ?= -fPIC
    124  1.165  dmcmahil CPICFLAGS ?= -fPIC -DPIC
    125  1.202       eeh CPPPICFLAGS?= -DPIC -DBIGPIC
    126  1.150  christos CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
    127  1.203       eeh APICFLAGS ?= -KPIC
    128  1.204  fredette 
    129  1.252     lukem .elif ${MACHINE_ARCH} == "ns32k"					# } {
    130  1.242    simonb 
    131  1.242    simonb # XXX no shared libraries yet on ns32k
    132  1.242    simonb FPICFLAGS?=
    133  1.242    simonb CPICFLAGS?=
    134  1.242    simonb CPPPICFLAGS?=
    135  1.242    simonb CAPICFLAGS?=
    136  1.242    simonb APICFLAGS?=
    137   1.86  jonathan 
    138  1.252     lukem .else									# } {
    139   1.86  jonathan 
    140  1.244     skrll # Platform-independent flags for NetBSD shared libraries
    141  1.171  christos SHLIB_SOVERSION=${SHLIB_FULLVERSION}
    142  1.125  jonathan SHLIB_SHFLAGS=
    143  1.179  dmcmahil FPICFLAGS ?= -fPIC
    144  1.165  dmcmahil CPICFLAGS?= -fPIC -DPIC
    145  1.222     lukem CPPPICFLAGS?= -DPIC
    146  1.107  jonathan CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
    147  1.107  jonathan APICFLAGS?= -k
    148   1.86  jonathan 
    149  1.252     lukem .endif									# }
    150  1.160    simonb 
    151  1.205      yamt .if ${MKPICLIB} != "no"
    152  1.205      yamt CSHLIBFLAGS+= ${CPICFLAGS}
    153  1.205      yamt .endif
    154  1.205      yamt 
    155  1.205      yamt .if defined(CSHLIBFLAGS) && !empty(CSHLIBFLAGS)
    156  1.205      yamt MKSHLIBOBJS= yes
    157  1.205      yamt .else
    158  1.205      yamt MKSHLIBOBJS= no
    159  1.205      yamt .endif
    160  1.205      yamt 
    161  1.123  jonathan # Platform-independent linker flags for ELF shared libraries
    162  1.148     lukem .if ${OBJECT_FMT} == "ELF"
    163  1.182       mrg SHLIB_SOVERSION=	${SHLIB_MAJOR}
    164  1.221  drochner SHLIB_SHFLAGS=		-Wl,-soname,lib${LIB}.so.${SHLIB_SOVERSION}
    165  1.219   thorpej SHLIB_LDSTARTFILE?=	${DESTDIR}/usr/lib/crti.o ${_GCC_CRTBEGINS}
    166  1.219   thorpej SHLIB_LDENDFILE?=	${_GCC_CRTENDS} ${DESTDIR}/usr/lib/crtn.o
    167  1.123  jonathan .endif
    168   1.86  jonathan 
    169   1.82     mikel CFLAGS+=	${COPTS}
    170  1.179  dmcmahil FFLAGS+=	${FOPTS}
    171    1.1       cgd 
    172    1.1       cgd .c.o:
    173  1.238     lukem 	${_MKTARGET_COMPILE}
    174  1.228     lukem 	${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}.tmp
    175  1.153  christos .if defined(COPTS) && !empty(COPTS:M*-g*)
    176  1.228     lukem 	mv ${.TARGET}.tmp ${.TARGET}
    177  1.153  christos .else
    178  1.228     lukem 	${LD} -x -r ${.TARGET}.tmp -o ${.TARGET}
    179  1.228     lukem 	rm -f ${.TARGET}.tmp
    180  1.153  christos .endif
    181    1.1       cgd 
    182    1.1       cgd .c.po:
    183  1.238     lukem 	${_MKTARGET_COMPILE}
    184  1.228     lukem 	${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET}.tmp
    185  1.153  christos .if defined(COPTS) && !empty(COPTS:M*-g*)
    186  1.228     lukem 	mv ${.TARGET}.tmp ${.TARGET}
    187  1.153  christos .else
    188  1.228     lukem 	${LD} -X -r ${.TARGET}.tmp -o ${.TARGET}
    189  1.228     lukem 	rm -f ${.TARGET}.tmp
    190  1.153  christos .endif
    191   1.17   mycroft 
    192   1.27        pk .c.so:
    193  1.238     lukem 	${_MKTARGET_COMPILE}
    194  1.228     lukem 	${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}.tmp
    195  1.153  christos .if defined(COPTS) && !empty(COPTS:M*-g*)
    196  1.228     lukem 	mv ${.TARGET}.tmp ${.TARGET}
    197  1.153  christos .else
    198  1.228     lukem 	${LD} -x -r ${.TARGET}.tmp -o ${.TARGET}
    199  1.228     lukem 	rm -f ${.TARGET}.tmp
    200  1.153  christos .endif
    201   1.27        pk 
    202  1.223     lukem .cc.o .cpp.o .cxx.o .C.o:
    203  1.238     lukem 	${_MKTARGET_COMPILE}
    204  1.228     lukem 	${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}.tmp
    205  1.153  christos .if defined(COPTS) && !empty(COPTS:M*-g*)
    206  1.228     lukem 	mv ${.TARGET}.tmp ${.TARGET}
    207  1.153  christos .else
    208  1.228     lukem 	${LD} -x -r ${.TARGET}.tmp -o ${.TARGET}
    209  1.228     lukem 	rm -f ${.TARGET}.tmp
    210  1.153  christos .endif
    211   1.17   mycroft 
    212  1.223     lukem .cc.po .cpp.po .cxx.o .C.po:
    213  1.238     lukem 	${_MKTARGET_COMPILE}
    214  1.228     lukem 	${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET}.tmp
    215  1.153  christos .if defined(COPTS) && !empty(COPTS:M*-g*)
    216  1.228     lukem 	mv ${.TARGET}.tmp ${.TARGET}
    217  1.153  christos .else
    218  1.228     lukem 	${LD} -X -r ${.TARGET}.tmp -o ${.TARGET}
    219  1.228     lukem 	rm -f ${.TARGET}.tmp
    220  1.153  christos .endif
    221   1.28       cgd 
    222  1.223     lukem .cc.so .cpp.so .cxx.so .C.so:
    223  1.238     lukem 	${_MKTARGET_COMPILE}
    224  1.228     lukem 	${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}.tmp
    225  1.153  christos .if defined(COPTS) && !empty(COPTS:M*-g*)
    226  1.228     lukem 	mv ${.TARGET}.tmp ${.TARGET}
    227  1.153  christos .else
    228  1.228     lukem 	${LD} -x -r ${.TARGET}.tmp -o ${.TARGET}
    229  1.228     lukem 	rm -f ${.TARGET}.tmp
    230  1.153  christos .endif
    231  1.118     lukem 
    232  1.179  dmcmahil .f.o:
    233  1.238     lukem 	${_MKTARGET_COMPILE}
    234  1.228     lukem 	${COMPILE.f} ${.IMPSRC} -o ${.TARGET}.tmp
    235  1.179  dmcmahil .if defined(FOPTS) && !empty(FOPTS:M*-g*)
    236  1.228     lukem 	mv ${.TARGET}.tmp ${.TARGET}
    237  1.179  dmcmahil .else
    238  1.228     lukem 	${LD} -x -r ${.TARGET}.tmp -o ${.TARGET}
    239  1.228     lukem 	rm -f ${.TARGET}.tmp
    240  1.179  dmcmahil .endif
    241  1.179  dmcmahil 
    242  1.179  dmcmahil .f.po:
    243  1.238     lukem 	${_MKTARGET_COMPILE}
    244  1.228     lukem 	${COMPILE.f} -pg ${.IMPSRC} -o ${.TARGET}.tmp
    245  1.179  dmcmahil .if defined(FOPTS) && !empty(FOPTS:M*-g*)
    246  1.228     lukem 	mv ${.TARGET}.tmp ${.TARGET}
    247  1.179  dmcmahil .else
    248  1.228     lukem 	${LD} -X -r ${.TARGET}.tmp -o ${.TARGET}
    249  1.228     lukem 	rm -f ${.TARGET}.tmp
    250  1.179  dmcmahil .endif
    251  1.179  dmcmahil 
    252  1.179  dmcmahil .f.so:
    253  1.238     lukem 	${_MKTARGET_COMPILE}
    254  1.228     lukem 	${COMPILE.f} ${FPICFLAGS} ${.IMPSRC} -o ${.TARGET}.tmp
    255  1.179  dmcmahil .if defined(FOPTS) && !empty(FOPTS:M*-g*)
    256  1.228     lukem 	mv ${.TARGET}.tmp ${.TARGET}
    257  1.179  dmcmahil .else
    258  1.228     lukem 	${LD} -x -r ${.TARGET}.tmp -o ${.TARGET}
    259  1.228     lukem 	rm -f ${.TARGET}.tmp
    260  1.179  dmcmahil .endif
    261  1.179  dmcmahil 
    262  1.179  dmcmahil .f.ln:
    263  1.238     lukem 	${_MKTARGET_COMPILE}
    264  1.217       wiz 	@echo Skipping lint for Fortran libraries.
    265  1.179  dmcmahil 
    266  1.118     lukem .m.o:
    267  1.238     lukem 	${_MKTARGET_COMPILE}
    268  1.228     lukem 	${COMPILE.m} ${.IMPSRC} -o ${.TARGET}.tmp
    269  1.153  christos .if defined(OBJCFLAGS) && !empty(OBJCFLAGS:M*-g*)
    270  1.228     lukem 	mv ${.TARGET}.tmp ${.TARGET}
    271  1.153  christos .else
    272  1.228     lukem 	${LD} -x -r ${.TARGET}.tmp -o ${.TARGET}
    273  1.228     lukem 	rm -f ${.TARGET}.tmp
    274  1.153  christos .endif
    275  1.118     lukem 
    276  1.118     lukem .m.po:
    277  1.238     lukem 	${_MKTARGET_COMPILE}
    278  1.228     lukem 	${COMPILE.m} -pg ${.IMPSRC} -o ${.TARGET}.tmp
    279  1.153  christos .if defined(OBJCFLAGS) && !empty(OBJCFLAGS:M*-g*)
    280  1.228     lukem 	mv ${.TARGET}.tmp ${.TARGET}
    281  1.153  christos .else
    282  1.228     lukem 	${LD} -X -r ${.TARGET}.tmp -o ${.TARGET}
    283  1.228     lukem 	rm -f ${.TARGET}.tmp
    284  1.153  christos .endif
    285  1.118     lukem 
    286  1.118     lukem .m.so:
    287  1.238     lukem 	${_MKTARGET_COMPILE}
    288  1.228     lukem 	${COMPILE.m} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}.tmp
    289  1.153  christos .if defined(OBJCFLAGS) && !empty(OBJCFLAGS:M*-g*)
    290  1.228     lukem 	mv ${.TARGET}.tmp ${.TARGET}
    291  1.153  christos .else
    292  1.228     lukem 	${LD} -x -r ${.TARGET}.tmp -o ${.TARGET}
    293  1.228     lukem 	rm -f ${.TARGET}.tmp
    294  1.153  christos .endif
    295    1.1       cgd 
    296  1.251     lukem .s.o:
    297  1.238     lukem 	${_MKTARGET_COMPILE}
    298  1.251     lukem 	${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}.tmp
    299  1.228     lukem 	${LD} -x -r ${.TARGET}.tmp -o ${.TARGET}
    300  1.228     lukem 	rm -f ${.TARGET}.tmp
    301    1.1       cgd 
    302  1.251     lukem .S.o:
    303  1.251     lukem 	${_MKTARGET_COMPILE}
    304  1.251     lukem 	${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}.tmp
    305  1.251     lukem 	${LD} -x -r ${.TARGET}.tmp -o ${.TARGET}
    306  1.251     lukem 	rm -f ${.TARGET}.tmp
    307  1.251     lukem 
    308  1.251     lukem .s.po:
    309  1.251     lukem 	${_MKTARGET_COMPILE}
    310  1.251     lukem 	${COMPILE.s} -DGPROF -DPROF ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}.tmp
    311  1.251     lukem 	${LD} -X -r ${.TARGET}.tmp -o ${.TARGET}
    312  1.251     lukem 	rm -f ${.TARGET}.tmp
    313  1.251     lukem 
    314  1.251     lukem .S.po:
    315  1.238     lukem 	${_MKTARGET_COMPILE}
    316  1.251     lukem 	${COMPILE.S} -DGPROF -DPROF ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}.tmp
    317  1.228     lukem 	${LD} -X -r ${.TARGET}.tmp -o ${.TARGET}
    318  1.228     lukem 	rm -f ${.TARGET}.tmp
    319    1.1       cgd 
    320  1.251     lukem .s.so:
    321  1.251     lukem 	${_MKTARGET_COMPILE}
    322  1.251     lukem 	${COMPILE.s} ${CAPICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}.tmp
    323  1.251     lukem 	${LD} -x -r ${.TARGET}.tmp -o ${.TARGET}
    324  1.251     lukem 	rm -f ${.TARGET}.tmp
    325  1.251     lukem 
    326  1.251     lukem .S.so:
    327  1.238     lukem 	${_MKTARGET_COMPILE}
    328  1.251     lukem 	${COMPILE.S} ${CAPICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}.tmp
    329  1.228     lukem 	${LD} -x -r ${.TARGET}.tmp -o ${.TARGET}
    330  1.228     lukem 	rm -f ${.TARGET}.tmp
    331   1.27        pk 
    332  1.252     lukem .if defined(LIB)							# {
    333  1.234     lukem .if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
    334  1.234     lukem 	|| ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
    335  1.130        tv _LIBS=lib${LIB}.a
    336  1.130        tv .else
    337  1.130        tv _LIBS=
    338  1.130        tv .endif
    339   1.58       cgd 
    340  1.167      matt OBJS+=${SRCS:N*.h:N*.sh:R:S/$/.o/g}
    341  1.158  christos 
    342  1.255   thorpej STOBJS+=${OBJS}
    343  1.255   thorpej 
    344  1.252     lukem .if ${MKPRIVATELIB} != "no"
    345  1.252     lukem # No installation is required
    346  1.252     lukem libinstall::
    347  1.252     lukem .else	# ${MKPRIVATELIB} == "no"					# {
    348  1.252     lukem 
    349  1.149     lukem .if ${MKPROFILE} != "no"
    350  1.130        tv _LIBS+=lib${LIB}_p.a
    351  1.167      matt POBJS+=${OBJS:.o=.po}
    352    1.1       cgd .endif
    353    1.1       cgd 
    354  1.252     lukem .if ${MKPIC} != "no"							# {
    355  1.160    simonb .if ${MKPICLIB} == "no"
    356  1.205      yamt .if ${MKSHLIBOBJS} != "no"
    357  1.205      yamt # make _pic.a, which isn't really pic,
    358  1.205      yamt # since it's needed for making shared lib.
    359  1.205      yamt # but don't install it.
    360  1.205      yamt SOLIB=lib${LIB}_pic.a
    361  1.205      yamt SOBJS+=${OBJS:.o=.so}
    362  1.205      yamt .else
    363  1.160    simonb SOLIB=lib${LIB}.a
    364  1.205      yamt .endif
    365  1.160    simonb .else
    366  1.160    simonb SOLIB=lib${LIB}_pic.a
    367  1.160    simonb _LIBS+=${SOLIB}
    368  1.167      matt SOBJS+=${OBJS:.o=.so}
    369  1.160    simonb .endif
    370  1.171  christos .if defined(SHLIB_FULLVERSION)
    371  1.171  christos _LIBS+=lib${LIB}.so.${SHLIB_FULLVERSION}
    372   1.27        pk .endif
    373  1.252     lukem .endif									# }
    374   1.27        pk 
    375  1.179  dmcmahil LOBJS+=${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
    376  1.179  dmcmahil .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS)
    377   1.58       cgd _LIBS+=llib-l${LIB}.ln
    378  1.215  christos .endif
    379   1.27        pk 
    380  1.252     lukem .endif	# ${MKPRIVATELIB} == "no"					# }
    381  1.252     lukem 
    382  1.234     lukem ALLOBJS=
    383  1.234     lukem .if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
    384  1.234     lukem 	|| ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
    385  1.255   thorpej ALLOBJS+=${STOBJS}
    386  1.179  dmcmahil .endif
    387  1.234     lukem ALLOBJS+=${POBJS} ${SOBJS}
    388  1.179  dmcmahil .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS)
    389  1.179  dmcmahil ALLOBJS+=${LOBJS}
    390  1.216  christos .endif
    391  1.252     lukem .else	# !defined(LIB)							# } {
    392  1.216  christos LOBJS=
    393  1.216  christos SOBJS=
    394  1.252     lukem .endif	# !defined(LIB)							# }
    395  1.186        tv 
    396  1.254     lukem _YLSRCS=	${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
    397  1.253  christos 
    398  1.253  christos .NOPATH: ${ALLOBJS} ${_LIBS} ${_YLSRCS}
    399  1.158  christos 
    400  1.162   mycroft realall: ${SRCS} ${ALLOBJS:O} ${_LIBS}
    401    1.1       cgd 
    402  1.243       rtr .if !target(__archivebuild)
    403   1.90  christos __archivebuild: .USE
    404  1.238     lukem 	${_MKTARGET_BUILD}
    405  1.236     lukem 	rm -f ${.TARGET}
    406  1.228     lukem 	${AR} cq ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
    407   1.89  christos 	${RANLIB} ${.TARGET}
    408  1.243       rtr .endif
    409   1.89  christos 
    410  1.243       rtr .if !target(__archiveinstall)
    411   1.89  christos __archiveinstall: .USE
    412  1.238     lukem 	${_MKTARGET_INSTALL}
    413  1.198     lukem 	${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
    414  1.208     perry 	    ${UPDATE:D:U-a "${RANLIB} -t"} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
    415  1.243       rtr .endif
    416   1.89  christos 
    417  1.197   mycroft __archivesymlinkpic: .USE
    418  1.238     lukem 	${_MKTARGET_INSTALL}
    419  1.208     perry 	${INSTALL_SYMLINK} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
    420  1.197   mycroft 
    421  1.253  christos DPSRCS+=	${_YLSRCS}
    422  1.253  christos CLEANFILES+=	${_YLSRCS}
    423  1.230     lukem 
    424  1.255   thorpej ${STOBJS} ${POBJS} ${SOBJS} ${LOBJS}: ${DPSRCS}
    425  1.103   mycroft 
    426  1.255   thorpej lib${LIB}.a:: ${STOBJS} __archivebuild
    427    1.1       cgd 
    428   1.89  christos lib${LIB}_p.a:: ${POBJS} __archivebuild
    429    1.1       cgd 
    430   1.89  christos lib${LIB}_pic.a:: ${SOBJS} __archivebuild
    431   1.27        pk 
    432  1.235     lukem 
    433  1.235     lukem _LIBLDOPTS=
    434  1.235     lukem .if ${SHLIBDIR} != "/usr/lib"
    435  1.235     lukem _LIBLDOPTS+=	-Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
    436  1.235     lukem 		-R${SHLIBDIR} \
    437  1.235     lukem 		-L${DESTDIR}${SHLIBDIR}
    438  1.235     lukem .elif ${SHLIBINSTALLDIR} != "/usr/lib"
    439  1.235     lukem _LIBLDOPTS+=	-Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
    440  1.235     lukem 		-L${DESTDIR}${SHLIBINSTALLDIR}
    441  1.235     lukem .endif
    442  1.235     lukem 
    443  1.171  christos lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOLIB} ${DPADD} \
    444   1.88       cgd     ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
    445  1.238     lukem 	${_MKTARGET_BUILD}
    446  1.236     lukem 	rm -f lib${LIB}.so.${SHLIB_FULLVERSION}
    447  1.152      fair .if defined(DESTDIR)
    448  1.228     lukem 	${CC} -Wl,-nostdlib -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/ \
    449  1.235     lukem 	    ${_LIBLDOPTS} \
    450  1.231     lukem 	    -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} -o ${.TARGET} \
    451  1.221  drochner 	    -Wl,--whole-archive ${SOLIB} \
    452  1.221  drochner 	    -Wl,--no-whole-archive ${LDADD} \
    453  1.235     lukem 	    -L${_GCC_LIBGCCDIR}
    454  1.221  drochner .else
    455  1.231     lukem 	${CC} -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} -o ${.TARGET} \
    456  1.235     lukem 	    ${_LIBLDOPTS} \
    457  1.221  drochner 	    -Wl,--whole-archive ${SOLIB} -Wl,--no-whole-archive ${LDADD}
    458  1.152      fair .endif
    459  1.148     lukem .if ${OBJECT_FMT} == "ELF"
    460  1.196     lukem #  We don't use INSTALL_SYMLINK here because this is just
    461  1.196     lukem #  happening inside the build directory/objdir. XXX Why does
    462  1.196     lukem #  this spend so much effort on libraries that aren't live??? XXX
    463  1.241      matt 	${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.${SHLIB_MAJOR}.tmp
    464  1.177   mycroft 	mv -f lib${LIB}.so.${SHLIB_MAJOR}.tmp lib${LIB}.so.${SHLIB_MAJOR}
    465  1.241      matt 	${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.tmp
    466  1.177   mycroft 	mv -f lib${LIB}.so.tmp lib${LIB}.so
    467  1.133        tv .endif
    468   1.35        pk 
    469  1.252     lukem .if !empty(LOBJS)							# {
    470  1.103   mycroft LLIBS?=		-lc
    471   1.58       cgd llib-l${LIB}.ln: ${LOBJS}
    472  1.238     lukem 	${_MKTARGET_COMPILE}
    473  1.236     lukem 	rm -f llib-l${LIB}.ln
    474  1.206   thorpej .if defined(DESTDIR)
    475  1.228     lukem 	${LINT} -C${LIB} ${.ALLSRC} -L${DESTDIR}/usr/libdata ${LLIBS}
    476  1.206   thorpej .else
    477  1.228     lukem 	${LINT} -C${LIB} ${.ALLSRC} ${LLIBS}
    478  1.206   thorpej .endif
    479  1.252     lukem .endif									# }
    480    1.1       cgd 
    481  1.246     lukem cleanlib: .PHONY
    482   1.48   mycroft 	rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
    483  1.255   thorpej 	rm -f lib${LIB}.a ${STOBJS}
    484   1.59       cgd 	rm -f lib${LIB}_p.a ${POBJS}
    485  1.133        tv 	rm -f lib${LIB}_pic.a lib${LIB}.so.* lib${LIB}.so ${SOBJS}
    486  1.255   thorpej 	rm -f ${STOBJS:=.tmp} ${POBJS:=.tmp} ${SOBJS:=.tmp}
    487   1.59       cgd 	rm -f llib-l${LIB}.ln ${LOBJS}
    488    1.1       cgd 
    489  1.252     lukem 
    490  1.252     lukem .if !target(libinstall)							# {
    491  1.148     lukem # Make sure it gets defined, in case MKPIC==no && MKLINKLIB==no
    492  1.139        tv libinstall::
    493  1.139        tv 
    494  1.234     lukem .if ${MKLINKLIB} != "no" && ${MKSTATICLIB} != "no"
    495   1.89  christos libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.a
    496  1.168   mycroft .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.a
    497  1.197   mycroft 
    498   1.89  christos .if !defined(UPDATE)
    499  1.197   mycroft .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a)
    500  1.197   mycroft ${DESTDIR}${LIBDIR}/lib${LIB}.a! .MADE
    501   1.89  christos .endif
    502  1.197   mycroft ${DESTDIR}${LIBDIR}/lib${LIB}.a! lib${LIB}.a __archiveinstall
    503  1.197   mycroft .else
    504  1.157     fredb .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a)
    505   1.89  christos ${DESTDIR}${LIBDIR}/lib${LIB}.a: .MADE
    506   1.89  christos .endif
    507   1.89  christos ${DESTDIR}${LIBDIR}/lib${LIB}.a: lib${LIB}.a __archiveinstall
    508  1.130        tv .endif
    509  1.197   mycroft .endif
    510   1.89  christos 
    511  1.149     lukem .if ${MKPROFILE} != "no"
    512   1.89  christos libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
    513  1.168   mycroft .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
    514  1.197   mycroft 
    515   1.89  christos .if !defined(UPDATE)
    516  1.197   mycroft .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a)
    517  1.197   mycroft ${DESTDIR}${LIBDIR}/lib${LIB}_p.a! .MADE
    518   1.32        pk .endif
    519  1.197   mycroft ${DESTDIR}${LIBDIR}/lib${LIB}_p.a! lib${LIB}_p.a __archiveinstall
    520  1.197   mycroft .else
    521  1.157     fredb .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a)
    522   1.89  christos ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: .MADE
    523   1.89  christos .endif
    524   1.89  christos ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: lib${LIB}_p.a __archiveinstall
    525   1.89  christos .endif
    526  1.197   mycroft .endif
    527   1.89  christos 
    528  1.149     lukem .if ${MKPIC} != "no" && ${MKPICINSTALL} != "no"
    529  1.168   mycroft libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
    530  1.160    simonb .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
    531  1.197   mycroft 
    532   1.89  christos .if !defined(UPDATE)
    533  1.197   mycroft .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a)
    534  1.197   mycroft ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! .MADE
    535   1.89  christos .endif
    536  1.197   mycroft .if ${MKPICLIB} == "no"
    537  1.197   mycroft ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}.a __archivesymlinkpic
    538  1.197   mycroft .else
    539  1.197   mycroft ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}_pic.a __archiveinstall
    540  1.197   mycroft .endif
    541  1.197   mycroft .else
    542  1.157     fredb .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a)
    543   1.89  christos ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: .MADE
    544   1.33        pk .endif
    545  1.160    simonb .if ${MKPICLIB} == "no"
    546  1.197   mycroft ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}.a __archivesymlinkpic
    547  1.160    simonb .else
    548   1.89  christos ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}_pic.a __archiveinstall
    549  1.160    simonb .endif
    550   1.89  christos .endif
    551  1.197   mycroft .endif
    552   1.89  christos 
    553  1.171  christos .if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION)
    554  1.195     lukem libinstall:: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
    555  1.195     lukem .PRECIOUS: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
    556  1.197   mycroft 
    557   1.89  christos .if !defined(UPDATE)
    558  1.197   mycroft .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION})
    559  1.197   mycroft ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}! .MADE
    560   1.89  christos .endif
    561  1.197   mycroft ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}! lib${LIB}.so.${SHLIB_FULLVERSION}
    562  1.197   mycroft .else
    563  1.171  christos .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION})
    564  1.195     lukem ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: .MADE
    565   1.89  christos .endif
    566  1.195     lukem ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: lib${LIB}.so.${SHLIB_FULLVERSION}
    567  1.197   mycroft .endif
    568  1.238     lukem 	${_MKTARGET_INSTALL}
    569  1.188        tv 	${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
    570  1.208     perry 		${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
    571  1.195     lukem .if ${_LIBSODIR} != ${LIBDIR}
    572  1.208     perry 	${INSTALL_SYMLINK} ${SYSPKGTAG} \
    573  1.208     perry 		${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \
    574  1.208     perry 		${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
    575  1.195     lukem .endif
    576  1.148     lukem .if ${OBJECT_FMT} == "a.out" && !defined(DESTDIR)
    577  1.195     lukem 	/sbin/ldconfig -m ${_LIBSODIR} ${LIBDIR}
    578  1.146   thorpej .endif
    579  1.148     lukem .if ${OBJECT_FMT} == "ELF"
    580  1.208     perry 	${INSTALL_SYMLINK} ${SYSPKGTAG} \
    581  1.208     perry 		lib${LIB}.so.${SHLIB_FULLVERSION} \
    582  1.208     perry 		${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_MAJOR}
    583  1.195     lukem .if ${_LIBSODIR} != ${LIBDIR}
    584  1.208     perry 	${INSTALL_SYMLINK} ${SYSPKGTAG} \
    585  1.208     perry 		${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \
    586  1.208     perry 		${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
    587  1.195     lukem .endif
    588  1.148     lukem .if ${MKLINKLIB} != "no"
    589  1.208     perry 	${INSTALL_SYMLINK} ${SYSPKGTAG} \
    590  1.208     perry 		lib${LIB}.so.${SHLIB_FULLVERSION} \
    591  1.208     perry 		${DESTDIR}${_LIBSODIR}/lib${LIB}.so
    592  1.195     lukem .if ${_LIBSODIR} != ${LIBDIR}
    593  1.208     perry 	${INSTALL_SYMLINK} ${SYSPKGTAG} \
    594  1.248     lukem 		${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \
    595  1.208     perry 		${DESTDIR}${LIBDIR}/lib${LIB}.so
    596  1.195     lukem .endif
    597   1.83       cgd .endif
    598   1.12       cgd .endif
    599  1.139        tv .endif
    600   1.89  christos 
    601  1.179  dmcmahil .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS)
    602   1.89  christos libinstall:: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
    603  1.168   mycroft .PRECIOUS: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
    604  1.197   mycroft 
    605   1.89  christos .if !defined(UPDATE)
    606  1.197   mycroft .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln)
    607  1.197   mycroft ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! .MADE
    608   1.89  christos .endif
    609  1.197   mycroft ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! llib-l${LIB}.ln
    610  1.197   mycroft .else
    611  1.157     fredb .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln)
    612   1.89  christos ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: .MADE
    613   1.89  christos .endif
    614   1.95   mycroft ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: llib-l${LIB}.ln
    615  1.197   mycroft .endif
    616  1.238     lukem 	${_MKTARGET_INSTALL}
    617  1.188        tv 	${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
    618  1.208     perry 		${SYSPKGTAG} ${.ALLSRC} ${DESTDIR}${LINTLIBDIR}
    619   1.58       cgd .endif
    620  1.252     lukem .endif	# !target(libinstall)						# }
    621    1.1       cgd 
    622  1.188        tv ##### Pull in related .mk logic
    623    1.1       cgd .include <bsd.man.mk>
    624   1.57       jtc .include <bsd.nls.mk>
    625   1.91  christos .include <bsd.files.mk>
    626   1.89  christos .include <bsd.inc.mk>
    627  1.109       cjs .include <bsd.links.mk>
    628   1.24   mycroft .include <bsd.dep.mk>
    629  1.117   mycroft 
    630  1.188        tv ${TARGETS}:	# ensure existence
    631