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

1.277   ! christos    1: #      $NetBSD: bsd.lib.mk,v 1.276 2008/04/26 22:28:13 christos 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.271     tsutsui   115: # CPPPICFLAGS:         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: .else                                                                  # } {
1.86      jonathan  143:
1.244     skrll     144: # Platform-independent flags for NetBSD shared libraries
1.171     christos  145: SHLIB_SOVERSION=${SHLIB_FULLVERSION}
1.125     jonathan  146: SHLIB_SHFLAGS=
1.179     dmcmahil  147: FPICFLAGS ?= -fPIC
1.165     dmcmahil  148: CPICFLAGS?= -fPIC -DPIC
1.222     lukem     149: CPPPICFLAGS?= -DPIC
1.107     jonathan  150: CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
                    151: APICFLAGS?= -k
1.86      jonathan  152:
1.252     lukem     153: .endif                                                                 # }
1.160     simonb    154:
1.205     yamt      155: .if ${MKPICLIB} != "no"
                    156: CSHLIBFLAGS+= ${CPICFLAGS}
                    157: .endif
                    158:
                    159: .if defined(CSHLIBFLAGS) && !empty(CSHLIBFLAGS)
                    160: MKSHLIBOBJS= yes
                    161: .else
                    162: MKSHLIBOBJS= no
                    163: .endif
                    164:
1.123     jonathan  165: # Platform-independent linker flags for ELF shared libraries
1.148     lukem     166: .if ${OBJECT_FMT} == "ELF"
1.182     mrg       167: SHLIB_SOVERSION=       ${SHLIB_MAJOR}
1.221     drochner  168: SHLIB_SHFLAGS=         -Wl,-soname,lib${LIB}.so.${SHLIB_SOVERSION}
1.272     christos  169: SHLIB_SHFLAGS+=                -Wl,--warn-shared-textrel
1.219     thorpej   170: SHLIB_LDSTARTFILE?=    ${DESTDIR}/usr/lib/crti.o ${_GCC_CRTBEGINS}
                    171: SHLIB_LDENDFILE?=      ${_GCC_CRTENDS} ${DESTDIR}/usr/lib/crtn.o
1.123     jonathan  172: .endif
1.86      jonathan  173:
1.82      mikel     174: CFLAGS+=       ${COPTS}
1.267     mrg       175: OBJCFLAGS+=    ${OBJCOPTS}
1.257     simonb    176: AFLAGS+=       ${COPTS}
1.179     dmcmahil  177: FFLAGS+=       ${FOPTS}
1.1       cgd       178:
                    179: .c.o:
1.238     lukem     180:        ${_MKTARGET_COMPILE}
1.263     dsl       181:        ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
1.270     martin    182: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263     dsl       183:        ${OBJCOPY} -x ${.TARGET}
1.153     christos  184: .endif
1.1       cgd       185:
                    186: .c.po:
1.238     lukem     187:        ${_MKTARGET_COMPILE}
1.263     dsl       188:        ${COMPILE.c} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET}
1.270     martin    189: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263     dsl       190:        ${OBJCOPY} -X ${.TARGET}
1.153     christos  191: .endif
1.17      mycroft   192:
1.266     christos  193: .c.go:
                    194:        ${_MKTARGET_COMPILE}
                    195:        ${COMPILE.c} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET}
                    196:
1.27      pk        197: .c.so:
1.238     lukem     198:        ${_MKTARGET_COMPILE}
1.263     dsl       199:        ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
1.270     martin    200: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263     dsl       201:        ${OBJCOPY} -x ${.TARGET}
1.153     christos  202: .endif
1.27      pk        203:
1.223     lukem     204: .cc.o .cpp.o .cxx.o .C.o:
1.238     lukem     205:        ${_MKTARGET_COMPILE}
1.263     dsl       206:        ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
1.270     martin    207: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263     dsl       208:        ${OBJCOPY} -x ${.TARGET}
1.153     christos  209: .endif
1.17      mycroft   210:
1.266     christos  211: .cc.po .cpp.po .cxx.po .C.po:
1.238     lukem     212:        ${_MKTARGET_COMPILE}
1.263     dsl       213:        ${COMPILE.cc} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET}
1.270     martin    214: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263     dsl       215:        ${OBJCOPY} -X ${.TARGET}
1.153     christos  216: .endif
1.28      cgd       217:
1.266     christos  218: .cc.go .cpp.go .cxx.go .C.go:
                    219:        ${_MKTARGET_COMPILE}
                    220:        ${COMPILE.cc} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET}
                    221:
