Annotation of src/share/mk/bsd.lib.mk, Revision 1.287
1.287 ! christos 1: # $NetBSD: bsd.lib.mk,v 1.286 2008/09/09 11:54:19 joerg Exp $
1.92 mikel 2: # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94
1.1 cgd 3:
1.188 tv 4: .include <bsd.init.mk>
1.207 thorpej 5: .include <bsd.shlib.mk>
1.219 thorpej 6: .include <bsd.gcc.mk>
1.227 lukem 7: # Pull in <bsd.sys.mk> here so we can override its .c.o rule
8: .include <bsd.sys.mk>
1.97 mycroft 9:
1.282 lukem 10: LIBISMODULE?= no
1.281 lukem 11: LIBISPRIVATE?= no
12:
1.282 lukem 13: _LIB_PREFIX= lib
14:
15: .if ${LIBISMODULE} != "no"
16: _LIB_PREFIX= # empty
17: MKDEBUGLIB:= no
18: MKLINT:= no
19: MKPICINSTALL:= no
20: MKPROFILE:= no
21: MKSTATICLIB:= no
22: .endif
23:
1.281 lukem 24: .if ${LIBISPRIVATE} != "no"
1.280 lukem 25: MKDEBUGLIB:= no
26: MKLINT:= no
27: MKPIC:= no
28: MKPROFILE:= no
29: .endif
30:
1.188 tv 31: ##### Basic targets
1.246 lukem 32: .PHONY: checkver libinstall
1.143 erh 33: realinstall: checkver libinstall
1.183 tv 34: clean: cleanlib
1.232 erh 35:
36: ##### LIB specific flags.
1.287 ! christos 37: # XXX: This is needed for programs that link with .a libraries
! 38: # Perhaps a more correct solution is to always generate _pic.a
! 39: # files or always have a shared library.
! 40: .if defined(MKPIE) && (${MKPIE} != "no")
! 41: CFLAGS+= ${PIE_CFLAGS}
! 42: .endif
1.267 mrg 43: COPTS+= ${COPTS.lib${LIB}}
1.232 erh 44: CPPFLAGS+= ${CPPFLAGS.lib${LIB}}
45: CXXFLAGS+= ${CXXFLAGS.lib${LIB}}
1.267 mrg 46: OBJCOPTS+= ${OBJCOPTS.lib${LIB}}
1.232 erh 47: LDADD+= ${LDADD.lib${LIB}}
1.233 erh 48: LDFLAGS+= ${LDFLAGS.lib${LIB}}
49: LDSTATIC+= ${LDSTATIC.lib${LIB}}
1.1 cgd 50:
1.256 lukem 51: ##### Libraries that this may depend upon.
52: .if defined(LIBDPLIBS) && ${MKPIC} != "no" # {
53: .for _lib _dir in ${LIBDPLIBS}
54: .if !defined(LIBDO.${_lib})
55: LIBDO.${_lib}!= cd ${_dir} && ${PRINTOBJDIR}
56: .MAKEOVERRIDES+=LIBDO.${_lib}
57: .endif
58: LDADD+= -L${LIBDO.${_lib}} -l${_lib}
59: DPADD+= ${LIBDO.${_lib}}/lib${_lib}.so
60: .endfor
61: .endif # }
62:
1.188 tv 63: ##### Build and install rules
1.285 christos 64: MKDEP_SUFFIXES?= .o .po .so .go .ln
1.192 thorpej 65: CPPFLAGS+= ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
1.225 mrg 66: CXXFLAGS+= ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} ${DESTDIR}/usr/include/g++}
1.190 tv 67:
1.252 lukem 68: .if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE}) # {
1.154 simonb 69: SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major
70: SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor
1.171 christos 71: SHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny
1.143 erh 72:
73: # Check for higher installed library versions.
1.145 erh 74: .if !defined(NOCHECKVER) && !defined(NOCHECKVER_${LIB}) && \
1.201 lukem 75: exists(${NETBSDSRCDIR}/lib/checkver)
1.143 erh 76: checkver:
1.144 erh 77: @(cd ${.CURDIR} && \
1.239 lukem 78: ${HOST_SH} ${NETBSDSRCDIR}/lib/checkver -v ${SHLIB_VERSION_FILE} \
1.195 lukem 79: -d ${DESTDIR}${_LIBSODIR} ${LIB})
1.173 christos 80: .endif
1.252 lukem 81: .endif # }
1.173 christos 82:
83: .if !target(checkver)
1.143 erh 84: checkver:
85: .endif
1.173 christos 86:
1.169 thorpej 87: print-shlib-major:
1.185 tv 88: .if defined(SHLIB_MAJOR) && ${MKPIC} != "no"
1.169 thorpej 89: @echo ${SHLIB_MAJOR}
1.173 christos 90: .else
91: @false
92: .endif
1.169 thorpej 93:
94: print-shlib-minor:
1.185 tv 95: .if defined(SHLIB_MINOR) && ${MKPIC} != "no"
1.169 thorpej 96: @echo ${SHLIB_MINOR}
1.173 christos 97: .else
98: @false
99: .endif
1.171 christos 100:
101: print-shlib-teeny:
1.185 tv 102: .if defined(SHLIB_TEENY) && ${MKPIC} != "no"
1.171 christos 103: @echo ${SHLIB_TEENY}
1.143 erh 104: .else
1.169 thorpej 105: @false
1.173 christos 106: .endif
1.169 thorpej 107:
1.252 lukem 108: .if defined(SHLIB_MAJOR) && !empty(SHLIB_MAJOR) # {
1.173 christos 109: .if defined(SHLIB_MINOR) && !empty(SHLIB_MINOR)
110: .if defined(SHLIB_TEENY) && !empty(SHLIB_TEENY)
111: SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}.${SHLIB_TEENY}
112: .else
113: SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}
114: .endif
115: .else
116: SHLIB_FULLVERSION=${SHLIB_MAJOR}
117: .endif
1.252 lukem 118: .endif # }
1.1 cgd 119:
1.101 mycroft 120: # add additional suffixes not exported.
121: # .po is used for profiling object files.
122: # .so is used for PIC object files.
1.266 christos 123: .SUFFIXES: .out .a .ln .so .po .go .o .s .S .c .cc .cpp .cxx .C .m .F .f .r .y .l .cl .p .h
1.118 lukem 124: .SUFFIXES: .sh .m4 .m
1.82 mikel 125:
1.86 jonathan 126:
127: # Set PICFLAGS to cc flags for producing position-independent code,
128: # if not already set. Includes -DPIC, if required.
129:
1.164 simonb 130: # Data-driven table using make variables to control how shared libraries
1.86 jonathan 131: # are built for different platforms and object formats.
1.125 jonathan 132: # OBJECT_FMT: currently either "ELF" or "a.out", from <bsd.own.mk>
1.164 simonb 133: # SHLIB_SOVERSION: version number to be compiled into a shared library
134: # via -soname. Usualy ${SHLIB_MAJOR} on ELF.
1.173 christos 135: # NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR}
136: # [.${SHLIB_TEENY}]]
1.164 simonb 137: # SHLIB_SHFLAGS: Flags to tell ${LD} to emit shared library.
1.123 jonathan 138: # with ELF, also set shared-lib version for ld.so.
139: # SHLIB_LDSTARTFILE: support .o file, call C++ file-level constructors
140: # SHLIB_LDENDFILE: support .o file, call C++ file-level destructors
1.179 dmcmahil 141: # FPICFLAGS: flags for ${FC} to compile .[fF] files to .so objects.
1.271 tsutsui 142: # CPPPICFLAGS: flags for ${CPP} to preprocess .[sS] files for ${AS}
1.205 yamt 143: # CPICFLAGS: flags for ${CC} to compile .[cC] files to pic objects.
144: # CSHLIBFLAGS: flags for ${CC} to compile .[cC] files to .so objects.
145: # (usually includes ${CPICFLAGS})
146: # CAPICFLAGS: flags for ${CC} to compiling .[Ss] files
1.107 jonathan 147: # (usually just ${CPPPICFLAGS} ${CPICFLAGS})
1.164 simonb 148: # APICFLAGS: flags for ${AS} to assemble .[sS] to .so objects.
1.86 jonathan 149:
1.252 lukem 150: .if ${MACHINE_ARCH} == "alpha" # {
1.209 thorpej 151:
1.179 dmcmahil 152: FPICFLAGS ?= -fPIC
1.165 dmcmahil 153: CPICFLAGS ?= -fPIC -DPIC
1.222 lukem 154: CPPPICFLAGS?= -DPIC
1.107 jonathan 155: CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
156: APICFLAGS ?=
1.209 thorpej 157:
1.175 mrg 158: .elif (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") && \
1.252 lukem 159: ${OBJECT_FMT} == "ELF" # } {
1.209 thorpej 160:
1.222 lukem 161: # If you use -fPIC you need to define BIGPIC to turn on 32-bit
1.202 eeh 162: # relocations in asm code
1.179 dmcmahil 163: FPICFLAGS ?= -fPIC
1.165 dmcmahil 164: CPICFLAGS ?= -fPIC -DPIC
1.202 eeh 165: CPPPICFLAGS?= -DPIC -DBIGPIC
1.150 christos 166: CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
1.203 eeh 167: APICFLAGS ?= -KPIC
1.204 fredette 168:
1.252 lukem 169: .else # } {
1.86 jonathan 170:
1.244 skrll 171: # Platform-independent flags for NetBSD shared libraries
1.171 christos 172: SHLIB_SOVERSION=${SHLIB_FULLVERSION}
1.125 jonathan 173: SHLIB_SHFLAGS=
1.179 dmcmahil 174: FPICFLAGS ?= -fPIC
1.165 dmcmahil 175: CPICFLAGS?= -fPIC -DPIC
1.222 lukem 176: CPPPICFLAGS?= -DPIC
1.107 jonathan 177: CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
178: APICFLAGS?= -k
1.86 jonathan 179:
1.252 lukem 180: .endif # }
1.160 simonb 181:
1.205 yamt 182: .if ${MKPICLIB} != "no"
183: CSHLIBFLAGS+= ${CPICFLAGS}
184: .endif
185:
186: .if defined(CSHLIBFLAGS) && !empty(CSHLIBFLAGS)
187: MKSHLIBOBJS= yes
188: .else
189: MKSHLIBOBJS= no
190: .endif
191:
1.123 jonathan 192: # Platform-independent linker flags for ELF shared libraries
1.148 lukem 193: .if ${OBJECT_FMT} == "ELF"
1.182 mrg 194: SHLIB_SOVERSION= ${SHLIB_MAJOR}
1.282 lukem 195: SHLIB_SHFLAGS= -Wl,-soname,${_LIB_PREFIX}${LIB}.so.${SHLIB_SOVERSION}
1.272 christos 196: SHLIB_SHFLAGS+= -Wl,--warn-shared-textrel
1.219 thorpej 197: SHLIB_LDSTARTFILE?= ${DESTDIR}/usr/lib/crti.o ${_GCC_CRTBEGINS}
198: SHLIB_LDENDFILE?= ${_GCC_CRTENDS} ${DESTDIR}/usr/lib/crtn.o
1.123 jonathan 199: .endif
1.86 jonathan 200:
1.82 mikel 201: CFLAGS+= ${COPTS}
1.267 mrg 202: OBJCFLAGS+= ${OBJCOPTS}
1.257 simonb 203: AFLAGS+= ${COPTS}
1.179 dmcmahil 204: FFLAGS+= ${FOPTS}
1.1 cgd 205:
206: .c.o:
1.238 lukem 207: ${_MKTARGET_COMPILE}
1.263 dsl 208: ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
1.270 martin 209: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263 dsl 210: ${OBJCOPY} -x ${.TARGET}
1.153 christos 211: .endif
1.1 cgd 212:
213: .c.po:
1.238 lukem 214: ${_MKTARGET_COMPILE}
1.263 dsl 215: ${COMPILE.c} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET}
1.270 martin 216: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263 dsl 217: ${OBJCOPY} -X ${.TARGET}
1.153 christos 218: .endif
1.17 mycroft 219:
1.266 christos 220: .c.go:
221: ${_MKTARGET_COMPILE}
222: ${COMPILE.c} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET}
223:
1.27 pk 224: .c.so:
1.238 lukem 225: ${_MKTARGET_COMPILE}
1.263 dsl 226: ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
1.270 martin 227: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263 dsl 228: ${OBJCOPY} -x ${.TARGET}
1.153 christos 229: .endif
1.27 pk 230:
1.223 lukem 231: .cc.o .cpp.o .cxx.o .C.o:
1.238 lukem 232: ${_MKTARGET_COMPILE}
1.263 dsl 233: ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
1.270 martin 234: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263 dsl 235: ${OBJCOPY} -x ${.TARGET}
1.153 christos 236: .endif
1.17 mycroft 237:
1.266 christos 238: .cc.po .cpp.po .cxx.po .C.po:
1.238 lukem 239: ${_MKTARGET_COMPILE}
1.263 dsl 240: ${COMPILE.cc} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET}
1.270 martin 241: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263 dsl 242: ${OBJCOPY} -X ${.TARGET}
1.153 christos 243: .endif
1.28 cgd 244:
1.266 christos 245: .cc.go .cpp.go .cxx.go .C.go:
246: ${_MKTARGET_COMPILE}
247: ${COMPILE.cc} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET}
248:
1.223 lukem 249: .cc.so .cpp.so .cxx.so .C.so:
1.238 lukem 250: ${_MKTARGET_COMPILE}
1.263 dsl 251: ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
1.270 martin 252: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263 dsl 253: ${OBJCOPY} -x ${.TARGET}
1.153 christos 254: .endif
1.118 lukem 255:
1.179 dmcmahil 256: .f.o:
1.238 lukem 257: ${_MKTARGET_COMPILE}
1.263 dsl 258: ${COMPILE.f} ${.IMPSRC} -o ${.TARGET}
259: .if !defined(FOPTS) || empty(FOPTS:M*-g*)
260: ${OBJCOPY} -x ${.TARGET}
1.179 dmcmahil 261: .endif
262:
263: .f.po:
1.238 lukem 264: ${_MKTARGET_COMPILE}
1.263 dsl 265: ${COMPILE.f} ${PROFFLAGS} -pg ${.IMPSRC} -o ${.TARGET}
266: .if !defined(FOPTS) || empty(FOPTS:M*-g*)
267: ${OBJCOPY} -X ${.TARGET}
1.179 dmcmahil 268: .endif
269:
1.266 christos 270: .f.go:
271: ${_MKTARGET_COMPILE}
272: ${COMPILE.f} ${DEBUGFLAGS} -g ${.IMPSRC} -o ${.TARGET}
273:
1.179 dmcmahil 274: .f.so:
1.238 lukem 275: ${_MKTARGET_COMPILE}
1.263 dsl 276: ${COMPILE.f} ${FPICFLAGS} ${.IMPSRC} -o ${.TARGET}
277: .if !defined(FOPTS) || empty(FOPTS:M*-g*)
278: ${OBJCOPY} -x ${.TARGET}
1.179 dmcmahil 279: .endif
280:
281: .f.ln:
1.238 lukem 282: ${_MKTARGET_COMPILE}
1.217 wiz 283: @echo Skipping lint for Fortran libraries.
1.179 dmcmahil 284:
1.118 lukem 285: .m.o:
1.238 lukem 286: ${_MKTARGET_COMPILE}
1.267 mrg 287: ${COMPILE.m} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
1.263 dsl 288: .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
289: ${OBJCOPY} -x ${.TARGET}
1.153 christos 290: .endif
1.118 lukem 291:
292: .m.po:
1.238 lukem 293: ${_MKTARGET_COMPILE}
1.267 mrg 294: ${COMPILE.m} ${PROFFLAGS} -pg ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
1.263 dsl 295: .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
296: ${OBJCOPY} -X ${.TARGET}
1.153 christos 297: .endif
1.118 lukem 298:
1.266 christos 299: .m.go:
300: ${_MKTARGET_COMPILE}
1.267 mrg 301: ${COMPILE.m} ${DEBUGFLAGS} -g ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
1.266 christos 302: .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
303: ${OBJCOPY} -X ${.TARGET}
304: .endif
305:
1.118 lukem 306: .m.so:
1.238 lukem 307: ${_MKTARGET_COMPILE}
1.267 mrg 308: ${COMPILE.m} ${CSHLIBFLAGS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
1.263 dsl 309: .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
310: ${OBJCOPY} -x ${.TARGET}
1.153 christos 311: .endif
1.1 cgd 312:
1.251 lukem 313: .s.o:
1.238 lukem 314: ${_MKTARGET_COMPILE}
1.263 dsl 315: ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
316: ${OBJCOPY} -x ${.TARGET}
1.1 cgd 317:
1.251 lukem 318: .S.o:
319: ${_MKTARGET_COMPILE}
1.263 dsl 320: ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
321: ${OBJCOPY} -x ${.TARGET}
1.251 lukem 322:
323: .s.po:
324: ${_MKTARGET_COMPILE}
1.263 dsl 325: ${COMPILE.s} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
326: ${OBJCOPY} -X ${.TARGET}
1.251 lukem 327:
328: .S.po:
1.238 lukem 329: ${_MKTARGET_COMPILE}
1.263 dsl 330: ${COMPILE.S} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
331: ${OBJCOPY} -X ${.TARGET}
1.1 cgd 332:
1.266 christos 333: .s.go:
334: ${_MKTARGET_COMPILE}
335: ${COMPILE.s} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
336:
337: .S.go:
338: ${_MKTARGET_COMPILE}
339: ${COMPILE.S} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
340:
1.251 lukem 341: .s.so:
342: ${_MKTARGET_COMPILE}
1.263 dsl 343: ${COMPILE.s} ${CAPICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
344: ${OBJCOPY} -x ${.TARGET}
1.251 lukem 345:
346: .S.so:
1.238 lukem 347: ${_MKTARGET_COMPILE}
1.263 dsl 348: ${COMPILE.S} ${CAPICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
349: ${OBJCOPY} -x ${.TARGET}
1.27 pk 350:
1.252 lukem 351: .if defined(LIB) # {
1.234 lukem 352: .if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
353: || ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
1.130 tv 354: _LIBS=lib${LIB}.a
355: .else
356: _LIBS=
357: .endif
1.58 cgd 358:
1.167 matt 359: OBJS+=${SRCS:N*.h:N*.sh:R:S/$/.o/g}
1.158 christos 360:
1.255 thorpej 361: STOBJS+=${OBJS}
362:
1.280 lukem 363: LOBJS+=${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
364:
1.281 lukem 365: .if ${LIBISPRIVATE} != "no"
1.252 lukem 366: # No installation is required
367: libinstall::
1.281 lukem 368: .else # ${LIBISPRIVATE} == "no" # {
1.252 lukem 369:
1.268 lukem 370: .if ${MKDEBUGLIB} != "no"
1.266 christos 371: _LIBS+=lib${LIB}_g.a
372: GOBJS+=${OBJS:.o=.go}
373: DEBUGFLAGS?=-DDEBUG
374: .endif
375:
1.149 lukem 376: .if ${MKPROFILE} != "no"
1.130 tv 377: _LIBS+=lib${LIB}_p.a
1.167 matt 378: POBJS+=${OBJS:.o=.po}
1.262 christos 379: PROFFLAGS?=-DGPROF -DPROF
1.1 cgd 380: .endif
381:
1.252 lukem 382: .if ${MKPIC} != "no" # {
1.160 simonb 383: .if ${MKPICLIB} == "no"
1.205 yamt 384: .if ${MKSHLIBOBJS} != "no"
385: # make _pic.a, which isn't really pic,
386: # since it's needed for making shared lib.
387: # but don't install it.
388: SOLIB=lib${LIB}_pic.a
389: SOBJS+=${OBJS:.o=.so}
390: .else
1.160 simonb 391: SOLIB=lib${LIB}.a
1.205 yamt 392: .endif
1.160 simonb 393: .else
394: SOLIB=lib${LIB}_pic.a
395: _LIBS+=${SOLIB}
1.167 matt 396: SOBJS+=${OBJS:.o=.so}
1.160 simonb 397: .endif
1.171 christos 398: .if defined(SHLIB_FULLVERSION)
399: _LIBS+=lib${LIB}.so.${SHLIB_FULLVERSION}
1.27 pk 400: .endif
1.252 lukem 401: .endif # }
1.27 pk 402:
1.279 lukem 403: .if ${MKLINT} != "no" && !empty(LOBJS)
1.58 cgd 404: _LIBS+=llib-l${LIB}.ln
1.215 christos 405: .endif
1.27 pk 406:
1.281 lukem 407: .endif # ${LIBISPRIVATE} == "no" # }
1.252 lukem 408:
1.234 lukem 409: ALLOBJS=
410: .if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
411: || ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
1.255 thorpej 412: ALLOBJS+=${STOBJS}
1.179 dmcmahil 413: .endif
1.234 lukem 414: ALLOBJS+=${POBJS} ${SOBJS}
1.279 lukem 415: .if ${MKLINT} != "no" && !empty(LOBJS)
1.179 dmcmahil 416: ALLOBJS+=${LOBJS}
1.216 christos 417: .endif
1.252 lukem 418: .else # !defined(LIB) # } {
1.216 christos 419: LOBJS=
420: SOBJS=
1.252 lukem 421: .endif # !defined(LIB) # }
1.186 tv 422:
1.254 lukem 423: _YLSRCS= ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.253 christos 424:
425: .NOPATH: ${ALLOBJS} ${_LIBS} ${_YLSRCS}
1.158 christos 426:
1.162 mycroft 427: realall: ${SRCS} ${ALLOBJS:O} ${_LIBS}
1.1 cgd 428:
1.243 rtr 429: .if !target(__archivebuild)
1.90 christos 430: __archivebuild: .USE
1.238 lukem 431: ${_MKTARGET_BUILD}
1.236 lukem 432: rm -f ${.TARGET}
1.228 lukem 433: ${AR} cq ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
1.89 christos 434: ${RANLIB} ${.TARGET}
1.243 rtr 435: .endif
1.89 christos 436:
1.243 rtr 437: .if !target(__archiveinstall)
1.89 christos 438: __archiveinstall: .USE
1.238 lukem 439: ${_MKTARGET_INSTALL}
1.198 lukem 440: ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.269 dbj 441: ${empty(PRESERVE):?-a "${RANLIB} -t":} ${.ALLSRC} ${.TARGET}
1.243 rtr 442: .endif
1.89 christos 443:
1.197 mycroft 444: __archivesymlinkpic: .USE
1.238 lukem 445: ${_MKTARGET_INSTALL}
1.264 jwise 446: ${INSTALL_SYMLINK} ${.ALLSRC} ${.TARGET}
1.197 mycroft 447:
1.253 christos 448: DPSRCS+= ${_YLSRCS}
449: CLEANFILES+= ${_YLSRCS}
1.230 lukem 450:
1.266 christos 451: ${STOBJS} ${POBJS} ${GOBJS} ${SOBJS} ${LOBJS}: ${DPSRCS}
1.103 mycroft 452:
1.255 thorpej 453: lib${LIB}.a:: ${STOBJS} __archivebuild
1.1 cgd 454:
1.89 christos 455: lib${LIB}_p.a:: ${POBJS} __archivebuild
1.1 cgd 456:
1.89 christos 457: lib${LIB}_pic.a:: ${SOBJS} __archivebuild
1.27 pk 458:
1.266 christos 459: lib${LIB}_g.a:: ${GOBJS} __archivebuild
460:
1.235 lukem 461:
462: _LIBLDOPTS=
463: .if ${SHLIBDIR} != "/usr/lib"
464: _LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
465: -R${SHLIBDIR} \
466: -L${DESTDIR}${SHLIBDIR}
467: .elif ${SHLIBINSTALLDIR} != "/usr/lib"
468: _LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
469: -L${DESTDIR}${SHLIBINSTALLDIR}
470: .endif
471:
1.277 christos 472: # gcc -shared now adds -lc automatically. For libraries other than libc and
473: # libgcc* we add as a dependency the installed shared libc. For libc and
474: # libgcc* we avoid adding libc as a dependency by using -nostdlib. Note that
475: # -Xl,-nostdlib is not enough because we want to tell the compiler-driver not
476: # to add standard libraries, not the linker.
1.276 christos 477: .if !defined(LIB)
1.274 christos 478: DPLIBC ?= ${DESTDIR}${LIBC_SO}
1.276 christos 479: .else
1.278 simonb 480: .if ${LIB} != "c" && ${LIB:Mgcc*} == ""
1.276 christos 481: DPLIBC ?= ${DESTDIR}${LIBC_SO}
1.277 christos 482: .else
1.278 simonb 483: LDLIBC ?= -nodefaultlibs
484: .if ${LIB} == "c"
485: LDADD+= -lgcc_pic
486: .endif
1.276 christos 487: .endif
1.274 christos 488: .endif
489:
490: lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOLIB} ${DPADD} ${DPLIBC} \
1.88 cgd 491: ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
1.238 lukem 492: ${_MKTARGET_BUILD}
1.236 lukem 493: rm -f lib${LIB}.so.${SHLIB_FULLVERSION}
1.152 fair 494: .if defined(DESTDIR)
1.277 christos 495: ${CC} ${LDLIBC} -Wl,-nostdlib -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/ \
1.235 lukem 496: ${_LIBLDOPTS} \
1.231 lukem 497: -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} -o ${.TARGET} \
1.221 drochner 498: -Wl,--whole-archive ${SOLIB} \
499: -Wl,--no-whole-archive ${LDADD} \
1.277 christos 500: -L${_GCC_LIBGCCDIR}
1.221 drochner 501: .else
1.277 christos 502: ${CC} ${LDLIBC} -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} \
503: -o ${.TARGET} ${_LIBLDOPTS} \
504: -Wl,--whole-archive ${SOLIB} -Wl,--no-whole-archive ${LDADD}
1.152 fair 505: .endif
1.148 lukem 506: .if ${OBJECT_FMT} == "ELF"
1.196 lukem 507: # We don't use INSTALL_SYMLINK here because this is just
508: # happening inside the build directory/objdir. XXX Why does
509: # this spend so much effort on libraries that aren't live??? XXX
1.284 lukem 510: .if defined(SHLIB_FULLVERSION) && defined(SHLIB_MAJOR) && \
511: "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
1.241 matt 512: ${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.${SHLIB_MAJOR}.tmp
1.177 mycroft 513: mv -f lib${LIB}.so.${SHLIB_MAJOR}.tmp lib${LIB}.so.${SHLIB_MAJOR}
1.283 lukem 514: .endif
1.241 matt 515: ${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.tmp
1.177 mycroft 516: mv -f lib${LIB}.so.tmp lib${LIB}.so
1.133 tv 517: .endif
1.286 joerg 518: .if ${MKSTRIPIDENT} != "no"
519: ${OBJCOPY} -R .ident ${.TARGET}
520: .endif
1.35 pk 521:
1.252 lukem 522: .if !empty(LOBJS) # {
1.103 mycroft 523: LLIBS?= -lc
1.58 cgd 524: llib-l${LIB}.ln: ${LOBJS}
1.238 lukem 525: ${_MKTARGET_COMPILE}
1.236 lukem 526: rm -f llib-l${LIB}.ln
1.206 thorpej 527: .if defined(DESTDIR)
1.228 lukem 528: ${LINT} -C${LIB} ${.ALLSRC} -L${DESTDIR}/usr/libdata ${LLIBS}
1.206 thorpej 529: .else
1.228 lukem 530: ${LINT} -C${LIB} ${.ALLSRC} ${LLIBS}
1.206 thorpej 531: .endif
1.252 lukem 532: .endif # }
1.1 cgd 533:
1.280 lukem 534: lint: ${LOBJS}
535: .if defined(LOBJS) && !empty(LOBJS)
536: ${LINT} ${LINTFLAGS} ${LOBJS}
537: .endif
538:
1.246 lukem 539: cleanlib: .PHONY
1.48 mycroft 540: rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
1.255 thorpej 541: rm -f lib${LIB}.a ${STOBJS}
1.59 cgd 542: rm -f lib${LIB}_p.a ${POBJS}
1.266 christos 543: rm -f lib${LIB}_g.a ${GOBJS}
1.133 tv 544: rm -f lib${LIB}_pic.a lib${LIB}.so.* lib${LIB}.so ${SOBJS}
1.266 christos 545: rm -f ${STOBJS:=.tmp} ${POBJS:=.tmp} ${SOBJS:=.tmp} ${GOBJS:=.tmp}
1.59 cgd 546: rm -f llib-l${LIB}.ln ${LOBJS}
1.1 cgd 547:
1.252 lukem 548:
549: .if !target(libinstall) # {
1.148 lukem 550: # Make sure it gets defined, in case MKPIC==no && MKLINKLIB==no
1.139 tv 551: libinstall::
552:
1.234 lukem 553: .if ${MKLINKLIB} != "no" && ${MKSTATICLIB} != "no"
1.89 christos 554: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.168 mycroft 555: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.197 mycroft 556:
1.269 dbj 557: .if ${MKUPDATE} == "no"
1.197 mycroft 558: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a)
559: ${DESTDIR}${LIBDIR}/lib${LIB}.a! .MADE
1.89 christos 560: .endif
1.197 mycroft 561: ${DESTDIR}${LIBDIR}/lib${LIB}.a! lib${LIB}.a __archiveinstall
562: .else
1.157 fredb 563: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a)
1.89 christos 564: ${DESTDIR}${LIBDIR}/lib${LIB}.a: .MADE
565: .endif
566: ${DESTDIR}${LIBDIR}/lib${LIB}.a: lib${LIB}.a __archiveinstall
1.130 tv 567: .endif
1.197 mycroft 568: .endif
1.89 christos 569:
1.149 lukem 570: .if ${MKPROFILE} != "no"
1.89 christos 571: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.168 mycroft 572: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.197 mycroft 573:
1.269 dbj 574: .if ${MKUPDATE} == "no"
1.197 mycroft 575: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a)
576: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a! .MADE
1.32 pk 577: .endif
1.197 mycroft 578: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a! lib${LIB}_p.a __archiveinstall
579: .else
1.157 fredb 580: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a)
1.89 christos 581: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: .MADE
582: .endif
583: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: lib${LIB}_p.a __archiveinstall
584: .endif
1.197 mycroft 585: .endif
1.89 christos 586:
1.268 lukem 587: .if ${MKDEBUGLIB} != "no"
1.266 christos 588: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a
589: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a
590:
1.269 dbj 591: .if ${MKUPDATE} == "no"
1.266 christos 592: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_g.a)
593: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a! .MADE
594: .endif
595: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a! lib${LIB}_g.a __archiveinstall
596: .else
597: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_g.a)
598: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a: .MADE
599: .endif
600: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a: lib${LIB}_g.a __archiveinstall
601: .endif
602: .endif
603:
1.149 lukem 604: .if ${MKPIC} != "no" && ${MKPICINSTALL} != "no"
1.168 mycroft 605: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.160 simonb 606: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.197 mycroft 607:
1.269 dbj 608: .if ${MKUPDATE} == "no"
1.197 mycroft 609: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a)
610: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! .MADE
1.89 christos 611: .endif
1.197 mycroft 612: .if ${MKPICLIB} == "no"
613: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}.a __archivesymlinkpic
614: .else
615: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}_pic.a __archiveinstall
616: .endif
617: .else
1.157 fredb 618: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a)
1.89 christos 619: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: .MADE
1.33 pk 620: .endif
1.160 simonb 621: .if ${MKPICLIB} == "no"
1.197 mycroft 622: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}.a __archivesymlinkpic
1.160 simonb 623: .else
1.89 christos 624: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}_pic.a __archiveinstall
1.160 simonb 625: .endif
1.89 christos 626: .endif
1.197 mycroft 627: .endif
1.89 christos 628:
1.171 christos 629: .if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION)
1.282 lukem 630: _LIB_SO_TGT= ${DESTDIR}${_LIBSODIR}/${_LIB_PREFIX}${LIB}.so
631: _LIB_SO_TGTLIBDIR= ${DESTDIR}${LIBDIR}/${_LIB_PREFIX}${LIB}.so
632:
633: libinstall:: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}
634: .PRECIOUS: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}
1.197 mycroft 635:
1.269 dbj 636: .if ${MKUPDATE} == "no"
1.197 mycroft 637: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION})
1.282 lukem 638: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}! .MADE
1.89 christos 639: .endif
1.282 lukem 640: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}! lib${LIB}.so.${SHLIB_FULLVERSION}
1.197 mycroft 641: .else
1.171 christos 642: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION})
1.282 lukem 643: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}: .MADE
1.89 christos 644: .endif
1.282 lukem 645: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}: lib${LIB}.so.${SHLIB_FULLVERSION}
1.197 mycroft 646: .endif
1.238 lukem 647: ${_MKTARGET_INSTALL}
1.188 tv 648: ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.264 jwise 649: ${.ALLSRC} ${.TARGET}
1.195 lukem 650: .if ${_LIBSODIR} != ${LIBDIR}
1.282 lukem 651: ${INSTALL_SYMLINK} -l r \
652: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION} \
653: ${_LIB_SO_TGTLIBDIR}.${SHLIB_FULLVERSION}
1.195 lukem 654: .endif
1.148 lukem 655: .if ${OBJECT_FMT} == "a.out" && !defined(DESTDIR)
1.195 lukem 656: /sbin/ldconfig -m ${_LIBSODIR} ${LIBDIR}
1.146 thorpej 657: .endif
1.148 lukem 658: .if ${OBJECT_FMT} == "ELF"
1.284 lukem 659: .if defined(SHLIB_FULLVERSION) && defined(SHLIB_MAJOR) && \
660: "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
1.264 jwise 661: ${INSTALL_SYMLINK} \
1.284 lukem 662: ${_LIB_PREFIX}${LIB}.so.${SHLIB_FULLVERSION} \
1.282 lukem 663: ${_LIB_SO_TGT}.${SHLIB_MAJOR}
1.195 lukem 664: .if ${_LIBSODIR} != ${LIBDIR}
1.282 lukem 665: ${INSTALL_SYMLINK} -l r \
666: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION} \
667: ${_LIB_SO_TGTLIBDIR}.${SHLIB_MAJOR}
1.195 lukem 668: .endif
1.284 lukem 669: .endif
1.148 lukem 670: .if ${MKLINKLIB} != "no"
1.264 jwise 671: ${INSTALL_SYMLINK} \
1.284 lukem 672: ${_LIB_PREFIX}${LIB}.so.${SHLIB_FULLVERSION} \
1.282 lukem 673: ${_LIB_SO_TGT}
1.195 lukem 674: .if ${_LIBSODIR} != ${LIBDIR}
1.282 lukem 675: ${INSTALL_SYMLINK} -l r \
676: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION} \
677: ${_LIB_SO_TGTLIBDIR}
1.195 lukem 678: .endif
1.83 cgd 679: .endif
1.12 cgd 680: .endif
1.139 tv 681: .endif
1.89 christos 682:
1.279 lukem 683: .if ${MKLINT} != "no" && !empty(LOBJS)
1.89 christos 684: libinstall:: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
1.168 mycroft 685: .PRECIOUS: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
1.197 mycroft 686:
1.269 dbj 687: .if ${MKUPDATE} == "no"
1.197 mycroft 688: .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln)
689: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! .MADE
1.89 christos 690: .endif
1.197 mycroft 691: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! llib-l${LIB}.ln
692: .else
1.157 fredb 693: .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln)
1.89 christos 694: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: .MADE
695: .endif
1.95 mycroft 696: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: llib-l${LIB}.ln
1.197 mycroft 697: .endif
1.238 lukem 698: ${_MKTARGET_INSTALL}
1.188 tv 699: ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.264 jwise 700: ${.ALLSRC} ${DESTDIR}${LINTLIBDIR}
1.58 cgd 701: .endif
1.252 lukem 702: .endif # !target(libinstall) # }
1.1 cgd 703:
1.188 tv 704: ##### Pull in related .mk logic
1.1 cgd 705: .include <bsd.man.mk>
1.57 jtc 706: .include <bsd.nls.mk>
1.91 christos 707: .include <bsd.files.mk>
1.89 christos 708: .include <bsd.inc.mk>
1.109 cjs 709: .include <bsd.links.mk>
1.24 mycroft 710: .include <bsd.dep.mk>
1.117 mycroft 711:
1.188 tv 712: ${TARGETS}: # ensure existence
CVSweb <webmaster@jp.NetBSD.org>