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