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

1.118   ! lukem       1: #      $NetBSD: bsd.lib.mk,v 1.117 1997/10/11 08:16:26 mycroft Exp $
1.92      mikel       2: #      @(#)bsd.lib.mk  8.3 (Berkeley) 4/22/94
1.1       cgd         3:
1.117     mycroft     4: .if !target(__initialized__)
                      5: __initialized__:
1.1       cgd         6: .if exists(${.CURDIR}/../Makefile.inc)
                      7: .include "${.CURDIR}/../Makefile.inc"
                      8: .endif
1.97      mycroft     9: .include <bsd.own.mk>
1.117     mycroft    10: .include <bsd.obj.mk>
                     11: .MAIN:         all
                     12: .endif
1.97      mycroft    13:
1.96      mycroft    14: .PHONY:                cleanlib libinstall
1.103     mycroft    15: realinstall:   libinstall
1.98      mycroft    16: clean cleandir:        cleanlib
1.1       cgd        17:
1.35      pk         18: .if exists(${.CURDIR}/shlib_version)
1.37      cgd        19: SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major
                     20: SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor
1.35      pk         21: .endif
1.1       cgd        22:
1.101     mycroft    23: # add additional suffixes not exported.
                     24: # .po is used for profiling object files.
                     25: # .so is used for PIC object files.
1.118   ! lukem      26: .SUFFIXES: .out .a .ln .so .po .o .s .S .c .cc .C .m .F .f .r .y .l .cl .p .h
        !            27: .SUFFIXES: .sh .m4 .m
1.82      mikel      28:
1.86      jonathan   29:
                     30: # Set PICFLAGS to cc flags for producing position-independent code,
                     31: # if not already set.  Includes -DPIC, if required.
                     32:
                     33: # Data-driven table using make variables to control  how shared libraries
                     34: # are built for different platforms and object formats.
                     35: # SHLIB_TYPE:          currently either "ELF" or "a.out".
                     36: # SHLIB_SOVERSION:     version number to be compiled into a shared library
                     37: #                      via -soname. Usualy ${SHLIB_MAJOR} on ELF.
                     38: #                      NetBSD/pmax used to use ${SHLIB_MAJOR}.{SHLIB-MINOR}.
                     39: # SHLIB_LDSTARTFILE:   ???
                     40: # SHLIB_LDENDTILE:     ??
1.107     jonathan   41: # CPPICFLAGS:  flags for ${CPP} to preprocess  .[sS]  files for ${AS}
                     42: # CPICFLAGS:   flags for ${CC} to compile  .[cC] files to .so objects.
                     43: # CAPICFLAGS   flags for {$CC} to compiling .[Ss] files
                     44: #                      (usually just ${CPPPICFLAGS} ${CPICFLAGS})
                     45: # APICFLAGS:   flags for ${AS} to assemble .[sS]  to .so objects.
1.86      jonathan   46:
                     47: .if (${MACHINE_ARCH} == "alpha")
                     48:
                     49: SHLIB_TYPE=ELF
1.115     cjs        50: SHLIB_LDSTARTFILE= ${DESTDIR}/usr/lib/crtbeginS.o
                     51: SHLIB_LDENDFILE= ${DESTDIR}/usr/lib/crtendS.o
1.86      jonathan   52: SHLIB_SOVERSION=${SHLIB_MAJOR}
                     53: CPICFLAGS ?= -fpic -DPIC
1.107     jonathan   54: CPPPICFLAGS?= -DPIC
                     55: CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
                     56: APICFLAGS ?=
1.86      jonathan   57:
                     58: .elif (${MACHINE_ARCH} == "mips")
                     59:
                     60: SHLIB_TYPE=ELF
                     61: # still use gnu-derived ld.so on pmax; don't have or need lib<>.so support.
                     62: SHLIB_LDSTARTFILE=
                     63: SHLIB_LDENDFILE=
                     64: SHLIB_SOVERSION=${SHLIB_MAJOR}
                     65:
                     66: # On mips, all libs need to be compiled with ABIcalls, not just sharedlibs.
                     67: CPICFLAGS?=
                     68: APICFLAGS?=
                     69: #CPICFLAGS?= -fpic -DPIC
                     70: #APICFLAGS?= -DPIC
                     71:
                     72: # so turn shlib PIC flags on for ${CPP}, ${CC}, and ${AS} as follows:
                     73: AINC+=-DPIC -DABICALLS
                     74: COPTS+=        -fPIC ${AINC}
                     75: AFLAGS+= -fPIC
                     76: AS+=   -KPIC
                     77:
                     78: .else
                     79:
                     80: SHLIB_TYPE=a.out
