[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.282

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

CVSweb <webmaster@jp.NetBSD.org>