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