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

1.20    ! espie       1: #      $OpenBSD: bsd.lib.mk,v 1.19 1999/01/27 03:28:51 espie 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.
1.20    ! espie      20: # .m for objective c files.
1.1       deraadt    21: .SUFFIXES:
1.20    ! espie      22: .SUFFIXES: .out .o .po .so .S .s .c .cc .C .cxx .f .y .l .ln .m4 .m
1.1       deraadt    23:
                     24: .c.o:
1.14      grr        25:        @echo "${COMPILE.c} ${.IMPSRC} -o ${.TARGET}"
1.1       deraadt    26:        @${COMPILE.c} ${.IMPSRC}  -o ${.TARGET}.o
                     27:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     28:        @rm -f ${.TARGET}.o
                     29:
                     30: .c.po:
                     31:        @echo "${COMPILE.c} -p ${.IMPSRC} -o ${.TARGET}"
                     32:        @${COMPILE.c} -p ${.IMPSRC} -o ${.TARGET}.o
                     33:        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
                     34:        @rm -f ${.TARGET}.o
                     35:
                     36: .c.so:
                     37:        @echo "${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}"
                     38:        @${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
                     39:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     40:        @rm -f ${.TARGET}.o
                     41:
                     42: .c.ln:
                     43:        ${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} -i ${.IMPSRC}
                     44:
1.16      deraadt    45: .cc.o .C.o .cxx.o:
1.19      espie      46:        @echo "${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}"
1.1       deraadt    47:        @${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}.o
                     48:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     49:        @rm -f ${.TARGET}.o
                     50:
1.16      deraadt    51: .cc.po .C.po .cxx.po:
1.1       deraadt    52:        @echo "${COMPILE.cc} -p ${.IMPSRC} -o ${.TARGET}"
                     53:        @${COMPILE.cc} -p ${.IMPSRC} -o ${.TARGET}.o
                     54:        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
                     55:        @rm -f ${.TARGET}.o
                     56:
1.16      deraadt    57: .cc.so .C.so .cxx.so:
1.1       deraadt    58:        @echo "${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}"
                     59:        @${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
                     60:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     61:        @rm -f ${.TARGET}.o
                     62:
                     63: .S.o .s.o:
                     64:        @echo "${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
                     65:                ${AS} -o ${.TARGET}"
                     66:        @${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
                     67:            ${AS} -o ${.TARGET}.o
                     68:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     69:        @rm -f ${.TARGET}.o
                     70:
                     71: .S.po .s.po:
                     72:        @echo "${CPP} -DPROF ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} |\
                     73:            ${AS} -o ${.TARGET}"
                     74:        @${CPP} -DPROF ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
                     75:            ${AS} -o ${.TARGET}.o
                     76:        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
                     77:        @rm -f ${.TARGET}.o
                     78:
                     79: .S.so .s.so:
                     80:        @echo "${CPP} -DPIC ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
                     81:            ${AS} -k -o ${.TARGET}"
                     82:        @${CPP} -DPIC ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
                     83:            ${AS} -k -o ${.TARGET}.o
                     84:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     85:        @rm -f ${.TARGET}.o
1.7       deraadt    86:
1.18      millert    87: CFLAGS+=       ${COPTS}
1.1       deraadt    88:
1.6       pefo       89: .if !defined(PICFLAG) && (${MACHINE_ARCH} != "mips")
1.1       deraadt    90: PICFLAG=-fpic
1.15      niklas     91: .if ${MACHINE_ARCH} == "m68k"
                     92: # Function CSE makes gas -k not recognize external function calls as lazily
                     93: # resolvable symbols, thus sometimes making ld.so report undefined symbol
                     94: # errors on symbols found in shared library members that would never be
                     95: # called.  Ask niklas@openbsd.org for details.
                     96: PICFLAG+=-fno-function-cse
                     97: .endif
1.1       deraadt    98: .endif
                     99:
                    100: .if !defined(NOPROFILE)
                    101: _LIBS=lib${LIB}.a lib${LIB}_p.a
                    102: .else
                    103: _LIBS=lib${LIB}.a
                    104: .endif
                    105:
                    106: .if !defined(NOPIC)
1.6       pefo      107: .if (${MACHINE_ARCH} != "mips")
1.1       deraadt   108: _LIBS+=lib${LIB}_pic.a
1.6       pefo      109: .endif
1.1       deraadt   110: .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
                    111: _LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
                    112: .endif
                    113: .endif
                    114:
                    115: .if !defined(NOLINT)
                    116: _LIBS+=llib-l${LIB}.ln
                    117: .endif
                    118:
                    119: all: ${_LIBS} _SUBDIRUSE
                    120:
                    121: OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
                    122:
                    123: lib${LIB}.a:: ${OBJS}
                    124:        @echo building standard ${LIB} library
                    125:        @rm -f lib${LIB}.a
1.12      niklas    126:        @${AR} cq lib${LIB}.a `${LORDER} ${OBJS} | tsort -q`
1.1       deraadt   127:        ${RANLIB} lib${LIB}.a
                    128:
                    129: POBJS+=        ${OBJS:.o=.po}
                    130: lib${LIB}_p.a:: ${POBJS}
                    131:        @echo building profiled ${LIB} library
                    132:        @rm -f lib${LIB}_p.a
1.12      niklas    133:        @${AR} cq lib${LIB}_p.a `${LORDER} ${POBJS} | tsort -q`
1.1       deraadt   134:        ${RANLIB} lib${LIB}_p.a
                    135:
                    136: SOBJS+=        ${OBJS:.o=.so}
                    137: lib${LIB}_pic.a:: ${SOBJS}
                    138:        @echo building shared object ${LIB} library
                    139:        @rm -f lib${LIB}_pic.a
1.12      niklas    140:        @${AR} cq lib${LIB}_pic.a `${LORDER} ${SOBJS} | tsort -q`
1.1       deraadt   141:        ${RANLIB} lib${LIB}_pic.a
                    142:
1.6       pefo      143: .if (${MACHINE_ARCH} != "mips")
1.1       deraadt   144: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}_pic.a ${DPADD}
                    145:        @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
                    146:        @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
                    147:        $(LD) -x -Bshareable -Bforcearchive \
                    148:            -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} lib${LIB}_pic.a ${LDADD}
1.6       pefo      149: .else
                    150: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}.a ${DPADD}
                    151:        @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
                    152:        @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
                    153:        $(LD) -x -shared --whole-archive -soname lib${LIB}.so.${SHLIB_MAJOR} \
                    154:            -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} lib${LIB}.a ${LDADD}
                    155: .endif
