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