[BACK]Return to bsd.lib.mk CVS log [TXT][DIR] Up to [local] / src / share / mk

Annotation of src/share/mk/bsd.lib.mk, Revision 1.6

1.6     ! pefo        1: #      $OpenBSD: bsd.lib.mk,v 1.5 1996/03/05 11:12:41 mickey Exp $
1.5       mickey      2: #      $NetBSD: bsd.lib.mk,v 1.67 1996/01/17 20:39:26 mycroft Exp $
1.1       deraadt     3: #      @(#)bsd.lib.mk  5.26 (Berkeley) 5/2/91
                      4:
                      5: .if exists(${.CURDIR}/../Makefile.inc)
                      6: .include "${.CURDIR}/../Makefile.inc"
                      7: .endif
                      8:
                      9: .include <bsd.own.mk>                          # for 'NOPIC' definition
                     10:
                     11: .if exists(${.CURDIR}/shlib_version)
                     12: SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major
                     13: SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor
                     14: .endif
                     15:
                     16: .MAIN: all
                     17:
                     18: # prefer .S to a .c, add .po, remove stuff not used in the BSD libraries.
                     19: # .so used for PIC object files.  .ln used for lint output files.
                     20: .SUFFIXES:
                     21: .SUFFIXES: .out .o .po .so .S .s .c .cc .C .f .y .l .ln .m4
                     22:
                     23: .c.o:
                     24:        @echo "${COMPILE.c} ${.IMPSRC}"
                     25:        @${COMPILE.c} ${.IMPSRC}  -o ${.TARGET}.o
                     26:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     27:        @rm -f ${.TARGET}.o
                     28:
                     29: .c.po:
                     30:        @echo "${COMPILE.c} -p ${.IMPSRC} -o ${.TARGET}"
                     31:        @${COMPILE.c} -p ${.IMPSRC} -o ${.TARGET}.o
                     32:        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
                     33:        @rm -f ${.TARGET}.o
                     34:
                     35: .c.so:
                     36:        @echo "${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}"
                     37:        @${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
                     38:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     39:        @rm -f ${.TARGET}.o
                     40:
                     41: .c.ln:
                     42:        ${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} -i ${.IMPSRC}
                     43:
                     44: .cc.o .C.o:
                     45:        @echo "${COMPILE.cc} ${.IMPSRC}"
                     46:        @${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}.o
                     47:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     48:        @rm -f ${.TARGET}.o
                     49:
                     50: .cc.po .C.po:
                     51:        @echo "${COMPILE.cc} -p ${.IMPSRC} -o ${.TARGET}"
                     52:        @${COMPILE.cc} -p ${.IMPSRC} -o ${.TARGET}.o
                     53:        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
                     54:        @rm -f ${.TARGET}.o
                     55:
                     56: .cc.so .C.so:
                     57:        @echo "${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}"
                     58:        @${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
                     59:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     60:        @rm -f ${.TARGET}.o
                     61:
                     62: .S.o .s.o:
                     63:        @echo "${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
                     64:                ${AS} -o ${.TARGET}"
                     65:        @${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
                     66:            ${AS} -o ${.TARGET}.o
                     67:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     68:        @rm -f ${.TARGET}.o
                     69:
                     70: .S.po .s.po:
                     71:        @echo "${CPP} -DPROF ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} |\
                     72:            ${AS} -o ${.TARGET}"
                     73:        @${CPP} -DPROF ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
                     74:            ${AS} -o ${.TARGET}.o
                     75:        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
                     76:        @rm -f ${.TARGET}.o
                     77:
                     78: .S.so .s.so:
                     79:        @echo "${CPP} -DPIC ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
                     80:            ${AS} -k -o ${.TARGET}"
                     81:        @${CPP} -DPIC ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
                     82:            ${AS} -k -o ${.TARGET}.o
                     83:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     84:        @rm -f ${.TARGET}.o
                     85:
1.6     ! pefo       86: .if !defined(PICFLAG) && (${MACHINE_ARCH} != "mips")
1.1       deraadt    87: PICFLAG=-fpic
                     88: .endif
                     89:
                     90: .if !defined(NOPROFILE)
                     91: _LIBS=lib${LIB}.a lib${LIB}_p.a
                     92: .else
                     93: _LIBS=lib${LIB}.a
                     94: .endif
                     95:
                     96: .if !defined(NOPIC)
1.6     ! pefo       97: .if (${MACHINE_ARCH} != "mips")
1.1       deraadt    98: _LIBS+=lib${LIB}_pic.a
1.6     ! pefo       99: .endif
1.1       deraadt   100: .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
                    101: _LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
                    102: .endif
                    103: .endif
                    104:
                    105: .if !defined(NOLINT)
                    106: _LIBS+=llib-l${LIB}.ln
                    107: .endif
                    108:
                    109: all: ${_LIBS} _SUBDIRUSE
                    110:
                    111: OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
                    112:
                    113: lib${LIB}.a:: ${OBJS}
                    114:        @echo building standard ${LIB} library
                    115:        @rm -f lib${LIB}.a
1.3       niklas    116:        @${AR} cq lib${LIB}.a `lorder ${OBJS} | tsort -q`
1.1       deraadt   117:        ${RANLIB} lib${LIB}.a
                    118:
                    119: POBJS+=        ${OBJS:.o=.po}
                    120: lib${LIB}_p.a:: ${POBJS}
                    121:        @echo building profiled ${LIB} library
                    122:        @rm -f lib${LIB}_p.a
1.3       niklas    123:        @${AR} cq lib${LIB}_p.a `lorder ${POBJS} | tsort -q`
1.1       deraadt   124:        ${RANLIB} lib${LIB}_p.a
                    125:
                    126: SOBJS+=        ${OBJS:.o=.so}
                    127: lib${LIB}_pic.a:: ${SOBJS}
                    128:        @echo building shared object ${LIB} library
                    129:        @rm -f lib${LIB}_pic.a
1.3       niklas    130:        @${AR} cq lib${LIB}_pic.a `lorder ${SOBJS} | tsort -q`
1.1       deraadt   131:        ${RANLIB} lib${LIB}_pic.a
                    132:
1.6     ! pefo      133: .if (${MACHINE_ARCH} != "mips")
1.1       deraadt   134: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}_pic.a ${DPADD}
                    135:        @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
                    136:        @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
                    137:        $(LD) -x -Bshareable -Bforcearchive \
                    138:            -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} lib${LIB}_pic.a ${LDADD}
1.6     ! pefo      139: .else
        !           140: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}.a ${DPADD}
        !           141:        @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
        !           142:        @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
        !           143:        $(LD) -x -shared --whole-archive -soname lib${LIB}.so.${SHLIB_MAJOR} \
        !           144:            -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} lib${LIB}.a ${LDADD}
        !           145: .endif
