Annotation of src/share/mk/bsd.lib.mk, Revision 1.9
1.9 ! mickey 1: # $OpenBSD: bsd.lib.mk,v 1.8 1996/08/05 16:56:55 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:
24: @echo "${COMPILE.c} ${.IMPSRC}"
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:
45: @echo "${COMPILE.cc} ${.IMPSRC}"
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.3 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.3 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.3 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
170: @(TMP=/tmp/_depend$$$$; \
171: sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so:/' \
172: < .depend > $$TMP; \
173: mv $$TMP .depend)
174: .endif
175:
176: .if !target(install)
177: .if !target(beforeinstall)
178: beforeinstall:
179: .endif
180:
181: realinstall:
182: # ranlib lib${LIB}.a
183: install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 lib${LIB}.a \
184: ${DESTDIR}${LIBDIR}
1.8 millert 185: .if (${COPY} != "-p")
1.1 deraadt 186: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.8 millert 187: .endif
1.1 deraadt 188: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
189: .if !defined(NOPROFILE)
190: # ranlib lib${LIB}_p.a
191: install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
192: lib${LIB}_p.a ${DESTDIR}${LIBDIR}
1.8 millert 193: .if (${COPY} != "-p")
1.1 deraadt 194: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.8 millert 195: .endif
1.1 deraadt 196: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
197: .endif
1.6 pefo 198: .if !defined(NOPIC) && (${MACHINE_ARCH} != "mips")
1.1 deraadt 199: # ranlib lib${LIB}_pic.a
200: install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
201: lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
1.8 millert 202: .if (${COPY} != "-p")
1.1 deraadt 203: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.8 millert 204: .endif
1.1 deraadt 205: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
206: .endif
207: .if !defined(NOPIC) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
208: install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
209: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} ${DESTDIR}${LIBDIR}
210: .endif
211: .if !defined(NOLINT)
212: install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
213: llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
214: .endif
215: .if defined(LINKS) && !empty(LINKS)
216: @set ${LINKS}; \
217: while test $$# -ge 2; do \
1.9 ! mickey 218: l=${DESTDIR}${BINDIR}/$$1; \
1.1 deraadt 219: shift; \
1.9 ! mickey 220: t=${DESTDIR}${BINDIR}/$$1; \
1.1 deraadt 221: shift; \
222: echo $$t -\> $$l; \
223: rm -f $$t; \
224: ln $$l $$t; \
225: done; true
226: .endif
227:
228: install: maninstall _SUBDIRUSE
229: maninstall: afterinstall
230: afterinstall: realinstall
231: realinstall: beforeinstall
232: .endif
233:
234: .if !defined(NOMAN)
235: .include <bsd.man.mk>
236: .endif
237:
238: .if !defined(NONLS)
239: .include <bsd.nls.mk>
240: .endif
241:
242: .include <bsd.obj.mk>
243: .include <bsd.dep.mk>
244: .include <bsd.subdir.mk>
1.2 deraadt 245: .include <bsd.sys.mk>