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

1.271.4.2! matt        1: #      bsd.lib.mk,v 1.271.4.1 2007/11/06 23:13:21 matt 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.271.4.1  matt      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.171     christos  444: lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOLIB} ${DPADD} \
1.88      cgd       445:     ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
1.238     lukem     446:        ${_MKTARGET_BUILD}
1.236     lukem     447:        rm -f lib${LIB}.so.${SHLIB_FULLVERSION}
1.152     fair      448: .if defined(DESTDIR)
1.228     lukem     449:        ${CC} -Wl,-nostdlib -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/ \
1.235     lukem     450:            ${_LIBLDOPTS} \
1.231     lukem     451:            -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} -o ${.TARGET} \
1.221     drochner  452:            -Wl,--whole-archive ${SOLIB} \
                    453:            -Wl,--no-whole-archive ${LDADD} \
1.235     lukem     454:            -L${_GCC_LIBGCCDIR}
1.221     drochner  455: .else
1.231     lukem     456:        ${CC} -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} -o ${.TARGET} \
1.235     lukem     457:            ${_LIBLDOPTS} \
1.221     drochner  458:            -Wl,--whole-archive ${SOLIB} -Wl,--no-whole-archive ${LDADD}
1.152     fair      459: .endif
1.148     lukem     460: .if ${OBJECT_FMT} == "ELF"
1.196     lukem     461: #  We don't use INSTALL_SYMLINK here because this is just
                    462: #  happening inside the build directory/objdir. XXX Why does
                    463: #  this spend so much effort on libraries that aren't live??? XXX
1.241     matt      464:        ${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.${SHLIB_MAJOR}.tmp
1.177     mycroft   465:        mv -f lib${LIB}.so.${SHLIB_MAJOR}.tmp lib${LIB}.so.${SHLIB_MAJOR}
1.241     matt      466:        ${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.tmp
1.177     mycroft   467:        mv -f lib${LIB}.so.tmp lib${LIB}.so
1.133     tv        468: .endif
1.35      pk        469:
1.252     lukem     470: .if !empty(LOBJS)                                                      # {
1.103     mycroft   471: LLIBS?=                -lc
1.58      cgd       472: llib-l${LIB}.ln: ${LOBJS}
1.238     lukem     473:        ${_MKTARGET_COMPILE}
1.236     lukem     474:        rm -f llib-l${LIB}.ln
1.206     thorpej   475: .if defined(DESTDIR)
1.228     lukem     476:        ${LINT} -C${LIB} ${.ALLSRC} -L${DESTDIR}/usr/libdata ${LLIBS}
1.206     thorpej   477: .else
1.228     lukem     478:        ${LINT} -C${LIB} ${.ALLSRC} ${LLIBS}
1.206     thorpej   479: .endif
1.252     lukem     480: .endif                                                                 # }
1.1       cgd       481:
1.246     lukem     482: cleanlib: .PHONY
1.48      mycroft   483:        rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
1.255     thorpej   484:        rm -f lib${LIB}.a ${STOBJS}
1.59      cgd       485:        rm -f lib${LIB}_p.a ${POBJS}
1.266     christos  486:        rm -f lib${LIB}_g.a ${GOBJS}
1.133     tv        487:        rm -f lib${LIB}_pic.a lib${LIB}.so.* lib${LIB}.so ${SOBJS}
1.266     christos  488:        rm -f ${STOBJS:=.tmp} ${POBJS:=.tmp} ${SOBJS:=.tmp} ${GOBJS:=.tmp}
1.59      cgd       489:        rm -f llib-l${LIB}.ln ${LOBJS}
1.1       cgd       490:
1.252     lukem     491:
                    492: .if !target(libinstall)                                                        # {
1.148     lukem     493: # Make sure it gets defined, in case MKPIC==no && MKLINKLIB==no
1.139     tv        494: libinstall::
                    495:
1.234     lukem     496: .if ${MKLINKLIB} != "no" && ${MKSTATICLIB} != "no"
1.89      christos  497: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.168     mycroft   498: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.197     mycroft   499:
1.269     dbj       500: .if ${MKUPDATE} == "no"
1.197     mycroft   501: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a)
                    502: ${DESTDIR}${LIBDIR}/lib${LIB}.a! .MADE
1.89      christos  503: .endif
1.197     mycroft   504: ${DESTDIR}${LIBDIR}/lib${LIB}.a! lib${LIB}.a __archiveinstall
                    505: .else
1.157     fredb     506: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a)
1.89      christos  507: ${DESTDIR}${LIBDIR}/lib${LIB}.a: .MADE
                    508: .endif
                    509: ${DESTDIR}${LIBDIR}/lib${LIB}.a: lib${LIB}.a __archiveinstall
1.130     tv        510: .endif
1.197     mycroft   511: .endif
1.89      christos  512:
1.149     lukem     513: .if ${MKPROFILE} != "no"
1.89      christos  514: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.168     mycroft   515: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.197     mycroft   516:
1.269     dbj       517: .if ${MKUPDATE} == "no"
1.197     mycroft   518: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a)
                    519: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a! .MADE
1.32      pk        520: .endif
1.197     mycroft   521: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a! lib${LIB}_p.a __archiveinstall
                    522: .else
1.157     fredb     523: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a)
1.89      christos  524: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: .MADE
                    525: .endif
                    526: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: lib${LIB}_p.a __archiveinstall
                    527: .endif
1.197     mycroft   528: .endif
1.89      christos  529:
1.268     lukem     530: .if ${MKDEBUGLIB} != "no"
1.266     christos  531: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a
                    532: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a
                    533:
