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

1.88    ! cgd         1: #      $NetBSD: bsd.lib.mk,v 1.87 1997/03/22 22:33:57 perry 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:
                    159: lib${LIB}.a:: ${OBJS}
                    160:        @echo building standard ${LIB} library
                    161:        @rm -f lib${LIB}.a
1.67      mycroft   162:        @${AR} cq lib${LIB}.a `lorder ${OBJS} | tsort -q`
1.13      cgd       163:        ${RANLIB} lib${LIB}.a
1.1       cgd       164:
                    165: POBJS+=        ${OBJS:.o=.po}
                    166: lib${LIB}_p.a:: ${POBJS}
                    167:        @echo building profiled ${LIB} library
                    168:        @rm -f lib${LIB}_p.a
1.67      mycroft   169:        @${AR} cq lib${LIB}_p.a `lorder ${POBJS} | tsort -q`
1.13      cgd       170:        ${RANLIB} lib${LIB}_p.a
1.1       cgd       171:
1.27      pk        172: SOBJS+=        ${OBJS:.o=.so}
                    173: lib${LIB}_pic.a:: ${SOBJS}
                    174:        @echo building shared object ${LIB} library
                    175:        @rm -f lib${LIB}_pic.a
1.67      mycroft   176:        @${AR} cq lib${LIB}_pic.a `lorder ${SOBJS} | tsort -q`
1.27      pk        177:        ${RANLIB} lib${LIB}_pic.a
                    178:
1.88    ! cgd       179: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}_pic.a ${DPADD} \
        !           180:     ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
1.38      cgd       181:        @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
1.37      cgd       182:        @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.86      jonathan  183: .if (${SHLIB_TYPE} == "a.out")
1.53      pk        184:        $(LD) -x -Bshareable -Bforcearchive \
1.42      mycroft   185:            -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} lib${LIB}_pic.a ${LDADD}
1.86      jonathan  186: .elif (${SHLIB_TYPE} == "ELF")
                    187:        $(LD) -x -shared -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
                    188:            -soname lib${LIB}.so.${SHLIB_SOVERSION}  ${SHLIB_LDSTARTFILE} \
1.77      cgd       189:            --whole-archive lib${LIB}_pic.a --no-whole-archive ${LDADD} \
1.86      jonathan  190:            ${SHLIB_LDENDFILE}
1.72      cgd       191: .endif
1.35      pk        192:
1.58      cgd       193: LOBJS+=        ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
                    194: LLIBS?=        -lc
                    195: llib-l${LIB}.ln: ${LOBJS}
                    196:        @echo building llib-l${LIB}.ln
                    197:        @rm -f llib-l${LIB}.ln
                    198:        @${LINT} -C${LIB} ${LOBJS} ${LLIBS}
1.1       cgd       199:
                    200: .if !target(clean)
1.81      cgd       201: cleanlib:
1.48      mycroft   202:        rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
1.59      cgd       203:        rm -f lib${LIB}.a ${OBJS}
                    204:        rm -f lib${LIB}_p.a ${POBJS}
1.61      cgd       205:        rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
1.59      cgd       206:        rm -f llib-l${LIB}.ln ${LOBJS}
1.1       cgd       207:
1.81      cgd       208: clean: _SUBDIRUSE cleanlib
                    209: cleandir: _SUBDIRUSE cleanlib
                    210: .else
1.49      cgd       211: cleandir: _SUBDIRUSE clean
1.81      cgd       212: .endif
1.25      mycroft   213:
1.26      mycroft   214: .if defined(SRCS)
1.64      christos  215: afterdepend: .depend
1.1       cgd       216:        @(TMP=/tmp/_depend$$$$; \
1.79      cgd       217:            sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.ln:/' \
1.58      cgd       218:              < .depend > $$TMP; \
1.1       cgd       219:            mv $$TMP .depend)
1.26      mycroft   220: .endif
1.1       cgd       221:
                    222: .if !target(install)
                    223: .if !target(beforeinstall)
                    224: beforeinstall:
                    225: .endif
                    226:
1.11      mycroft   227: realinstall:
1.13      cgd       228: #      ranlib lib${LIB}.a
1.73      thorpej   229:        ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 lib${LIB}.a \
1.1       cgd       230:            ${DESTDIR}${LIBDIR}
                    231:        ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.56      cgd       232:        chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.12      cgd       233: .if !defined(NOPROFILE)
1.13      cgd       234: #      ranlib lib${LIB}_p.a
1.73      thorpej   235:        ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
1.1       cgd       236:            lib${LIB}_p.a ${DESTDIR}${LIBDIR}
                    237:        ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.56      cgd       238:        chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.32      pk        239: .endif
1.39      pk        240: .if !defined(NOPIC)
1.32      pk        241: #      ranlib lib${LIB}_pic.a
1.73      thorpej   242:        ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
1.32      pk        243:            lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
                    244:        ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.56      cgd       245:        chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.33      pk        246: .endif
1.37      cgd       247: .if !defined(NOPIC) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
1.73      thorpej   248:        ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.37      cgd       249:            lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} ${DESTDIR}${LIBDIR}
1.86      jonathan  250: .if (${SHLIB_TYPE} == "ELF")
1.83      cgd       251:        rm -f ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
                    252:        ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
                    253:            ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
                    254:        rm -f ${DESTDIR}${LIBDIR}/lib${LIB}.so
                    255:        ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
                    256:            ${DESTDIR}${LIBDIR}/lib${LIB}.so
                    257: .endif
1.12      cgd       258: .endif
1.58      cgd       259: .if !defined(NOLINT)
1.73      thorpej   260:        ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.58      cgd       261:            llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
                    262: .endif
1.1       cgd       263: .if defined(LINKS) && !empty(LINKS)
                    264:        @set ${LINKS}; \
                    265:        while test $$# -ge 2; do \
                    266:                l=${DESTDIR}$$1; \
                    267:                shift; \
                    268:                t=${DESTDIR}$$1; \
                    269:                shift; \
                    270:                echo $$t -\> $$l; \
                    271:                rm -f $$t; \
                    272:                ln $$l $$t; \
1.84      perry     273:        done; true
                    274: .endif
                    275: .if defined(SYMLINKS) && !empty(SYMLINKS)
                    276:        @set ${SYMLINKS}; \
                    277:        while test $$# -ge 2; do \
1.87      perry     278:                l=$$1; \
1.84      perry     279:                shift; \
                    280:                t=${DESTDIR}$$1; \
                    281:                shift; \
                    282:                echo $$t -\> $$l; \
                    283:                rm -f $$t; \
                    284:                ln -s $$l $$t; \
1.1       cgd       285:        done; true
                    286: .endif
                    287:
1.49      cgd       288: install: maninstall _SUBDIRUSE
1.11      mycroft   289: maninstall: afterinstall
                    290: afterinstall: realinstall
                    291: realinstall: beforeinstall
1.1       cgd       292: .endif
                    293:
1.10      mycroft   294: .if !defined(NOMAN)
1.1       cgd       295: .include <bsd.man.mk>
1.57      jtc       296: .endif
                    297:
                    298: .if !defined(NONLS)
                    299: .include <bsd.nls.mk>
1.10      mycroft   300: .endif
                    301:
1.22      mycroft   302: .include <bsd.obj.mk>
1.24      mycroft   303: .include <bsd.dep.mk>
1.49      cgd       304: .include <bsd.subdir.mk>
1.66      christos  305: .include <bsd.sys.mk>

CVSweb <webmaster@jp.NetBSD.org>