1.223     lukem     222: .cc.so .cpp.so .cxx.so .C.so:
1.238     lukem     223:        ${_MKTARGET_COMPILE}
1.263     dsl       224:        ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
1.270     martin    225: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263     dsl       226:        ${OBJCOPY} -x ${.TARGET}
1.153     christos  227: .endif
1.118     lukem     228:
1.179     dmcmahil  229: .f.o:
1.238     lukem     230:        ${_MKTARGET_COMPILE}
1.263     dsl       231:        ${COMPILE.f} ${.IMPSRC} -o ${.TARGET}
                    232: .if !defined(FOPTS) || empty(FOPTS:M*-g*)
                    233:        ${OBJCOPY} -x ${.TARGET}
1.179     dmcmahil  234: .endif
                    235:
                    236: .f.po:
1.238     lukem     237:        ${_MKTARGET_COMPILE}
1.263     dsl       238:        ${COMPILE.f} ${PROFFLAGS} -pg ${.IMPSRC} -o ${.TARGET}
                    239: .if !defined(FOPTS) || empty(FOPTS:M*-g*)
                    240:        ${OBJCOPY} -X ${.TARGET}
1.179     dmcmahil  241: .endif
                    242:
1.266     christos  243: .f.go:
                    244:        ${_MKTARGET_COMPILE}
                    245:        ${COMPILE.f} ${DEBUGFLAGS} -g ${.IMPSRC} -o ${.TARGET}
                    246:
1.179     dmcmahil  247: .f.so:
1.238     lukem     248:        ${_MKTARGET_COMPILE}
1.263     dsl       249:        ${COMPILE.f} ${FPICFLAGS} ${.IMPSRC} -o ${.TARGET}
                    250: .if !defined(FOPTS) || empty(FOPTS:M*-g*)
                    251:        ${OBJCOPY} -x ${.TARGET}
1.179     dmcmahil  252: .endif
                    253:
                    254: .f.ln:
1.238     lukem     255:        ${_MKTARGET_COMPILE}
1.217     wiz       256:        @echo Skipping lint for Fortran libraries.
1.179     dmcmahil  257:
1.118     lukem     258: .m.o:
1.238     lukem     259:        ${_MKTARGET_COMPILE}
1.267     mrg       260:        ${COMPILE.m} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
1.263     dsl       261: .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
                    262:        ${OBJCOPY} -x ${.TARGET}
1.153     christos  263: .endif
1.118     lukem     264:
                    265: .m.po:
1.238     lukem     266:        ${_MKTARGET_COMPILE}
1.267     mrg       267:        ${COMPILE.m} ${PROFFLAGS} -pg ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
1.263     dsl       268: .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
                    269:        ${OBJCOPY} -X ${.TARGET}
1.153     christos  270: .endif
1.118     lukem     271:
1.266     christos  272: .m.go:
                    273:        ${_MKTARGET_COMPILE}
1.267     mrg       274:        ${COMPILE.m} ${DEBUGFLAGS} -g ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
1.266     christos  275: .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
                    276:        ${OBJCOPY} -X ${.TARGET}
                    277: .endif
                    278:
1.118     lukem     279: .m.so:
1.238     lukem     280:        ${_MKTARGET_COMPILE}
1.267     mrg       281:        ${COMPILE.m} ${CSHLIBFLAGS} ${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.1       cgd       285:
1.251     lukem     286: .s.o:
1.238     lukem     287:        ${_MKTARGET_COMPILE}
1.263     dsl       288:        ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
                    289:        ${OBJCOPY} -x ${.TARGET}
1.1       cgd       290:
1.251     lukem     291: .S.o:
                    292:        ${_MKTARGET_COMPILE}
1.263     dsl       293:        ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
                    294:        ${OBJCOPY} -x ${.TARGET}
1.251     lukem     295:
                    296: .s.po:
                    297:        ${_MKTARGET_COMPILE}
1.263     dsl       298:        ${COMPILE.s} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
                    299:        ${OBJCOPY} -X ${.TARGET}
1.251     lukem     300:
                    301: .S.po:
1.238     lukem     302:        ${_MKTARGET_COMPILE}
1.263     dsl       303:        ${COMPILE.S} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
                    304:        ${OBJCOPY} -X ${.TARGET}
1.1       cgd       305:
1.266     christos  306: .s.go:
                    307:        ${_MKTARGET_COMPILE}
                    308:        ${COMPILE.s} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
                    309:
                    310: .S.go:
                    311:        ${_MKTARGET_COMPILE}
                    312:        ${COMPILE.S} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
                    313:
1.251     lukem     314: .s.so:
                    315:        ${_MKTARGET_COMPILE}
1.263     dsl       316:        ${COMPILE.s} ${CAPICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
                    317:        ${OBJCOPY} -x ${.TARGET}
1.251     lukem     318:
                    319: .S.so:
1.238     lukem     320:        ${_MKTARGET_COMPILE}
1.263     dsl       321:        ${COMPILE.S} ${CAPICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
                    322:        ${OBJCOPY} -x ${.TARGET}
1.27      pk        323:
1.252     lukem     324: .if defined(LIB)                                                       # {
1.234     lukem     325: .if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
                    326:        || ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
1.130     tv        327: _LIBS=lib${LIB}.a
                    328: .else
                    329: _LIBS=
                    330: .endif
1.58      cgd       331:
1.167     matt      332: OBJS+=${SRCS:N*.h:N*.sh:R:S/$/.o/g}
1.158     christos  333:
1.255     thorpej   334: STOBJS+=${OBJS}
                    335:
1.252     lukem     336: .if ${MKPRIVATELIB} != "no"
                    337: # No installation is required
                    338: libinstall::
                    339: .else  # ${MKPRIVATELIB} == "no"                                       # {
                    340:
1.268     lukem     341: .if ${MKDEBUGLIB} != "no"
1.266     christos  342: _LIBS+=lib${LIB}_g.a
                    343: GOBJS+=${OBJS:.o=.go}
                    344: DEBUGFLAGS?=-DDEBUG
                    345: .endif
                    346:
1.149     lukem     347: .if ${MKPROFILE} != "no"
1.130     tv        348: _LIBS+=lib${LIB}_p.a
1.167     matt      349: POBJS+=${OBJS:.o=.po}
1.262     christos  350: PROFFLAGS?=-DGPROF -DPROF
1.1       cgd       351: .endif
                    352:
1.252     lukem     353: .if ${MKPIC} != "no"                                                   # {
1.160     simonb    354: .if ${MKPICLIB} == "no"
1.205     yamt      355: .if ${MKSHLIBOBJS} != "no"
                    356: # make _pic.a, which isn't really pic,
                    357: # since it's needed for making shared lib.
                    358: # but don't install it.
                    359: SOLIB=lib${LIB}_pic.a
                    360: SOBJS+=${OBJS:.o=.so}
                    361: .else
1.160     simonb    362: SOLIB=lib${LIB}.a
1.205     yamt      363: .endif
1.160     simonb    364: .else
                    365: SOLIB=lib${LIB}_pic.a
                    366: _LIBS+=${SOLIB}
1.167     matt      367: SOBJS+=${OBJS:.o=.so}
1.160     simonb    368: .endif
1.171     christos  369: .if defined(SHLIB_FULLVERSION)
                    370: _LIBS+=lib${LIB}.so.${SHLIB_FULLVERSION}
1.27      pk        371: .endif
1.252     lukem     372: .endif                                                                 # }
1.27      pk        373:
1.179     dmcmahil  374: LOBJS+=${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
                    375: .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS)
1.58      cgd       376: _LIBS+=llib-l${LIB}.ln
1.215     christos  377: .endif
1.27      pk        378:
1.252     lukem     379: .endif # ${MKPRIVATELIB} == "no"                                       # }
                    380:
1.234     lukem     381: ALLOBJS=
                    382: .if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
                    383:        || ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
1.255     thorpej   384: ALLOBJS+=${STOBJS}
1.179     dmcmahil  385: .endif
1.234     lukem     386: ALLOBJS+=${POBJS} ${SOBJS}
1.179     dmcmahil  387: .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS)
                    388: ALLOBJS+=${LOBJS}
1.216     christos  389: .endif
1.252     lukem     390: .else  # !defined(LIB)                                                 # } {
1.216     christos  391: LOBJS=
                    392: SOBJS=
1.252     lukem     393: .endif # !defined(LIB)                                                 # }
1.186     tv        394:
1.254     lukem     395: _YLSRCS=       ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.253     christos  396:
                    397: .NOPATH: ${ALLOBJS} ${_LIBS} ${_YLSRCS}
1.158     christos  398:
1.162     mycroft   399: realall: ${SRCS} ${ALLOBJS:O} ${_LIBS}
1.1       cgd       400:
1.243     rtr       401: .if !target(__archivebuild)
1.90      christos  402: __archivebuild: .USE
1.238     lukem     403:        ${_MKTARGET_BUILD}
1.236     lukem     404:        rm -f ${.TARGET}
1.228     lukem     405:        ${AR} cq ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
1.89      christos  406:        ${RANLIB} ${.TARGET}
1.243     rtr       407: .endif
1.89      christos  408:
1.243     rtr       409: .if !target(__archiveinstall)
1.89      christos  410: __archiveinstall: .USE
1.238     lukem     411:        ${_MKTARGET_INSTALL}
1.198     lukem     412:        ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.269     dbj       413:            ${empty(PRESERVE):?-a "${RANLIB} -t":} ${.ALLSRC} ${.TARGET}
1.243     rtr       414: .endif
1.89      christos  415:
1.197     mycroft   416: __archivesymlinkpic: .USE
1.238     lukem     417:        ${_MKTARGET_INSTALL}
1.264     jwise     418:        ${INSTALL_SYMLINK} ${.ALLSRC} ${.TARGET}
1.197     mycroft   419:
1.253     christos  420: DPSRCS+=       ${_YLSRCS}
                    421: CLEANFILES+=   ${_YLSRCS}
1.230     lukem     422:
1.266     christos  423: ${STOBJS} ${POBJS} ${GOBJS} ${SOBJS} ${LOBJS}: ${DPSRCS}
1.103     mycroft   424:
1.255     thorpej   425: lib${LIB}.a:: ${STOBJS} __archivebuild
1.1       cgd       426:
1.89      christos  427: lib${LIB}_p.a:: ${POBJS} __archivebuild
1.1       cgd       428:
1.89      christos  429: lib${LIB}_pic.a:: ${SOBJS} __archivebuild
1.27      pk        430:
1.266     christos  431: lib${LIB}_g.a:: ${GOBJS} __archivebuild
                    432:
1.235     lukem     433:
                    434: _LIBLDOPTS=
                    435: .if ${SHLIBDIR} != "/usr/lib"
                    436: _LIBLDOPTS+=   -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
                    437:                -R${SHLIBDIR} \
                    438:                -L${DESTDIR}${SHLIBDIR}
                    439: .elif ${SHLIBINSTALLDIR} != "/usr/lib"
                    440: _LIBLDOPTS+=   -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
                    441:                -L${DESTDIR}${SHLIBINSTALLDIR}
                    442: .endif
                    443:
1.277   ! christos  444: # gcc -shared now adds -lc automatically. For libraries other than libc and
        !           445: # libgcc* we add as a dependency the installed shared libc. For libc and
        !           446: # libgcc* we avoid adding libc as a dependency by using -nostdlib. Note that
        !           447: # -Xl,-nostdlib is not enough because we want to tell the compiler-driver not
        !           448: # to add standard libraries, not the linker.
1.276     christos  449: .if !defined(LIB)
1.274     christos  450: DPLIBC ?= ${DESTDIR}${LIBC_SO}
1.276     christos  451: .else
                    452: .if ${LIB} != "c" && ${LIB:M*gcc*} == ""
                    453: DPLIBC ?= ${DESTDIR}${LIBC_SO}
1.277   ! christos  454: .else
        !           455: LDLIBC ?= -nostdlib
1.276     christos  456: .endif
1.274     christos  457: .endif
                    458:
                    459: lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOLIB} ${DPADD} ${DPLIBC} \
1.88      cgd       460:     ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
1.238     lukem     461:        ${_MKTARGET_BUILD}
1.236     lukem     462:        rm -f lib${LIB}.so.${SHLIB_FULLVERSION}
1.152     fair      463: .if defined(DESTDIR)
1.277   ! christos  464:        ${CC} ${LDLIBC} -Wl,-nostdlib -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/ \
1.235     lukem     465:            ${_LIBLDOPTS} \
1.231     lukem     466:            -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} -o ${.TARGET} \
1.221     drochner  467:            -Wl,--whole-archive ${SOLIB} \
                    468:            -Wl,--no-whole-archive ${LDADD} \
