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

1.122   ! cgd         1: #      $NetBSD: bsd.lib.mk,v 1.121 1997/11/05 05:34:24 thorpej 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.122   ! cgd        96:        @${COMPILE.c} ${.IMPSRC} -o ${.TARGET}.o
1.62      christos   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:
1.121     thorpej   113:        ${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
1.58      cgd       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}
1.122   ! cgd       135:        @${COMPILE.m} ${.IMPSRC} -o ${.TARGET}.o
1.118     lukem     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
1.1       cgd       150:
1.40      cgd       151: .S.o .s.o:
1.80      christos  152:        @echo ${COMPILE.S:Q} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
1.69      jtc       153:        @${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
1.62      christos  154:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                    155:        @rm -f ${.TARGET}.o
1.1       cgd       156:
1.40      cgd       157: .S.po .s.po:
1.80      christos  158:        @echo ${COMPILE.S:Q} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
1.75      jtc       159:        @${COMPILE.S} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
1.62      christos  160:        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
                    161:        @rm -f ${.TARGET}.o
1.1       cgd       162:
1.40      cgd       163: .S.so .s.so:
1.107     jonathan  164:        @echo ${COMPILE.S:Q} ${CAPICFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
                    165:        @${COMPILE.S} ${CAPICFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
1.62      christos  166:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                    167:        @rm -f ${.TARGET}.o
1.27      pk        168:
1.58      cgd       169:
1.1       cgd       170: .if !defined(NOPROFILE)
                    171: _LIBS=lib${LIB}.a lib${LIB}_p.a
                    172: .else
                    173: _LIBS=lib${LIB}.a
                    174: .endif
                    175:
1.27      pk        176: .if !defined(NOPIC)
                    177: _LIBS+=lib${LIB}_pic.a
1.37      cgd       178: .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
                    179: _LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.27      pk        180: .endif
1.35      pk        181: .endif
1.27      pk        182:
1.58      cgd       183: .if !defined(NOLINT)
                    184: _LIBS+=llib-l${LIB}.ln
1.27      pk        185: .endif
                    186:
1.102     mycroft   187: all: ${SRCS} ${_LIBS}
1.1       cgd       188:
1.90      christos  189: __archivebuild: .USE
1.89      christos  190:        @rm -f ${.TARGET}
1.120     gwr       191:        @${AR} cq ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC} | ${TSORT}`
1.89      christos  192:        ${RANLIB} ${.TARGET}
                    193:
                    194: __archiveinstall: .USE
                    195:        ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 ${.ALLSRC} \
                    196:                ${.TARGET}
                    197:        ${RANLIB} -t ${.TARGET}
                    198:        chmod ${LIBMODE} ${.TARGET}
                    199:
1.104     mycroft   200: DPSRCS+=       ${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c}
1.103     mycroft   201: CLEANFILES+=   ${DPSRCS}
                    202:
                    203: OBJS+=         ${SRCS:N*.h:N*.sh:R:S/$/.o/g}
1.89      christos  204: lib${LIB}.a:: ${OBJS} __archivebuild
1.1       cgd       205:        @echo building standard ${LIB} library
                    206:
1.103     mycroft   207: POBJS+=                ${OBJS:.o=.po}
1.89      christos  208: lib${LIB}_p.a:: ${POBJS} __archivebuild
1.1       cgd       209:        @echo building profiled ${LIB} library
                    210:
1.103     mycroft   211: SOBJS+=                ${OBJS:.o=.so}
1.89      christos  212: lib${LIB}_pic.a:: ${SOBJS} __archivebuild
1.27      pk        213:        @echo building shared object ${LIB} library
                    214:
1.88      cgd       215: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}_pic.a ${DPADD} \
                    216:     ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
1.38      cgd       217:        @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
1.37      cgd       218:        @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.86      jonathan  219: .if (${SHLIB_TYPE} == "a.out")
1.53      pk        220:        $(LD) -x -Bshareable -Bforcearchive \
1.115     cjs       221:            -o ${.TARGET} lib${LIB}_pic.a ${LDADD}
1.86      jonathan  222: .elif (${SHLIB_TYPE} == "ELF")
1.89      christos  223:        $(LD) -x -shared -o ${.TARGET} \
1.86      jonathan  224:            -soname lib${LIB}.so.${SHLIB_SOVERSION}  ${SHLIB_LDSTARTFILE} \
1.115     cjs       225:            --whole-archive lib${LIB}_pic.a --no-whole-archive ${LDADD} \
                    226:            ${SHLIB_LDENDFILE}
1.72      cgd       227: .endif
1.35      pk        228:
1.103     mycroft   229: LOBJS+=                ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
                    230: LLIBS?=                -lc
1.58      cgd       231: llib-l${LIB}.ln: ${LOBJS}
                    232:        @echo building llib-l${LIB}.ln
                    233:        @rm -f llib-l${LIB}.ln
                    234:        @${LINT} -C${LIB} ${LOBJS} ${LLIBS}
1.1       cgd       235:
1.81      cgd       236: cleanlib:
1.48      mycroft   237:        rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
1.59      cgd       238:        rm -f lib${LIB}.a ${OBJS}
                    239:        rm -f lib${LIB}_p.a ${POBJS}
1.61      cgd       240:        rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
1.59      cgd       241:        rm -f llib-l${LIB}.ln ${LOBJS}
1.1       cgd       242:
1.26      mycroft   243: .if defined(SRCS)
1.64      christos  244: afterdepend: .depend
1.1       cgd       245:        @(TMP=/tmp/_depend$$$$; \
1.79      cgd       246:            sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.ln:/' \
1.58      cgd       247:              < .depend > $$TMP; \
1.1       cgd       248:            mv $$TMP .depend)
1.26      mycroft   249: .endif
1.1       cgd       250:
1.97      mycroft   251: .if !target(libinstall)
1.89      christos  252: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.a
                    253: .if !defined(UPDATE)
                    254: .PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}.a
                    255: .endif
                    256: .if !defined(BUILD)
                    257: ${DESTDIR}${LIBDIR}/lib${LIB}.a: .MADE
                    258: .endif
                    259:
1.95      mycroft   260: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.89      christos  261: ${DESTDIR}${LIBDIR}/lib${LIB}.a: lib${LIB}.a __archiveinstall
                    262:
1.12      cgd       263: .if !defined(NOPROFILE)
1.89      christos  264: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
                    265: .if !defined(UPDATE)
                    266: .PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.32      pk        267: .endif
1.89      christos  268: .if !defined(BUILD)
                    269: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: .MADE
                    270: .endif
                    271:
1.95      mycroft   272: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.89      christos  273: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: lib${LIB}_p.a __archiveinstall
                    274: .endif
                    275:
1.39      pk        276: .if !defined(NOPIC)
1.89      christos  277: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
                    278: .if !defined(UPDATE)
                    279: .PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
                    280: .endif
                    281: .if !defined(BUILD)
                    282: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: .MADE
1.33      pk        283: .endif
1.89      christos  284:
1.95      mycroft   285: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.89      christos  286: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}_pic.a __archiveinstall
                    287: .endif
                    288:
1.37      cgd       289: .if !defined(NOPIC) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
1.89      christos  290: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
                    291: .if !defined(UPDATE)
                    292: .PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
                    293: .endif
                    294: .if !defined(BUILD)
                    295: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: .MADE
                    296: .endif
1.92      mikel     297:
1.95      mycroft   298: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.89      christos  299: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
                    300:        ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} ${.ALLSRC} \
                    301:                ${.TARGET}
1.86      jonathan  302: .if (${SHLIB_TYPE} == "ELF")
1.83      cgd       303:        rm -f ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
                    304:        ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
                    305:            ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
                    306:        rm -f ${DESTDIR}${LIBDIR}/lib${LIB}.so
                    307:        ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
                    308:            ${DESTDIR}${LIBDIR}/lib${LIB}.so
                    309: .endif
1.12      cgd       310: .endif
1.89      christos  311:
1.58      cgd       312: .if !defined(NOLINT)
1.89      christos  313: libinstall:: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
                    314: .if !defined(UPDATE)
                    315: .PHONY: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
                    316: .endif
                    317: .if !defined(BUILD)
                    318: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: .MADE
                    319: .endif
                    320:
1.95      mycroft   321: .PRECIOUS: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
                    322: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: llib-l${LIB}.ln
1.73      thorpej   323:        ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.58      cgd       324:            llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
                    325: .endif
1.1       cgd       326: .endif
                    327:
                    328: .include <bsd.man.mk>
1.57      jtc       329: .include <bsd.nls.mk>
1.91      christos  330: .include <bsd.files.mk>
1.89      christos  331: .include <bsd.inc.mk>
1.109     cjs       332: .include <bsd.links.mk>
1.24      mycroft   333: .include <bsd.dep.mk>
1.66      christos  334: .include <bsd.sys.mk>
1.117     mycroft   335:
                    336: # Make sure all of the standard targets are defined, even if they do nothing.
                    337: lint regress:

CVSweb <webmaster@jp.NetBSD.org>