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

1.45    ! deraadt     1: #      $OpenBSD: bsd.lib.mk,v 1.44 2005/09/12 17:10:40 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:
1.25      mickey      5: .include <bsd.own.mk>                          # for 'NOPIC' definition
                      6:
1.1       deraadt     7: .if exists(${.CURDIR}/../Makefile.inc)
                      8: .include "${.CURDIR}/../Makefile.inc"
                      9: .endif
                     10:
                     11: .if exists(${.CURDIR}/shlib_version)
1.33      espie      12: .include "${.CURDIR}/shlib_version"
1.34      espie      13: SHLIB_MAJOR=${major}
                     14: SHLIB_MINOR=${minor}
1.1       deraadt    15: .endif
                     16:
                     17: .MAIN: all
                     18:
                     19: # prefer .S to a .c, add .po, remove stuff not used in the BSD libraries.
                     20: # .so used for PIC object files.  .ln used for lint output files.
1.20      espie      21: # .m for objective c files.
1.1       deraadt    22: .SUFFIXES:
1.21      niklas     23: .SUFFIXES: .out .o .go .po .so .S .s .c .cc .C .cxx .f .y .l .ln .m4 .m
1.1       deraadt    24:
                     25: .c.o:
1.14      grr        26:        @echo "${COMPILE.c} ${.IMPSRC} -o ${.TARGET}"
1.1       deraadt    27:        @${COMPILE.c} ${.IMPSRC}  -o ${.TARGET}.o
                     28:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     29:        @rm -f ${.TARGET}.o
                     30:
1.21      niklas     31: .c.go:
                     32:        @echo "${COMPILE.c} -g ${.IMPSRC} -o ${.TARGET}"
                     33:        @${COMPILE.c} -g ${.IMPSRC} -o ${.TARGET}.o
                     34:        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
                     35:        @rm -f ${.TARGET}.o
                     36:
