Annotation of src/share/mk/bsd.lib.mk, Revision 1.5
1.5 ! mickey 1: # $OpenBSD$
! 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
85:
86: .if !defined(PICFLAG)
87: PICFLAG=-fpic
88: .endif
89:
90: .if !defined(NOPROFILE)
91: _LIBS=lib${LIB}.a lib${LIB}_p.a
92: .else
93: _LIBS=lib${LIB}.a
94: .endif
95:
96: .if !defined(NOPIC)
97: _LIBS+=lib${LIB}_pic.a
98: .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
99: _LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
100: .endif
101: .endif
102:
103: .if !defined(NOLINT)
104: _LIBS+=llib-l${LIB}.ln
105: .endif
106:
107: all: ${_LIBS} _SUBDIRUSE
108:
109: OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
110:
111: lib${LIB}.a:: ${OBJS}
112: @echo building standard ${LIB} library
113: @rm -f lib${LIB}.a
1.3 niklas 114: @${AR} cq lib${LIB}.a `lorder ${OBJS} | tsort -q`
1.1 deraadt 115: ${RANLIB} lib${LIB}.a
116:
117: POBJS+= ${OBJS:.o=.po}
118: lib${LIB}_p.a:: ${POBJS}
119: @echo building profiled ${LIB} library
120: @rm -f lib${LIB}_p.a
1.3 niklas 121: @${AR} cq lib${LIB}_p.a `lorder ${POBJS} | tsort -q`
1.1 deraadt 122: ${RANLIB} lib${LIB}_p.a
123:
124: SOBJS+= ${OBJS:.o=.so}
125: lib${LIB}_pic.a:: ${SOBJS}
126: @echo building shared object ${LIB} library
127: @rm -f lib${LIB}_pic.a
1.3 niklas 128: @${AR} cq lib${LIB}_pic.a `lorder ${SOBJS} | tsort -q`
1.1 deraadt 129: ${RANLIB} lib${LIB}_pic.a
130:
131: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}_pic.a ${DPADD}
132: @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
133: @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
134: $(LD) -x -Bshareable -Bforcearchive \
135: -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} lib${LIB}_pic.a ${LDADD}
136:
137: LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
138: # the following looks XXX to me... -- cgd
139: LLIBS?= -lc
140: llib-l${LIB}.ln: ${LOBJS}
141: @echo building llib-l${LIB}.ln
142: @rm -f llib-l${LIB}.ln
143: @${LINT} -C${LIB} ${LOBJS} ${LLIBS}
144:
145: .if !target(clean)
146: clean: _SUBDIRUSE
147: rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
148: rm -f lib${LIB}.a ${OBJS}
149: rm -f lib${LIB}_p.a ${POBJS}
150: rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
151: rm -f llib-l${LIB}.ln ${LOBJS}
152: .endif
153:
154: cleandir: _SUBDIRUSE clean
155:
156: .if defined(SRCS)
157: afterdepend: .depend
158: @(TMP=/tmp/_depend$$$$; \
159: sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so:/' \
160: < .depend > $$TMP; \
161: mv $$TMP .depend)
162: .endif
163:
164: .if !target(install)
165: .if !target(beforeinstall)
166: beforeinstall:
167: .endif
168:
169: realinstall:
170: # ranlib lib${LIB}.a
171: install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 lib${LIB}.a \
172: ${DESTDIR}${LIBDIR}
173: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
174: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
175: .if !defined(NOPROFILE)
176: # ranlib lib${LIB}_p.a
177: install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
178: lib${LIB}_p.a ${DESTDIR}${LIBDIR}
179: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
180: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
181: .endif
182: .if !defined(NOPIC)
183: # ranlib lib${LIB}_pic.a
184: install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
185: lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
186: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
187: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
188: .endif
189: .if !defined(NOPIC) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
190: install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
191: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} ${DESTDIR}${LIBDIR}
192: .endif
193: .if !defined(NOLINT)
194: install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
195: llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
196: .endif
197: .if defined(LINKS) && !empty(LINKS)
198: @set ${LINKS}; \
199: while test $$# -ge 2; do \
200: l=${DESTDIR}$$1; \
201: shift; \
202: t=${DESTDIR}$$1; \
203: shift; \
204: echo $$t -\> $$l; \
205: rm -f $$t; \
206: ln $$l $$t; \
207: done; true
208: .endif
209:
210: install: maninstall _SUBDIRUSE
211: maninstall: afterinstall
212: afterinstall: realinstall
213: realinstall: beforeinstall
214: .endif
215:
216: .if !defined(NOMAN)
217: .include <bsd.man.mk>
218: .endif
219:
220: .if !defined(NONLS)
221: .include <bsd.nls.mk>
222: .endif
223:
224: .include <bsd.obj.mk>
225: .include <bsd.dep.mk>
226: .include <bsd.subdir.mk>
1.2 deraadt 227: .include <bsd.sys.mk>