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