1.1       deraadt    37: .c.po:
                     38:        @echo "${COMPILE.c} -p ${.IMPSRC} -o ${.TARGET}"
                     39:        @${COMPILE.c} -p ${.IMPSRC} -o ${.TARGET}.o
                     40:        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
                     41:        @rm -f ${.TARGET}.o
                     42:
                     43: .c.so:
                     44:        @echo "${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}"
                     45:        @${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
                     46:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     47:        @rm -f ${.TARGET}.o
                     48:
                     49: .c.ln:
1.43      espie      50:        ${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
1.1       deraadt    51:
1.16      deraadt    52: .cc.o .C.o .cxx.o:
1.19      espie      53:        @echo "${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}"
1.1       deraadt    54:        @${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}.o
                     55:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     56:        @rm -f ${.TARGET}.o
                     57:
1.21      niklas     58: .cc.go .C.go .cxx.go:
                     59:        @echo "${COMPILE.cc} -g ${.IMPSRC} -o ${.TARGET}"
                     60:        @${COMPILE.cc} -g ${.IMPSRC} -o ${.TARGET}.o
                     61:        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
                     62:        @rm -f ${.TARGET}.o
                     63:
1.16      deraadt    64: .cc.po .C.po .cxx.po:
1.1       deraadt    65:        @echo "${COMPILE.cc} -p ${.IMPSRC} -o ${.TARGET}"
                     66:        @${COMPILE.cc} -p ${.IMPSRC} -o ${.TARGET}.o
                     67:        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
                     68:        @rm -f ${.TARGET}.o
                     69:
1.16      deraadt    70: .cc.so .C.so .cxx.so:
1.1       deraadt    71:        @echo "${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}"
                     72:        @${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
                     73:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     74:        @rm -f ${.TARGET}.o
                     75:
                     76: .S.o .s.o:
1.37      drahn      77: .if (${MACHINE_ARCH} == "arm")
1.41      deraadt    78:        @echo ${COMPILE.S:Q} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
1.37      drahn      79:        @${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
                     80: .else
1.1       deraadt    81:        @echo "${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
                     82:                ${AS} -o ${.TARGET}"
                     83:        @${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
                     84:            ${AS} -o ${.TARGET}.o
1.37      drahn      85: .endif
1.1       deraadt    86:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                     87:        @rm -f ${.TARGET}.o
                     88:
1.21      niklas     89: .S.go .s.go:
                     90:        @echo "${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} |\
                     91:            ${AS} -o ${.TARGET}"
                     92:        @${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
                     93:            ${AS} -o ${.TARGET}.o
                     94:        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
                     95:        @rm -f ${.TARGET}.o
                     96:
1.1       deraadt    97: .S.po .s.po:
                     98:        @echo "${CPP} -DPROF ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} |\
                     99:            ${AS} -o ${.TARGET}"
                    100:        @${CPP} -DPROF ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
                    101:            ${AS} -o ${.TARGET}.o
                    102:        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
                    103:        @rm -f ${.TARGET}.o
                    104:
                    105: .S.so .s.so:
                    106:        @echo "${CPP} -DPIC ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
1.36      drahn     107:            ${AS} ${ASPICFLAG} -o ${.TARGET}"
1.1       deraadt   108:        @${CPP} -DPIC ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
1.36      drahn     109:            ${AS} ${ASPICFLAG} -o ${.TARGET}.o
1.1       deraadt   110:        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
                    111:        @rm -f ${.TARGET}.o
1.7       deraadt   112:
1.30      espie     113: .if ${WARNINGS:L} == "yes"
                    114: CFLAGS+=       ${CDIAGFLAGS}
                    115: CXXFLAGS+=     ${CXXDIAGFLAGS}
                    116: .endif
1.18      millert   117: CFLAGS+=       ${COPTS}
1.30      espie     118: CXXFLAGS+=     ${CXXOPTS}
1.39      pvalchev  119:
1.21      niklas    120: _LIBS=lib${LIB}.a
1.24      espie     121: .if (${DEBUGLIBS:L} == "yes")
1.21      niklas    122: _LIBS+=lib${LIB}_g.a
                    123: .endif
1.1       deraadt   124: .if !defined(NOPROFILE)
1.21      niklas    125: _LIBS+=lib${LIB}_p.a
1.1       deraadt   126: .endif
                    127:
                    128: .if !defined(NOPIC)
1.42      deraadt   129: .if (${MACHINE_ARCH} != "mips64")
1.1       deraadt   130: _LIBS+=lib${LIB}_pic.a
1.6       pefo      131: .endif
1.35      espie     132: .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
                    133: _LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.1       deraadt   134: .endif
                    135: .endif
                    136:
1.45    ! deraadt   137: .if defined(WANTLINT)
1.1       deraadt   138: _LIBS+=llib-l${LIB}.ln
                    139: .endif
                    140:
                    141: all: ${_LIBS} _SUBDIRUSE
                    142:
                    143: OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
                    144:
                    145: lib${LIB}.a:: ${OBJS}
                    146:        @echo building standard ${LIB} library
                    147:        @rm -f lib${LIB}.a
1.12      niklas    148:        @${AR} cq lib${LIB}.a `${LORDER} ${OBJS} | tsort -q`
1.1       deraadt   149:        ${RANLIB} lib${LIB}.a
                    150:
1.21      niklas    151: GOBJS+=        ${OBJS:.o=.go}
                    152: lib${LIB}_g.a:: ${GOBJS}
                    153:        @echo building debugging ${LIB} library
                    154:        @rm -f lib${LIB}_g.a
                    155:        @${AR} cq lib${LIB}_g.a `${LORDER} ${GOBJS} | tsort -q`
                    156:        ${RANLIB} lib${LIB}_g.a
                    157:
1.1       deraadt   158: POBJS+=        ${OBJS:.o=.po}
                    159: lib${LIB}_p.a:: ${POBJS}
                    160:        @echo building profiled ${LIB} library
                    161:        @rm -f lib${LIB}_p.a
1.12      niklas    162:        @${AR} cq lib${LIB}_p.a `${LORDER} ${POBJS} | tsort -q`
1.1       deraadt   163:        ${RANLIB} lib${LIB}_p.a
                    164:
                    165: SOBJS+=        ${OBJS:.o=.so}
                    166: lib${LIB}_pic.a:: ${SOBJS}
                    167:        @echo building shared object ${LIB} library
                    168:        @rm -f lib${LIB}_pic.a
1.12      niklas    169:        @${AR} cq lib${LIB}_pic.a `${LORDER} ${SOBJS} | tsort -q`
1.1       deraadt   170:        ${RANLIB} lib${LIB}_pic.a
                    171:
1.35      espie     172: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: ${SOBJS} ${DPADD}
                    173:        @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
                    174:        @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.27      brad      175:        ${CC} -shared ${PICFLAG} \
1.35      espie     176:            -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
1.26      espie     177:            `${LORDER} ${SOBJS}|tsort -q` ${LDADD}
1.1       deraadt   178:
                    179: LOBJS+=        ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
                    180: # the following looks XXX to me... -- cgd
                    181: LLIBS?=        -lc
                    182: llib-l${LIB}.ln: ${LOBJS}
                    183:        @echo building llib-l${LIB}.ln
                    184:        @rm -f llib-l${LIB}.ln
                    185:        @${LINT} -C${LIB} ${LOBJS} ${LLIBS}
                    186:
                    187: .if !target(clean)
                    188: clean: _SUBDIRUSE
                    189:        rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
                    190:        rm -f lib${LIB}.a ${OBJS}
1.21      niklas    191:        rm -f lib${LIB}_g.a ${GOBJS}
1.1       deraadt   192:        rm -f lib${LIB}_p.a ${POBJS}
                    193:        rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
                    194:        rm -f llib-l${LIB}.ln ${LOBJS}
                    195: .endif
                    196:
                    197: cleandir: _SUBDIRUSE clean
                    198:
                    199: .if defined(SRCS)
                    200: afterdepend: .depend
1.11      deraadt   201:        @(TMP=`mktemp -q /tmp/_dependXXXXXXXXXX`; \
                    202:        if [ $$? -ne 0 ]; then \
                    203:                echo "$$0: cannot create temp file, exiting..."; \
                    204:                exit 1; \
                    205:        fi; \
                    206:        sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so:/' \
1.1       deraadt   207:              < .depend > $$TMP; \
1.11      deraadt   208:        mv $$TMP .depend)
1.1       deraadt   209: .endif
                    210:
                    211: .if !target(install)
                    212: .if !target(beforeinstall)
                    213: beforeinstall:
                    214: .endif
                    215:
                    216: realinstall:
                    217: #      ranlib lib${LIB}.a
1.13      millert   218:        ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 lib${LIB}.a \
1.44      espie     219:            ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.13      millert   220: .if (${INSTALL_COPY} != "-p")
1.1       deraadt   221:        ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.8       millert   222: .endif
1.1       deraadt   223:        chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.24      espie     224: .if (${DEBUGLIBS:L} == "yes")
1.21      niklas    225: #      ranlib lib${LIB}_g.a
                    226:        ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
                    227:            lib${LIB}_g.a ${DESTDIR}${LIBDIR}/debug/lib${LIB}.a
                    228: .if (${INSTALL_COPY} != "-p")
                    229:        ${RANLIB} -t ${DESTDIR}${LIBDIR}/debug/lib${LIB}.a
                    230: .endif
                    231:        chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/debug/lib${LIB}.a
                    232: .endif
1.1       deraadt   233: .if !defined(NOPROFILE)
                    234: #      ranlib lib${LIB}_p.a
1.13      millert   235:        ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
1.1       deraadt   236:            lib${LIB}_p.a ${DESTDIR}${LIBDIR}
1.13      millert   237: .if (${INSTALL_COPY} != "-p")
1.1       deraadt   238:        ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.8       millert   239: .endif
1.1       deraadt   240:        chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
                    241: .endif
1.42      deraadt   242: .if !defined(NOPIC) && (${MACHINE_ARCH} != "mips64")
1.1       deraadt   243: #      ranlib lib${LIB}_pic.a
1.13      millert   244:        ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
1.1       deraadt   245:            lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
1.13      millert   246: .if (${INSTALL_COPY} != "-p")
1.1       deraadt   247:        ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.8       millert   248: .endif
1.1       deraadt   249:        chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
                    250: .endif
1.35      espie     251: .if !defined(NOPIC) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
1.13      millert   252:        ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.35      espie     253:            lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} ${DESTDIR}${LIBDIR}
1.1       deraadt   254: .endif
1.45    ! deraadt   255: .if defined(WANTLINT)
1.13      millert   256:        ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.1       deraadt   257:            llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
                    258: .endif
                    259: .if defined(LINKS) && !empty(LINKS)
1.33      espie     260: .  for lnk file in ${LINKS}
                    261:        @l=${DESTDIR}${lnk}; \
                    262:         t=${DESTDIR}${file}; \
                    263:         echo $$t -\> $$l; \
                    264:         rm -f $$t; ln $$l $$t
                    265: .  endfor
1.1       deraadt   266: .endif
                    267:
                    268: install: maninstall _SUBDIRUSE
                    269: maninstall: afterinstall
                    270: afterinstall: realinstall
                    271: realinstall: beforeinstall
                    272: .endif
                    273:
                    274: .if !defined(NOMAN)
                    275: .include <bsd.man.mk>
                    276: .endif
                    277:
                    278: .if !defined(NONLS)
                    279: .include <bsd.nls.mk>
                    280: .endif
                    281:
                    282: .include <bsd.obj.mk>
                    283: .include <bsd.dep.mk>
                    284: .include <bsd.subdir.mk>
1.2       deraadt   285: .include <bsd.sys.mk>