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