mkfs: drop support for zone != block
[minix.git] / share / mk / bsd.lib.mk
blobdb7acbfacd4b8c1210430aa7632290ed5e408454
1 # $NetBSD: bsd.lib.mk,v 1.299 2009/11/27 11:44:36 tsutsui Exp $
2 # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94
4 .include <bsd.init.mk>
5 .include <bsd.shlib.mk>
6 #.include <bsd.gcc.mk>
7 # Pull in <bsd.sys.mk> here so we can override its .c.o rule
8 .include <bsd.sys.mk>
10 LIBISMODULE?= no
11 LIBISPRIVATE?= no
12 LIBISCXX?= no
14 # Build shared libraries if not set to no by now
15 MKPIC?= yes
17 # If we're making a library but aren't making shared
18 # libraries and it's because there's a non-shared-aware clang
19 # installed, warn the user that that's the reason.
20 .if $(MKPIC) == "no" && defined(NONPICCLANG)
21 .warning Old clang, not building shared.
22 .endif
24 _LIB_PREFIX= lib
26 .if ${LIBISMODULE} != "no"
27 _LIB_PREFIX= # empty
28 MKDEBUGLIB:= no
29 MKLINT:= no
30 MKPICINSTALL:= no
31 MKPROFILE:= no
32 MKSTATICLIB:= no
33 .endif
35 .if ${LIBISPRIVATE} != "no"
36 MKDEBUGLIB:= no
37 MKLINT:= no
38 MKPICINSTALL:= no
39 . if defined(NOSTATICLIB) && ${MKPICLIB} != "no"
40 MKSTATICLIB:= no
41 . else
42 MKPIC:= no
43 . endif
44 MKPROFILE:= no
45 .endif
47 ##### Basic targets
48 .PHONY: checkver libinstall
49 realinstall: checkver libinstall
50 clean: cleanlib
52 ##### LIB specific flags.
53 # XXX: This is needed for programs that link with .a libraries
54 # Perhaps a more correct solution is to always generate _pic.a
55 # files or always have a shared library.
56 .if defined(MKPIE) && (${MKPIE} != "no")
57 CFLAGS+= ${PIE_CFLAGS}
58 AFLAGS+= ${PIE_AFLAGS}
59 .endif
60 COPTS+= ${COPTS.lib${LIB}}
61 CPPFLAGS+= ${CPPFLAGS.lib${LIB}}
62 CXXFLAGS+= ${CXXFLAGS.lib${LIB}}
63 OBJCOPTS+= ${OBJCOPTS.lib${LIB}}
64 LDADD+= ${LDADD.lib${LIB}}
65 LDFLAGS+= ${LDFLAGS.lib${LIB}}
66 LDSTATIC+= ${LDSTATIC.lib${LIB}}
68 ##### Libraries that this may depend upon.
69 .if defined(LIBDPLIBS) && ${MKPIC} != "no" # {
70 .for _lib _dir in ${LIBDPLIBS}
71 .if !defined(LIBDO.${_lib})
72 LIBDO.${_lib}!= cd ${_dir} && ${PRINTOBJDIR}
73 .MAKEOVERRIDES+=LIBDO.${_lib}
74 .endif
75 LDADD+= -L${LIBDO.${_lib}} -l${_lib}
76 DPADD+= ${LIBDO.${_lib}}/lib${_lib}.so
77 .endfor
78 .endif # }
80 ##### Build and install rules
81 MKDEP_SUFFIXES?= .o .po .so .go .ln
83 # Use purely kernel private headers in rump builds
84 .if !defined(RUMPKERNEL)
85 .if empty(CPPFLAGS:M-nostdinc)
86 CPPFLAGS+= ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
87 .endif
88 .if empty(CXXFLAGS:M-nostdinc++)
89 CXXFLAGS+= ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} ${DESTDIR}/usr/include/g++}
90 .endif
91 .endif
93 .if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE}) # {
94 SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major
95 SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor
96 SHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny
98 DPADD+= ${SHLIB_VERSION_FILE}
100 # Check for higher installed library versions.
101 .if !defined(NOCHECKVER) && !defined(NOCHECKVER_${LIB}) && \
102 exists(${NETBSDSRCDIR}/lib/checkver)
103 checkver:
104 @(cd ${.CURDIR} && \
105 HOST_SH=${HOST_SH:Q} AWK=${TOOL_AWK:Q} \
106 ${HOST_SH} ${NETBSDSRCDIR}/lib/checkver -v ${SHLIB_VERSION_FILE} \
107 -d ${DESTDIR}${_LIBSODIR} ${LIB})
108 .endif
109 .endif # }
111 .if !target(checkver)
112 checkver:
113 .endif
115 print-shlib-major:
116 .if defined(SHLIB_MAJOR) && ${MKPIC} != "no"
117 @echo ${SHLIB_MAJOR}
118 .else
119 @false
120 .endif
122 print-shlib-minor:
123 .if defined(SHLIB_MINOR) && ${MKPIC} != "no"
124 @echo ${SHLIB_MINOR}
125 .else
126 @false
127 .endif
129 print-shlib-teeny:
130 .if defined(SHLIB_TEENY) && ${MKPIC} != "no"
131 @echo ${SHLIB_TEENY}
132 .else
133 @false
134 .endif
136 .if defined(SHLIB_MAJOR) && !empty(SHLIB_MAJOR) # {
137 .if defined(SHLIB_MINOR) && !empty(SHLIB_MINOR)
138 .if defined(SHLIB_TEENY) && !empty(SHLIB_TEENY)
139 SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}.${SHLIB_TEENY}
140 .else
141 SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}
142 .endif
143 .else
144 SHLIB_FULLVERSION=${SHLIB_MAJOR}
145 .endif
146 .endif # }
148 # add additional suffixes not exported.
149 # .po is used for profiling object files.
150 # .so is used for PIC object files.
151 .SUFFIXES: .out .a .ln .so .po .go .o .s .S .c .cc .cpp .cxx .C .m .F .f .r .y .l .cl .p .h
152 .SUFFIXES: .sh .m4 .m
155 # Set PICFLAGS to cc flags for producing position-independent code,
156 # if not already set. Includes -DPIC, if required.
158 # Data-driven table using make variables to control how shared libraries
159 # are built for different platforms and object formats.
160 # OBJECT_FMT: currently either "ELF" or "a.out", from <bsd.own.mk>
161 # SHLIB_SOVERSION: version number to be compiled into a shared library
162 # via -soname. Usualy ${SHLIB_MAJOR} on ELF.
163 # NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR}
164 # [.${SHLIB_TEENY}]]
165 # SHLIB_SHFLAGS: Flags to tell ${LD} to emit shared library.
166 # with ELF, also set shared-lib version for ld.so.
167 # SHLIB_LDSTARTFILE: support .o file, call C++ file-level constructors
168 # SHLIB_LDENDFILE: support .o file, call C++ file-level destructors
169 # FPICFLAGS: flags for ${FC} to compile .[fF] files to .so objects.
170 # CPPPICFLAGS: flags for ${CPP} to preprocess .[sS] files for ${AS}
171 # CPICFLAGS: flags for ${CC} to compile .[cC] files to pic objects.
172 # CSHLIBFLAGS: flags for ${CC} to compile .[cC] files to .so objects.
173 # (usually includes ${CPICFLAGS})
174 # CAPICFLAGS: flags for ${CC} to compiling .[Ss] files
175 # (usually just ${CPPPICFLAGS} ${CPICFLAGS})
176 # APICFLAGS: flags for ${AS} to assemble .[sS] to .so objects.
178 .if ${MACHINE_ARCH} == "alpha" # {
180 FPICFLAGS ?= -fPIC
181 CPICFLAGS ?= -fPIC -DPIC
182 CPPPICFLAGS?= -DPIC
183 CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
184 APICFLAGS ?=
186 .elif (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") && \
187 ${OBJECT_FMT} == "ELF" # } {
189 # If you use -fPIC you need to define BIGPIC to turn on 32-bit
190 # relocations in asm code
191 FPICFLAGS ?= -fPIC
192 CPICFLAGS ?= -fPIC -DPIC
193 CPPPICFLAGS?= -DPIC -DBIGPIC
194 CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
195 APICFLAGS ?= -KPIC
197 .else # } {
199 # Platform-independent flags for NetBSD shared libraries
200 SHLIB_SOVERSION=${SHLIB_FULLVERSION}
201 SHLIB_SHFLAGS=
202 FPICFLAGS ?= -fPIC
203 CPICFLAGS?= -fPIC -DPIC
204 CPPPICFLAGS?= -DPIC
205 CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
206 APICFLAGS?= -k
208 .endif # }
210 .if ${MKPICLIB} != "no"
211 CSHLIBFLAGS+= ${CPICFLAGS}
212 .endif
214 .if defined(CSHLIBFLAGS) && !empty(CSHLIBFLAGS)
215 MKSHLIBOBJS= yes
216 .else
217 MKSHLIBOBJS= no
218 .endif
220 # Platform-independent linker flags for ELF shared libraries
221 .if ${OBJECT_FMT} == "ELF"
222 SHLIB_SOVERSION= ${SHLIB_MAJOR}
223 SHLIB_SHFLAGS= -Wl,-soname,${_LIB_PREFIX}${LIB}.so.${SHLIB_SOVERSION}
224 SHLIB_SHFLAGS+= -Wl,--warn-shared-textrel
225 SHLIB_LDSTARTFILE?= ${DESTDIR}/usr/lib/crti.o ${_GCC_CRTBEGINS}
226 SHLIB_LDENDFILE?= ${_GCC_CRTENDS} ${DESTDIR}/usr/lib/crtn.o
227 .endif
229 CFLAGS+= ${COPTS}
230 OBJCFLAGS+= ${OBJCOPTS}
231 AFLAGS+= ${COPTS}
232 FFLAGS+= ${FOPTS}
234 .c.o:
235 ${_MKTARGET_COMPILE}
236 ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
237 .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
238 ${OBJCOPY} -x ${.TARGET}
239 .endif
241 .c.po:
242 ${_MKTARGET_COMPILE}
243 ${COMPILE.c} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET}
244 .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
245 ${OBJCOPY} -X ${.TARGET}
246 .endif
248 .c.go:
249 ${_MKTARGET_COMPILE}
250 ${COMPILE.c} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET}
252 .c.so:
253 ${_MKTARGET_COMPILE}
254 ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
255 .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
256 ${OBJCOPY} -x ${.TARGET}
257 .endif
259 .cc.o .cpp.o .cxx.o .C.o:
260 ${_MKTARGET_COMPILE}
261 ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
262 .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
263 ${OBJCOPY} -x ${.TARGET}
264 .endif
266 .cc.po .cpp.po .cxx.po .C.po:
267 ${_MKTARGET_COMPILE}
268 ${COMPILE.cc} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET}
269 .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
270 ${OBJCOPY} -X ${.TARGET}
271 .endif
273 .cc.go .cpp.go .cxx.go .C.go:
274 ${_MKTARGET_COMPILE}
275 ${COMPILE.cc} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET}
277 .cc.so .cpp.so .cxx.so .C.so:
278 ${_MKTARGET_COMPILE}
279 ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
280 .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
281 ${OBJCOPY} -x ${.TARGET}
282 .endif
284 .f.o:
285 ${_MKTARGET_COMPILE}
286 ${COMPILE.f} ${.IMPSRC} -o ${.TARGET}
287 .if !defined(FOPTS) || empty(FOPTS:M*-g*)
288 ${OBJCOPY} -x ${.TARGET}
289 .endif
291 .f.po:
292 ${_MKTARGET_COMPILE}
293 ${COMPILE.f} ${PROFFLAGS} -pg ${.IMPSRC} -o ${.TARGET}
294 .if !defined(FOPTS) || empty(FOPTS:M*-g*)
295 ${OBJCOPY} -X ${.TARGET}
296 .endif
298 .f.go:
299 ${_MKTARGET_COMPILE}
300 ${COMPILE.f} ${DEBUGFLAGS} -g ${.IMPSRC} -o ${.TARGET}
302 .f.so:
303 ${_MKTARGET_COMPILE}
304 ${COMPILE.f} ${FPICFLAGS} ${.IMPSRC} -o ${.TARGET}
305 .if !defined(FOPTS) || empty(FOPTS:M*-g*)
306 ${OBJCOPY} -x ${.TARGET}
307 .endif
309 .f.ln:
310 ${_MKTARGET_COMPILE}
311 @echo Skipping lint for Fortran libraries.
313 .m.o:
314 ${_MKTARGET_COMPILE}
315 ${COMPILE.m} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
316 .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
317 ${OBJCOPY} -x ${.TARGET}
318 .endif
320 .m.po:
321 ${_MKTARGET_COMPILE}
322 ${COMPILE.m} ${PROFFLAGS} -pg ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
323 .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
324 ${OBJCOPY} -X ${.TARGET}
325 .endif
327 .m.go:
328 ${_MKTARGET_COMPILE}
329 ${COMPILE.m} ${DEBUGFLAGS} -g ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
330 .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
331 ${OBJCOPY} -X ${.TARGET}
332 .endif
334 .m.so:
335 ${_MKTARGET_COMPILE}
336 ${COMPILE.m} ${CSHLIBFLAGS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
337 .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
338 ${OBJCOPY} -x ${.TARGET}
339 .endif
341 .s.o:
342 ${_MKTARGET_COMPILE}
343 ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
344 ${OBJCOPY} -x ${.TARGET}
346 .S.o:
347 ${_MKTARGET_COMPILE}
348 ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
349 ${OBJCOPY} -x ${.TARGET}
351 .s.po:
352 ${_MKTARGET_COMPILE}
353 ${COMPILE.s} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
354 ${OBJCOPY} -X ${.TARGET}
356 .S.po:
357 ${_MKTARGET_COMPILE}
358 ${COMPILE.S} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
359 ${OBJCOPY} -X ${.TARGET}
361 .s.go:
362 ${_MKTARGET_COMPILE}
363 ${COMPILE.s} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
365 .S.go:
366 ${_MKTARGET_COMPILE}
367 ${COMPILE.S} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
369 .s.so:
370 ${_MKTARGET_COMPILE}
371 ${COMPILE.s} ${CAPICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
372 ${OBJCOPY} -x ${.TARGET}
374 .S.so:
375 ${_MKTARGET_COMPILE}
376 ${COMPILE.S} ${CAPICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
377 ${OBJCOPY} -x ${.TARGET}
379 .if defined(LIB) # {
380 .if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
381 || ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
382 _LIBS=lib${LIB}.a
383 .else
384 _LIBS=
385 .endif
387 OBJS+=${SRCS:N*.h:N*.sh:R:S/$/.o/g}
389 STOBJS+=${OBJS}
391 LOBJS+=${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
393 .if ${LIBISPRIVATE} != "no"
394 # No installation is required
395 libinstall::
396 .endif # ${LIBISPRIVATE} == "no" # {
398 .if ${MKDEBUGLIB} != "no"
399 _LIBS+=lib${LIB}_g.a
400 GOBJS+=${OBJS:.o=.go}
401 DEBUGFLAGS?=-DDEBUG
402 .endif
404 .if ${MKPROFILE} != "no"
405 _LIBS+=lib${LIB}_p.a
406 POBJS+=${OBJS:.o=.po}
407 PROFFLAGS?=-DGPROF -DPROF
408 .endif
410 .if ${MKPIC} != "no" # {
411 .if ${MKPICLIB} == "no"
412 .if ${MKSHLIBOBJS} != "no"
413 # make _pic.a, which isn't really pic,
414 # since it's needed for making shared lib.
415 # but don't install it.
416 SOLIB=lib${LIB}_pic.a
417 SOBJS+=${OBJS:.o=.so}
418 .else
419 SOLIB=lib${LIB}.a
420 .endif
421 .else
422 SOLIB=lib${LIB}_pic.a
423 _LIBS+=${SOLIB}
424 SOBJS+=${OBJS:.o=.so}
425 .endif
426 .if defined(SHLIB_FULLVERSION)
427 _LIBS+=lib${LIB}.so.${SHLIB_FULLVERSION}
428 .endif
429 .endif # }
431 .if ${MKLINT} != "no" && !empty(LOBJS)
432 _LIBS+=llib-l${LIB}.ln
433 .endif
435 ALLOBJS=
436 .if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
437 || ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
438 ALLOBJS+=${STOBJS}
439 .endif
440 ALLOBJS+=${POBJS} ${SOBJS}
441 .if ${MKLINT} != "no" && !empty(LOBJS)
442 ALLOBJS+=${LOBJS}
443 .endif
444 .else # !defined(LIB) # } {
445 LOBJS=
446 SOBJS=
447 .endif # !defined(LIB) # }
449 _YLSRCS= ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
451 .NOPATH: ${ALLOBJS} ${_LIBS} ${_YLSRCS}
453 realall: ${SRCS} ${ALLOBJS:O} ${_LIBS}
455 MKARZERO?=no
457 .if ${MKARZERO} == "yes"
458 _ARFL=crsD
459 _ARRANFL=sD
460 _INSTRANLIB=
461 .else
462 _ARFL=crs
463 _ARRANFL=s
464 #_INSTRANLIB=${empty(PRESERVE):?-a "${RANLIB} -t":}
465 .endif
467 # If you change this, please consider reflecting the change in
468 # the override in sys/rump/Makefile.rump.
469 .if !target(__archivebuild)
470 __archivebuild: .USE
471 ${_MKTARGET_BUILD}
472 rm -f ${.TARGET}
473 # ${AR} ${_ARFL} ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
474 ${AR} ${_ARFL} ${.TARGET} ${.ALLSRC:M*o}
475 .endif
477 .if !target(__archiveinstall)
478 __archiveinstall: .USE
479 ${_MKTARGET_INSTALL}
480 ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
481 ${_INSTRANLIB} ${.ALLSRC} ${.TARGET}
482 .endif
484 __archivesymlinkpic: .USE
485 ${_MKTARGET_INSTALL}
486 ${INSTALL_SYMLINK} ${.ALLSRC} ${.TARGET}
488 DPSRCS+= ${_YLSRCS}
489 CLEANFILES+= ${_YLSRCS}
491 ${STOBJS} ${POBJS} ${GOBJS} ${SOBJS} ${LOBJS}: ${DPSRCS}
493 lib${LIB}.a:: ${STOBJS} __archivebuild
495 lib${LIB}_p.a:: ${POBJS} __archivebuild
497 lib${LIB}_pic.a:: ${SOBJS} __archivebuild
499 lib${LIB}_g.a:: ${GOBJS} __archivebuild
502 _LIBLDOPTS=
503 #.if ${SHLIBDIR} != "/usr/lib"
504 #_LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
505 # -R${SHLIBDIR} \
506 # -L${DESTDIR}${SHLIBDIR}
507 #.elif ${SHLIBINSTALLDIR} != "/usr/lib"
508 #_LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
509 # -L${DESTDIR}${SHLIBINSTALLDIR}
510 #.endif
512 # gcc -shared now adds -lc automatically. For libraries other than libc and
513 # libgcc* we add as a dependency the installed shared libc. For libc and
514 # libgcc* we avoid adding libc as a dependency by using -nostdlib. Note that
515 # -Xl,-nostdlib is not enough because we want to tell the compiler-driver not
516 # to add standard libraries, not the linker.
517 .if !defined(LIB)
518 DPLIBC ?= ${DESTDIR}${LIBC_SO}
519 .else
520 .if ${LIB} != "c" && ${LIB:Mgcc*} == ""
521 DPLIBC ?= ${DESTDIR}${LIBC_SO}
522 .else
523 LDLIBC ?= -nodefaultlibs
524 .if ${LIB} == "c"
525 #LDADD+= -lgcc_pic
526 .endif
527 .endif
528 .endif
530 .if ${LIBISCXX} != "no"
531 LIBCC:= ${CXX}
532 .else
533 LIBCC:= ${CC}
534 .endif
536 lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOLIB} ${DPADD} ${DPLIBC} \
537 ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
538 ${_MKTARGET_BUILD}
539 rm -f lib${LIB}.so.${SHLIB_FULLVERSION}
540 .if defined(DESTDIR)
541 ${LIBCC} ${LDLIBC} -Wl,-nostdlib -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/ \
542 -Wl,-x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
543 -Wl,--whole-archive ${SOLIB} \
544 -Wl,--no-whole-archive ${LDADD} \
545 ${_LIBLDOPTS} ${LDFLAGS} \
546 -L${_GCC_LIBGCCDIR}
547 .else
548 ${LIBCC} ${LDLIBC} -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} \
549 -o ${.TARGET} ${_LIBLDOPTS} \
550 -Wl,--whole-archive ${SOLIB} -Wl,--no-whole-archive ${LDADD}
551 .endif
552 .if ${OBJECT_FMT} == "ELF"
553 # We don't use INSTALL_SYMLINK here because this is just
554 # happening inside the build directory/objdir. XXX Why does
555 # this spend so much effort on libraries that aren't live??? XXX
556 .if defined(SHLIB_FULLVERSION) && defined(SHLIB_MAJOR) && \
557 "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
558 ${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.${SHLIB_MAJOR}.tmp
559 mv -f lib${LIB}.so.${SHLIB_MAJOR}.tmp lib${LIB}.so.${SHLIB_MAJOR}
560 .endif
561 ${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.tmp
562 mv -f lib${LIB}.so.tmp lib${LIB}.so
563 .endif
564 .if ${MKSTRIPIDENT} != "no"
565 ${OBJCOPY} -R .ident ${.TARGET}
566 .endif
568 .if !empty(LOBJS) # {
569 LLIBS?= -lc
570 llib-l${LIB}.ln: ${LOBJS}
571 ${_MKTARGET_COMPILE}
572 rm -f llib-l${LIB}.ln
573 .if defined(DESTDIR)
574 ${LINT} -C${LIB} ${.ALLSRC} -L${DESTDIR}/usr/libdata ${LLIBS}
575 .else
576 ${LINT} -C${LIB} ${.ALLSRC} ${LLIBS}
577 .endif
578 .endif # }
580 lint: ${LOBJS}
581 .if defined(LOBJS) && !empty(LOBJS)
582 ${LINT} ${LINTFLAGS} ${LOBJS}
583 .endif
585 cleanlib: .PHONY
586 rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
587 rm -f lib${LIB}.a ${STOBJS}
588 rm -f lib${LIB}_p.a ${POBJS}
589 rm -f lib${LIB}_g.a ${GOBJS}
590 rm -f lib${LIB}_pic.a lib${LIB}.so.* lib${LIB}.so ${SOBJS}
591 rm -f ${STOBJS:=.tmp} ${POBJS:=.tmp} ${SOBJS:=.tmp} ${GOBJS:=.tmp}
592 rm -f llib-l${LIB}.ln ${LOBJS}
595 .if !target(libinstall) # {
596 # Make sure it gets defined, in case MKPIC==no && MKLINKLIB==no
597 libinstall::
599 .if ${MKLINKLIB} != "no" && ${MKSTATICLIB} != "no"
600 libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.a
601 .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.a
603 .if ${MKUPDATE} == "no"
604 .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a)
605 ${DESTDIR}${LIBDIR}/lib${LIB}.a! .MADE
606 .endif
607 ${DESTDIR}${LIBDIR}/lib${LIB}.a! lib${LIB}.a __archiveinstall
608 .else
609 .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a)
610 ${DESTDIR}${LIBDIR}/lib${LIB}.a: .MADE
611 .endif
612 ${DESTDIR}${LIBDIR}/lib${LIB}.a: lib${LIB}.a __archiveinstall
613 .endif
614 .endif
616 .if ${MKPROFILE} != "no"
617 libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
618 .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
620 .if ${MKUPDATE} == "no"
621 .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a)
622 ${DESTDIR}${LIBDIR}/lib${LIB}_p.a! .MADE
623 .endif
624 ${DESTDIR}${LIBDIR}/lib${LIB}_p.a! lib${LIB}_p.a __archiveinstall
625 .else
626 .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a)
627 ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: .MADE
628 .endif
629 ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: lib${LIB}_p.a __archiveinstall
630 .endif
631 .endif
633 .if ${MKDEBUGLIB} != "no"
634 libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a
635 .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a
637 .if ${MKUPDATE} == "no"
638 .if !defined(BUILD) && !make(all) && !make(lib${LIB}_g.a)
639 ${DESTDIR}${LIBDIR}/lib${LIB}_g.a! .MADE
640 .endif
641 ${DESTDIR}${LIBDIR}/lib${LIB}_g.a! lib${LIB}_g.a __archiveinstall
642 .else
643 .if !defined(BUILD) && !make(all) && !make(lib${LIB}_g.a)
644 ${DESTDIR}${LIBDIR}/lib${LIB}_g.a: .MADE
645 .endif
646 ${DESTDIR}${LIBDIR}/lib${LIB}_g.a: lib${LIB}_g.a __archiveinstall
647 .endif
648 .endif
650 .if ${MKPIC} != "no" && ${MKPICINSTALL} != "no"
651 libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
652 .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
654 .if ${MKUPDATE} == "no"
655 .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a)
656 ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! .MADE
657 .endif
658 .if ${MKPICLIB} == "no"
659 ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}.a __archivesymlinkpic
660 .else
661 ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}_pic.a __archiveinstall
662 .endif
663 .else
664 .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a)
665 ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: .MADE
666 .endif
667 .if ${MKPICLIB} == "no"
668 ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}.a __archivesymlinkpic
669 .else
670 ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}_pic.a __archiveinstall
671 .endif
672 .endif
673 .endif
675 .if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION)
676 _LIB_SO_TGT= ${DESTDIR}${_LIBSODIR}/${_LIB_PREFIX}${LIB}.so
677 _LIB_SO_TGTLIBDIR= ${DESTDIR}${LIBDIR}/${_LIB_PREFIX}${LIB}.so
679 libinstall:: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}
680 .PRECIOUS: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}
682 .if ${MKUPDATE} == "no"
683 .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION})
684 ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}! .MADE
685 .endif
686 ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}! lib${LIB}.so.${SHLIB_FULLVERSION}
687 .else
688 .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION})
689 ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}: .MADE
690 .endif
691 ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}: lib${LIB}.so.${SHLIB_FULLVERSION}
692 .endif
693 ${_MKTARGET_INSTALL}
694 ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
695 ${.ALLSRC} ${.TARGET}
696 .if ${_LIBSODIR} != ${LIBDIR}
697 ${INSTALL_SYMLINK} -l r \
698 ${_LIB_SO_TGT}.${SHLIB_FULLVERSION} \
699 ${_LIB_SO_TGTLIBDIR}.${SHLIB_FULLVERSION}
700 .endif
701 .if ${OBJECT_FMT} == "a.out" && !defined(DESTDIR)
702 /sbin/ldconfig -m ${_LIBSODIR} ${LIBDIR}
703 .endif
704 .if ${OBJECT_FMT} == "ELF"
705 .if defined(SHLIB_FULLVERSION) && defined(SHLIB_MAJOR) && \
706 "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
707 ${INSTALL_SYMLINK} \
708 ${_LIB_PREFIX}${LIB}.so.${SHLIB_FULLVERSION} \
709 ${_LIB_SO_TGT}.${SHLIB_MAJOR}
710 .if ${_LIBSODIR} != ${LIBDIR}
711 ${INSTALL_SYMLINK} -l r \
712 ${_LIB_SO_TGT}.${SHLIB_FULLVERSION} \
713 ${_LIB_SO_TGTLIBDIR}.${SHLIB_MAJOR}
714 .endif
715 .endif
716 .if ${MKLINKLIB} != "no"
717 ${INSTALL_SYMLINK} \
718 ${_LIB_PREFIX}${LIB}.so.${SHLIB_FULLVERSION} \
719 ${_LIB_SO_TGT}
720 .if ${_LIBSODIR} != ${LIBDIR}
721 ${INSTALL_SYMLINK} -l r \
722 ${_LIB_SO_TGT}.${SHLIB_FULLVERSION} \
723 ${_LIB_SO_TGTLIBDIR}
724 .endif
725 .endif
726 .endif
727 .endif
729 .if ${MKLINT} != "no" && !empty(LOBJS)
730 libinstall:: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
731 .PRECIOUS: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
733 .if ${MKUPDATE} == "no"
734 .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln)
735 ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! .MADE
736 .endif
737 ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! llib-l${LIB}.ln
738 .else
739 .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln)
740 ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: .MADE
741 .endif
742 ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: llib-l${LIB}.ln
743 .endif
744 ${_MKTARGET_INSTALL}
745 ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
746 ${.ALLSRC} ${DESTDIR}${LINTLIBDIR}
747 .endif
748 .endif # !target(libinstall) # }
750 ##### Pull in related .mk logic
751 LINKSOWN?= ${LIBOWN}
752 LINKSGRP?= ${LIBGRP}
753 LINKSMODE?= ${LIBMODE}
754 .include <bsd.man.mk>
755 #.include <bsd.nls.mk>
756 .include <bsd.files.mk>
757 .include <bsd.inc.mk>
758 .include <bsd.links.mk>
759 .include <bsd.dep.mk>
760 .include <minix.gcc.mk>
762 ${TARGETS}: # ensure existence