Annotation of src/share/mk/bsd.lib.mk, Revision 1.46
1.46 ! steven 1: # $OpenBSD: bsd.lib.mk,v 1.45 2005/11/23 18:34:33 deraadt 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:
1.43 espie 50: ${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
1.1 deraadt 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
1.46 ! steven 73: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
! 74: @rm -f ${.TARGET}.o
! 75:
! 76: # Fortran 77
! 77: .f.o:
! 78: @echo "${COMPILE.f} ${.IMPSRC} -o ${.TARGET}"
! 79: @${COMPILE.f} ${.IMPSRC} -o ${.TARGET}.o
! 80: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
! 81: @rm -f ${.TARGET}.o
! 82:
! 83: .f.go:
! 84: @echo "${COMPILE.f} -g ${.IMPSRC} -o ${.TARGET}"
! 85: @${COMPILE.f} -g ${.IMPSRC} -o ${.TARGET}.o
! 86: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
! 87: @rm -f ${.TARGET}.o
! 88:
! 89: .f.po:
! 90: @echo "${COMPILE.f} -p ${.IMPSRC} -o ${.TARGET}"
! 91: @${COMPILE.f} -p ${.IMPSRC} -o ${.TARGET}.o
! 92: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
! 93: @rm -f ${.TARGET}.o
! 94:
! 95: .f.so:
! 96: @echo "${COMPILE.f} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}"
! 97: @${COMPILE.f} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
1.1 deraadt 98: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
99: @rm -f ${.TARGET}.o
100:
101: .S.o .s.o:
1.37 drahn 102: .if (${MACHINE_ARCH} == "arm")
1.41 deraadt 103: @echo ${COMPILE.S:Q} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
1.37 drahn 104: @${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
105: .else
1.1 deraadt 106: @echo "${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
107: ${AS} -o ${.TARGET}"
108: @${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
109: ${AS} -o ${.TARGET}.o
1.37 drahn 110: .endif
1.1 deraadt 111: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
112: @rm -f ${.TARGET}.o
113:
1.21 niklas 114: .S.go .s.go:
115: @echo "${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} |\
116: ${AS} -o ${.TARGET}"
117: @${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
118: ${AS} -o ${.TARGET}.o
119: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
120: @rm -f ${.TARGET}.o
121:
1.1 deraadt 122: .S.po .s.po:
123: @echo "${CPP} -DPROF ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} |\
124: ${AS} -o ${.TARGET}"
125: @${CPP} -DPROF ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
126: ${AS} -o ${.TARGET}.o
127: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
128: @rm -f ${.TARGET}.o
129:
130: .S.so .s.so:
131: @echo "${CPP} -DPIC ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
1.36 drahn 132: ${AS} ${ASPICFLAG} -o ${.TARGET}"
1.1 deraadt 133: @${CPP} -DPIC ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
1.36 drahn 134: ${AS} ${ASPICFLAG} -o ${.TARGET}.o
1.1 deraadt 135: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
136: @rm -f ${.TARGET}.o
1.7 deraadt 137:
1.30 espie 138: .if ${WARNINGS:L} == "yes"
139: CFLAGS+= ${CDIAGFLAGS}
140: CXXFLAGS+= ${CXXDIAGFLAGS}
141: .endif
1.18 millert 142: CFLAGS+= ${COPTS}
1.30 espie 143: CXXFLAGS+= ${CXXOPTS}
1.39 pvalchev 144:
1.21 niklas 145: _LIBS=lib${LIB}.a
1.24 espie 146: .if (${DEBUGLIBS:L} == "yes")
1.21 niklas 147: _LIBS+=lib${LIB}_g.a
148: .endif
1.1 deraadt 149: .if !defined(NOPROFILE)
1.21 niklas 150: _LIBS+=lib${LIB}_p.a
1.1 deraadt 151: .endif
152:
153: .if !defined(NOPIC)
1.42 deraadt 154: .if (${MACHINE_ARCH} != "mips64")
1.1 deraadt 155: _LIBS+=lib${LIB}_pic.a
1.6 pefo 156: .endif
1.35 espie 157: .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
158: _LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.1 deraadt 159: .endif
160: .endif
161:
1.45 deraadt 162: .if defined(WANTLINT)
1.1 deraadt 163: _LIBS+=llib-l${LIB}.ln
164: .endif
165:
166: all: ${_LIBS} _SUBDIRUSE
167:
168: OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
169:
170: lib${LIB}.a:: ${OBJS}
171: @echo building standard ${LIB} library
172: @rm -f lib${LIB}.a
1.12 niklas 173: @${AR} cq lib${LIB}.a `${LORDER} ${OBJS} | tsort -q`
1.1 deraadt 174: ${RANLIB} lib${LIB}.a
175:
1.21 niklas 176: GOBJS+= ${OBJS:.o=.go}
177: lib${LIB}_g.a:: ${GOBJS}
178: @echo building debugging ${LIB} library
179: @rm -f lib${LIB}_g.a
180: @${AR} cq lib${LIB}_g.a `${LORDER} ${GOBJS} | tsort -q`
181: ${RANLIB} lib${LIB}_g.a
182:
1.1 deraadt 183: POBJS+= ${OBJS:.o=.po}
184: lib${LIB}_p.a:: ${POBJS}
185: @echo building profiled ${LIB} library
186: @rm -f lib${LIB}_p.a
1.12 niklas 187: @${AR} cq lib${LIB}_p.a `${LORDER} ${POBJS} | tsort -q`
1.1 deraadt 188: ${RANLIB} lib${LIB}_p.a
189:
190: SOBJS+= ${OBJS:.o=.so}
191: lib${LIB}_pic.a:: ${SOBJS}
192: @echo building shared object ${LIB} library
193: @rm -f lib${LIB}_pic.a
1.12 niklas 194: @${AR} cq lib${LIB}_pic.a `${LORDER} ${SOBJS} | tsort -q`
1.1 deraadt 195: ${RANLIB} lib${LIB}_pic.a
196:
1.35 espie 197: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: ${SOBJS} ${DPADD}
198: @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
199: @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.27 brad 200: ${CC} -shared ${PICFLAG} \
1.35 espie 201: -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
1.26 espie 202: `${LORDER} ${SOBJS}|tsort -q` ${LDADD}
1.1 deraadt 203:
204: LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
205: # the following looks XXX to me... -- cgd
206: LLIBS?= -lc
207: llib-l${LIB}.ln: ${LOBJS}
208: @echo building llib-l${LIB}.ln
209: @rm -f llib-l${LIB}.ln
210: @${LINT} -C${LIB} ${LOBJS} ${LLIBS}
211:
212: .if !target(clean)
213: clean: _SUBDIRUSE
214: rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
215: rm -f lib${LIB}.a ${OBJS}
1.21 niklas 216: rm -f lib${LIB}_g.a ${GOBJS}
1.1 deraadt 217: rm -f lib${LIB}_p.a ${POBJS}
218: rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
219: rm -f llib-l${LIB}.ln ${LOBJS}
220: .endif
221:
222: cleandir: _SUBDIRUSE clean
223:
224: .if defined(SRCS)
225: afterdepend: .depend
1.11 deraadt 226: @(TMP=`mktemp -q /tmp/_dependXXXXXXXXXX`; \
227: if [ $$? -ne 0 ]; then \
228: echo "$$0: cannot create temp file, exiting..."; \
229: exit 1; \
230: fi; \
231: sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so:/' \
1.1 deraadt 232: < .depend > $$TMP; \
1.11 deraadt 233: mv $$TMP .depend)
1.1 deraadt 234: .endif
235:
236: .if !target(install)
237: .if !target(beforeinstall)
238: beforeinstall:
239: .endif
240:
241: realinstall:
242: # ranlib lib${LIB}.a
1.13 millert 243: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 lib${LIB}.a \
1.44 espie 244: ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.13 millert 245: .if (${INSTALL_COPY} != "-p")
1.1 deraadt 246: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.8 millert 247: .endif
1.1 deraadt 248: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.24 espie 249: .if (${DEBUGLIBS:L} == "yes")
1.21 niklas 250: # ranlib lib${LIB}_g.a
251: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
252: lib${LIB}_g.a ${DESTDIR}${LIBDIR}/debug/lib${LIB}.a
253: .if (${INSTALL_COPY} != "-p")
254: ${RANLIB} -t ${DESTDIR}${LIBDIR}/debug/lib${LIB}.a
255: .endif
256: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/debug/lib${LIB}.a
257: .endif
1.1 deraadt 258: .if !defined(NOPROFILE)
259: # ranlib lib${LIB}_p.a
1.13 millert 260: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
1.1 deraadt 261: lib${LIB}_p.a ${DESTDIR}${LIBDIR}
1.13 millert 262: .if (${INSTALL_COPY} != "-p")
1.1 deraadt 263: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.8 millert 264: .endif
1.1 deraadt 265: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
266: .endif
1.42 deraadt 267: .if !defined(NOPIC) && (${MACHINE_ARCH} != "mips64")
1.1 deraadt 268: # ranlib lib${LIB}_pic.a
1.13 millert 269: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
1.1 deraadt 270: lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
1.13 millert 271: .if (${INSTALL_COPY} != "-p")
1.1 deraadt 272: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.8 millert 273: .endif
1.1 deraadt 274: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
275: .endif
1.35 espie 276: .if !defined(NOPIC) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
1.13 millert 277: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.35 espie 278: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} ${DESTDIR}${LIBDIR}
1.1 deraadt 279: .endif
1.45 deraadt 280: .if defined(WANTLINT)
1.13 millert 281: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.1 deraadt 282: llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
283: .endif
284: .if defined(LINKS) && !empty(LINKS)
1.33 espie 285: . for lnk file in ${LINKS}
286: @l=${DESTDIR}${lnk}; \
287: t=${DESTDIR}${file}; \
288: echo $$t -\> $$l; \
289: rm -f $$t; ln $$l $$t
290: . endfor
1.1 deraadt 291: .endif
292:
293: install: maninstall _SUBDIRUSE
294: maninstall: afterinstall
295: afterinstall: realinstall
296: realinstall: beforeinstall
297: .endif
298:
299: .if !defined(NOMAN)
300: .include <bsd.man.mk>
301: .endif
302:
303: .if !defined(NONLS)
304: .include <bsd.nls.mk>
305: .endif
306:
307: .include <bsd.obj.mk>
308: .include <bsd.dep.mk>
309: .include <bsd.subdir.mk>
1.2 deraadt 310: .include <bsd.sys.mk>