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

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

CVSweb <webmaster@jp.NetBSD.org>