1.277   ! christos  469:            -L${_GCC_LIBGCCDIR}
1.221     drochner  470: .else
1.277   ! christos  471:        ${CC} ${LDLIBC} -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} \
        !           472:            -o ${.TARGET} ${_LIBLDOPTS} \
        !           473:            -Wl,--whole-archive ${SOLIB} -Wl,--no-whole-archive ${LDADD}
1.152     fair      474: .endif
1.148     lukem     475: .if ${OBJECT_FMT} == "ELF"
1.196     lukem     476: #  We don't use INSTALL_SYMLINK here because this is just
                    477: #  happening inside the build directory/objdir. XXX Why does
                    478: #  this spend so much effort on libraries that aren't live??? XXX
1.241     matt      479:        ${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.${SHLIB_MAJOR}.tmp
1.177     mycroft   480:        mv -f lib${LIB}.so.${SHLIB_MAJOR}.tmp lib${LIB}.so.${SHLIB_MAJOR}
1.241     matt      481:        ${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.tmp
1.177     mycroft   482:        mv -f lib${LIB}.so.tmp lib${LIB}.so
1.133     tv        483: .endif
1.35      pk        484:
1.252     lukem     485: .if !empty(LOBJS)                                                      # {
1.103     mycroft   486: LLIBS?=                -lc
1.58      cgd       487: llib-l${LIB}.ln: ${LOBJS}
1.238     lukem     488:        ${_MKTARGET_COMPILE}
1.236     lukem     489:        rm -f llib-l${LIB}.ln
1.206     thorpej   490: .if defined(DESTDIR)
1.228     lukem     491:        ${LINT} -C${LIB} ${.ALLSRC} -L${DESTDIR}/usr/libdata ${LLIBS}
1.206     thorpej   492: .else
1.228     lukem     493:        ${LINT} -C${LIB} ${.ALLSRC} ${LLIBS}
1.206     thorpej   494: .endif
1.252     lukem     495: .endif                                                                 # }
1.1       cgd       496:
1.246     lukem     497: cleanlib: .PHONY
1.48      mycroft   498:        rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
1.255     thorpej   499:        rm -f lib${LIB}.a ${STOBJS}
1.59      cgd       500:        rm -f lib${LIB}_p.a ${POBJS}
1.266     christos  501:        rm -f lib${LIB}_g.a ${GOBJS}
1.133     tv        502:        rm -f lib${LIB}_pic.a lib${LIB}.so.* lib${LIB}.so ${SOBJS}
1.266     christos  503:        rm -f ${STOBJS:=.tmp} ${POBJS:=.tmp} ${SOBJS:=.tmp} ${GOBJS:=.tmp}
1.59      cgd       504:        rm -f llib-l${LIB}.ln ${LOBJS}
1.1       cgd       505:
1.252     lukem     506:
                    507: .if !target(libinstall)                                                        # {
1.148     lukem     508: # Make sure it gets defined, in case MKPIC==no && MKLINKLIB==no
1.139     tv        509: libinstall::
                    510:
1.234     lukem     511: .if ${MKLINKLIB} != "no" && ${MKSTATICLIB} != "no"
1.89      christos  512: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.168     mycroft   513: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.197     mycroft   514:
1.269     dbj       515: .if ${MKUPDATE} == "no"
1.197     mycroft   516: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a)
                    517: ${DESTDIR}${LIBDIR}/lib${LIB}.a! .MADE
1.89      christos  518: .endif
1.197     mycroft   519: ${DESTDIR}${LIBDIR}/lib${LIB}.a! lib${LIB}.a __archiveinstall
                    520: .else
1.157     fredb     521: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a)
1.89      christos  522: ${DESTDIR}${LIBDIR}/lib${LIB}.a: .MADE
                    523: .endif
                    524: ${DESTDIR}${LIBDIR}/lib${LIB}.a: lib${LIB}.a __archiveinstall
