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

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

CVSweb <webmaster@jp.NetBSD.org>