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