Annotation of src/share/mk/bsd.lib.mk, Revision 1.14
1.14 ! grr 1: # $OpenBSD: bsd.lib.mk,v 1.13 1997/04/27 21:38:28 millert 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:
21: .SUFFIXES: .out .o .po .so .S .s .c .cc .C .f .y .l .ln .m4
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:
44: .cc.o .C.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:
50: .cc.po .C.po:
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:
56: .cc.so .C.so:
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
90: .endif
91:
92: .if !defined(NOPROFILE)
93: _LIBS=lib${LIB}.a lib${LIB}_p.a
94: .else
95: _LIBS=lib${LIB}.a
96: .endif
97:
98: .if !defined(NOPIC)
1.6 pefo 99: .if (${MACHINE_ARCH} != "mips")
1.1 deraadt 100: _LIBS+=lib${LIB}_pic.a
1.6 pefo 101: .endif
1.1 deraadt 102: .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
103: _LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
104: .endif
105: .endif
106:
107: .if !defined(NOLINT)
108: _LIBS+=llib-l${LIB}.ln
109: .endif
110:
111: all: ${_LIBS} _SUBDIRUSE
112:
113: OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
114:
115: lib${LIB}.a:: ${OBJS}
116: @echo building standard ${LIB} library
117: @rm -f lib${LIB}.a
1.12 niklas 118: @${AR} cq lib${LIB}.a `${LORDER} ${OBJS} | tsort -q`
1.1 deraadt 119: ${RANLIB} lib${LIB}.a
120:
121: POBJS+= ${OBJS:.o=.po}
122: lib${LIB}_p.a:: ${POBJS}
123: @echo building profiled ${LIB} library
124: @rm -f lib${LIB}_p.a
1.12 niklas 125: @${AR} cq lib${LIB}_p.a `${LORDER} ${POBJS} | tsort -q`
1.1 deraadt 126: ${RANLIB} lib${LIB}_p.a
127:
128: SOBJS+= ${OBJS:.o=.so}
129: lib${LIB}_pic.a:: ${SOBJS}
130: @echo building shared object ${LIB} library
131: @rm -f lib${LIB}_pic.a
1.12 niklas 132: @${AR} cq lib${LIB}_pic.a `${LORDER} ${SOBJS} | tsort -q`
1.1 deraadt 133: ${RANLIB} lib${LIB}_pic.a
134:
1.6 pefo 135: .if (${MACHINE_ARCH} != "mips")
1.1 deraadt 136: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}_pic.a ${DPADD}
137: @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
138: @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
139: $(LD) -x -Bshareable -Bforcearchive \
140: -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} lib${LIB}_pic.a ${LDADD}
1.6 pefo 141: .else
142: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}.a ${DPADD}
143: @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
144: @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
145: $(LD) -x -shared --whole-archive -soname lib${LIB}.so.${SHLIB_MAJOR} \
146: -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} lib${LIB}.a ${LDADD}
147: .endif
1.1 deraadt 148:
149: LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
150: # the following looks XXX to me... -- cgd
151: LLIBS?= -lc
152: llib-l${LIB}.ln: ${LOBJS}
153: @echo building llib-l${LIB}.ln
154: @rm -f llib-l${LIB}.ln
155: @${LINT} -C${LIB} ${LOBJS} ${LLIBS}
156:
157: .if !target(clean)
158: clean: _SUBDIRUSE
159: rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
160: rm -f lib${LIB}.a ${OBJS}
161: rm -f lib${LIB}_p.a ${POBJS}
162: rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
163: rm -f llib-l${LIB}.ln ${LOBJS}
164: .endif
165:
166: cleandir: _SUBDIRUSE clean
167:
168: .if defined(SRCS)
169: afterdepend: .depend
1.11 deraadt 170: @(TMP=`mktemp -q /tmp/_dependXXXXXXXXXX`; \
171: if [ $$? -ne 0 ]; then \
172: echo "$$0: cannot create temp file, exiting..."; \
173: exit 1; \
174: fi; \
175: sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so:/' \
1.1 deraadt 176: < .depend > $$TMP; \
1.11 deraadt 177: mv $$TMP .depend)
1.1 deraadt 178: .endif
179:
180: .if !target(install)
181: .if !target(beforeinstall)
182: beforeinstall:
183: .endif
184:
185: realinstall:
186: # ranlib lib${LIB}.a
1.13 millert 187: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 lib${LIB}.a \
1.1 deraadt 188: ${DESTDIR}${LIBDIR}
1.13 millert 189: .if (${INSTALL_COPY} != "-p")
1.1 deraadt 190: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.8 millert 191: .endif
1.1 deraadt 192: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
193: .if !defined(NOPROFILE)
194: # ranlib lib${LIB}_p.a
1.13 millert 195: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
1.1 deraadt 196: lib${LIB}_p.a ${DESTDIR}${LIBDIR}
1.13 millert 197: .if (${INSTALL_COPY} != "-p")
1.1 deraadt 198: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.8 millert 199: .endif
1.1 deraadt 200: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
201: .endif
1.6 pefo 202: .if !defined(NOPIC) && (${MACHINE_ARCH} != "mips")
1.1 deraadt 203: # ranlib lib${LIB}_pic.a
1.13 millert 204: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
1.1 deraadt 205: lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
1.13 millert 206: .if (${INSTALL_COPY} != "-p")
1.1 deraadt 207: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.8 millert 208: .endif
1.1 deraadt 209: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
210: .endif
211: .if !defined(NOPIC) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
1.13 millert 212: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.1 deraadt 213: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} ${DESTDIR}${LIBDIR}
214: .endif
215: .if !defined(NOLINT)
1.13 millert 216: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.1 deraadt 217: llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
218: .endif
219: .if defined(LINKS) && !empty(LINKS)
220: @set ${LINKS}; \
221: while test $$# -ge 2; do \
1.9 mickey 222: l=${DESTDIR}${BINDIR}/$$1; \
1.1 deraadt 223: shift; \
1.9 mickey 224: t=${DESTDIR}${BINDIR}/$$1; \
1.1 deraadt 225: shift; \
226: echo $$t -\> $$l; \
227: rm -f $$t; \
228: ln $$l $$t; \
229: done; true
230: .endif
231:
232: install: maninstall _SUBDIRUSE
233: maninstall: afterinstall
234: afterinstall: realinstall
235: realinstall: beforeinstall
236: .endif
237:
238: .if !defined(NOMAN)
239: .include <bsd.man.mk>
240: .endif
241:
242: .if !defined(NONLS)
243: .include <bsd.nls.mk>
244: .endif
245:
246: .include <bsd.obj.mk>
247: .include <bsd.dep.mk>
248: .include <bsd.subdir.mk>
1.2 deraadt 249: .include <bsd.sys.mk>