1.1       deraadt   156:
                    157: LOBJS+=        ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
                    158: # the following looks XXX to me... -- cgd
                    159: LLIBS?=        -lc
                    160: llib-l${LIB}.ln: ${LOBJS}
                    161:        @echo building llib-l${LIB}.ln
                    162:        @rm -f llib-l${LIB}.ln
                    163:        @${LINT} -C${LIB} ${LOBJS} ${LLIBS}
                    164:
                    165: .if !target(clean)
                    166: clean: _SUBDIRUSE
                    167:        rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
                    168:        rm -f lib${LIB}.a ${OBJS}
                    169:        rm -f lib${LIB}_p.a ${POBJS}
                    170:        rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
                    171:        rm -f llib-l${LIB}.ln ${LOBJS}
                    172: .endif
                    173:
                    174: cleandir: _SUBDIRUSE clean
                    175:
                    176: .if defined(SRCS)
                    177: afterdepend: .depend
1.11      deraadt   178:        @(TMP=`mktemp -q /tmp/_dependXXXXXXXXXX`; \
                    179:        if [ $$? -ne 0 ]; then \
                    180:                echo "$$0: cannot create temp file, exiting..."; \
                    181:                exit 1; \
                    182:        fi; \
                    183:        sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so:/' \
1.1       deraadt   184:              < .depend > $$TMP; \
1.11      deraadt   185:        mv $$TMP .depend)
1.1       deraadt   186: .endif
                    187:
                    188: .if !target(install)
                    189: .if !target(beforeinstall)
                    190: beforeinstall:
                    191: .endif
                    192:
                    193: realinstall:
                    194: #      ranlib lib${LIB}.a
1.13      millert   195:        ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 lib${LIB}.a \
1.1       deraadt   196:            ${DESTDIR}${LIBDIR}
1.13      millert   197: .if (${INSTALL_COPY} != "-p")
1.1       deraadt   198:        ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.8       millert   199: .endif
1.1       deraadt   200:        chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
                    201: .if !defined(NOPROFILE)
                    202: #      ranlib lib${LIB}_p.a
1.13      millert   203:        ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
1.1       deraadt   204:            lib${LIB}_p.a ${DESTDIR}${LIBDIR}
1.13      millert   205: .if (${INSTALL_COPY} != "-p")
1.1       deraadt   206:        ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.8       millert   207: .endif
1.1       deraadt   208:        chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
                    209: .endif
1.6       pefo      210: .if !defined(NOPIC) && (${MACHINE_ARCH} != "mips")
1.1       deraadt   211: #      ranlib lib${LIB}_pic.a
1.13      millert   212:        ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
1.1       deraadt   213:            lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
1.13      millert   214: .if (${INSTALL_COPY} != "-p")
1.1       deraadt   215:        ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.8       millert   216: .endif
1.1       deraadt   217:        chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
                    218: .endif
                    219: .if !defined(NOPIC) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
1.13      millert   220:        ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.1       deraadt   221:            lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} ${DESTDIR}${LIBDIR}
                    222: .endif
                    223: .if !defined(NOLINT)
1.13      millert   224:        ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.1       deraadt   225:            llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
                    226: .endif
                    227: .if defined(LINKS) && !empty(LINKS)
                    228:        @set ${LINKS}; \
                    229:        while test $$# -ge 2; do \
1.9       mickey    230:                l=${DESTDIR}${BINDIR}/$$1; \
1.1       deraadt   231:                shift; \
1.9       mickey    232:                t=${DESTDIR}${BINDIR}/$$1; \
1.1       deraadt   233:                shift; \
                    234:                echo $$t -\> $$l; \
                    235:                rm -f $$t; \
                    236:                ln $$l $$t; \
                    237:        done; true
                    238: .endif
                    239:
                    240: install: maninstall _SUBDIRUSE
                    241: maninstall: afterinstall
                    242: afterinstall: realinstall
                    243: realinstall: beforeinstall
                    244: .endif
                    245:
                    246: .if !defined(NOMAN)
                    247: .include <bsd.man.mk>
                    248: .endif
                    249:
                    250: .if !defined(NONLS)
                    251: .include <bsd.nls.mk>
                    252: .endif
                    253:
                    254: .include <bsd.obj.mk>
                    255: .include <bsd.dep.mk>
                    256: .include <bsd.subdir.mk>
1.2       deraadt   257: .include <bsd.sys.mk>