Annotation of src/share/mk/bsd.lib.mk, Revision 1.32
1.31 espie 1: # $OpenBSD: bsd.lib.mk,v 1.30 2001/07/18 13:23:03 espie Exp $
1.5 mickey 2: # $NetBSD: bsd.lib.mk,v 1.67 1996/01/17 20:39:26 mycroft Exp $
1.1 deraadt 3: # @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91
4:
1.25 mickey 5: .include <bsd.own.mk> # for 'NOPIC' definition
6:
1.1 deraadt 7: .if exists(${.CURDIR}/../Makefile.inc)
8: .include "${.CURDIR}/../Makefile.inc"
9: .endif
10:
11: .if exists(${.CURDIR}/shlib_version)
1.32 ! mickey 12: SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major
! 13: SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor
1.1 deraadt 14: .endif
15:
16: .MAIN: all
17:
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.20 espie 20: # .m for objective c files.
1.1 deraadt 21: .SUFFIXES:
1.21 niklas 22: .SUFFIXES: .out .o .go .po .so .S .s .c .cc .C .cxx .f .y .l .ln .m4 .m
1.1 deraadt 23:
24: .c.o:
1.14 grr 25: @echo "${COMPILE.c} ${.IMPSRC} -o ${.TARGET}"
1.1 deraadt 26: @${COMPILE.c} ${.IMPSRC} -o ${.TARGET}.o
27: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
28: @rm -f ${.TARGET}.o
29:
1.21 niklas 30: .c.go:
31: @echo "${COMPILE.c} -g ${.IMPSRC} -o ${.TARGET}"
32: @${COMPILE.c} -g ${.IMPSRC} -o ${.TARGET}.o
33: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
34: @rm -f ${.TARGET}.o
35:
1.1 deraadt 36: .c.po:
37: @echo "${COMPILE.c} -p ${.IMPSRC} -o ${.TARGET}"
38: @${COMPILE.c} -p ${.IMPSRC} -o ${.TARGET}.o
39: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
40: @rm -f ${.TARGET}.o
41:
42: .c.so:
43: @echo "${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}"
44: @${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
45: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
46: @rm -f ${.TARGET}.o
47:
48: .c.ln:
49: ${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} -i ${.IMPSRC}
50:
1.16 deraadt 51: .cc.o .C.o .cxx.o:
1.19 espie 52: @echo "${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}"
1.1 deraadt 53: @${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}.o
54: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
55: @rm -f ${.TARGET}.o
56:
1.21 niklas 57: .cc.go .C.go .cxx.go:
58: @echo "${COMPILE.cc} -g ${.IMPSRC} -o ${.TARGET}"
59: @${COMPILE.cc} -g ${.IMPSRC} -o ${.TARGET}.o
60: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
61: @rm -f ${.TARGET}.o
62:
1.16 deraadt 63: .cc.po .C.po .cxx.po:
1.1 deraadt 64: @echo "${COMPILE.cc} -p ${.IMPSRC} -o ${.TARGET}"
65: @${COMPILE.cc} -p ${.IMPSRC} -o ${.TARGET}.o
66: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
67: @rm -f ${.TARGET}.o
68:
1.16 deraadt 69: .cc.so .C.so .cxx.so:
1.1 deraadt 70: @echo "${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}"
71: @${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
72: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
73: @rm -f ${.TARGET}.o
74:
75: .S.o .s.o:
76: @echo "${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
77: ${AS} -o ${.TARGET}"
78: @${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
79: ${AS} -o ${.TARGET}.o
80: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
81: @rm -f ${.TARGET}.o
82:
1.21 niklas 83: .S.go .s.go:
84: @echo "${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} |\
85: ${AS} -o ${.TARGET}"
86: @${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
87: ${AS} -o ${.TARGET}.o
88: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
89: @rm -f ${.TARGET}.o
90:
1.1 deraadt 91: .S.po .s.po:
92: @echo "${CPP} -DPROF ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} |\
93: ${AS} -o ${.TARGET}"
94: @${CPP} -DPROF ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
95: ${AS} -o ${.TARGET}.o
96: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
97: @rm -f ${.TARGET}.o
98:
99: .S.so .s.so:
100: @echo "${CPP} -DPIC ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
101: ${AS} -k -o ${.TARGET}"
102: @${CPP} -DPIC ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
103: ${AS} -k -o ${.TARGET}.o
104: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
105: @rm -f ${.TARGET}.o
1.7 deraadt 106:
1.30 espie 107: .if ${WARNINGS:L} == "yes"
108: CFLAGS+= ${CDIAGFLAGS}
109: CXXFLAGS+= ${CXXDIAGFLAGS}
110: .endif
1.18 millert 111: CFLAGS+= ${COPTS}
1.30 espie 112: CXXFLAGS+= ${CXXOPTS}
1.1 deraadt 113:
1.6 pefo 114: .if !defined(PICFLAG) && (${MACHINE_ARCH} != "mips")
1.1 deraadt 115: PICFLAG=-fpic
1.15 niklas 116: .if ${MACHINE_ARCH} == "m68k"
117: # Function CSE makes gas -k not recognize external function calls as lazily
118: # resolvable symbols, thus sometimes making ld.so report undefined symbol
119: # errors on symbols found in shared library members that would never be
120: # called. Ask niklas@openbsd.org for details.
121: PICFLAG+=-fno-function-cse
122: .endif
1.1 deraadt 123: .endif
124:
1.21 niklas 125: _LIBS=lib${LIB}.a
1.24 espie 126: .if (${DEBUGLIBS:L} == "yes")
1.21 niklas 127: _LIBS+=lib${LIB}_g.a
128: .endif
1.1 deraadt 129: .if !defined(NOPROFILE)
1.21 niklas 130: _LIBS+=lib${LIB}_p.a
1.1 deraadt 131: .endif
132:
133: .if !defined(NOPIC)
1.6 pefo 134: .if (${MACHINE_ARCH} != "mips")
1.1 deraadt 135: _LIBS+=lib${LIB}_pic.a
1.6 pefo 136: .endif
1.32 ! mickey 137: .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
! 138: _LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.1 deraadt 139: .endif
140: .endif
141:
142: .if !defined(NOLINT)
143: _LIBS+=llib-l${LIB}.ln
144: .endif
145:
146: all: ${_LIBS} _SUBDIRUSE
147:
148: OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
149:
150: lib${LIB}.a:: ${OBJS}
151: @echo building standard ${LIB} library
152: @rm -f lib${LIB}.a
1.12 niklas 153: @${AR} cq lib${LIB}.a `${LORDER} ${OBJS} | tsort -q`
1.1 deraadt 154: ${RANLIB} lib${LIB}.a
155:
1.21 niklas 156: GOBJS+= ${OBJS:.o=.go}
157: lib${LIB}_g.a:: ${GOBJS}
158: @echo building debugging ${LIB} library
159: @rm -f lib${LIB}_g.a
160: @${AR} cq lib${LIB}_g.a `${LORDER} ${GOBJS} | tsort -q`
161: ${RANLIB} lib${LIB}_g.a
162:
1.1 deraadt 163: POBJS+= ${OBJS:.o=.po}
164: lib${LIB}_p.a:: ${POBJS}
165: @echo building profiled ${LIB} library
166: @rm -f lib${LIB}_p.a
1.12 niklas 167: @${AR} cq lib${LIB}_p.a `${LORDER} ${POBJS} | tsort -q`
1.1 deraadt 168: ${RANLIB} lib${LIB}_p.a
169:
170: SOBJS+= ${OBJS:.o=.so}
171: lib${LIB}_pic.a:: ${SOBJS}
172: @echo building shared object ${LIB} library
173: @rm -f lib${LIB}_pic.a
1.12 niklas 174: @${AR} cq lib${LIB}_pic.a `${LORDER} ${SOBJS} | tsort -q`
1.1 deraadt 175: ${RANLIB} lib${LIB}_pic.a
176:
1.32 ! mickey 177: .if (${MACHINE_ARCH} == "mips")
! 178: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: ${OBJS} ${DPADD}
! 179: @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
! 180: @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
! 181: ${CC} -shared ${PICFLAG} -Wl,-soname,lib${LIB}.so.${SHLIB_MAJOR} \
! 182: -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
! 183: `${LORDER} ${OBJS}|tsort -q` ${LDADD}
! 184: .else
! 185: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: ${SOBJS} ${DPADD}
! 186: @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
! 187: @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.27 brad 188: ${CC} -shared ${PICFLAG} \
1.32 ! mickey 189: -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
1.26 espie 190: `${LORDER} ${SOBJS}|tsort -q` ${LDADD}
1.32 ! mickey 191: .endif
1.1 deraadt 192:
193: LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
194: # the following looks XXX to me... -- cgd
195: LLIBS?= -lc
196: llib-l${LIB}.ln: ${LOBJS}
197: @echo building llib-l${LIB}.ln
198: @rm -f llib-l${LIB}.ln
199: @${LINT} -C${LIB} ${LOBJS} ${LLIBS}
200:
201: .if !target(clean)
202: clean: _SUBDIRUSE
203: rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
204: rm -f lib${LIB}.a ${OBJS}
1.21 niklas 205: rm -f lib${LIB}_g.a ${GOBJS}
1.1 deraadt 206: rm -f lib${LIB}_p.a ${POBJS}
207: rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
208: rm -f llib-l${LIB}.ln ${LOBJS}
209: .endif
210:
211: cleandir: _SUBDIRUSE clean
212:
213: .if defined(SRCS)
214: afterdepend: .depend
1.11 deraadt 215: @(TMP=`mktemp -q /tmp/_dependXXXXXXXXXX`; \
216: if [ $$? -ne 0 ]; then \
217: echo "$$0: cannot create temp file, exiting..."; \
218: exit 1; \
219: fi; \
220: sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so:/' \
1.1 deraadt 221: < .depend > $$TMP; \
1.11 deraadt 222: mv $$TMP .depend)
1.1 deraadt 223: .endif
224:
225: .if !target(install)
226: .if !target(beforeinstall)
227: beforeinstall:
228: .endif
229:
230: realinstall:
231: # ranlib lib${LIB}.a
1.13 millert 232: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 lib${LIB}.a \
1.1 deraadt 233: ${DESTDIR}${LIBDIR}
1.13 millert 234: .if (${INSTALL_COPY} != "-p")
1.1 deraadt 235: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.8 millert 236: .endif
1.1 deraadt 237: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.24 espie 238: .if (${DEBUGLIBS:L} == "yes")
1.21 niklas 239: # ranlib lib${LIB}_g.a
240: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
241: lib${LIB}_g.a ${DESTDIR}${LIBDIR}/debug/lib${LIB}.a
242: .if (${INSTALL_COPY} != "-p")
243: ${RANLIB} -t ${DESTDIR}${LIBDIR}/debug/lib${LIB}.a
244: .endif
245: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/debug/lib${LIB}.a
246: .endif
1.1 deraadt 247: .if !defined(NOPROFILE)
248: # ranlib lib${LIB}_p.a
1.13 millert 249: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
1.1 deraadt 250: lib${LIB}_p.a ${DESTDIR}${LIBDIR}
1.13 millert 251: .if (${INSTALL_COPY} != "-p")
1.1 deraadt 252: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.8 millert 253: .endif
1.1 deraadt 254: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
255: .endif
1.6 pefo 256: .if !defined(NOPIC) && (${MACHINE_ARCH} != "mips")
1.1 deraadt 257: # ranlib lib${LIB}_pic.a
1.13 millert 258: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
1.1 deraadt 259: lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
1.13 millert 260: .if (${INSTALL_COPY} != "-p")
1.1 deraadt 261: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.8 millert 262: .endif
1.1 deraadt 263: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
264: .endif
1.32 ! mickey 265: .if !defined(NOPIC) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
1.13 millert 266: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.32 ! mickey 267: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} ${DESTDIR}${LIBDIR}
1.1 deraadt 268: .endif
269: .if !defined(NOLINT)
1.13 millert 270: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.1 deraadt 271: llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
272: .endif
273: .if defined(LINKS) && !empty(LINKS)
1.32 ! mickey 274: @set ${LINKS}; \
! 275: while test $$# -ge 2; do \
! 276: l=${DESTDIR}$$1; \
! 277: shift; \
! 278: t=${DESTDIR}$$1; \
! 279: shift; \
! 280: echo $$t -\> $$l; \
! 281: rm -f $$t; \
! 282: ln $$l $$t; \
! 283: done; true
1.1 deraadt 284: .endif
285:
286: install: maninstall _SUBDIRUSE
287: maninstall: afterinstall
288: afterinstall: realinstall
289: realinstall: beforeinstall
290: .endif
291:
292: .if !defined(NOMAN)
293: .include <bsd.man.mk>
294: .endif
295:
296: .if !defined(NONLS)
297: .include <bsd.nls.mk>
298: .endif
299:
300: .include <bsd.obj.mk>
301: .include <bsd.dep.mk>
302: .include <bsd.subdir.mk>
1.2 deraadt 303: .include <bsd.sys.mk>