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