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