1.269     dbj       534: .if ${MKUPDATE} == "no"
1.266     christos  535: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_g.a)
                    536: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a! .MADE
                    537: .endif
                    538: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a! lib${LIB}_g.a __archiveinstall
                    539: .else
                    540: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_g.a)
                    541: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a: .MADE
                    542: .endif
                    543: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a: lib${LIB}_g.a __archiveinstall
                    544: .endif
                    545: .endif
                    546:
1.149     lukem     547: .if ${MKPIC} != "no" && ${MKPICINSTALL} != "no"
1.168     mycroft   548: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.160     simonb    549: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.197     mycroft   550:
1.269     dbj       551: .if ${MKUPDATE} == "no"
1.197     mycroft   552: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a)
                    553: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! .MADE
1.89      christos  554: .endif
1.197     mycroft   555: .if ${MKPICLIB} == "no"
                    556: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}.a __archivesymlinkpic
                    557: .else
                    558: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}_pic.a __archiveinstall
                    559: .endif
                    560: .else
1.157     fredb     561: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a)
1.89      christos  562: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: .MADE
1.33      pk        563: .endif
1.160     simonb    564: .if ${MKPICLIB} == "no"
1.197     mycroft   565: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}.a __archivesymlinkpic
1.160     simonb    566: .else
1.89      christos  567: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}_pic.a __archiveinstall
1.160     simonb    568: .endif
1.89      christos  569: .endif
1.197     mycroft   570: .endif
1.89      christos  571:
1.171     christos  572: .if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION)
1.195     lukem     573: libinstall:: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
                    574: .PRECIOUS: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
1.197     mycroft   575:
1.269     dbj       576: .if ${MKUPDATE} == "no"
1.197     mycroft   577: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION})
                    578: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}! .MADE
1.89      christos  579: .endif
1.197     mycroft   580: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}! lib${LIB}.so.${SHLIB_FULLVERSION}
                    581: .else
1.171     christos  582: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION})
1.195     lukem     583: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: .MADE
1.89      christos  584: .endif
1.195     lukem     585: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: lib${LIB}.so.${SHLIB_FULLVERSION}
1.197     mycroft   586: .endif
1.238     lukem     587:        ${_MKTARGET_INSTALL}
1.188     tv        588:        ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.264     jwise     589:                ${.ALLSRC} ${.TARGET}
1.195     lukem     590: .if ${_LIBSODIR} != ${LIBDIR}
1.264     jwise     591:        ${INSTALL_SYMLINK} \
1.261     lukem     592:                -l r ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \
1.208     perry     593:                ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
1.195     lukem     594: .endif
1.148     lukem     595: .if ${OBJECT_FMT} == "a.out" && !defined(DESTDIR)
1.195     lukem     596:        /sbin/ldconfig -m ${_LIBSODIR} ${LIBDIR}
1.146     thorpej   597: .endif
1.148     lukem     598: .if ${OBJECT_FMT} == "ELF"
1.264     jwise     599:        ${INSTALL_SYMLINK} \
1.208     perry     600:                lib${LIB}.so.${SHLIB_FULLVERSION} \
                    601:                ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_MAJOR}
1.195     lukem     602: .if ${_LIBSODIR} != ${LIBDIR}
1.264     jwise     603:        ${INSTALL_SYMLINK} \
1.265     christos  604:                -l r ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \
1.208     perry     605:                ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
1.195     lukem     606: .endif
1.148     lukem     607: .if ${MKLINKLIB} != "no"
1.264     jwise     608:        ${INSTALL_SYMLINK} \
1.208     perry     609:                lib${LIB}.so.${SHLIB_FULLVERSION} \
                    610:                ${DESTDIR}${_LIBSODIR}/lib${LIB}.so
1.195     lukem     611: .if ${_LIBSODIR} != ${LIBDIR}
1.264     jwise     612:        ${INSTALL_SYMLINK} \
1.260     lukem     613:                -l r ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \
1.208     perry     614:                ${DESTDIR}${LIBDIR}/lib${LIB}.so
1.195     lukem     615: .endif
1.83      cgd       616: .endif
1.12      cgd       617: .endif
1.139     tv        618: .endif
1.89      christos  619:
1.179     dmcmahil  620: .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS)
1.89      christos  621: libinstall:: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
1.168     mycroft   622: .PRECIOUS: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
1.197     mycroft   623:
1.269     dbj       624: .if ${MKUPDATE} == "no"
1.197     mycroft   625: .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln)
                    626: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! .MADE
1.89      christos  627: .endif
1.197     mycroft   628: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! llib-l${LIB}.ln
                    629: .else
1.157     fredb     630: .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln)
1.89      christos  631: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: .MADE
                    632: .endif
1.95      mycroft   633: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: llib-l${LIB}.ln
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} ${DESTDIR}${LINTLIBDIR}
1.58      cgd       638: .endif
1.252     lukem     639: .endif # !target(libinstall)                                           # }
1.1       cgd       640:
1.188     tv        641: ##### Pull in related .mk logic
1.1       cgd       642: .include <bsd.man.mk>
1.57      jtc       643: .include <bsd.nls.mk>
1.91      christos  644: .include <bsd.files.mk>
1.89      christos  645: .include <bsd.inc.mk>
1.109     cjs       646: .include <bsd.links.mk>
1.24      mycroft   647: .include <bsd.dep.mk>
1.117     mycroft   648:
1.188     tv        649: ${TARGETS}:    # ensure existence

CVSweb <webmaster@jp.NetBSD.org>