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

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

CVSweb <webmaster@jp.NetBSD.org>