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