1.1       deraadt   146:
                    147: LOBJS+=        ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
                    148: # the following looks XXX to me... -- cgd
                    149: LLIBS?=        -lc
                    150: llib-l${LIB}.ln: ${LOBJS}
                    151:        @echo building llib-l${LIB}.ln
                    152:        @rm -f llib-l${LIB}.ln
                    153:        @${LINT} -C${LIB} ${LOBJS} ${LLIBS}
                    154:
                    155: .if !target(clean)
                    156: clean: _SUBDIRUSE
                    157:        rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
                    158:        rm -f lib${LIB}.a ${OBJS}
                    159:        rm -f lib${LIB}_p.a ${POBJS}
                    160:        rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
                    161:        rm -f llib-l${LIB}.ln ${LOBJS}
                    162: .endif
                    163:
                    164: cleandir: _SUBDIRUSE clean
                    165:
                    166: .if defined(SRCS)
                    167: afterdepend: .depend
                    168:        @(TMP=/tmp/_depend$$$$; \
                    169:            sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so:/' \
                    170:              < .depend > $$TMP; \
                    171:            mv $$TMP .depend)
                    172: .endif
                    173:
                    174: .if !target(install)
                    175: .if !target(beforeinstall)
                    176: beforeinstall:
                    177: .endif
                    178:
                    179: realinstall:
                    180: #      ranlib lib${LIB}.a
                    181:        install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 lib${LIB}.a \
                    182:            ${DESTDIR}${LIBDIR}
                    183:        ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
                    184:        chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
                    185: .if !defined(NOPROFILE)
                    186: #      ranlib lib${LIB}_p.a
                    187:        install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
                    188:            lib${LIB}_p.a ${DESTDIR}${LIBDIR}
                    189:        ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
                    190:        chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
                    191: .endif
1.6     ! pefo      192: .if !defined(NOPIC) && (${MACHINE_ARCH} != "mips")
1.1       deraadt   193: #      ranlib lib${LIB}_pic.a
                    194:        install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
                    195:            lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
                    196:        ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
                    197:        chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
                    198: .endif
                    199: .if !defined(NOPIC) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
                    200:        install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
                    201:            lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} ${DESTDIR}${LIBDIR}
                    202: .endif
                    203: .if !defined(NOLINT)
                    204:        install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
                    205:            llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
                    206: .endif
                    207: .if defined(LINKS) && !empty(LINKS)
                    208:        @set ${LINKS}; \
                    209:        while test $$# -ge 2; do \
                    210:                l=${DESTDIR}$$1; \
                    211:                shift; \
                    212:                t=${DESTDIR}$$1; \
                    213:                shift; \
                    214:                echo $$t -\> $$l; \
                    215:                rm -f $$t; \
                    216:                ln $$l $$t; \
                    217:        done; true
                    218: .endif
                    219:
                    220: install: maninstall _SUBDIRUSE
                    221: maninstall: afterinstall
                    222: afterinstall: realinstall
                    223: realinstall: beforeinstall
                    224: .endif
                    225:
                    226: .if !defined(NOMAN)
                    227: .include <bsd.man.mk>
                    228: .endif
                    229:
                    230: .if !defined(NONLS)
                    231: .include <bsd.nls.mk>
                    232: .endif
                    233:
                    234: .include <bsd.obj.mk>
                    235: .include <bsd.dep.mk>
                    236: .include <bsd.subdir.mk>
1.2       deraadt   237: .include <bsd.sys.mk>