[BACK]Return to bsd.lib.mk CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / share / mk

Annotation of src/share/mk/bsd.lib.mk, Revision 1.269

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

CVSweb <webmaster@jp.NetBSD.org>