1.130     tv        525: .endif
1.197     mycroft   526: .endif
1.89      christos  527:
1.149     lukem     528: .if ${MKPROFILE} != "no"
1.89      christos  529: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.168     mycroft   530: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.197     mycroft   531:
1.269     dbj       532: .if ${MKUPDATE} == "no"
1.197     mycroft   533: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a)
                    534: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a! .MADE
1.32      pk        535: .endif
1.197     mycroft   536: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a! lib${LIB}_p.a __archiveinstall
                    537: .else
1.157     fredb     538: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a)
1.89      christos  539: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: .MADE
                    540: .endif
                    541: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: lib${LIB}_p.a __archiveinstall
                    542: .endif
1.197     mycroft   543: .endif
1.89      christos  544:
1.268     lukem     545: .if ${MKDEBUGLIB} != "no"
1.266     christos  546: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a
                    547: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a
                    548:
1.269     dbj       549: .if ${MKUPDATE} == "no"
1.266     christos  550: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_g.a)
                    551: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a! .MADE
                    552: .endif
                    553: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a! lib${LIB}_g.a __archiveinstall
                    554: .else
                    555: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_g.a)
                    556: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a: .MADE
                    557: .endif
                    558: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a: lib${LIB}_g.a __archiveinstall
                    559: .endif
                    560: .endif
                    561:
