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

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

CVSweb <webmaster@jp.NetBSD.org>