1.88      cgd        81: SHLIB_LDSTARTFILE=
                     82: SHLIB_LDENDFILE=
1.86      jonathan   83: SHLIB_SOVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}
1.116     pk         84: CPICFLAGS?= -fpic -DPIC
1.107     jonathan   85: CPPPICFLAGS?= -DPIC
                     86: CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
                     87: APICFLAGS?= -k
1.86      jonathan   88:
                     89: .endif
                     90:
                     91:
1.82      mikel      92: CFLAGS+=       ${COPTS}
1.1       cgd        93:
                     94: .c.o:
1.80      christos   95:        @echo ${COMPILE.c:Q} ${.IMPSRC}
1.62      christos   96:        @${COMPILE.c} ${.IMPSRC}  -o ${.TARGET}.o
                     97:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     98:        @rm -f ${.TARGET}.o
1.1       cgd        99:
                    100: .c.po:
1.80      christos  101:        @echo ${COMPILE.c:Q} -pg ${.IMPSRC} -o ${.TARGET}
1.68      cgd       102:        @${COMPILE.c} -pg ${.IMPSRC} -o ${.TARGET}.o
1.62      christos  103:        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
                    104:        @rm -f ${.TARGET}.o
1.17      mycroft   105:
1.27      pk        106: .c.so:
1.86      jonathan  107:        @echo ${COMPILE.c:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
                    108:        @${COMPILE.c} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
1.62      christos  109:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                    110:        @rm -f ${.TARGET}.o
1.27      pk        111:
1.58      cgd       112: .c.ln:
                    113:        ${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} -i ${.IMPSRC}
                    114:
1.18      mycroft   115: .cc.o .C.o:
1.80      christos  116:        @echo ${COMPILE.cc:Q} ${.IMPSRC}
1.62      christos  117:        @${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}.o
1.63      jtc       118:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
1.62      christos  119:        @rm -f ${.TARGET}.o
1.17      mycroft   120:
1.18      mycroft   121: .cc.po .C.po:
1.80      christos  122:        @echo ${COMPILE.cc:Q} -pg ${.IMPSRC} -o ${.TARGET}
1.68      cgd       123:        @${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}.o
1.62      christos  124:        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
                    125:        @rm -f ${.TARGET}.o
1.28      cgd       126:
                    127: .cc.so .C.so:
1.86      jonathan  128:        @echo ${COMPILE.cc:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
                    129:        @${COMPILE.cc} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
1.62      christos  130:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                    131:        @rm -f ${.TARGET}.o
1.118   ! lukem     132:
        !           133: .m.o:
        !           134:        @echo ${COMPILE.m:Q} ${.IMPSRC}
        !           135:        @${COMPILE.m} ${.IMPSRC}  -o ${.TARGET}.o
        !           136:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
        !           137:        @rm -f ${.TARGET}.o
        !           138:
        !           139: .m.po:
        !           140:        @echo ${COMPILE.m:Q} -pg ${.IMPSRC} -o ${.TARGET}
        !           141:        @${COMPILE.m} -pg ${.IMPSRC} -o ${.TARGET}.o
        !           142:        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
        !           143:        @rm -f ${.TARGET}.o
        !           144:
        !           145: .m.so:
        !           146:        @echo ${COMPILE.m:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
        !           147:        @${COMPILE.m} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
        !           148:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
        !           149:        @rm -f ${.TARGET}.o
        !           150:
        !           151: .m.ln:
        !           152:        ${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} -i ${.IMPSRC}
1.1       cgd       153:
1.40      cgd       154: .S.o .s.o:
1.80      christos  155:        @echo ${COMPILE.S:Q} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
1.69      jtc       156:        @${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
1.62      christos  157:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                    158:        @rm -f ${.TARGET}.o
1.1       cgd       159:
1.40      cgd       160: .S.po .s.po:
1.80      christos  161:        @echo ${COMPILE.S:Q} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
1.75      jtc       162:        @${COMPILE.S} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
1.62      christos  163:        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
                    164:        @rm -f ${.TARGET}.o
1.1       cgd       165:
1.40      cgd       166: .S.so .s.so:
1.107     jonathan  167:        @echo ${COMPILE.S:Q} ${CAPICFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
                    168:        @${COMPILE.S} ${CAPICFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
1.62      christos  169:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                    170:        @rm -f ${.TARGET}.o
1.27      pk        171:
1.58      cgd       172:
1.1       cgd       173: .if !defined(NOPROFILE)
                    174: _LIBS=lib${LIB}.a lib${LIB}_p.a
                    175: .else
                    176: _LIBS=lib${LIB}.a
                    177: .endif
                    178:
1.27      pk        179: .if !defined(NOPIC)
                    180: _LIBS+=lib${LIB}_pic.a
1.37      cgd       181: .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
                    182: _LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.27      pk        183: .endif
1.35      pk        184: .endif
1.27      pk        185:
1.58      cgd       186: .if !defined(NOLINT)
                    187: _LIBS+=llib-l${LIB}.ln
1.27      pk        188: .endif
                    189:
1.102     mycroft   190: all: ${SRCS} ${_LIBS}
1.1       cgd       191:
1.90      christos  192: __archivebuild: .USE
1.89      christos  193:        @rm -f ${.TARGET}
1.93      thorpej   194:        @${AR} cq ${.TARGET} `NM=${NM} lorder ${.ALLSRC} | tsort -q`
1.89      christos  195:        ${RANLIB} ${.TARGET}
                    196:
                    197: __archiveinstall: .USE
                    198:        ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 ${.ALLSRC} \
                    199:                ${.TARGET}
                    200:        ${RANLIB} -t ${.TARGET}
                    201:        chmod ${LIBMODE} ${.TARGET}
                    202:
1.104     mycroft   203: DPSRCS+=       ${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c}
1.103     mycroft   204: CLEANFILES+=   ${DPSRCS}
                    205:
                    206: OBJS+=         ${SRCS:N*.h:N*.sh:R:S/$/.o/g}
1.89      christos  207: lib${LIB}.a:: ${OBJS} __archivebuild
1.1       cgd       208:        @echo building standard ${LIB} library
                    209:
1.103     mycroft   210: POBJS+=                ${OBJS:.o=.po}
1.89      christos  211: lib${LIB}_p.a:: ${POBJS} __archivebuild
1.1       cgd       212:        @echo building profiled ${LIB} library
                    213:
1.103     mycroft   214: SOBJS+=                ${OBJS:.o=.so}
1.89      christos  215: lib${LIB}_pic.a:: ${SOBJS} __archivebuild
1.27      pk        216:        @echo building shared object ${LIB} library
                    217:
1.88      cgd       218: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}_pic.a ${DPADD} \
                    219:     ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
1.38      cgd       220:        @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
1.37      cgd       221:        @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.86      jonathan  222: .if (${SHLIB_TYPE} == "a.out")
1.53      pk        223:        $(LD) -x -Bshareable -Bforcearchive \
1.115     cjs       224:            -o ${.TARGET} lib${LIB}_pic.a ${LDADD}
1.86      jonathan  225: .elif (${SHLIB_TYPE} == "ELF")
1.89      christos  226:        $(LD) -x -shared -o ${.TARGET} \
1.86      jonathan  227:            -soname lib${LIB}.so.${SHLIB_SOVERSION}  ${SHLIB_LDSTARTFILE} \
1.115     cjs       228:            --whole-archive lib${LIB}_pic.a --no-whole-archive ${LDADD} \
                    229:            ${SHLIB_LDENDFILE}
1.72      cgd       230: .endif
1.35      pk        231:
1.103     mycroft   232: LOBJS+=                ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
                    233: LLIBS?=                -lc
1.58      cgd       234: llib-l${LIB}.ln: ${LOBJS}
                    235:        @echo building llib-l${LIB}.ln
                    236:        @rm -f llib-l${LIB}.ln
                    237:        @${LINT} -C${LIB} ${LOBJS} ${LLIBS}
1.1       cgd       238:
1.81      cgd       239: cleanlib:
1.48      mycroft   240:        rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
1.59      cgd       241:        rm -f lib${LIB}.a ${OBJS}
                    242:        rm -f lib${LIB}_p.a ${POBJS}
1.61      cgd       243:        rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
1.59      cgd       244:        rm -f llib-l${LIB}.ln ${LOBJS}
1.1       cgd       245:
1.26      mycroft   246: .if defined(SRCS)
1.64      christos  247: afterdepend: .depend
1.1       cgd       248:        @(TMP=/tmp/_depend$$$$; \
1.79      cgd       249:            sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.ln:/' \
1.58      cgd       250:              < .depend > $$TMP; \
1.1       cgd       251:            mv $$TMP .depend)
1.26      mycroft   252: .endif
1.1       cgd       253:
1.97      mycroft   254: .if !target(libinstall)
1.89      christos  255: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.a
                    256: .if !defined(UPDATE)
                    257: .PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}.a
                    258: .endif
                    259: .if !defined(BUILD)
                    260: ${DESTDIR}${LIBDIR}/lib${LIB}.a: .MADE
                    261: .endif
                    262:
1.95      mycroft   263: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.89      christos  264: ${DESTDIR}${LIBDIR}/lib${LIB}.a: lib${LIB}.a __archiveinstall
                    265:
1.12      cgd       266: .if !defined(NOPROFILE)
1.89      christos  267: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
                    268: .if !defined(UPDATE)
                    269: .PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.32      pk        270: .endif
1.89      christos  271: .if !defined(BUILD)
                    272: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: .MADE
                    273: .endif
                    274:
1.95      mycroft   275: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.89      christos  276: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: lib${LIB}_p.a __archiveinstall
                    277: .endif
                    278:
1.39      pk        279: .if !defined(NOPIC)
1.89      christos  280: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
                    281: .if !defined(UPDATE)
                    282: .PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
                    283: .endif
                    284: .if !defined(BUILD)
                    285: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: .MADE
1.33      pk        286: .endif
1.89      christos  287:
1.95      mycroft   288: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.89      christos  289: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}_pic.a __archiveinstall
                    290: .endif
                    291:
1.37      cgd       292: .if !defined(NOPIC) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
1.89      christos  293: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
                    294: .if !defined(UPDATE)
                    295: .PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
                    296: .endif
                    297: .if !defined(BUILD)
                    298: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: .MADE
                    299: .endif
1.92      mikel     300:
1.95      mycroft   301: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.89      christos  302: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
                    303:        ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} ${.ALLSRC} \
                    304:                ${.TARGET}
1.86      jonathan  305: .if (${SHLIB_TYPE} == "ELF")
1.83      cgd       306:        rm -f ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
                    307:        ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
                    308:            ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
                    309:        rm -f ${DESTDIR}${LIBDIR}/lib${LIB}.so
                    310:        ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
                    311:            ${DESTDIR}${LIBDIR}/lib${LIB}.so
                    312: .endif
1.12      cgd       313: .endif
1.89      christos  314:
1.58      cgd       315: .if !defined(NOLINT)
1.89      christos  316: libinstall:: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
                    317: .if !defined(UPDATE)
                    318: .PHONY: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
                    319: .endif
                    320: .if !defined(BUILD)
                    321: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: .MADE
                    322: .endif
                    323:
1.95      mycroft   324: .PRECIOUS: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
                    325: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: llib-l${LIB}.ln
1.73      thorpej   326:        ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.58      cgd       327:            llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
                    328: .endif
1.1       cgd       329: .endif
                    330:
                    331: .include <bsd.man.mk>
1.57      jtc       332: .include <bsd.nls.mk>
1.91      christos  333: .include <bsd.files.mk>
1.89      christos  334: .include <bsd.inc.mk>
1.109     cjs       335: .include <bsd.links.mk>
1.24      mycroft   336: .include <bsd.dep.mk>
1.66      christos  337: .include <bsd.sys.mk>
1.117     mycroft   338:
                    339: # Make sure all of the standard targets are defined, even if they do nothing.
                    340: lint regress:

CVSweb <webmaster@jp.NetBSD.org>