1.149     lukem     562: .if ${MKPIC} != "no" && ${MKPICINSTALL} != "no"
1.168     mycroft   563: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.160     simonb    564: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.197     mycroft   565:
1.269     dbj       566: .if ${MKUPDATE} == "no"
1.197     mycroft   567: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a)
                    568: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! .MADE
1.89      christos  569: .endif
1.197     mycroft   570: .if ${MKPICLIB} == "no"
                    571: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}.a __archivesymlinkpic
                    572: .else
                    573: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}_pic.a __archiveinstall
                    574: .endif
                    575: .else
1.157     fredb     576: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a)
1.89      christos  577: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: .MADE
1.33      pk        578: .endif
1.160     simonb    579: .if ${MKPICLIB} == "no"
1.197     mycroft   580: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}.a __archivesymlinkpic
1.160     simonb    581: .else
1.89      christos  582: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}_pic.a __archiveinstall
1.160     simonb    583: .endif
1.89      christos  584: .endif
1.197     mycroft   585: .endif
1.89      christos  586:
1.171     christos  587: .if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION)
1.195     lukem     588: libinstall:: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
                    589: .PRECIOUS: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
1.197     mycroft   590:
1.269     dbj       591: .if ${MKUPDATE} == "no"
1.197     mycroft   592: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION})
                    593: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}! .MADE
