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

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

CVSweb <webmaster@jp.NetBSD.org>