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