1.89      christos  594: .endif
1.197     mycroft   595: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}! lib${LIB}.so.${SHLIB_FULLVERSION}
                    596: .else
1.171     christos  597: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION})
1.195     lukem     598: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: .MADE
1.89      christos  599: .endif
1.195     lukem     600: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: lib${LIB}.so.${SHLIB_FULLVERSION}
1.197     mycroft   601: .endif
1.238     lukem     602:        ${_MKTARGET_INSTALL}
1.188     tv        603:        ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.264     jwise     604:                ${.ALLSRC} ${.TARGET}
1.195     lukem     605: .if ${_LIBSODIR} != ${LIBDIR}
1.264     jwise     606:        ${INSTALL_SYMLINK} \
1.261     lukem     607:                -l r ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \
1.208     perry     608:                ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
1.195     lukem     609: .endif
1.148     lukem     610: .if ${OBJECT_FMT} == "a.out" && !defined(DESTDIR)
1.195     lukem     611:        /sbin/ldconfig -m ${_LIBSODIR} ${LIBDIR}
1.146     thorpej   612: .endif
1.148     lukem     613: .if ${OBJECT_FMT} == "ELF"
1.264     jwise     614:        ${INSTALL_SYMLINK} \
1.208     perry     615:                lib${LIB}.so.${SHLIB_FULLVERSION} \
                    616:                ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_MAJOR}
1.195     lukem     617: .if ${_LIBSODIR} != ${LIBDIR}
1.264     jwise     618:        ${INSTALL_SYMLINK} \
1.265     christos  619:                -l r ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \
1.208     perry     620:                ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
1.195     lukem     621: .endif
1.148     lukem     622: .if ${MKLINKLIB} != "no"
1.264     jwise     623:        ${INSTALL_SYMLINK} \
1.208     perry     624:                lib${LIB}.so.${SHLIB_FULLVERSION} \
                    625:                ${DESTDIR}${_LIBSODIR}/lib${LIB}.so
1.195     lukem     626: .if ${_LIBSODIR} != ${LIBDIR}
1.264     jwise     627:        ${INSTALL_SYMLINK} \
1.260     lukem     628:                -l r ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \
1.208     perry     629:                ${DESTDIR}${LIBDIR}/lib${LIB}.so
1.195     lukem     630: .endif
1.83      cgd       631: .endif
1.12      cgd       632: .endif
1.139     tv        633: .endif
1.89      christos  634:
1.179     dmcmahil  635: .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS)
1.89      christos  636: libinstall:: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
1.168     mycroft   637: .PRECIOUS: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
1.197     mycroft   638:
1.269     dbj       639: .if ${MKUPDATE} == "no"
1.197     mycroft   640: .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln)
                    641: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! .MADE
1.89      christos  642: .endif
1.197     mycroft   643: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! llib-l${LIB}.ln
                    644: .else
1.157     fredb     645: .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln)
1.89      christos  646: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: .MADE
                    647: .endif
1.95      mycroft   648: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: llib-l${LIB}.ln
1.197     mycroft   649: .endif
1.238     lukem     650:        ${_MKTARGET_INSTALL}
1.188     tv        651:        ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.264     jwise     652:                ${.ALLSRC} ${DESTDIR}${LINTLIBDIR}
1.58      cgd       653: .endif
1.252     lukem     654: .endif # !target(libinstall)                                           # }
1.1       cgd       655:
1.188     tv        656: ##### Pull in related .mk logic
1.1       cgd       657: .include <bsd.man.mk>
1.57      jtc       658: .include <bsd.nls.mk>
1.91      christos  659: .include <bsd.files.mk>
1.89      christos  660: .include <bsd.inc.mk>
1.109     cjs       661: .include <bsd.links.mk>
1.24      mycroft   662: .include <bsd.dep.mk>
1.117     mycroft   663:
1.188     tv        664: ${TARGETS}:    # ensure existence

CVSweb <webmaster@jp.NetBSD.org>