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

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

CVSweb <webmaster@jp.NetBSD.org>