turns printfs back on
[freebsd-src/fkvm-freebsd.git] / share / mk / bsd.lib.mk
blob741c9cb2b618b975ff409c0127b54dbea83c0046
1 # from: @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91
2 # $FreeBSD$
5 .include <bsd.init.mk>
7 # Set up the variables controlling shared libraries. After this section,
8 # SHLIB_NAME will be defined only if we are to create a shared library.
9 # SHLIB_LINK will be defined only if we are to create a link to it.
10 # INSTALL_PIC_ARCHIVE will be defined only if we are to create a PIC archive.
11 .if defined(NO_PIC)
12 .undef SHLIB_NAME
13 .undef INSTALL_PIC_ARCHIVE
14 .else
15 .if !defined(SHLIB) && defined(LIB)
16 SHLIB= ${LIB}
17 .endif
18 .if !defined(SHLIB_NAME) && defined(SHLIB) && defined(SHLIB_MAJOR)
19 SHLIB_NAME= lib${SHLIB}.so.${SHLIB_MAJOR}
20 .endif
21 .if defined(SHLIB_NAME) && !empty(SHLIB_NAME:M*.so.*)
22 SHLIB_LINK?= ${SHLIB_NAME:R}
23 .endif
24 SONAME?= ${SHLIB_NAME}
25 .endif
27 .if defined(CRUNCH_CFLAGS)
28 CFLAGS+= ${CRUNCH_CFLAGS}
29 .endif
31 .if ${MK_ASSERT_DEBUG} == "no"
32 CFLAGS+= -DNDEBUG
33 NO_WERROR=
34 .endif
36 .if defined(DEBUG_FLAGS)
37 CFLAGS+= ${DEBUG_FLAGS}
39 .if !defined(NO_CTF) && (${DEBUG_FLAGS:M-g} != "")
40 CTFFLAGS+= -g
41 .endif
42 .endif
44 .if !defined(DEBUG_FLAGS)
45 STRIP?= -s
46 .endif
48 .include <bsd.libnames.mk>
50 # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
51 # .So used for PIC object files
52 .SUFFIXES:
53 .SUFFIXES: .out .o .po .So .S .asm .s .c .cc .cpp .cxx .m .C .f .y .l .ln
55 .if !defined(PICFLAG)
56 .if ${MACHINE_ARCH} == "sparc64"
57 PICFLAG=-fPIC
58 .else
59 PICFLAG=-fpic
60 .endif
61 .endif
63 .if ${CC} == "icc"
64 PO_FLAG=-p
65 .else
66 PO_FLAG=-pg
67 .endif
69 .c.po:
70 ${CC} ${PO_FLAG} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
71 .if defined(CTFCONVERT)
72 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
73 .endif
75 .c.So:
76 ${CC} ${PICFLAG} -DPIC ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
77 .if defined(CTFCONVERT)
78 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
79 .endif
81 .cc.po .C.po .cpp.po .cxx.po:
82 ${CXX} ${PO_FLAG} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
84 .cc.So .C.So .cpp.So .cxx.So:
85 ${CXX} ${PICFLAG} -DPIC ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
87 .f.po:
88 ${FC} -pg ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC}
89 .if defined(CTFCONVERT)
90 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
91 .endif
93 .f.So:
94 ${FC} ${PICFLAG} -DPIC ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC}
95 .if defined(CTFCONVERT)
96 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
97 .endif
99 .m.po:
100 ${OBJC} ${OBJCFLAGS} -pg -c ${.IMPSRC} -o ${.TARGET}
101 .if defined(CTFCONVERT)
102 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
103 .endif
105 .m.So:
106 ${OBJC} ${PICFLAG} -DPIC ${OBJCFLAGS} -c ${.IMPSRC} -o ${.TARGET}
107 .if defined(CTFCONVERT)
108 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
109 .endif
111 .s.po .s.So:
112 ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
113 .if defined(CTFCONVERT)
114 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
115 .endif
117 .asm.po:
118 ${CC} -x assembler-with-cpp -DPROF ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
119 .if defined(CTFCONVERT)
120 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
121 .endif
123 .asm.So:
124 ${CC} -x assembler-with-cpp ${PICFLAG} -DPIC ${CFLAGS} \
125 -c ${.IMPSRC} -o ${.TARGET}
126 .if defined(CTFCONVERT)
127 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
128 .endif
130 .S.po:
131 ${CC} -DPROF ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
132 .if defined(CTFCONVERT)
133 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
134 .endif
136 .S.So:
137 ${CC} ${PICFLAG} -DPIC ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
138 .if defined(CTFCONVERT)
139 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
140 .endif
142 all: objwarn
144 .include <bsd.symver.mk>
146 # Allow libraries to specify their own version map or have it
147 # automatically generated (see bsd.symver.mk above).
148 .if ${MK_SYMVER} == "yes" && !empty(VERSION_MAP)
149 ${SHLIB_NAME}: ${VERSION_MAP}
150 LDFLAGS+= -Wl,--version-script=${VERSION_MAP}
151 .endif
153 .if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME)
154 OBJS+= ${SRCS:N*.h:R:S/$/.o/}
155 .endif
157 .if defined(LIB) && !empty(LIB)
158 _LIBS= lib${LIB}.a
160 lib${LIB}.a: ${OBJS} ${STATICOBJS}
161 @${ECHO} building static ${LIB} library
162 @rm -f ${.TARGET}
163 .if !defined(NM)
164 @${AR} cq ${.TARGET} `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
165 .else
166 @${AR} cq ${.TARGET} `NM='${NM}' lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
167 .endif
168 ${RANLIB} ${.TARGET}
169 .endif
171 .if !defined(INTERNALLIB)
173 .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
174 _LIBS+= lib${LIB}_p.a
175 POBJS+= ${OBJS:.o=.po} ${STATICOBJS:.o=.po}
177 lib${LIB}_p.a: ${POBJS}
178 @${ECHO} building profiled ${LIB} library
179 @rm -f ${.TARGET}
180 .if !defined(NM)
181 @${AR} cq ${.TARGET} `lorder ${POBJS} | tsort -q` ${ARADD}
182 .else
183 @${AR} cq ${.TARGET} `NM='${NM}' lorder ${POBJS} | tsort -q` ${ARADD}
184 .endif
185 ${RANLIB} ${.TARGET}
186 .endif
188 .if defined(SHLIB_NAME) || \
189 defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
190 SOBJS+= ${OBJS:.o=.So}
191 .endif
193 .if defined(SHLIB_NAME)
194 _LIBS+= ${SHLIB_NAME}
196 ${SHLIB_NAME}: ${SOBJS}
197 @${ECHO} building shared library ${SHLIB_NAME}
198 @rm -f ${.TARGET} ${SHLIB_LINK}
199 .if defined(SHLIB_LINK)
200 @ln -fs ${.TARGET} ${SHLIB_LINK}
201 .endif
202 .if !defined(NM)
203 @${CC} ${LDFLAGS} -shared -Wl,-x \
204 -o ${.TARGET} -Wl,-soname,${SONAME} \
205 `lorder ${SOBJS} | tsort -q` ${LDADD}
206 .else
207 @${CC} ${LDFLAGS} -shared -Wl,-x \
208 -o ${.TARGET} -Wl,-soname,${SONAME} \
209 `NM='${NM}' lorder ${SOBJS} | tsort -q` ${LDADD}
210 .endif
211 .if defined(CTFMERGE)
212 ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS}
213 .endif
214 .endif
216 .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
217 _LIBS+= lib${LIB}_pic.a
219 lib${LIB}_pic.a: ${SOBJS}
220 @${ECHO} building special pic ${LIB} library
221 @rm -f ${.TARGET}
222 @${AR} cq ${.TARGET} ${SOBJS} ${ARADD}
223 ${RANLIB} ${.TARGET}
224 .endif
226 .if defined(WANT_LINT) && !defined(NO_LINT) && defined(LIB) && !empty(LIB)
227 LINTLIB= llib-l${LIB}.ln
228 _LIBS+= ${LINTLIB}
229 LINTOBJS+= ${SRCS:M*.c:.c=.ln}
231 ${LINTLIB}: ${LINTOBJS}
232 @${ECHO} building lint library ${.TARGET}
233 @rm -f ${.TARGET}
234 ${LINT} ${LINTLIBFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC}
235 .endif
237 .endif # !defined(INTERNALLIB)
239 all: ${_LIBS}
241 .if ${MK_MAN} != "no"
242 all: _manpages
243 .endif
245 _EXTRADEPEND:
246 @TMP=_depend$$$$; \
247 sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.So:/' < ${DEPENDFILE} \
248 > $$TMP; \
249 mv $$TMP ${DEPENDFILE}
250 .if !defined(NO_EXTRADEPEND) && defined(SHLIB_NAME)
251 .if defined(DPADD) && !empty(DPADD)
252 echo ${SHLIB_NAME}: ${DPADD} >> ${DEPENDFILE}
253 .endif
254 .endif
256 .if !target(install)
258 .if defined(PRECIOUSLIB)
259 .if !defined(NO_FSCHG)
260 SHLINSTALLFLAGS+= -fschg
261 .endif
262 SHLINSTALLFLAGS+= -S
263 .endif
265 _INSTALLFLAGS:= ${INSTALLFLAGS}
266 .for ie in ${INSTALLFLAGS_EDIT}
267 _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
268 .endfor
269 _SHLINSTALLFLAGS:= ${SHLINSTALLFLAGS}
270 .for ie in ${INSTALLFLAGS_EDIT}
271 _SHLINSTALLFLAGS:= ${_SHLINSTALLFLAGS${ie}}
272 .endfor
274 .if !defined(INTERNALLIB)
275 realinstall: _libinstall
276 .ORDER: beforeinstall _libinstall
277 _libinstall:
278 .if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
279 ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
280 ${_INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR}
281 .endif
282 .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
283 ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
284 ${_INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR}
285 .endif
286 .if defined(SHLIB_NAME)
287 ${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
288 ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
289 ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}
290 .if defined(SHLIB_LINK)
291 .if ${SHLIBDIR} == ${LIBDIR}
292 ln -fs ${SHLIB_NAME} ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
293 .else
294 ln -fs ${_SHLIBDIRPREFIX}${SHLIBDIR}/${SHLIB_NAME} \
295 ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
296 .if exists(${DESTDIR}${LIBDIR}/${SHLIB_NAME})
297 -chflags noschg ${DESTDIR}${LIBDIR}/${SHLIB_NAME}
298 rm -f ${DESTDIR}${LIBDIR}/${SHLIB_NAME}
299 .endif
300 .endif
301 .endif
302 .endif
303 .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
304 ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
305 ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
306 .endif
307 .if defined(WANT_LINT) && !defined(NO_LINT) && defined(LIB) && !empty(LIB)
308 ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
309 ${_INSTALLFLAGS} ${LINTLIB} ${DESTDIR}${LINTLIBDIR}
310 .endif
311 .endif # !defined(INTERNALLIB)
313 .include <bsd.nls.mk>
314 .include <bsd.files.mk>
315 .include <bsd.incs.mk>
316 .include <bsd.links.mk>
318 .if ${MK_MAN} != "no"
319 realinstall: _maninstall
320 .ORDER: beforeinstall _maninstall
321 .endif
323 .endif
325 .if !target(lint)
326 lint: ${SRCS:M*.c}
327 ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC}
328 .endif
330 .if ${MK_MAN} != "no"
331 .include <bsd.man.mk>
332 .endif
334 .include <bsd.dep.mk>
336 .if !exists(${.OBJDIR}/${DEPENDFILE})
337 .if defined(LIB) && !empty(LIB)
338 ${OBJS} ${STATICOBJS} ${POBJS}: ${SRCS:M*.h}
339 .for _S in ${SRCS:N*.[hly]}
340 ${_S:R}.po: ${_S}
341 .endfor
342 .endif
343 .if defined(SHLIB_NAME) || \
344 defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
345 ${SOBJS}: ${SRCS:M*.h}
346 .for _S in ${SRCS:N*.[hly]}
347 ${_S:R}.So: ${_S}
348 .endfor
349 .endif
350 .endif
352 .if !target(clean)
353 clean:
354 .if defined(CLEANFILES) && !empty(CLEANFILES)
355 rm -f ${CLEANFILES}
356 .endif
357 .if defined(LIB) && !empty(LIB)
358 rm -f a.out ${OBJS} ${OBJS:S/$/.tmp/} ${STATICOBJS}
359 .endif
360 .if !defined(INTERNALLIB)
361 .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
362 rm -f ${POBJS} ${POBJS:S/$/.tmp/}
363 .endif
364 .if defined(SHLIB_NAME) || \
365 defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
366 rm -f ${SOBJS} ${SOBJS:.So=.so} ${SOBJS:S/$/.tmp/}
367 .endif
368 .if defined(SHLIB_NAME)
369 .if defined(SHLIB_LINK)
370 rm -f ${SHLIB_LINK}
371 .endif
372 .if defined(LIB) && !empty(LIB)
373 rm -f lib${LIB}.so.* lib${LIB}.so
374 .endif
375 .endif
376 .if defined(WANT_LINT) && defined(LIB) && !empty(LIB)
377 rm -f ${LINTOBJS}
378 .endif
379 .endif # !defined(INTERNALLIB)
380 .if defined(_LIBS) && !empty(_LIBS)
381 rm -f ${_LIBS}
382 .endif
383 .if defined(CLEANDIRS) && !empty(CLEANDIRS)
384 rm -rf ${CLEANDIRS}
385 .endif
386 .if !empty(VERSION_DEF) && !empty(SYMBOL_MAPS)
387 rm -f ${VERSION_MAP}
388 .endif
389 .endif
391 .include <bsd.obj.mk>
393 .include <bsd.sys.mk>